mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-10-02 13:27:21 +00:00
fix(nimble): Remove extra code in reattempt connection
This commit is contained in:
@@ -1023,7 +1023,7 @@ static void
|
|||||||
ble_gap_update_notify(uint16_t conn_handle, int status);
|
ble_gap_update_notify(uint16_t conn_handle, int status);
|
||||||
|
|
||||||
int
|
int
|
||||||
ble_gap_master_connect_reattempt(uint16_t conn_handle, ble_addr_t *peer_addr)
|
ble_gap_master_connect_reattempt(uint16_t conn_handle)
|
||||||
{
|
{
|
||||||
struct ble_gap_snapshot snap;
|
struct ble_gap_snapshot snap;
|
||||||
struct ble_gap_conn_desc conn;
|
struct ble_gap_conn_desc conn;
|
||||||
@@ -1061,7 +1061,7 @@ ble_gap_master_connect_reattempt(uint16_t conn_handle, ble_addr_t *peer_addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc = ble_gap_connect(ble_conn_reattempt.own_addr_type,
|
rc = ble_gap_connect(ble_conn_reattempt.own_addr_type,
|
||||||
(ble_conn_reattempt.peer_addr_present == 1 ? peer_addr : NULL),
|
(ble_conn_reattempt.peer_addr_present == 1 ? &ble_conn_reattempt.peer_addr : NULL),
|
||||||
ble_conn_reattempt.duration_ms,
|
ble_conn_reattempt.duration_ms,
|
||||||
&ble_conn_reattempt.conn_params,
|
&ble_conn_reattempt.conn_params,
|
||||||
ble_conn_reattempt.cb,
|
ble_conn_reattempt.cb,
|
||||||
@@ -5878,13 +5878,13 @@ ble_gap_connect(uint8_t own_addr_type, const ble_addr_t *peer_addr,
|
|||||||
memset(&ble_conn_reattempt.peer_addr, 0,
|
memset(&ble_conn_reattempt.peer_addr, 0,
|
||||||
sizeof(ble_addr_t));
|
sizeof(ble_addr_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
ble_conn_reattempt.duration_ms = duration_ms;
|
ble_conn_reattempt.duration_ms = duration_ms;
|
||||||
memcpy(&ble_conn_reattempt.conn_params,
|
memcpy(&ble_conn_reattempt.conn_params,
|
||||||
conn_params,
|
conn_params,
|
||||||
sizeof(struct ble_gap_conn_params));
|
sizeof(struct ble_gap_conn_params));
|
||||||
ble_conn_reattempt.cb = cb;
|
ble_conn_reattempt.cb = cb;
|
||||||
ble_conn_reattempt.cb_arg = cb_arg;
|
ble_conn_reattempt.cb_arg = cb_arg;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (peer_addr != NULL) {
|
if (peer_addr != NULL) {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ struct ble_gap_reattempt_ctxt {
|
|||||||
uint8_t count;
|
uint8_t count;
|
||||||
}reattempt_conn;
|
}reattempt_conn;
|
||||||
|
|
||||||
extern int ble_gap_master_connect_reattempt(uint16_t conn_handle, ble_addr_t *peer_addr);
|
extern int ble_gap_master_connect_reattempt(uint16_t conn_handle);
|
||||||
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_MAX_CONN_REATTEMPT
|
#ifdef CONFIG_BT_NIMBLE_MAX_CONN_REATTEMPT
|
||||||
#define MAX_REATTEMPT_ALLOWED CONFIG_BT_NIMBLE_MAX_CONN_REATTEMPT
|
#define MAX_REATTEMPT_ALLOWED CONFIG_BT_NIMBLE_MAX_CONN_REATTEMPT
|
||||||
@@ -238,26 +238,11 @@ ble_hs_hci_evt_disconn_complete(uint8_t event_code, const void *data,
|
|||||||
if (conn->bhc_flags & BLE_HS_CONN_F_MASTER) {
|
if (conn->bhc_flags & BLE_HS_CONN_F_MASTER) {
|
||||||
reattempt_conn.count += 1;
|
reattempt_conn.count += 1;
|
||||||
|
|
||||||
|
|
||||||
switch (conn->bhc_peer_addr.type) {
|
|
||||||
case BLE_ADDR_PUBLIC:
|
|
||||||
case BLE_ADDR_RANDOM:
|
|
||||||
memcpy(&reattempt_conn.peer_addr, &conn->bhc_peer_addr, sizeof(ble_addr_t));
|
|
||||||
reattempt_conn.peer_addr.type = conn->bhc_peer_addr.type;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BLE_ADDR_PUBLIC_ID:
|
|
||||||
case BLE_ADDR_RANDOM_ID:
|
|
||||||
memcpy(&reattempt_conn.peer_addr, &conn->bhc_peer_rpa_addr, sizeof(ble_addr_t));
|
|
||||||
reattempt_conn.peer_addr.type = conn->bhc_peer_rpa_addr.type;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
handle = le16toh(ev->conn_handle);
|
handle = le16toh(ev->conn_handle);
|
||||||
/* Post event to interested application */
|
/* Post event to interested application */
|
||||||
ble_gap_reattempt_count(handle, reattempt_conn.count);
|
ble_gap_reattempt_count(handle, reattempt_conn.count);
|
||||||
|
|
||||||
rc = ble_gap_master_connect_reattempt(ev->conn_handle , &reattempt_conn.peer_addr );
|
rc = ble_gap_master_connect_reattempt(ev->conn_handle);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
BLE_HS_LOG(INFO, "Master reconnect attempt failed; rc = %d", rc);
|
BLE_HS_LOG(INFO, "Master reconnect attempt failed; rc = %d", rc);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user