Can I access the BLE mesh unicast address in my firmware after provisioning?

Hello all,

I’ve already looked in the following files:

C:\ncs\v3.1.0\zephyr\include\zephyr\bluetooth\mesh\access.h
C:\ncs\v3.1.0\zephyr\include\zephyr\bluetooth\mesh\main.h

But I can’t find where to get the BLE Mesh unicast address of the node I’m testing.
The node is already provisioned into a mesh network and is working.

Could anyone point me to a variable, struct, or function in the Zephyr 3.1.0 APIs that provides the node’s BLE Mesh unicast address? I’d be really grateful.

Parents Reply Children
  • I noticed there are two different access.h files in NCS v3.1.0:

    • C:\ncs\v3.1.0\zephyr\subsys\bluetooth\mesh\access.h (the source file, ~121 lines, includes functions like bt_mesh_primary_addr())

    • C:\ncs\v3.1.0\zephyr\include\zephyr\bluetooth\mesh\access.h (the header that actually gets pulled in by #include <zephyr/bluetooth/mesh.h>, which is much larger but doesn’t include functions like bt_mesh_primary_addr()).

    When I include Mesh in my project using:

    #include <zephyr/bluetooth/mesh.h>

    it pulls in the access.h from zephyr/include/..., not the one from subsys/....

    So my question is:

    • Do I need to include another header file explicitly to get access to functions like bt_mesh_primary_addr()?

    • Or is there a missing prj.conf setting that controls whether those APIs appear in the generated access.h?

  • comp->elem[0]->rt->addr will give the unicast address of the primary element, as suggested if node is provisined. It's still not clear why you need this. Could you elaborate on your use case?

  • Sorry, I need it because my network is always set up in a static way, like this:

    Group 1:

    Node 2

    Node 3

    Group 2:

    Node 4

    Node 5

    ...and so on.

    If a node knows its own primary unicast address, it can also determine its group partner:

    Even-numbered nodes know their partner is the next node.

    Odd-numbered nodes know their partner is the previous node.

    This way, they can communicate with each other, and when I use my phone app, I can address them through their group address.

Related