@@ -1134,13 +1134,6 @@ static void light_lightness_set_unack(struct bt_mesh_model *model,
11341134 ctl -> transition -> tt = tt ;
11351135 ctl -> transition -> delay = delay ;
11361136 ctl -> transition -> type = NON_MOVE ;
1137-
1138- if (actual > 0 && actual < ctl -> light -> range_min ) {
1139- actual = ctl -> light -> range_min ;
1140- } else if (actual > ctl -> light -> range_max ) {
1141- actual = ctl -> light -> range_max ;
1142- }
1143-
11441137 set_target (ACTUAL , & actual );
11451138
11461139 if (ctl -> light -> target != ctl -> light -> current ) {
@@ -1206,13 +1199,6 @@ static void light_lightness_set(struct bt_mesh_model *model,
12061199 ctl -> transition -> tt = tt ;
12071200 ctl -> transition -> delay = delay ;
12081201 ctl -> transition -> type = NON_MOVE ;
1209-
1210- if (actual > 0 && actual < ctl -> light -> range_min ) {
1211- actual = ctl -> light -> range_min ;
1212- } else if (actual > ctl -> light -> range_max ) {
1213- actual = ctl -> light -> range_max ;
1214- }
1215-
12161202 set_target (ACTUAL , & actual );
12171203
12181204 if (ctl -> light -> target != ctl -> light -> current ) {
@@ -1490,9 +1476,10 @@ static void light_lightness_default_set_unack(struct bt_mesh_model *model,
14901476 u16_t lightness ;
14911477
14921478 lightness = net_buf_simple_pull_le16 (buf );
1479+ lightness = constrain_lightness (lightness );
14931480
14941481 if (ctl -> light -> def != lightness ) {
1495- ctl -> light -> def = constrain_lightness ( lightness ) ;
1482+ ctl -> light -> def = lightness ;
14961483
14971484 light_lightness_default_publish (model );
14981485 save_on_flash (DEF_STATES );
@@ -1745,13 +1732,6 @@ static void light_ctl_set_unack(struct bt_mesh_model *model,
17451732 ctl -> transition -> delay = delay ;
17461733 ctl -> transition -> type = NON_MOVE ;
17471734 set_target (CTL_LIGHT , & lightness );
1748-
1749- if (temp < ctl -> temp -> range_min ) {
1750- temp = ctl -> temp -> range_min ;
1751- } else if (temp > ctl -> temp -> range_max ) {
1752- temp = ctl -> temp -> range_max ;
1753- }
1754-
17551735 set_target (CTL_TEMP , & temp );
17561736 set_target (CTL_DELTA_UV , & delta_uv );
17571737
@@ -1830,13 +1810,6 @@ static void light_ctl_set(struct bt_mesh_model *model,
18301810 ctl -> transition -> delay = delay ;
18311811 ctl -> transition -> type = NON_MOVE ;
18321812 set_target (CTL_LIGHT , & lightness );
1833-
1834- if (temp < ctl -> temp -> range_min ) {
1835- temp = ctl -> temp -> range_min ;
1836- } else if (temp > ctl -> temp -> range_max ) {
1837- temp = ctl -> temp -> range_max ;
1838- }
1839-
18401813 set_target (CTL_TEMP , & temp );
18411814 set_target (CTL_DELTA_UV , & delta_uv );
18421815
@@ -1933,15 +1906,12 @@ static bool light_ctl_default_setunack(struct bt_mesh_model *model,
19331906 return false;
19341907 }
19351908
1936- if (temp < ctl -> temp -> range_min ) {
1937- temp = ctl -> temp -> range_min ;
1938- } else if (temp > ctl -> temp -> range_max ) {
1939- temp = ctl -> temp -> range_max ;
1940- }
1909+ lightness = constrain_lightness (lightness );
1910+ temp = constrain_temperature (temp );
19411911
19421912 if (ctl -> light -> def != lightness || ctl -> temp -> def != temp ||
19431913 ctl -> duv -> def != delta_uv ) {
1944- ctl -> light -> def = constrain_lightness ( lightness ) ;
1914+ ctl -> light -> def = lightness ;
19451915 ctl -> temp -> def = temp ;
19461916 ctl -> duv -> def = delta_uv ;
19471917
@@ -2205,13 +2175,6 @@ static void light_ctl_temp_set_unack(struct bt_mesh_model *model,
22052175 ctl -> transition -> tt = tt ;
22062176 ctl -> transition -> delay = delay ;
22072177 ctl -> transition -> type = NON_MOVE ;
2208-
2209- if (temp < ctl -> temp -> range_min ) {
2210- temp = ctl -> temp -> range_min ;
2211- } else if (temp > ctl -> temp -> range_max ) {
2212- temp = ctl -> temp -> range_max ;
2213- }
2214-
22152178 set_target (CTL_TEMP , & temp );
22162179 set_target (CTL_DELTA_UV , & delta_uv );
22172180
@@ -2286,13 +2249,6 @@ static void light_ctl_temp_set(struct bt_mesh_model *model,
22862249 ctl -> transition -> tt = tt ;
22872250 ctl -> transition -> delay = delay ;
22882251 ctl -> transition -> type = NON_MOVE ;
2289-
2290- if (temp < ctl -> temp -> range_min ) {
2291- temp = ctl -> temp -> range_min ;
2292- } else if (temp > ctl -> temp -> range_max ) {
2293- temp = ctl -> temp -> range_max ;
2294- }
2295-
22962252 set_target (CTL_TEMP , & temp );
22972253 set_target (CTL_DELTA_UV , & delta_uv );
22982254
0 commit comments