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

sleep after disconnect

Hi

what is the best way to implement a sleep after disconnect? We are using a custom board and I implemented it this way:

on connect : turn advertisement off on disconnect : event set WDT interval to longer interval, go to system-off on wakeup : read original WDT interval from eeprom

Still I'm getting alot of advertisement packages after the disconnect. Is this a problem in my FW?

  • If you are still getting advertising packets then it simply means that you have enabled scanning again somewhere after the disconnect. Are you using example code from SDK? if so, can you please let us know which SDK version and which example have you been trying?

  • Hi sorry, I can't paste large code snips as this is a customer project. I will try to break down the code. The thing is I have over 1000 devices, that need to be scanned, connected, read, disconnected in intervals. I want to implement a "sleep after talk" on the peripheral device - the central continues to scan for the next device after disconnect.

    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:
            m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
        	battery_level_update();
            break;
            
        case BLE_GAP_EVT_DISCONNECTED:
        	sd_ble_gap_adv_stop();
            m_conn_handle = BLE_CONN_HANDLE_INVALID;
            // set after connect wakeup to eeprom.
            set_wdt_time(STATE_AFTER_CONNECT);
            power_off();
            break;
    }
    

    But this still leaves me with advert packets received on the central...

  • You said your system is going to system off, so after the wakeup, which will cause a system reset, the scanner is started again (sd_ble_gap_scan_start), could this be the reason you are seeing more adv packets? If not then probably APP_ERROR_CHECK failure is causing system reset and causing the scanner to be started again?

    I am assuming that you have double verified that there are no other calls or paths to sd_ble_gap_scan_start other than reset.

  • Thanks for your reply. You are looking from the wrong side ;-) My problem is not the scan_start but the adv_stop. I need the sleep on the peripheral side...

  • sorry, when you said that you are receiving packets, I thought DUT was central. OK , is it possible that you are using ble_advertising.c module. If so it will start the advertising automatically after DISCONNECTED event. If not then the same logic for scanner applies to advertising also except that instead of searching of sd_ble_gap_scan_start now you have to trace sd_ble_Gap_adv_start in your program.

Related