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

BLE Uart Example - Ready Event ?

Is there an event that I can hook into that fires when the soft device has finished it's connection and negotiation with the phone and is ready to send data to the phone ?

Basically, what I'm trying to achieve is the following:

  1. Device is asleep and wakes up every xx minutes
  2. Device initiates advertising
  3. Phone with Uart App running connects to device
  4. Device fires event that tells device application that it can send data. (This is where I'm stuck)
  5. Device goes back to sleep after phone confirms data received.
Parents
  • Hi,

    You will get a BLE_GAP_EVT_CONNECTED event in the BLE event handler, on_ble_evt(), when the device is connected. The issue with start sending data when this event is received is that the BLE UART example use notifications when sending data. The function ble_nus_string_send() will not send any data before notifacations is enabled from the central side. When the CCCD handle for the characteristic is written, to enable notifications, the function on_write() in ble_nus.c is called. You can use the method described in this post to send data on notifications enable.

    Best regards,

    Jørgen

Reply
  • Hi,

    You will get a BLE_GAP_EVT_CONNECTED event in the BLE event handler, on_ble_evt(), when the device is connected. The issue with start sending data when this event is received is that the BLE UART example use notifications when sending data. The function ble_nus_string_send() will not send any data before notifacations is enabled from the central side. When the CCCD handle for the characteristic is written, to enable notifications, the function on_write() in ble_nus.c is called. You can use the method described in this post to send data on notifications enable.

    Best regards,

    Jørgen

Children
Related