This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How do I know the MAC address of the sending device when it receives a nus message?

Hi Everyone,

My Environment: nRF52840, SDK15.3, Keil

I'm developing a central / peripheral device that can automatically connect up to three peripherals.

I want to know the mac address of the peripheral device sent when the central device receives nus data.

What should I do?

Alex

Parents
  • Hi Alex,

    Write and notification events do not include the address of the peer device, but a connection handle that references an active link with a specific device.  The handle is assigned when a new connection is established and freed on disconnect. So, in other words, the application has to keep track of the connections handles to determine which device the data came from.

    You can associate the connection handle with a MAC address if you want. The peer address is received in the BLE_GAP_CONNECTED event along with the connection handle (ble_gap_evt_connected_t)). "BLE Link Context Manager" is an SDK module that may be useful for managing the connection handles. 

    -Vidar

Reply
  • Hi Alex,

    Write and notification events do not include the address of the peer device, but a connection handle that references an active link with a specific device.  The handle is assigned when a new connection is established and freed on disconnect. So, in other words, the application has to keep track of the connections handles to determine which device the data came from.

    You can associate the connection handle with a MAC address if you want. The peer address is received in the BLE_GAP_CONNECTED event along with the connection handle (ble_gap_evt_connected_t)). "BLE Link Context Manager" is an SDK module that may be useful for managing the connection handles. 

    -Vidar

Children
Related