Accessing mesh relay data from the application layer in Zephyr

Is there a way to access the data that comes into a provisioned node and is relayed on the mesh network, from the application layer in Zephyr?

I have a battery models erver and  I set it up for publishing to a certain address

On another device I subscribed to that address and in the RTT log I  see the data coming in and being relayed by the mesh stack but don't see a way to access it from my application.

There are callbacks in mesh model definitions , i.e BT_MESH_MODEL_CB and BT_MESH_MODEL_VND_CB  that use  bt_mesh_model_cb but it does not have any functions to examine the incoming data. What's the proper way to do this under Zephyr?
Thanks

Parents Reply Children
  • Update

    I added a battery model client and set up  a handler but I'm still not getting any battery info on the receiving side

    The client is instantiated as follows

    struct bt_mesh_battery_cli  _batt_client = BT_MESH_BATTERY_CLI_INIT(&batt_cli_handler);
    struct bt_mesh_model root_models[] = {
        BT_MESH_MODEL_CFG_SRV,
        BT_MESH_MODEL_HEALTH_SRV(&_health_srv, &_health_pub),          
        //TODO: FW reporting. Possibly use level server?
        // config and health clients needed for mesh shell,
        BT_MESH_MODEL_BATTERY_SRV(&_batt_srv),          
        BT_MESH_MODEL_CFG_CLI(&_config_client),
        BT_MESH_MODEL_BATTERY_CLI(&_batt_client),
    };
    static struct bt_mesh_elem elements[] = {
        BT_MESH_ELEM(0, root_models, vnd_models),
    };
    I then provision the device and enable publish on the battery model.
    mesh mod-pub 0x00ab 0x100c 0xC002 0 0 5 74 2 200
    That succeeds and I see messages from my "get" opcode handler in the debug log
    Then I provision a second device and subscribe to the battery server like so
     mesh mod-sub-add 0x100 0xC002 0x100c
    This also succeeds 
    I see that the messages arrive  in the log (see below)
    But my batt_cli_handler function is not called.
    What am I missing?
    Thanks

    00> [00:03:55.746,795] <dbg> bt_mesh_net: bt_mesh_net_decode: 28 bytes: 689acc3f34f33bdb64a2426c9b21cf38aed1a8ff82ee42a7dd145947
    00> [00:03:55.746,826] <dbg> bt_mesh_net_keys: bt_mesh_net_cred_find:
    00> [00:03:55.746,826] <dbg> bt_mesh_net: net_decrypt: NID 0x68
    00> [00:03:55.746,826] <dbg> bt_mesh_net: net_decrypt: IVI 0 net->iv_index 0x00000000
    00> [00:03:55.746,856] <dbg> bt_mesh_net: net_decrypt: src 0x00ab
    00> [00:03:55.746,948] <dbg> bt_mesh_net: bt_mesh_net_decode: Decryption successful. Payload len 24
    00> [00:03:55.746,978] <dbg> bt_mesh_net: bt_mesh_net_decode: src 0x00ab dst 0xc002 ttl 5
    00> [00:03:55.747,039] <dbg> bt_mesh_net: bt_mesh_net_decode: PDU: 68050000b400abc0026361ef25f1233a49acf4bcc8ad5865
    00> [00:03:55.747,161] <dbg> bt_mesh_net: bt_mesh_net_relay: TTL 5 CTL 0 dst 0xc002
    00> [00:03:55.747,192] <dbg> bt_mesh_net: bt_mesh_net_relay: Relaying packet. TTL is now 4
  • Update2

    Set up publication and subscription to battery model - all succeeded

    Battery client and server set up as above

    Tried calling bt_mesh_battery_cli_get(batt_client,NULL,NULL) - get an error -125

    Stumped. Please help

    Thanks

Related