mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(nimble): Keep only BLE_GAP_EVENT_CONNECT gap event
This commit is contained in:
@@ -347,9 +347,9 @@ blecent_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. */
|
||||
if (event->link_estab.status == 0) {
|
||||
if (event->connect.status == 0) {
|
||||
/* Connection successfully established. */
|
||||
|
||||
switch (s_current_phy) {
|
||||
@@ -367,20 +367,20 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
||||
break;
|
||||
}
|
||||
|
||||
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, "\n");
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/* Perform service discovery. */
|
||||
rc = peer_disc_all(event->link_estab.conn_handle,
|
||||
rc = peer_disc_all(event->connect.conn_handle,
|
||||
blecent_on_disc_complete, NULL);
|
||||
if (rc != 0) {
|
||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||
@@ -389,7 +389,7 @@ blecent_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);
|
||||
blecent_scan();
|
||||
}
|
||||
|
||||
|
||||
@@ -183,19 +183,19 @@ bleprph_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);
|
||||
bleprph_print_conn_desc(&desc);
|
||||
}
|
||||
MODLOG_DFLT(INFO, "\n");
|
||||
|
||||
if (event->link_estab.status != 0) {
|
||||
if (event->connect.status != 0) {
|
||||
/* Connection failed; resume advertising. */
|
||||
ext_bleprph_advertise();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user