2 Replies Latest reply on Aug 22, 2016 8:30 AM by bobcat_1857246

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

    bobcat_1857246

      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.

        • 1. Re: Distinguishing which slave is source of notification from leatt_regNotificationCb() callback
          JacobT_81

          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:

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

           

          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

          1 of 1 people found this helpful