This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LP-CC1352P7: How to configure handler for gen model state change in BLE Mesh

Part Number: LP-CC1352P7
Other Parts Discussed in Thread: SYSCONFIG

Hello experts,

what is the correct way to process state changes of the generic model?

I use Simple Mesh Node example project as a base. There is a good documentation how to configure vendor model and set custom handler for a message.

But it's not clear what to do with all gen models.

For example I want to turn LED on/off using gen onOff server.

The handlers are defined in the ti_device_composition.c:

/* Mapping of message handlers for Generic OnOff Server (0x1000) */
const struct bt_mesh_model_op gen_onoff_srv_op[] = {
                {BT_MESH_MODEL_OP_2(0x82, 0x01) , 0, gen_OnOff_get },
                {BT_MESH_MODEL_OP_2(0x82, 0x02) , 0, gen_OnOff_set },
                {BT_MESH_MODEL_OP_2(0x82, 0x03) , 0, gen_OnOff_set_unack },
        BT_MESH_MODEL_OP_END,
};

But I did not find how I can modify those values in SysConfig, I can modify the function directly in the generic_models.c and it actually worked. But the file belongs to SDK, so it looks like not a good idea.

Also the functions from SDK are doing other useful things such as transition and delay, so it would be good to use them. I suppose there should be some event that I can process in the application, something like MODEL_STATE_CHANGE, but I could not find anything like that. Also I did not find that any event is enqueued in the handler. The handlers just change the model state value and that's it.

Did I miss something?

  • Hey Evgenii,

    But I did not find how I can modify those values in SysConfig, I can modify the function directly in the generic_models.c and it actually worked. But the file belongs to SDK, so it looks like not a good idea.

    Your statement here summarizes the status here. It looks like these hooks are not configurable in SysConfig as you've found. To help improve the experience for customers these hooks should probably be tied to SysConfig in the same way vendor models are. My thoughts are this may not have been included since these are SIG defined models (so their functionality is fixed), but I agree with you so I will file a ticket for our team to take a look at this and improve. I cannot comment on when this will occur at this time. For now, I would proceed how you did, by modifying the generic_models.c directly.

    Also the functions from SDK are doing other useful things such as transition and delay, so it would be good to use them. I suppose there should be some event that I can process in the application, something like MODEL_STATE_CHANGE, but I could not find anything like that. Also I did not find that any event is enqueued in the handler. The handlers just change the model state value and that's it.

    I would invite you to modify this code to add some specific application handling. I understand the need for wanting a callback at the application, to help decouple things from the TI provided model files. I will include this in the ticket.

    Did I miss something?

    I don't believe you did, great job!

  • Hi Ammar,

    thanks a lot for the clarification!