Hi,
I am working on a multiple custom models, wherein I need one model to extend the functionality of another model.
I was analyzing through nCS provided "Chat" sample code, where I saw that Chat client model extends to health server model as an example.
To extend first Health model handlers were initialized as in:
static void attention_on(struct bt_mesh_model *mod)
{
attention = true;
k_work_reschedule(&attention_blink_work, K_NO_WAIT);
}
static void attention_off(struct bt_mesh_model *mod)
{
/* Will stop rescheduling blink timer */
attention = false;
}
static const struct bt_mesh_health_srv_cb health_srv_cb = {
.attn_on = attention_on,
.attn_off = attention_off,
};
static struct bt_mesh_health_srv health_srv = {
.cb = &health_srv_cb,
};
BT_MESH_HEALTH_PUB_DEFINE(health_pub, 0);
Then The health model was initialized along with Chat client as in:
static struct bt_mesh_elem elements[] = {
BT_MESH_ELEM(
1,
BT_MESH_MODEL_LIST(
BT_MESH_MODEL_CFG_SRV,
BT_MESH_MODEL_HEALTH_SRV(&health_srv, &health_pub)),
BT_MESH_MODEL_LIST(BT_MESH_MODEL_CHAT_CLI(&chat))),
};
My questions are:
1. Suppose I want to call attention on when a chat message is received. How do I do this & what changes I need to make in code..?
2. In my custom models, how do exchange data between models..?
3. How do I trigger an extending model API from the main model API..?
Thanks,