@@ -403,81 +403,6 @@ static void light_ctl_status(struct light_ctl_ctx *ctx,
403403 ctx -> light_temp_ctx .remaining );
404404}
405405
406- static void periodic_led_lightness_work (struct k_work * work )
407- {
408- struct lightness_ctx * ctx =
409- CONTAINER_OF (work , struct lightness_ctx , work .work );
410-
411- ctx -> remaining -= ctx -> period ;
412-
413- if ((ctx -> remaining <= ctx -> period ) ||
414- (abs (ctx -> target - ctx -> current ) <= PWM_SIZE_STEP )) {
415- ctx -> current = ctx -> target ;
416- ctx -> remaining = 0 ;
417- /* Publish the new value at the end of the transition */
418- struct bt_mesh_lightness_status status ;
419-
420- lightness_status (ctx , & status );
421- bt_mesh_lightness_srv_pub (ctx -> srv , NULL , & status );
422- return ;
423- } else if (ctx -> target > ctx -> current ) {
424- ctx -> current += PWM_SIZE_STEP ;
425- } else {
426- ctx -> current -= PWM_SIZE_STEP ;
427- }
428-
429- k_work_reschedule (& ctx -> work , K_MSEC (ctx -> period ));
430- }
431-
432- /* Forward declaration */
433- static struct lightness_ctx lightness_ctx ;
434-
435- static void light_set (struct bt_mesh_lightness_srv * srv ,
436- struct bt_mesh_msg_ctx * ctx ,
437- const struct bt_mesh_lightness_set * set ,
438- struct bt_mesh_lightness_status * rsp )
439- {
440- uint32_t step_cnt ;
441-
442- lightness_ctx .target = set -> lvl ;
443- if (set -> transition ) {
444- lightness_ctx .remaining = set -> transition -> time ;
445- } else {
446- lightness_ctx .remaining = 0 ;
447- }
448-
449- if (lightness_ctx .remaining ) {
450- step_cnt = abs (lightness_ctx .target - lightness_ctx .current ) / PWM_SIZE_STEP ;
451- start_new_lightness_trans (step_cnt , set -> transition , & lightness_ctx );
452- } else {
453- lightness_ctx .current = lightness_ctx .target ;
454- }
455-
456- lightness_status (& lightness_ctx , rsp );
457- }
458-
459- static void light_get (struct bt_mesh_lightness_srv * srv ,
460- struct bt_mesh_msg_ctx * ctx ,
461- struct bt_mesh_lightness_status * rsp )
462- {
463- lightness_status (& lightness_ctx , rsp );
464- }
465-
466- static const struct bt_mesh_lightness_srv_handlers lightness_srv_handlers = {
467- .light_set = light_set ,
468- .light_get = light_get ,
469- };
470-
471- static struct bt_mesh_lightness_srv lightness_srv = BT_MESH_LIGHTNESS_SRV_INIT (
472- & lightness_srv_handlers );
473-
474- static struct lightness_ctx lightness_ctx = {
475- .srv = & lightness_srv ,
476- };
477-
478- static struct bt_mesh_light_ctrl_srv light_ctrl_srv =
479- BT_MESH_LIGHT_CTRL_SRV_INIT (& lightness_srv );
480-
481406static void
482407start_new_light_temp_trans (uint32_t step_cnt ,
483408 const struct bt_mesh_model_transition * transition ,
@@ -1159,6 +1084,9 @@ static struct light_xyl_hsl_ctx xyl_hsl_ctx = {
11591084 }
11601085};
11611086
1087+ static struct bt_mesh_light_ctrl_srv light_ctrl_srv =
1088+ BT_MESH_LIGHT_CTRL_SRV_INIT (& xyl_hsl_lightness_srv );
1089+
11621090static void get_faults (uint8_t * faults , uint8_t faults_size , uint8_t * dst ,
11631091 uint8_t * count )
11641092{
@@ -1307,18 +1235,14 @@ static struct bt_mesh_elem elements[] = {
13071235 BT_MESH_MODEL_NONE ),
13081236 BT_MESH_ELEM (40 ,
13091237 BT_MESH_MODEL_LIST (
1310- BT_MESH_MODEL_LIGHTNESS_SRV (& lightness_srv )),
1238+ BT_MESH_MODEL_LIGHTNESS_SRV (& xyl_hsl_lightness_srv ),
1239+ BT_MESH_MODEL_LIGHT_XYL_SRV (& xyl_hsl_ctx .xyl_ctx .srv ),
1240+ BT_MESH_MODEL_LIGHT_HSL_SRV (& xyl_hsl_ctx .hsl_ctx .srv )),
13111241 BT_MESH_MODEL_NONE ),
13121242 BT_MESH_ELEM (41 ,
13131243 BT_MESH_MODEL_LIST (
13141244 BT_MESH_MODEL_LIGHT_CTRL_SRV (& light_ctrl_srv )),
13151245 BT_MESH_MODEL_NONE ),
1316- BT_MESH_ELEM (50 ,
1317- BT_MESH_MODEL_LIST (
1318- BT_MESH_MODEL_LIGHTNESS_SRV (& xyl_hsl_lightness_srv ),
1319- BT_MESH_MODEL_LIGHT_XYL_SRV (& xyl_hsl_ctx .xyl_ctx .srv ),
1320- BT_MESH_MODEL_LIGHT_HSL_SRV (& xyl_hsl_ctx .hsl_ctx .srv )),
1321- BT_MESH_MODEL_NONE ),
13221246 BT_MESH_ELEM (51 ,
13231247 BT_MESH_MODEL_LIST (
13241248 BT_MESH_MODEL_LIGHT_HUE_SRV (& xyl_hsl_ctx .hsl_ctx .srv .hue )),
@@ -1366,7 +1290,6 @@ static const struct bt_mesh_comp comp = {
13661290const struct bt_mesh_comp * model_handler_init (void )
13671291{
13681292 k_work_init_delayable (& lvl_ctx .work , periodic_led_work );
1369- k_work_init_delayable (& lightness_ctx .work , periodic_led_lightness_work );
13701293 k_work_init_delayable (& xyl_hsl_ctx .xyl_ctx .work , periodic_light_xy_work );
13711294 k_work_init_delayable (& xyl_hsl_ctx .lightness_ctx .work ,
13721295 periodic_light_xyl_hsl_lightness_work );
0 commit comments