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

What calls nus_data_handler()?

Hello,

I've been using the SDK 15's "ble_app_uart" example and I've been curious on how the function nus_data_handler() gets called after data is sent over BLE.  More specifically who sends * p_evt to the function.

Regards,

Thomas

Parents
  • Hi Thomas,

    The user event handler (nus_data_handler() in the ble_app_uart example) is registered with the call to ble_nus_init(). You can see from the implementation in ble_nus.c that the pointer is copied to p_nus->data_handler, and it is called whenever there is an event that the application should know about (connection, write, read etc.). You can see that the pointer to the event structure is always passed when it is called.

    For example, line 114 in ble_nus.c in SDK 15 informs the application about the connected event and passes a pointer to the event structure that was populated immediately before that call.

Reply
  • Hi Thomas,

    The user event handler (nus_data_handler() in the ble_app_uart example) is registered with the call to ble_nus_init(). You can see from the implementation in ble_nus.c that the pointer is copied to p_nus->data_handler, and it is called whenever there is an event that the application should know about (connection, write, read etc.). You can see that the pointer to the event structure is always passed when it is called.

    For example, line 114 in ble_nus.c in SDK 15 informs the application about the connected event and passes a pointer to the event structure that was populated immediately before that call.

Children
Related