mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 09:09:10 -04:00
fix(nimble): Keep only BLE_GAP_EVENT_CONNECT gap event
This commit is contained in:
parent
de853be81e
commit
891f86d649
@ -1 +1 @@
|
||||
Subproject commit a9a4c701981b86c91fdc63fce4cb7bc05c69caac
|
||||
Subproject commit 9b2b013c114d592ceb045f5545343af44d2a8fef
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -373,19 +373,19 @@ ble_cts_cent_gap_event(struct ble_gap_event *event, void *arg)
|
||||
ble_cts_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, "\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;
|
||||
@ -398,17 +398,17 @@ ble_cts_cent_gap_event(struct ble_gap_event *event, void *arg)
|
||||
* Encryption (Enable encryption)
|
||||
* Will invoke event BLE_GAP_EVENT_ENC_CHANGE
|
||||
**/
|
||||
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");
|
||||
}
|
||||
#else
|
||||
/* Perform service discovery */
|
||||
rc = peer_disc_all(event->link_estab.conn_handle,
|
||||
rc = peer_disc_all(event->connect.conn_handle,
|
||||
ble_cts_cent_on_disc_complete, NULL);
|
||||
if (rc != 0) {
|
||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||
@ -418,7 +418,7 @@ ble_cts_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);
|
||||
ble_cts_cent_scan();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -178,13 +178,13 @@ static int
|
||||
ble_cts_prph_gap_event(struct ble_gap_event *event, void *arg)
|
||||
{
|
||||
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\n",
|
||||
event->link_estab.status == 0 ? "established" : "failed",
|
||||
event->link_estab.status);
|
||||
event->connect.status == 0 ? "established" : "failed",
|
||||
event->connect.status);
|
||||
|
||||
if (event->link_estab.status != 0) {
|
||||
if (event->connect.status != 0) {
|
||||
/* Connection failed; resume advertising */
|
||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||
ext_ble_cts_prph_advertise();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
@ -136,19 +136,19 @@ dynamic_service_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);
|
||||
dynamic_service_print_conn_desc(&desc);
|
||||
}
|
||||
MODLOG_DFLT(INFO, "\n");
|
||||
|
||||
if (event->link_estab.status != 0) {
|
||||
if (event->connect.status != 0) {
|
||||
/* Connection failed; resume advertising. */
|
||||
dynamic_service_advertise();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
@ -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();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -488,19 +488,19 @@ ble_htp_cent_gap_event(struct ble_gap_event *event, void *arg)
|
||||
ble_htp_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, "\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;
|
||||
@ -513,17 +513,17 @@ ble_htp_cent_gap_event(struct ble_gap_event *event, void *arg)
|
||||
* Encryption (Enable encryption)
|
||||
* Will invoke event BLE_GAP_EVENT_ENC_CHANGE
|
||||
**/
|
||||
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");
|
||||
}
|
||||
#else
|
||||
/* Perform service discovery */
|
||||
rc = peer_disc_all(event->link_estab.conn_handle,
|
||||
rc = peer_disc_all(event->connect.conn_handle,
|
||||
ble_htp_cent_on_disc_complete, NULL);
|
||||
if (rc != 0) {
|
||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||
@ -533,7 +533,7 @@ ble_htp_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);
|
||||
ble_htp_cent_scan();
|
||||
}
|
||||
|
||||
@ -566,7 +566,7 @@ ble_htp_cent_gap_event(struct ble_gap_event *event, void *arg)
|
||||
print_conn_desc(&desc);
|
||||
#if CONFIG_EXAMPLE_ENCRYPTION
|
||||
/*** Go for service discovery after encryption has been successfully enabled ***/
|
||||
rc = peer_disc_all(event->link_estab.conn_handle,
|
||||
rc = peer_disc_all(event->connect.conn_handle,
|
||||
ble_htp_cent_on_disc_complete, NULL);
|
||||
if (rc != 0) {
|
||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -230,13 +230,13 @@ static int
|
||||
ble_htp_prph_gap_event(struct ble_gap_event *event, void *arg)
|
||||
{
|
||||
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\n",
|
||||
event->link_estab.status == 0 ? "established" : "failed",
|
||||
event->link_estab.status);
|
||||
event->connect.status == 0 ? "established" : "failed",
|
||||
event->connect.status);
|
||||
|
||||
if (event->link_estab.status != 0) {
|
||||
if (event->connect.status != 0) {
|
||||
/* Connection failed; resume advertising */
|
||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||
ext_ble_htp_prph_advertise();
|
||||
@ -245,7 +245,7 @@ ble_htp_prph_gap_event(struct ble_gap_event *event, void *arg)
|
||||
#endif
|
||||
|
||||
}
|
||||
conn_handle = event->link_estab.conn_handle;
|
||||
conn_handle = event->connect.conn_handle;
|
||||
break;
|
||||
|
||||
case BLE_GAP_EVENT_DISCONNECT:
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
@ -412,32 +412,32 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
||||
blecent_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, "\n");
|
||||
|
||||
#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) >= 1
|
||||
conn_handle_coc = event->link_estab.conn_handle;
|
||||
conn_handle_coc = event->connect.conn_handle;
|
||||
disc_cb = blecent_l2cap_coc_on_disc_complete;
|
||||
#else
|
||||
disc_cb = blecent_on_disc_complete;
|
||||
#endif
|
||||
/* 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,
|
||||
disc_cb, NULL);
|
||||
if (rc != 0) {
|
||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||
@ -446,7 +446,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();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
@ -315,19 +315,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. */
|
||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||
ext_bleprph_advertise();
|
||||
@ -335,7 +335,7 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
|
||||
bleprph_advertise();
|
||||
#endif
|
||||
} else {
|
||||
rc = ble_gap_conn_find(event->link_estab.conn_handle, &desc);
|
||||
rc = ble_gap_conn_find(event->connect.conn_handle, &desc);
|
||||
assert(rc == 0);
|
||||
bleprph_print_conn_desc(&desc);
|
||||
#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) >= 1
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -337,13 +337,13 @@ ble_multi_adv_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);
|
||||
ble_multi_adv_print_conn_desc(&desc);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -93,17 +93,17 @@ ble_cent_client_gap_event(struct ble_gap_event *event, void *arg)
|
||||
|
||||
return 0;
|
||||
|
||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||
if (event->link_estab.status == 0) {
|
||||
ESP_LOGI(TAG, "Connection established. Handle:%d, Total:%d", event->link_estab.conn_handle,
|
||||
case BLE_GAP_EVENT_CONNECT:
|
||||
if (event->connect.status == 0) {
|
||||
ESP_LOGI(TAG, "Connection established. Handle:%d, Total:%d", event->connect.conn_handle,
|
||||
++s_ble_multi_conn_num);
|
||||
/* Remember peer. */
|
||||
rc = peer_add(event->link_estab.conn_handle);
|
||||
rc = peer_add(event->connect.conn_handle);
|
||||
if (rc != 0) {
|
||||
ESP_LOGE(TAG, "Failed to add peer; rc=%d\n", rc);
|
||||
} else {
|
||||
/* Perform service discovery */
|
||||
rc = peer_disc_svc_by_uuid(event->link_estab.conn_handle, remote_svc_uuid,
|
||||
rc = peer_disc_svc_by_uuid(event->connect.conn_handle, remote_svc_uuid,
|
||||
ble_cent_on_disc_complete, NULL);
|
||||
if(rc != 0) {
|
||||
ESP_LOGE(TAG, "Failed to discover services; rc=%d\n", rc);
|
||||
@ -111,7 +111,7 @@ ble_cent_client_gap_event(struct ble_gap_event *event, void *arg)
|
||||
}
|
||||
} else {
|
||||
/* Connection attempt failed; resume scanning. */
|
||||
ESP_LOGE(TAG, "Central: Connection failed; status=0x%x\n", event->link_estab.status);
|
||||
ESP_LOGE(TAG, "Central: Connection failed; status=0x%x\n", event->connect.status);
|
||||
}
|
||||
ble_cent_scan();
|
||||
return 0;
|
||||
@ -174,12 +174,12 @@ static int
|
||||
ble_cent_server_gap_event(struct ble_gap_event *event, void *arg)
|
||||
{
|
||||
switch (event->type) {
|
||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||
case BLE_GAP_EVENT_CONNECT:
|
||||
/* The connectable adv has been established. We will act as the peripheral. */
|
||||
if (event->link_estab.status == 0) {
|
||||
ESP_LOGI(TAG, "Peripheral connected to central. Handle:%d", event->link_estab.conn_handle);
|
||||
if (event->connect.status == 0) {
|
||||
ESP_LOGI(TAG, "Peripheral connected to central. Handle:%d", event->connect.conn_handle);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Peripheral: Connection failed; status=0x%x\n", event->link_estab.status);
|
||||
ESP_LOGE(TAG, "Peripheral: Connection failed; status=0x%x\n", event->connect.status);
|
||||
ble_cent_advertise();
|
||||
}
|
||||
return 0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -189,10 +189,10 @@ static int
|
||||
ble_prph_gap_event(struct ble_gap_event *event, void *arg)
|
||||
{
|
||||
switch (event->type) {
|
||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||
if (event->link_estab.status == 0) {
|
||||
case BLE_GAP_EVENT_CONNECT:
|
||||
if (event->connect.status == 0) {
|
||||
/* A new connection was established. */
|
||||
ESP_LOGI(TAG, "Connection established. Handle:%d. Total:%d", event->link_estab.conn_handle,
|
||||
ESP_LOGI(TAG, "Connection established. Handle:%d. Total:%d", event->connect.conn_handle,
|
||||
++s_ble_prph_conn_num);
|
||||
#if CONFIG_EXAMPLE_RESTART_ADV_AFTER_CONNECTED
|
||||
ble_prph_restart_adv();
|
||||
|
@ -73,10 +73,10 @@ gap_event_cb(struct ble_gap_event *event, void *arg)
|
||||
|
||||
switch (event->type) {
|
||||
|
||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||
if (event->link_estab.status == 0) {
|
||||
ESP_LOGI(TAG, "[Connection established], conn_handle = 0x%02x, Adv handle = 0x%0x, status = 0x%0x\n",event->link_estab.conn_handle, event->link_estab.adv_handle, event->link_estab.status);
|
||||
rc = ble_gap_conn_find(event->link_estab.conn_handle, &desc);
|
||||
case BLE_GAP_EVENT_CONNECT:
|
||||
if (event->connect.status == 0) {
|
||||
ESP_LOGI(TAG, "[Connection established], conn_handle = 0x%02x, Adv handle = 0x%0x, status = 0x%0x\n",event->connect.conn_handle, event->connect.adv_handle, event->connect.status);
|
||||
rc = ble_gap_conn_find(event->connect.conn_handle, &desc);
|
||||
if (rc == 0) {
|
||||
print_conn_desc(&desc);
|
||||
}
|
||||
@ -84,7 +84,7 @@ gap_event_cb(struct ble_gap_event *event, void *arg)
|
||||
ESP_LOGE(TAG,"Failed to find Conn Information");
|
||||
}
|
||||
} else {
|
||||
ESP_LOGW(TAG, "[Connection Failed], conn_handle = 0x%02x, Adv handle = 0x%0x, status = 0x%0x\n",event->link_estab.conn_handle, event->link_estab.adv_handle, event->link_estab.status);
|
||||
ESP_LOGW(TAG, "[Connection Failed], conn_handle = 0x%02x, Adv handle = 0x%0x, status = 0x%0x\n",event->connect.conn_handle, event->connect.adv_handle, event->connect.status);
|
||||
conn = 0;
|
||||
}
|
||||
|
||||
|
@ -65,10 +65,10 @@ gap_event_cb(struct ble_gap_event *event, void *arg)
|
||||
struct ble_gap_ext_disc_desc *disc;
|
||||
|
||||
switch (event->type) {
|
||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||
if (event->link_estab.status == 0) {
|
||||
ESP_LOGI(TAG, "Connection established, conn_handle = 0x%0x, sync handle= 0x%02x, status = 0x%0x\n",event->link_estab.conn_handle, event->link_estab.sync_handle, event->link_estab.status);
|
||||
rc = ble_gap_conn_find(event->link_estab.conn_handle, &desc);
|
||||
case BLE_GAP_EVENT_CONNECT:
|
||||
if (event->connect.status == 0) {
|
||||
ESP_LOGI(TAG, "Connection established, conn_handle = 0x%0x, sync handle= 0x%02x, status = 0x%0x\n",event->connect.conn_handle, event->connect.sync_handle, event->connect.status);
|
||||
rc = ble_gap_conn_find(event->connect.conn_handle, &desc);
|
||||
if (rc == 0) {
|
||||
print_conn_desc(&desc);
|
||||
}
|
||||
@ -76,7 +76,7 @@ gap_event_cb(struct ble_gap_event *event, void *arg)
|
||||
ESP_LOGE(TAG,"Failed to find Conn Information");
|
||||
}
|
||||
} else{
|
||||
ESP_LOGW(TAG, "[Connection Failed], conn_handle = 0x%02x, sync handle = 0x%0x, status = 0x%0x\n",event->link_estab.conn_handle, event->link_estab.sync_handle, event->link_estab.status);
|
||||
ESP_LOGW(TAG, "[Connection Failed], conn_handle = 0x%02x, sync handle = 0x%0x, status = 0x%0x\n",event->connect.conn_handle, event->connect.sync_handle, event->connect.status);
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
@ -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();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -405,13 +405,13 @@ ble_prox_cent_gap_event(struct ble_gap_event *event, void *arg)
|
||||
ble_prox_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, "\n");
|
||||
@ -419,7 +419,7 @@ ble_prox_cent_gap_event(struct ble_gap_event *event, void *arg)
|
||||
link_supervision_timeout = 8 * desc.conn_itvl;
|
||||
|
||||
/* 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;
|
||||
@ -445,17 +445,17 @@ ble_prox_cent_gap_event(struct ble_gap_event *event, void *arg)
|
||||
* Encryption (Enable encryption)
|
||||
* Will invoke event BLE_GAP_EVENT_ENC_CHANGE
|
||||
**/
|
||||
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");
|
||||
}
|
||||
#else
|
||||
/* Perform service discovery */
|
||||
rc = peer_disc_all(event->link_estab.conn_handle,
|
||||
rc = peer_disc_all(event->connect.conn_handle,
|
||||
ble_prox_cent_on_disc_complete, NULL);
|
||||
if (rc != 0) {
|
||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||
@ -465,7 +465,7 @@ ble_prox_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);
|
||||
}
|
||||
ble_prox_cent_scan();
|
||||
return 0;
|
||||
@ -514,7 +514,7 @@ ble_prox_cent_gap_event(struct ble_gap_event *event, void *arg)
|
||||
print_conn_desc(&desc);
|
||||
#if CONFIG_EXAMPLE_ENCRYPTION
|
||||
/*** Go for service discovery after encryption has been successfully enabled ***/
|
||||
rc = peer_disc_all(event->link_estab.conn_handle,
|
||||
rc = peer_disc_all(event->connect.conn_handle,
|
||||
ble_prox_cent_on_disc_complete, NULL);
|
||||
if (rc != 0) {
|
||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -177,13 +177,13 @@ static int
|
||||
ble_prox_prph_gap_event(struct ble_gap_event *event, void *arg)
|
||||
{
|
||||
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\n",
|
||||
event->link_estab.status == 0 ? "established" : "failed",
|
||||
event->link_estab.status);
|
||||
event->connect.status == 0 ? "established" : "failed",
|
||||
event->connect.status);
|
||||
|
||||
if (event->link_estab.status != 0) {
|
||||
if (event->connect.status != 0) {
|
||||
/* Connection failed, resume advertising */
|
||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||
ext_ble_prox_prph_advertise();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
@ -271,27 +271,27 @@ ble_spp_client_gap_event(struct ble_gap_event *event, void *arg)
|
||||
ble_spp_client_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);
|
||||
memcpy(&connected_addr[event->link_estab.conn_handle].val, desc.peer_id_addr.val,
|
||||
memcpy(&connected_addr[event->connect.conn_handle].val, desc.peer_id_addr.val,
|
||||
PEER_ADDR_VAL_SIZE);
|
||||
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,
|
||||
ble_spp_client_on_disc_complete, NULL);
|
||||
if (rc != 0) {
|
||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||
@ -300,7 +300,7 @@ ble_spp_client_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);
|
||||
ble_spp_client_scan();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
@ -141,18 +141,18 @@ ble_spp_server_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);
|
||||
ble_spp_server_print_conn_desc(&desc);
|
||||
}
|
||||
MODLOG_DFLT(INFO, "\n");
|
||||
if (event->link_estab.status != 0 || CONFIG_BT_NIMBLE_MAX_CONNECTIONS > 1) {
|
||||
if (event->connect.status != 0 || CONFIG_BT_NIMBLE_MAX_CONNECTIONS > 1) {
|
||||
/* Connection failed or if multiple connection allowed; resume advertising. */
|
||||
ble_spp_server_advertise();
|
||||
}
|
||||
|
@ -703,32 +703,32 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
||||
blecent_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, "\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;
|
||||
}
|
||||
|
||||
#if MYNEWT_VAL(BLE_POWER_CONTROL)
|
||||
blecent_power_control(event->link_estab.conn_handle);
|
||||
blecent_power_control(event->connect.conn_handle);
|
||||
#endif
|
||||
|
||||
#if MYNEWT_VAL(BLE_HCI_VS)
|
||||
#if MYNEWT_VAL(BLE_POWER_CONTROL)
|
||||
memset(¶ms, 0x0, sizeof(struct ble_gap_set_auto_pcl_params));
|
||||
params.conn_handle = event->link_estab.conn_handle;
|
||||
params.conn_handle = event->connect.conn_handle;
|
||||
rc = ble_gap_set_auto_pcl_param(¶ms);
|
||||
if (rc != 0) {
|
||||
MODLOG_DFLT(INFO, "Failed to send VSC %x \n", rc);
|
||||
@ -747,17 +747,17 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
||||
* Encryption (Enable encryption)
|
||||
* Will invoke event BLE_GAP_EVENT_ENC_CHANGE
|
||||
**/
|
||||
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");
|
||||
}
|
||||
#else
|
||||
/* 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);
|
||||
@ -767,7 +767,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();
|
||||
}
|
||||
|
||||
|
@ -213,19 +213,19 @@ static int
|
||||
blecsc_gap_event(struct ble_gap_event *event, void *arg)
|
||||
{
|
||||
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\n",
|
||||
event->link_estab.status == 0 ? "established" : "failed",
|
||||
event->link_estab.status);
|
||||
event->connect.status == 0 ? "established" : "failed",
|
||||
event->connect.status);
|
||||
|
||||
if (event->link_estab.status != 0) {
|
||||
if (event->connect.status != 0) {
|
||||
/* Connection failed; resume advertising */
|
||||
blecsc_advertise();
|
||||
conn_handle = 0;
|
||||
}
|
||||
else {
|
||||
conn_handle = event->link_estab.conn_handle;
|
||||
conn_handle = event->connect.conn_handle;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -184,17 +184,17 @@ static int
|
||||
blehr_gap_event(struct ble_gap_event *event, void *arg)
|
||||
{
|
||||
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\n",
|
||||
event->link_estab.status == 0 ? "established" : "failed",
|
||||
event->link_estab.status);
|
||||
event->connect.status == 0 ? "established" : "failed",
|
||||
event->connect.status);
|
||||
|
||||
if (event->link_estab.status != 0) {
|
||||
if (event->connect.status != 0) {
|
||||
/* Connection failed; resume advertising */
|
||||
blehr_advertise();
|
||||
}
|
||||
conn_handle = event->link_estab.conn_handle;
|
||||
conn_handle = event->connect.conn_handle;
|
||||
break;
|
||||
|
||||
case BLE_GAP_EVENT_DISCONNECT:
|
||||
|
@ -240,19 +240,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. */
|
||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||
ext_bleprph_advertise();
|
||||
@ -262,7 +262,7 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
|
||||
}
|
||||
|
||||
#if MYNEWT_VAL(BLE_POWER_CONTROL)
|
||||
bleprph_power_control(event->link_estab.conn_handle);
|
||||
bleprph_power_control(event->connect.conn_handle);
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -223,19 +223,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. */
|
||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||
ext_bleprph_advertise();
|
||||
@ -245,7 +245,7 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
|
||||
}
|
||||
|
||||
#if MYNEWT_VAL(BLE_POWER_CONTROL)
|
||||
bleprph_power_control(event->link_estab.conn_handle);
|
||||
bleprph_power_control(event->connect.conn_handle);
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
|
@ -389,18 +389,18 @@ 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. */
|
||||
ESP_LOGI(TAG, "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);
|
||||
}
|
||||
|
||||
if (event->link_estab.status != 0) {
|
||||
if (event->connect.status != 0) {
|
||||
/* Connection failed; resume advertising. */
|
||||
bleprph_advertise();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -284,19 +284,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. */
|
||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||
ext_bleprph_advertise();
|
||||
@ -306,7 +306,7 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
|
||||
}
|
||||
|
||||
#if MYNEWT_VAL(BLE_POWER_CONTROL)
|
||||
bleprph_power_control(event->link_estab.conn_handle);
|
||||
bleprph_power_control(event->connect.conn_handle);
|
||||
|
||||
ble_gap_event_listener_register(&power_control_event_listener,
|
||||
bleprph_gap_power_event, NULL);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -538,13 +538,13 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
||||
blecent_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. */
|
||||
/* XXX Set packet length in controller for better throughput */
|
||||
ESP_LOGI(tag, "Connection established ");
|
||||
rc = ble_hs_hci_util_set_data_len(event->link_estab.conn_handle,
|
||||
rc = ble_hs_hci_util_set_data_len(event->connect.conn_handle,
|
||||
LL_PACKET_LENGTH, LL_PACKET_TIME);
|
||||
if (rc != 0) {
|
||||
ESP_LOGE(tag, "Set packet length failed; rc = %d", rc);
|
||||
@ -555,29 +555,29 @@ blecent_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);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
rc = ble_gap_update_params(event->link_estab.conn_handle, &conn_params);
|
||||
rc = ble_gap_update_params(event->connect.conn_handle, &conn_params);
|
||||
if (rc != 0) {
|
||||
ESP_LOGE(tag, "Failed to update params; rc = %d", rc);
|
||||
}
|
||||
|
||||
/* Remember peer. */
|
||||
rc = peer_add(event->link_estab.conn_handle);
|
||||
rc = peer_add(event->connect.conn_handle);
|
||||
if (rc != 0) {
|
||||
ESP_LOGE(tag, "Failed to add peer; rc = %d", 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) {
|
||||
ESP_LOGE(tag, "Failed to discover services; rc = %d", rc);
|
||||
@ -586,7 +586,7 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
||||
} else {
|
||||
/* Connection attempt failed; resume scanning. */
|
||||
ESP_LOGE(tag, "Error: Connection failed; status = %d",
|
||||
event->link_estab.status);
|
||||
event->connect.status);
|
||||
blecent_scan();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -239,29 +239,29 @@ gatts_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 */
|
||||
ESP_LOGI(tag, "connection %s; status = %d ",
|
||||
event->link_estab.status == 0 ? "established" : "failed",
|
||||
event->link_estab.status);
|
||||
event->connect.status == 0 ? "established" : "failed",
|
||||
event->connect.status);
|
||||
rc = ble_att_set_preferred_mtu(PREFERRED_MTU_VALUE);
|
||||
if (rc != 0) {
|
||||
ESP_LOGE(tag, "Failed to set preferred MTU; rc = %d", rc);
|
||||
}
|
||||
|
||||
if (event->link_estab.status != 0) {
|
||||
if (event->connect.status != 0) {
|
||||
/* Connection failed; resume advertising */
|
||||
gatts_advertise();
|
||||
}
|
||||
|
||||
rc = ble_hs_hci_util_set_data_len(event->link_estab.conn_handle,
|
||||
rc = ble_hs_hci_util_set_data_len(event->connect.conn_handle,
|
||||
LL_PACKET_LENGTH,
|
||||
LL_PACKET_TIME);
|
||||
if (rc != 0) {
|
||||
ESP_LOGE(tag, "Set packet length failed");
|
||||
}
|
||||
|
||||
conn_handle = event->link_estab.conn_handle;
|
||||
conn_handle = event->connect.conn_handle;
|
||||
break;
|
||||
|
||||
case BLE_GAP_EVENT_DISCONNECT:
|
||||
|
Loading…
x
Reference in New Issue
Block a user