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

Need to switch BLE off and on

I am developing based on ble_app_uart example of SDK12 for nRF51 DK and I need to switch BLE off completely when power disappears to save battery and switch back on when power is restored. How can I proceed?

In detail, I need answers to the following situations:

1) Power fails during active connection: how to detect that it is connected and how to disconnect the connection?

2) How can I then switch off BLE completely (stop advertising and switch radio off)?

3) What sequence should be called to restart advertising when power is back?

Parents
  • Hi Sergio, 

    Is the NRF51 powered by both battery and a power supply? If so how are you switching between battery and power supply?

    The nRF51 has a Power Failure Comparator that can configured to generate an event when the supply voltage drops below a certain threshold, see the POFCON register in the nRF51 Reference Manual. You could also use the Low Power Comparator for this. 

    Q1: You can check the connection handle, m_conn_handle. It is non-zero if you have a connection and is set to BLE_CONN_HANDLE_INVALID = 0xFFFF if no connection is active. To disconnect you call sd_ble_gap_disconnect() with the connection handle and a hci_status_code. 

    Q2: Call sd_ble_gap_adv_stop() to stop advertising. The Radio will then be automatically switched off. 

    Q3: Call ble_advertising_start(BLE_ADV_MODE_FAST) to start advertising again. 

    Best regards
    Bjørn

Reply
  • Hi Sergio, 

    Is the NRF51 powered by both battery and a power supply? If so how are you switching between battery and power supply?

    The nRF51 has a Power Failure Comparator that can configured to generate an event when the supply voltage drops below a certain threshold, see the POFCON register in the nRF51 Reference Manual. You could also use the Low Power Comparator for this. 

    Q1: You can check the connection handle, m_conn_handle. It is non-zero if you have a connection and is set to BLE_CONN_HANDLE_INVALID = 0xFFFF if no connection is active. To disconnect you call sd_ble_gap_disconnect() with the connection handle and a hci_status_code. 

    Q2: Call sd_ble_gap_adv_stop() to stop advertising. The Radio will then be automatically switched off. 

    Q3: Call ble_advertising_start(BLE_ADV_MODE_FAST) to start advertising again. 

    Best regards
    Bjørn

Children
Related