mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
fix(hid): Fixed HID repeatedly reporting the close event
This commit is contained in:
@@ -250,7 +250,10 @@ static void hidd_l2cif_connect_cfm(uint16_t cid, uint16_t result)
|
||||
}
|
||||
|
||||
hidd_conn_disconnect();
|
||||
hd_cb.callback(hd_cb.device.addr, HID_DHOST_EVT_CLOSE, HID_L2CAP_CONN_FAIL | (uint32_t)result, NULL);
|
||||
p_hcon->disc_reason = HID_L2CAP_CONN_FAIL | (uint32_t)result;
|
||||
if (p_hcon->conn_state == HID_CONN_STATE_UNUSED) {
|
||||
hd_cb.callback(hd_cb.device.addr, HID_DHOST_EVT_CLOSE, p_hcon->disc_reason, NULL);
|
||||
}
|
||||
return;
|
||||
}
|
||||
/* CTRL connect conf */
|
||||
@@ -329,7 +332,6 @@ static void hidd_l2cif_config_ind(uint16_t cid, tL2CAP_CFG_INFO *p_cfg)
|
||||
static void hidd_l2cif_config_cfm(uint16_t cid, tL2CAP_CFG_INFO *p_cfg)
|
||||
{
|
||||
tHID_CONN *p_hcon;
|
||||
uint32_t reason;
|
||||
HIDD_TRACE_EVENT("%s: cid=%04x pcfg->result=%d", __func__, cid, p_cfg->result);
|
||||
p_hcon = &hd_cb.device.conn;
|
||||
if (p_hcon->ctrl_cid != cid && p_hcon->intr_cid != cid) {
|
||||
@@ -353,8 +355,10 @@ static void hidd_l2cif_config_cfm(uint16_t cid, tL2CAP_CFG_INFO *p_cfg)
|
||||
} else if (p_cfg->result != L2CAP_CFG_OK) {
|
||||
HIDD_TRACE_WARNING("%s: config failed, disconnecting", __func__);
|
||||
hidd_conn_disconnect();
|
||||
reason = HID_L2CAP_CFG_FAIL | (uint32_t)p_cfg->result;
|
||||
hd_cb.callback(hd_cb.device.addr, HID_DHOST_EVT_CLOSE, reason, NULL);
|
||||
p_hcon->disc_reason = HID_L2CAP_CFG_FAIL | (uint32_t)p_cfg->result;
|
||||
if (p_hcon->conn_state == HID_CONN_STATE_UNUSED) {
|
||||
hd_cb.callback(hd_cb.device.addr, HID_DHOST_EVT_CLOSE, p_hcon->disc_reason, NULL);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// update flags
|
||||
|
||||
@@ -353,7 +353,6 @@ static void hidh_l2cif_connect_cfm (UINT16 l2cap_cid, UINT16 result)
|
||||
{
|
||||
UINT8 dhandle;
|
||||
tHID_CONN *p_hcon = NULL;
|
||||
UINT32 reason;
|
||||
tHID_HOST_DEV_CTB *p_dev = NULL;
|
||||
|
||||
/* Find CCB based on CID, and verify we are in a state to accept this message */
|
||||
@@ -388,8 +387,10 @@ static void hidh_l2cif_connect_cfm (UINT16 l2cap_cid, UINT16 result)
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
reason = HID_L2CAP_CONN_FAIL | (UINT32) result ;
|
||||
hh_cb.callback( dhandle, hh_cb.devices[dhandle].addr, HID_HDEV_EVT_CLOSE, reason, NULL ) ;
|
||||
p_hcon->disc_reason = HID_L2CAP_CONN_FAIL | (UINT32) result;
|
||||
if (p_hcon->conn_state == HID_CONN_STATE_UNUSED) {
|
||||
hh_cb.callback( dhandle, hh_cb.devices[dhandle].addr, HID_HDEV_EVT_CLOSE, p_hcon->disc_reason, NULL ) ;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -521,8 +522,10 @@ static void hidh_l2cif_config_cfm (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cfg)
|
||||
/* If configuration failed, disconnect the channel(s) */
|
||||
if (p_cfg->result != L2CAP_CFG_OK) {
|
||||
hidh_conn_disconnect (dhandle);
|
||||
reason = HID_L2CAP_CFG_FAIL | (UINT32) p_cfg->result ;
|
||||
hh_cb.callback( dhandle, hh_cb.devices[dhandle].addr, HID_HDEV_EVT_CLOSE, reason, NULL ) ;
|
||||
p_hcon->disc_reason = HID_L2CAP_CFG_FAIL | (UINT32) p_cfg->result ;
|
||||
if (p_hcon->conn_state == HID_CONN_STATE_UNUSED) {
|
||||
hh_cb.callback( dhandle, hh_cb.devices[dhandle].addr, HID_HDEV_EVT_CLOSE, p_hcon->disc_reason, NULL ) ;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user