- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
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:
WICED_BT_MESH_LIGHT_LC_MODE_SET
WICED_BT_MESH_LIGHT_LC_MODE_STATUS
WICED_BT_MESH_LIGHT_LC_OCCUPANCY_MODE_SET
etc.
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?
Thanks,
Robert
Solved! Go to Solution.
- Tags:
- bt mesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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_DEVICE,
WICED_BT_MESH_MODEL_LIGHT_LIGHTNESS_SERVER,
};
wiced_bt_mesh_core_config_model_t mesh_element2_models[] =
{
WICED_BT_MESH_MODEL_LIGHT_LC_SERVER,
};
If you expand WICED_BT_MESH_MODEL_LIGHT_LC_SERVER you will see all the callbacks. You should be able to provide yours.