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

Advertising restart after a disconnect event

Hi!

Using SDK 14, I am advertising and see my device on the phone with nRFConnect. The indication LED flashes (indication) properly and in fixed intervals. When I connect with my phone the LED lights up without flashing as expected. After I disconnect the device wont advertise anymore and the LED doesn't flash anymore. I can also not find the device with my phone.

I tried to put a advertising_start(false); in the disconnected event:

case BLE_GAP_EVT_DISCONNECTED:
            NRF_LOG_INFO("Disconnected, reason %d\r\n",
                          p_ble_evt->evt.gap_evt.params.disconnected.reason);
            m_conn_handle = BLE_CONN_HANDLE_INVALID;
            advertising_start(false);
            break; // BLE_GAP_EVT_DISCONNECTED

This makes the LED flash again as if it was advertising but I can't find the device with my phone. Very sad. The boolean false just states that no bonds should be erased (I took this one from the examples)

So two questions:

  • How do I make this work (that I can connect and advertise over and over again)?
  • Sometimes after just some seconds the LED will light up as if it's in connected state. I cannot figure why ...

I would be very glad if someone could give me some advice ...

Best Noah

Parents
  • I don't know what you mean by the BAS example, but did you take a look at the migration notes when porting your project? When porting from SDK12 to SDK14, it might be a good idea to look at the SDK13 migration document first, before migrating to SDK14.
    You can take a look at how the advertising is handled for the BLE_GAP_EVT_DISCONNECTED by taking a look at ble_advertising_on_ble_evt() in the ble_advertising.c file.

Reply
  • I don't know what you mean by the BAS example, but did you take a look at the migration notes when porting your project? When porting from SDK12 to SDK14, it might be a good idea to look at the SDK13 migration document first, before migrating to SDK14.
    You can take a look at how the advertising is handled for the BLE_GAP_EVT_DISCONNECTED by taking a look at ble_advertising_on_ble_evt() in the ble_advertising.c file.

Children
No Data
Related