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

Advertising and sleep

I tried searching for this response but cant find exact answer

SDK15.2 and API6.1

I am trying to have an advertiser but would like to put it in some sleep mode and advertise. if i do sd_power_system_off() it turns off until i hit the wake GPIO. I tried using sd_app_evt_wait(), however that too doe snot seem to allow me to advertise and sleep at the same time.

What is recommended call to put the thing to sleep but be able to wake on ble event when the scanner tries to connect.

Parents
  • Hi,

    It is not possible to advertise when you are in deep sleep. In system off mode, all clock sources will be turned off, and you will only be able to wake on certain peripherals (reset, GPIO, NFCT, LPCOMP).

    It is also not possible to "advertise and sleep at the same time". You can enter system on idle mode between advertising events, but the chip will wake up to process and prepare advertising, as the CPU is required to start the advertising and setup buffers, etc.

    Running sd_app_evt_wait() in the main-loop is the correct way to enter lowest possible sleep mode while doing advertising and receive connection events.

    Best regards,
    Jørgen

  • Put it in idle_state_handler. As long as you do not have any blocking loops in your application, the application will enter the idle_state_handler when there is no more work to be done, allowing the CPU to go to sleep. This is what we do in all our BLE examples in the SDK.

  • Is there a way to check if the system did a brown out reset? When i turn the motor on it drops the input voltage a lot and sometimes causes the chip to reset. When it comes back from brown out reset though, it does not return to low power mode like if I turn power off and back on.

  • I'm not aware of any ways to detect that the device is restarted due to a brownout reset. All peripherals are reset similar to a power on reset. The device should still be able to enter low power mode by calling the correct sleep functions.

  • I got it to error in a way I am hoping can explain why it goes into this non shutdown state. 

    System goes like this:

    2 boards: button board and motor board

    push button on button board and it scans, connects, sends turn motor command

    motor board after receiving turn motor command, turns motor and sends done command back to button board

    button board having received done command, disconnects.

    If the motor board remains connected for longer than 10 seconds, it will disconnect on its own.

    I have a debug LED that turns on when the motor board enters BLE_GAP_EVT_CONNECTED and it turns off when it calls BLE_GAP_EVT_DISCONNECTED. 

    The system appears to work if i do not turn the command. If i receive the command and respond ignoring the motor turn command 

    In the following section I get a NRF_ERROR_CONN_COUNT

    void advertising_start(bool erase_bonds)
    {
        ret_code_t err_code = NRF_ERROR_INVALID_STATE;
    
        if (erase_bonds == true){
            delete_bonds();
            // Advertising is started by PM_EVT_PEERS_DELETED_SUCEEDED event
        }else{
            if(!is_advertising){
              err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);      /**< Follows ble_app_blinky example */
              APP_ERROR_CHECK(err_code);
    
              is_advertising = true;
            }
        }
    }

    I have my peripheral count set to 7 and central count set to 1 in the sdk_config file. 

    Am I making multiple connections or something that is eating into my connected count or is there a disconnect all function that will reset everything. Because once it goes into this state, even after brownout and reset, it does not go into low power mode again. I HAVE to disconnect power and restart it and it will start in low power mode (0.6mA) for a couple cycles but will always ned using 8mA eventually and only way to stop it is to remove power.

  • Did you configure the link conts using defines NRF_SDH_BLE_PERIPHERAL_LINK_COUNT and NRF_SDH_BLE_CENTRAL_LINK_COUNT in the sdk_config.h file? Did you also increase NRF_SDH_BLE_TOTAL_LINK_COUNT to the sum of the two last parameters? It is the last parameter that is used to configure the allowed link count for the softdevice. You get an event whenever a connection is established and disconnected, so you should be able to keep track of how many connections are active at any time.

  • yes i think iwas able to correct this issue. I think this was an issue with being new to nRF and the examples. I was establishing 2 NRF_OBSERVERS to do the same thing. 1 in my _DEF() and 1 in the advertising_init(). After i removed the observer in the advertising_init() things cleared up.

    if i put the system in sd_power_off(), and never trigger the wake_on pin, is there anything else that can wake the system up to scan or anything? or the only way wake it up from sd_power_off() is a physical interaction of sorts. Meaning it just sitting there isnt going to wake up on its own randomly and then go back to power_off?

Reply
  • yes i think iwas able to correct this issue. I think this was an issue with being new to nRF and the examples. I was establishing 2 NRF_OBSERVERS to do the same thing. 1 in my _DEF() and 1 in the advertising_init(). After i removed the observer in the advertising_init() things cleared up.

    if i put the system in sd_power_off(), and never trigger the wake_on pin, is there anything else that can wake the system up to scan or anything? or the only way wake it up from sd_power_off() is a physical interaction of sorts. Meaning it just sitting there isnt going to wake up on its own randomly and then go back to power_off?

Children
Related