Re: Unable to set Appkey for generic server model

Mani Sadhasivam

Hi Johan,

On Sat, Dec 23, 2017 at 5:21 PM, Johan Hedberg <johan.hedberg@...> wrote:
Hi Mani,

On Sat, Dec 23, 2017, Mani Sadhasivam wrote:
> [bt] [ERR] model_send: Model not bound to AppKey 0x0001
> Thread used for publishing sensor data:
> void temp_work_thread(struct k_work *work)
> {
>         if (node_addr == BT_MESH_ADDR_UNASSIGNED)
>                 return;
>         struct net_buf_simple *msg = NET_BUF_SIMPLE(3 + 4);
>         struct bt_mesh_msg_ctx ctx = {
>                 .net_idx = 0,
>                 .app_idx = 1,
>                 .addr = BT_MESH_ADDR_ALL_NODES,
>                 .send_ttl = BT_MESH_TTL_DEFAULT,
>         };
>         bt_mesh_model_msg_init(msg, BT_MESH_MODEL_OP);
>         net_buf_simple_add_u8(msg, 1);
>         if (bt_mesh_model_send(&root_models[0], &ctx, msg, NULL, NULL)) {

A couple of things come to mind here:

Is root_models[0] really the model that's supposed to do the publishing?
It's often the Configuration Server Model, which would explain the error
you're getting. You didn't show the definition of your models array, so
I'm just guessing here.

You are right... Mistakenly specified the cfg_srv model. It is working fine now :)
Also, if this is really a formal publish message you're sending, you
should be using the bt_mesh_model_publish() API instead of
bt_mesh_model_send(). The latter is intended mainly for client model
messages as well as for the server's responses to those, and it doesn't
take into consideration things like the Model Publish Retransmit state
or that you're actually publishing using the configured publication
state (correct app key, destination address, TTL, etc).

Sure, will make use of it. Thanks for the clarification!


Join to automatically receive all group messages.