Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Why are most services's evt_handler in peripheral example NULL, but central's ones aren't?

Hello~

I have finished a few easy peripheral project.

Now I tried to understand the structure of central example, ex: ble_hrs_c, ble_nus_c....

I found that services of peripheral wouldn't be provided evt_handler, except ble_nus.

What is the time the evt_handler would be called?

However, almost every central example has evt_handler to be called.

I can't understand the rule of using evt_handler or not.

Please give me some direction. Thanks! 

  • Hello,

    For the NUS the application needs an event handler to know when data has been received from the client unlike the hr service where the app is only sending data. But you can use the event from hr service  if you want you app to get notified when the client has enabled or disabled notification. In other words, event handlers are optional as long required events are handled internally inside the service module. You can see what kind of events the event handler will notify the app about if you search for "evt_handler" inside the service module. 

     

Related