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

sd_app_evt_wait only waits until central is connected

Hello,

I'm trying to put a BLENano board to slepp every loop iteration. These are te steps:

  1. setup:

    sd_power_mode_set(NRF_POWER_MODE_LOWPWR);
    NRF_POWER->TASKS_LOWPWR = 0; NRF_POWER->DCDCEN = 0x00000000;

2: loop:


   [...]

   sd_app_evt_wait();

   BLECentral central = ble.central(); 

   // if a central is connected to peripheral:
   if (central) {        

        sd_app_evt_wait();

       // while the central is still connected to peripheral:
       while (central.connected()) {
              sd_app_evt_wait()
              [...]
    }

   [...]

The first time sd_app_evt_wait is called, it waits until a central is connected. But then, the execution enters the inner loop and sd_app_evt_wait returns instantly.

I've read things about pending events or interrupts, bu I've not managed to get to work. I've also tried calling sd_nvic_EnableIRQ(SWI2_IRQn); with a proper empty SWI2_IRQHandler, but then sd_app_evt_wait never returns and no central can connect to the device.

Please, ¿is there something with the library I have to setup in order for this to work?

Thanks!

Parents Reply
  • SWI2 is the software interrupt that the softdevice uses to throw BLE events to the application. It's the responsibility to implement the interrupt handle for this interrupt and pull the event out from softdevice buffer. It's not a good idea to ignore this and simply clear the event, the buffer in the softdevice will be full and the stack will start NACKing the packets. Please see how we do it in softdevice_handler.c in SOFTDEVICE_EVT_IRQHandler().

Children
No Data
Related