mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
fix(nimble): Keep only BLE_GAP_EVENT_CONNECT gap event
This commit is contained in:
@@ -424,13 +424,13 @@ enc_adv_data_cent_gap_event(struct ble_gap_event *event, void *arg)
|
||||
enc_adv_data_cent_connect_if_interesting(&event->disc);
|
||||
return 0;
|
||||
|
||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||
case BLE_GAP_EVENT_CONNECT:
|
||||
/* A new connection was established or a connection attempt failed. */
|
||||
if (event->link_estab.status == 0) {
|
||||
if (event->connect.status == 0) {
|
||||
/* Connection successfully established. */
|
||||
MODLOG_DFLT(INFO, "Connection established ");
|
||||
|
||||
rc = ble_gap_conn_find(event->link_estab.conn_handle, &desc);
|
||||
rc = ble_gap_conn_find(event->connect.conn_handle, &desc);
|
||||
assert(rc == 0);
|
||||
print_conn_desc(&desc);
|
||||
MODLOG_DFLT(INFO, "");
|
||||
@@ -440,29 +440,29 @@ enc_adv_data_cent_gap_event(struct ble_gap_event *event, void *arg)
|
||||
ESP_LOGE(tag, "Failed to set preferred MTU; rc = %d", rc);
|
||||
}
|
||||
|
||||
rc = ble_gattc_exchange_mtu(event->link_estab.conn_handle, NULL, NULL);
|
||||
rc = ble_gattc_exchange_mtu(event->connect.conn_handle, NULL, NULL);
|
||||
if (rc != 0) {
|
||||
ESP_LOGE(tag, "Failed to negotiate MTU; rc = %d", rc);
|
||||
}
|
||||
|
||||
/* Remember peer. */
|
||||
rc = peer_add(event->link_estab.conn_handle);
|
||||
rc = peer_add(event->connect.conn_handle);
|
||||
if (rc != 0) {
|
||||
MODLOG_DFLT(ERROR, "Failed to add peer; rc=%d\n", rc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
rc = peer_set_addr(event->link_estab.conn_handle, desc.peer_id_addr.val);
|
||||
rc = peer_set_addr(event->connect.conn_handle, desc.peer_id_addr.val);
|
||||
if (rc != 0) {
|
||||
MODLOG_DFLT(ERROR, "Failed to set peer addr; rc=%d\n", rc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Authorization is required for this characterisitc */
|
||||
rc = ble_gap_security_initiate(event->link_estab.conn_handle);
|
||||
rc = ble_gap_security_initiate(event->connect.conn_handle);
|
||||
if (rc != 0) {
|
||||
MODLOG_DFLT(INFO, "Security could not be initiated, rc = %d\n", rc);
|
||||
return ble_gap_terminate(event->link_estab.conn_handle,
|
||||
return ble_gap_terminate(event->connect.conn_handle,
|
||||
BLE_ERR_REM_USER_CONN_TERM);
|
||||
} else {
|
||||
MODLOG_DFLT(INFO, "Connection secured\n");
|
||||
@@ -471,7 +471,7 @@ enc_adv_data_cent_gap_event(struct ble_gap_event *event, void *arg)
|
||||
} else {
|
||||
/* Connection attempt failed; resume scanning. */
|
||||
MODLOG_DFLT(ERROR, "Error: Connection failed; status=%d\n",
|
||||
event->link_estab.status);
|
||||
event->connect.status);
|
||||
enc_adv_data_cent_scan();
|
||||
}
|
||||
|
||||
|
||||
@@ -185,19 +185,19 @@ enc_adv_data_prph_gap_event(struct ble_gap_event *event, void *arg)
|
||||
int rc;
|
||||
|
||||
switch (event->type) {
|
||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||
case BLE_GAP_EVENT_CONNECT:
|
||||
/* A new connection was established or a connection attempt failed. */
|
||||
MODLOG_DFLT(INFO, "connection %s; status=%d ",
|
||||
event->link_estab.status == 0 ? "established" : "failed",
|
||||
event->link_estab.status);
|
||||
if (event->link_estab.status == 0) {
|
||||
rc = ble_gap_conn_find(event->link_estab.conn_handle, &desc);
|
||||
event->connect.status == 0 ? "established" : "failed",
|
||||
event->connect.status);
|
||||
if (event->connect.status == 0) {
|
||||
rc = ble_gap_conn_find(event->connect.conn_handle, &desc);
|
||||
assert(rc == 0);
|
||||
enc_adv_data_prph_print_conn_desc(&desc);
|
||||
}
|
||||
MODLOG_DFLT(INFO, "\n");
|
||||
|
||||
if (event->link_estab.status != 0) {
|
||||
if (event->connect.status != 0) {
|
||||
/* Connection failed; resume advertising. */
|
||||
enc_adv_data_prph_advertise();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user