Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

Bluetooth SDK Forum Discussions

Level 1
First like given
Level 1


I'm trying to figure out how to process LC Server messages in BT Mesh. I'm using Modus Toolbox 2 with wiced-btsdk 2.1, and the Mesh EZ-BT Kit. I started with the mesh-demo light smart program. The mesh_app_message_handler() function is setup to process WICED_BT_MESH_LIGHT_LIGHTNESS_SET messages for the light lightness server, and this works as expected. But it doesn't seem to process any other message type. Per the Mesh spec, LC Server is supposed to be able to process LC messages such as:





Adding cases for these in the function doesn't help, and they would hit the default case anyway if they were making it to the message handler function. So my question is, how can I setup a message handler for LC Server messages?



1 Solution
5 comments on blog 25 sign-ins 250 likes received

In the current implementation, the over the air messages are processed by mesh model library. Application is notified only if HW needs to access, for example, if brightness of the bulb needs to be changed.

I guess there are multiple ways you can proceed. First you can completely bypass mesh_models library. See mesh_app_lib/mesh_application.c

// Application can set this handler to process if it implements models layer.

wiced_bt_mesh_core_received_msg_handler_t p_app_model_message_handler = NULL;

If you provide p_app_model_message_handler, you will have to process everything.

This is probably pretty big development, but you can do everything.

The second method is to hook into processing of the specific Opcode. When Mesh Core receives a message, it calls mesh_app_lib\mesh_application.c

wiced_bt_mesh_core_received_msg_handler_t get_msg_handler_callback(uint16_t company_id, uint16_t opcode, uint16_t *p_model_id, uint8_t *p_rpl_delay)

to return the message handler based on the opcode that has been received over the air. You can see the loop in the function that goes through all elements, and all models and it asks each model if this opcode is for this model. You can probably provide your callback for the situation if opcode is WICED_BT_MESH_OPCODE_SENSOR_STATUS. If you want your functionality in addition to the standard LC functionality, you can call

void light_lc_server_process_sensor_status(wiced_bt_mesh_event_t *p_event, mesh_light_lc_state_t *p_state, uint8_t *p_data, uint16_t data_len)

after your completed your processing.

Another method is to provide your callbacks in the device definition. For example, Light Smart application defines 2 elements

wiced_bt_mesh_core_config_model_t   mesh_element1_models[] =





wiced_bt_mesh_core_config_model_t   mesh_element2_models[] =




If you expand WICED_BT_MESH_MODEL_LIGHT_LC_SERVER ​you will see all the callbacks. You should be able to provide yours.

View solution in original post

3 Replies