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

pm_sec_error_code_t is defined by two overlapping ranges

Looking at PM_EVT_CONN_SEC_FAILED parameters, i.e.,

 pm_evt_t.params.pm_conn_sec_failed_evt_t.error (pm_sec_error_code_t)

re: nRF5 SDK v16.0.0, nRF58233, S113

Looking at the definition for pm_sec_error_code_t: “Possible values are defined in Peer Manager defined security errors and GAP Security status.“

Peer Manager defined security errors – “the first 256 numbers, from PM_CONN_SEC_ERROR_BASE to (PM_CONN_SEC_ERROR_BASE + 0xFF), correspond to the status codes in Bluetooth status codes…” This is the HCI status codes. For example, BLE_HCI_STATUS_CODE_UNKNOWN_BTLE_COMMAND is 0x01.

GAP Security status – BLE_GAP_SEC_STATUS_XXX, e.g., BLE_GAP_SEC_STATUS_TIMEOUT is 0x01

Conclusion: the two status code ranges overlap – how does one interpret pm_conn_sec_failed_evt_t.error?

Parents
  • Hi Randy, 

    The docs are wrong, but the dox in the code is correct in peer_manager_types.h. 

    /**@defgroup PM_SEC_ERRORS Peer Manager defined security errors
     *
     * @details The first 256 numbers in this range correspond to the status codes in
     *          @ref BLE_HCI_STATUS_CODES.
     * @{ */
    #define PM_CONN_SEC_ERROR_PIN_OR_KEY_MISSING (PM_CONN_SEC_ERROR_BASE + 0x06)  /**< @brief Encryption failed because the peripheral has lost the LTK for this bond. See also @ref BLE_HCI_STATUS_CODE_PIN_OR_KEY_MISSING and Table 3.7 ("Pairing Failed Reason Codes") in the Bluetooth Core Specification 4.2, section 3.H.3.5.5 (@linkBLEcore).  */
    #define PM_CONN_SEC_ERROR_MIC_FAILURE        (PM_CONN_SEC_ERROR_BASE + 0x3D)  /**< @brief Encryption ended with disconnection because of mismatching keys or a stray packet during a procedure. See the SoftDevice GAP Message Sequence Charts on encryption (@linkBLEMSCgap), the Bluetooth Core Specification 4.2, sections 6.B.5.1.3.1 and 3.H.3.5.5 (@linkBLEcore), and @ref BLE_HCI_CONN_TERMINATED_DUE_TO_MIC_FAILURE. */
    #define PM_CONN_SEC_ERROR_DISCONNECT         (PM_CONN_SEC_ERROR_BASE + 0x100) /**< @brief Pairing or encryption did not finish before the link disconnected for an unrelated reason. */
    #define PM_CONN_SEC_ERROR_SMP_TIMEOUT        (PM_CONN_SEC_ERROR_BASE + 0x101) /**< @brief Pairing/bonding could not start because an SMP time-out has already happened on this link. This means that no more pairing or bonding can happen on this link. To be able to pair or bond, the link must be disconnected and then reconnected. See Bluetooth Core Specification 4.2 section 3.H.3.4 (@linkBLEcore). */
     /** @} */
    

    BLE_HCI_STATUS_CODES are mapped directly, i.e. from 0 to 256, not PM_CONN_SEC_ERROR_BASE to (PM_CONN_SEC_ERROR_BASE + 0xFF). 

    It's wrong in the latest SDK docs as well. I have reported to the internal. Thanks. 

    Please note that due to the Easter holiday, we're low on staff, so somewhat lower response times must be expected until April 6th. Sorry about the inconvenience.

    -Amanda H.

Reply Children
No Data
Related