NRF52840在配对连接后过个几十秒就连接断开是什么原因?BLE_HCI_STATUS_CODE_LMP_RESPONSE_TIMEOUT

黛丝滢芸RF/无线 2024-01-15 10:21:51 5725阅读 河南省周口市 电信

NRF52840在配对连接后过个几十秒就连接断开是什么原因?

通过在断开连接的处理函数的位置打断点,查看p_ble_evt变量下的ble_gap_evt_disconnected_t里边的reason原因:

typedef struct
{
  uint8_t reason;                               /**< HCI error code, see @ref BLE_HCI_STATUS_CODES. */
} ble_gap_evt_disconnected_t;

reason的值为0x22。

在ble_hci.h中有错误原因的代码定义,如下:

#define BLE_HCI_STATUS_CODE_SUCCESS                        0x00   /**< Success. */
#define BLE_HCI_STATUS_CODE_UNKNOWN_BTLE_COMMAND           0x01   /**< Unknown BLE Command. */
#define BLE_HCI_STATUS_CODE_UNKNOWN_CONNECTION_IDENTIFIER  0x02   /**< Unknown Connection Identifier. */
/*0x03 Hardware Failure
0x04 Page Timeout
*/
#define BLE_HCI_AUTHENTICATION_FAILURE                     0x05   /**< Authentication Failure. */
#define BLE_HCI_STATUS_CODE_PIN_OR_KEY_MISSING             0x06   /**< Pin or Key missing. */
#define BLE_HCI_MEMORY_CAPACITY_EXCEEDED                   0x07   /**< Memory Capacity Exceeded. */
#define BLE_HCI_CONNECTION_TIMEOUT                         0x08   /**< Connection Timeout. */
/*0x09 Connection Limit Exceeded
0x0A Synchronous Connection Limit To A Device Exceeded
0x0B ACL Connection Already Exists*/
#define BLE_HCI_STATUS_CODE_COMMAND_DISALLOWED             0x0C   /**< Command Disallowed. */
/*0x0D Connection Rejected due to Limited Resources
0x0E Connection Rejected Due To Security Reasons
0x0F Connection Rejected due to Unacceptable BD_ADDR
0x10 Connection Accept Timeout Exceeded
0x11 Unsupported Feature or Parameter Value*/
#define BLE_HCI_STATUS_CODE_INVALID_BTLE_COMMAND_PARAMETERS 0x12  /**< Invalid BLE Command Parameters. */
#define BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION           0x13  /**< Remote User Terminated Connection. */
#define BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES 0x14  /**< Remote Device Terminated Connection due to low resources.*/
#define BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF     0x15  /**< Remote Device Terminated Connection due to power off. */
#define BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION            0x16  /**< Local Host Terminated Connection. */
/*
0x17 Repeated Attempts
0x18 Pairing Not Allowed
0x19 Unknown LMP PDU
*/
#define BLE_HCI_UNSUPPORTED_REMOTE_FEATURE 0x1A                   /**< Unsupported Remote Feature. */
/*
0x1B SCO Offset Rejected
0x1C SCO Interval Rejected
0x1D SCO Air Mode Rejected*/
#define BLE_HCI_STATUS_CODE_INVALID_LMP_PARAMETERS     0x1E       /**< Invalid LMP Parameters. */
#define BLE_HCI_STATUS_CODE_UNSPECIFIED_ERROR          0x1F       /**< Unspecified Error. */
/*0x20 Unsupported LMP Parameter Value
0x21 Role Change Not Allowed
*/
#define BLE_HCI_STATUS_CODE_LMP_RESPONSE_TIMEOUT            0x22       /**< LMP Response Timeout. */
#define BLE_HCI_STATUS_CODE_LMP_ERROR_TRANSACTION_COLLISION 0x23  /**< LMP Error Transaction Collision/LL Procedure Collision. */
#define BLE_HCI_STATUS_CODE_LMP_PDU_NOT_ALLOWED             0x24       /**< LMP PDU Not Allowed. */
/*0x25 Encryption Mode Not Acceptable
0x26 Link Key Can Not be Changed
0x27 Requested QoS Not Supported
*/
#define BLE_HCI_INSTANT_PASSED                         0x28       /**< Instant Passed. */
#define BLE_HCI_PAIRING_WITH_UNIT_KEY_UNSUPPORTED      0x29       /**< Pairing with Unit Key Unsupported. */
#define BLE_HCI_DIFFERENT_TRANSACTION_COLLISION        0x2A       /**< Different Transaction Collision. */
/*
0x2B Reserved
0x2C QoS Unacceptable Parameter
0x2D QoS Rejected
0x2E Channel Classification Not Supported
0x2F Insufficient Security
*/
#define BLE_HCI_PARAMETER_OUT_OF_MANDATORY_RANGE       0x30            /**< Parameter Out Of Mandatory Range. */

从上面可以看到0x22为BLE_HCI_STATUS_CODE_LMP_RESPONSE_TIMEOUT,那这个是什么意思和原因呢?




标签: #NRF52840#

提示:如果此问题没有解决您的需求,您可以点击 “我也要问” 在线咨询。 我也要问

若此问题存在违规行为,您可以点击 “举报”

1条回答

  • Luuu0324
    2024-01-17 10:29:34 已采纳

    蓝牙service端和client端使用蓝牙nus串口透传服务传输数据,在client端与service端建立连接后的30s后,蓝牙连接就会莫名断开(两设备相邻很近),查看断开的原因提示为BLE_HCI_STATUS_CODE_LMP_RESPONSE_TIMEOUT,就是LMP回复超时,因为两端设置的最大MTU大小不一样导致的,只需要把NRF_SDH_BLE_GATT_MAX_MTU_SIZE改为和service一样的就可以了


    489 举报
103电阻是多少
STM32 38470人阅读
Linux内核printfk打印信息怎么打开
Linux驱动 8491人阅读

快速提问,在线解答

1

描述需求

填写需求概要标题,补充详细需求

2

耐心等

等待网友或网站工作人员在线解答

3

巧咨询

还有疑问?及时追问回复

立即咨询