Distinguishing which slave is source of notification from leatt_regNotificationCb() callback

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
BoCo_1857246
Level 4
Level 4
10 replies posted 5 replies posted 10 questions asked

Looking, for example, at hello_client.c leatt_regNotificationCb() registers a callback handler. The handler has parameters (int len, int attr_len, UINT8 *data).

In that callback, how can I distinguish which of the multiple slaves issued the notification? Perhaps there's a getter function equivalent to blecm_SetPtrConMux()? but I can't find it.

0 Likes
1 Solution
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

In hello_client everything is tracked via connection handles. When a device is first encountered in the connection_up callback, the handle is used to store all pertinent data.

The connection handle can be retrieved as below:

UINT16 con_handle = emconinfo_getConnHandle();

This handle is used to reference and dereference the connection mux index via:

blecm_FindConMux(con_handle);

blecm_DelConMux(connection_mux_index);

blecm_FindFreeConMux();

These connection mux indices are used to dereference hello_client.dev_info:

pastedImage_0.png

This is where all information specific to that device is stored. And, optionally, stored to NVRAM.

pastedImage_1.png

In connection up, the handle is used to reference data about that slave. After connection up, the handle can be used to dereference data about the slave. So from within your notification handler, you should be able to call emconinfo_getConnHandle(); and pull the necessary data from hello_client.dev_info.

What should also work is to pull the slave's address via:

UINT8 *p_remote_addr = (UINT8 *)emconninfo_getPeerAddr();

If you call something like this from within the notification handler, you should be able to pull the sender's address.

Jacob

View solution in original post

2 Replies
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

In hello_client everything is tracked via connection handles. When a device is first encountered in the connection_up callback, the handle is used to store all pertinent data.

The connection handle can be retrieved as below:

UINT16 con_handle = emconinfo_getConnHandle();

This handle is used to reference and dereference the connection mux index via:

blecm_FindConMux(con_handle);

blecm_DelConMux(connection_mux_index);

blecm_FindFreeConMux();

These connection mux indices are used to dereference hello_client.dev_info:

pastedImage_0.png

This is where all information specific to that device is stored. And, optionally, stored to NVRAM.

pastedImage_1.png

In connection up, the handle is used to reference data about that slave. After connection up, the handle can be used to dereference data about the slave. So from within your notification handler, you should be able to call emconinfo_getConnHandle(); and pull the necessary data from hello_client.dev_info.

What should also work is to pull the slave's address via:

UINT8 *p_remote_addr = (UINT8 *)emconninfo_getPeerAddr();

If you call something like this from within the notification handler, you should be able to pull the sender's address.

Jacob

Exactly what I needed. Thank you!

0 Likes