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

Why delay make ble_nus_string_send() totally not working?

A beginner's question.

I am using UART over BLE to send data out.

As codes below, ble_nus_string_send() works and continuously sending data out, with the Wireshark's help, I can see notification packet are always sending out.

when I was trying to slow data sending down, I put a counter there, when counter equals 2, ble_nus_string_send() is called, but this way, make it not working, maybe at the beginning it will send one data out, the rest are all empty PDU. why? thanks for help. D_Peripheral_PCA10031_Rigado.zip

  • When you call sd_app_evt_wait() in power_manage() you will wait for events from the SoftDevice, you will not be running in the for loop. The counter will only increase when you events from the SoftDevice. If you (after you are connected) put a breakpoint at ble_nus_string_send() inside the if you will see that you never hit it. If you comment out power_manager(), you can see that notifications are sent all the time.

    ble_nus_string_send() outside the if will be called because when the notification is sent you will receive the BLE_EVT_TX_COMPLETE event, which will trigger a new call to ble_nus_string_send().

Related