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

Closing connection with reason BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF

My nRF52 device has a connection opened in peripheral mode and in some cases I want to close the connection with reason code "power off", i.e. call sd_ble_gap_disconnect with reason code set to BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF.

When testing this with the nRF Connect mobile app (on Android), the logging shows: "Error 21 (0x15): UNKNOWN (21) "

21 is the numeric value that maps to BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF. 

Is this a problem with the Android mobile app? Or Android BLE stack? Or perhaps this is not a proper way to close a connection. Any ideas?

Just before clicking POST button I double-checked the API documentation of sd_ble_gap_disconnect and there's a note regarding the reason code:

(accepted values are @ref BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION and @ref BLE_HCI_CONN_INTERVAL_UNACCEPTABLE).

Now I'm even more confused. Is there a possibility to close connection with reason code "power off"? 

Parents
  • Hi Jaakko, 

    It's a bug in our documentation, the following disconnection code are accepted in S13x v7.x: 

     BTLE_AUTHENTICATION_FAILURE
     BTLE_REMOTE_USER_TERMINATED_CONNECTION
     BTLE_REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES
     BTLE_REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF
     BTLE_UNSUPPORTED_REMOTE_FEATURE
     BTLE_PAIRING_WITH_UNIT_KEY_UNSUPPORTED
     BTLE_CONN_TERMINATED_DUE_TO_MIC_FAILURE
     BTLE_CONN_INTERVAL_UNACCEPTABLE

    I don't see any issue of using code BTLE_REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF to terminate the connection. There could be a chance that the nRF Connect app doesn't have this opcode in the list hence throwing Error Unknown. But it's not a big issue from my point of view. It's not a problem for Android BLE stack as you can find the connection terminated gracefully and the stack reported the correct disconnect code. 

Reply
  • Hi Jaakko, 

    It's a bug in our documentation, the following disconnection code are accepted in S13x v7.x: 

     BTLE_AUTHENTICATION_FAILURE
     BTLE_REMOTE_USER_TERMINATED_CONNECTION
     BTLE_REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES
     BTLE_REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF
     BTLE_UNSUPPORTED_REMOTE_FEATURE
     BTLE_PAIRING_WITH_UNIT_KEY_UNSUPPORTED
     BTLE_CONN_TERMINATED_DUE_TO_MIC_FAILURE
     BTLE_CONN_INTERVAL_UNACCEPTABLE

    I don't see any issue of using code BTLE_REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF to terminate the connection. There could be a chance that the nRF Connect app doesn't have this opcode in the list hence throwing Error Unknown. But it's not a big issue from my point of view. It's not a problem for Android BLE stack as you can find the connection terminated gracefully and the stack reported the correct disconnect code. 

Children
Related