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

After BLE_GAP_EVT_DISCONNECTED event advertisement module stops

Hi

I have written this code based on a sample from SDK12. The board is a pca10040 and nRF52832 chip. It seems like after disconnection from the master device the Softdevice is not starting the advertisement again, which according to the documentation should be the case. I have to reset the board using nrfjprog in order to start advertising again. I do not handle this even in the code and I found out that BLE_GAP_EVT_DISCONNECTED is fired by SoftDevice after disconnection. Please advise. This a show stopper.

Parents
  • Hello,

    You  need to start the advertisement somewhere in the source code after a disconnect event. 

     

    In most of the examples in SDK 12 (I have checked SDK12.3.0, since you didn't specify one specific, but I assume that it is the same in the other SDK12.x.x) the ble_advertising_start(...) call is done in the on_disconnect() function, which is called in the BLE_GAP_EVT_DISCONNECTED event in in the ble_advertising_on_ble_evt(...) function inside the ble_advertising.c file.

     

    Have you changed anything in this file?

     

    Best regards,

    Edvin

  • No I have not touched any library file. I took the initial code from the Heart Rate in the peripheral section of the examples and wrote custom service on top of that. I had tried adding ble_advertising_start on the handler of BLE_GAP_EVT_DISCONNECTED. There is no failure on the ble_advertising_start but the advertising does not actually start. It would only start if I reset the app with a APP_ERROR_CHECK with some error code. I also had advertising started on PM_EVT_PEERS_DELETE_SUCCEEDED, but this event is never fired. My guess is that this is for Central devices and not peripheral ones. I also checked the ble_app_hrs code again and there is no advertisement start in the BLE_GAP_EVT_DISCONNECTED  code.

  • What SDK version do you use? I don't know if it is any difference in the advertising_start implementation between the SDK12.x.x versions, but if you could tell me, we might avoid some misunderstandings. Can you check the ble_advertising.c file, and search for BLE_GAP_EVT_DISCONNECTED in that file? It should call a function named on_disconnect(), where it should call ble_advertising_start().

     

    BR,

    Edvin

Reply Children
Related