Receiving publication messages from a battery model serve

I asked this question in a different form but not getting any answers on that thread.

My goal is to publish battery level messages to a certain address and receive it on all devices that subscribe to that publication

I'm beginning to suspect that this is not possible with the standard SIG model. The documentation talks about a client that reads battery info from a "bound server"  which implies a 1-1 relationship. Also looking at the _bt_mesh_battery_srv_op in  gen_batttery_srv.c  in Zephyr SDK , I only see one opcode BT_MESH_BATTERY_OP_GET but no other opcodes 

If I'm correct I suppose I could create a custom model with the get and set opcodes - are there any other options? Mesh specification allows extending models - would this be possible here?

If so -can you provide specifics ? Could I just add a custom "set" opcode to _bt_mesh_battery_srv_op  somehow?

Thanks

Parents
  • Hi Andy, 

    I would suggest to continue on the other case. Terje may have some delay but he will get back to you. 

    But anyway, I got a quick glance at the implementation of the generic battery server and it's pretty obvious that when a battery get message is sent, only the sender of the command receive the battery status. Not all the nodes that subscribe to the same address as the publication address of the server. 

    What you can do instead is to call bt_mesh_battery_srv_pub() in the server application. This call will publish the battery status to the address in the publication address that the server model configured to. 
    You can choose to call bt_mesh_battery_srv_pub() from the application when you receive a get request, or you can call it only when the battery level is changed or periodically. 

Reply Children
  • Turns out this was an operator error
    Here are the commands to make it work
    1. provision device

    uart:~$ mesh init
    Mesh shell initialized
    uart:~$ mesh dst 0x00ab
    Destination address set to 0x00ab
    uart:~$ mesh app-key-add 0 0 522975C06BCADCBBF4A402DF2F895226
    AppKey added, NetKeyIndex 0x0000 AppKeyIndex 0x0000
    uart:~$ mesh mod-app-bind 0x00ab 0 0x100c <-- bind with the battery server model
    AppKey successfully bound
    uart:~$ mesh mod-app-bind 0x00ab 0 0x100d <-- bind with the battery client model
    AppKey successfully bound
    uart:~$ mesh mod-pub 0x00ab 0x100c 0xC100 0 0 255 10 0 0 <--publish battery messages
    Model Publication successfully set
    uart:~$ mesh mod-sub-add 0x00ab 0xC100 0x100d <--- subscribe to battery messages
    Model subscription was successful

    In  the application

    struct bt_mesh_battery_srv _batt_srv = BT_MESH_BATTERY_SRV_INIT(batt_get);
    struct bt_mesh_battery_cli  _batt_client = BT_MESH_BATTERY_CLI_INIT(&batt_cli_handler);
    batt_get is called at publication intervals to get the battery measurement
    batt_cli_handler is called when battery server message arrives over the mesh network.
     
     
Related