Merge branch 'feat/add_ble_link_estab_event_v5.3' into 'release/v5.3'

feat(nimble): BLE_GAP_EVENT_LINK_ESTAB event to ensure link established

See merge request espressif/esp-idf!33332
This commit is contained in:
Rahul Tank 2024-09-05 10:37:08 +08:00
commit 10bba8feda
28 changed files with 35 additions and 35 deletions

@ -1 +1 @@
Subproject commit 50c2641a04e356fdac9c53fae56f5004f26605e0 Subproject commit 6e423e457b183bf0b845fae23279c84f0e822ef3

View File

@ -373,7 +373,7 @@ ble_cts_cent_gap_event(struct ble_gap_event *event, void *arg)
ble_cts_cent_connect_if_interesting(&event->disc); ble_cts_cent_connect_if_interesting(&event->disc);
return 0; return 0;
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed. */ /* A new connection was established or a connection attempt failed. */
if (event->connect.status == 0) { if (event->connect.status == 0) {
/* Connection successfully established. */ /* Connection successfully established. */

View File

@ -178,7 +178,7 @@ static int
ble_cts_prph_gap_event(struct ble_gap_event *event, void *arg) ble_cts_prph_gap_event(struct ble_gap_event *event, void *arg)
{ {
switch (event->type) { switch (event->type) {
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed */ /* A new connection was established or a connection attempt failed */
MODLOG_DFLT(INFO, "connection %s; status=%d\n", MODLOG_DFLT(INFO, "connection %s; status=%d\n",
event->connect.status == 0 ? "established" : "failed", event->connect.status == 0 ? "established" : "failed",

View File

@ -136,7 +136,7 @@ dynamic_service_gap_event(struct ble_gap_event *event, void *arg)
int rc; int rc;
switch (event->type) { switch (event->type) {
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed. */ /* A new connection was established or a connection attempt failed. */
MODLOG_DFLT(INFO, "connection %s; status=%d ", MODLOG_DFLT(INFO, "connection %s; status=%d ",
event->connect.status == 0 ? "established" : "failed", event->connect.status == 0 ? "established" : "failed",

View File

@ -425,7 +425,7 @@ enc_adv_data_cent_gap_event(struct ble_gap_event *event, void *arg)
enc_adv_data_cent_connect_if_interesting(&event->disc); enc_adv_data_cent_connect_if_interesting(&event->disc);
return 0; return 0;
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed. */ /* A new connection was established or a connection attempt failed. */
if (event->connect.status == 0) { if (event->connect.status == 0) {
/* Connection successfully established. */ /* Connection successfully established. */

View File

@ -204,7 +204,7 @@ enc_adv_data_prph_gap_event(struct ble_gap_event *event, void *arg)
int rc; int rc;
switch (event->type) { switch (event->type) {
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed. */ /* A new connection was established or a connection attempt failed. */
MODLOG_DFLT(INFO, "connection %s; status=%d ", MODLOG_DFLT(INFO, "connection %s; status=%d ",
event->connect.status == 0 ? "established" : "failed", event->connect.status == 0 ? "established" : "failed",

View File

@ -488,7 +488,7 @@ ble_htp_cent_gap_event(struct ble_gap_event *event, void *arg)
ble_htp_cent_connect_if_interesting(&event->disc); ble_htp_cent_connect_if_interesting(&event->disc);
return 0; return 0;
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed. */ /* A new connection was established or a connection attempt failed. */
if (event->connect.status == 0) { if (event->connect.status == 0) {
/* Connection successfully established. */ /* Connection successfully established. */

View File

@ -230,7 +230,7 @@ static int
ble_htp_prph_gap_event(struct ble_gap_event *event, void *arg) ble_htp_prph_gap_event(struct ble_gap_event *event, void *arg)
{ {
switch (event->type) { switch (event->type) {
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed */ /* A new connection was established or a connection attempt failed */
MODLOG_DFLT(INFO, "connection %s; status=%d\n", MODLOG_DFLT(INFO, "connection %s; status=%d\n",
event->connect.status == 0 ? "established" : "failed", event->connect.status == 0 ? "established" : "failed",

View File

@ -412,7 +412,7 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
blecent_connect_if_interesting(&event->disc); blecent_connect_if_interesting(&event->disc);
return 0; return 0;
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed. */ /* A new connection was established or a connection attempt failed. */
if (event->connect.status == 0) { if (event->connect.status == 0) {
/* Connection successfully established. */ /* Connection successfully established. */

View File

@ -315,7 +315,7 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
int rc; int rc;
switch (event->type) { switch (event->type) {
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed. */ /* A new connection was established or a connection attempt failed. */
MODLOG_DFLT(INFO, "connection %s; status=%d ", MODLOG_DFLT(INFO, "connection %s; status=%d ",
event->connect.status == 0 ? "established" : "failed", event->connect.status == 0 ? "established" : "failed",

View File

@ -302,7 +302,7 @@ ble_multi_advertise(ble_addr_t addr)
static void static void
ble_multi_perform_gatt_proc(ble_addr_t addr) ble_multi_perform_gatt_proc(ble_addr_t addr)
{ {
/* GATT procedures like notify, indicate can be perfomed now */ /* GATT procedures like notify, indicate can be performed now */
for (int i = 0; i < BLE_ADV_INSTANCES; i++) { for (int i = 0; i < BLE_ADV_INSTANCES; i++) {
if (memcmp(&addr, &ble_instance_cb[i].addr, sizeof(addr)) == 0) { if (memcmp(&addr, &ble_instance_cb[i].addr, sizeof(addr)) == 0) {
if (ble_instance_cb[i].cb) { if (ble_instance_cb[i].cb) {
@ -335,7 +335,7 @@ ble_multi_adv_gap_event(struct ble_gap_event *event, void *arg)
int rc; int rc;
switch (event->type) { switch (event->type) {
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed. */ /* A new connection was established or a connection attempt failed. */
MODLOG_DFLT(INFO, "connection %s; status=%d ", MODLOG_DFLT(INFO, "connection %s; status=%d ",
event->connect.status == 0 ? "established" : "failed", event->connect.status == 0 ? "established" : "failed",

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -93,7 +93,7 @@ ble_cent_client_gap_event(struct ble_gap_event *event, void *arg)
return 0; return 0;
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
if (event->connect.status == 0) { if (event->connect.status == 0) {
ESP_LOGI(TAG, "Connection established. Handle:%d, Total:%d", event->connect.conn_handle, ESP_LOGI(TAG, "Connection established. Handle:%d, Total:%d", event->connect.conn_handle,
++s_ble_multi_conn_num); ++s_ble_multi_conn_num);
@ -174,7 +174,7 @@ static int
ble_cent_server_gap_event(struct ble_gap_event *event, void *arg) ble_cent_server_gap_event(struct ble_gap_event *event, void *arg)
{ {
switch (event->type) { switch (event->type) {
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* The connectable adv has been established. We will act as the peripheral. */ /* The connectable adv has been established. We will act as the peripheral. */
if (event->connect.status == 0) { if (event->connect.status == 0) {
ESP_LOGI(TAG, "Peripheral connected to central. Handle:%d", event->connect.conn_handle); ESP_LOGI(TAG, "Peripheral connected to central. Handle:%d", event->connect.conn_handle);

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -163,7 +163,7 @@ ble_prph_restart_adv(void)
{ {
#if CONFIG_EXAMPLE_RESTART_ADV_AFTER_CONNECTED #if CONFIG_EXAMPLE_RESTART_ADV_AFTER_CONNECTED
if (!xSemaphoreGive(s_sem_restart_adv)) { if (!xSemaphoreGive(s_sem_restart_adv)) {
ESP_LOGE(TAG, "Failed to give Semaphor"); ESP_LOGE(TAG, "Failed to give Semaphore");
} }
#else #else
ble_prph_advertise(); ble_prph_advertise();
@ -189,7 +189,7 @@ static int
ble_prph_gap_event(struct ble_gap_event *event, void *arg) ble_prph_gap_event(struct ble_gap_event *event, void *arg)
{ {
switch (event->type) { switch (event->type) {
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
if (event->connect.status == 0) { if (event->connect.status == 0) {
/* A new connection was established. */ /* A new connection was established. */
ESP_LOGI(TAG, "Connection established. Handle:%d. Total:%d", event->connect.conn_handle, ESP_LOGI(TAG, "Connection established. Handle:%d. Total:%d", event->connect.conn_handle,
@ -316,7 +316,7 @@ app_main(void)
vTaskDelay(pdMS_TO_TICKS(delay_ms)); vTaskDelay(pdMS_TO_TICKS(delay_ms));
ble_prph_advertise(); ble_prph_advertise();
} else { } else {
ESP_LOGE(TAG, "Failed to take Semaphor"); ESP_LOGE(TAG, "Failed to take Semaphore");
} }
} }
#endif // CONFIG_EXAMPLE_RESTART_ADV_AFTER_CONNECTED #endif // CONFIG_EXAMPLE_RESTART_ADV_AFTER_CONNECTED

View File

@ -347,7 +347,7 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
int rc; int rc;
switch (event->type) { switch (event->type) {
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed. */ /* A new connection was established or a connection attempt failed. */
if (event->connect.status == 0) { if (event->connect.status == 0) {
/* Connection successfully established. */ /* Connection successfully established. */

View File

@ -183,7 +183,7 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
int rc; int rc;
switch (event->type) { switch (event->type) {
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed. */ /* A new connection was established or a connection attempt failed. */
MODLOG_DFLT(INFO, "connection %s; status=%d ", MODLOG_DFLT(INFO, "connection %s; status=%d ",
event->connect.status == 0 ? "established" : "failed", event->connect.status == 0 ? "established" : "failed",

View File

@ -405,7 +405,7 @@ ble_prox_cent_gap_event(struct ble_gap_event *event, void *arg)
ble_prox_cent_connect_if_interesting(&event->disc); ble_prox_cent_connect_if_interesting(&event->disc);
return 0; return 0;
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed. */ /* A new connection was established or a connection attempt failed. */
if (event->connect.status == 0) { if (event->connect.status == 0) {
/* Connection successfully established. */ /* Connection successfully established. */

View File

@ -177,7 +177,7 @@ static int
ble_prox_prph_gap_event(struct ble_gap_event *event, void *arg) ble_prox_prph_gap_event(struct ble_gap_event *event, void *arg)
{ {
switch (event->type) { switch (event->type) {
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed */ /* A new connection was established or a connection attempt failed */
MODLOG_DFLT(INFO, "connection %s; status=%d\n", MODLOG_DFLT(INFO, "connection %s; status=%d\n",
event->connect.status == 0 ? "established" : "failed", event->connect.status == 0 ? "established" : "failed",

View File

@ -230,7 +230,7 @@ ble_spp_client_gap_event(struct ble_gap_event *event, void *arg)
ble_spp_client_connect_if_interesting(&event->disc); ble_spp_client_connect_if_interesting(&event->disc);
return 0; return 0;
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed. */ /* A new connection was established or a connection attempt failed. */
if (event->connect.status == 0) { if (event->connect.status == 0) {
/* Connection successfully established. */ /* Connection successfully established. */

View File

@ -141,7 +141,7 @@ ble_spp_server_gap_event(struct ble_gap_event *event, void *arg)
int rc; int rc;
switch (event->type) { switch (event->type) {
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed. */ /* A new connection was established or a connection attempt failed. */
MODLOG_DFLT(INFO, "connection %s; status=%d ", MODLOG_DFLT(INFO, "connection %s; status=%d ",
event->connect.status == 0 ? "established" : "failed", event->connect.status == 0 ? "established" : "failed",

View File

@ -696,7 +696,7 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
blecent_connect_if_interesting(&event->disc); blecent_connect_if_interesting(&event->disc);
return 0; return 0;
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed. */ /* A new connection was established or a connection attempt failed. */
if (event->connect.status == 0) { if (event->connect.status == 0) {
/* Connection successfully established. */ /* Connection successfully established. */

View File

@ -213,7 +213,7 @@ static int
blecsc_gap_event(struct ble_gap_event *event, void *arg) blecsc_gap_event(struct ble_gap_event *event, void *arg)
{ {
switch (event->type) { switch (event->type) {
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed */ /* A new connection was established or a connection attempt failed */
MODLOG_DFLT(INFO, "connection %s; status=%d\n", MODLOG_DFLT(INFO, "connection %s; status=%d\n",
event->connect.status == 0 ? "established" : "failed", event->connect.status == 0 ? "established" : "failed",

View File

@ -184,7 +184,7 @@ static int
blehr_gap_event(struct ble_gap_event *event, void *arg) blehr_gap_event(struct ble_gap_event *event, void *arg)
{ {
switch (event->type) { switch (event->type) {
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed */ /* A new connection was established or a connection attempt failed */
MODLOG_DFLT(INFO, "connection %s; status=%d\n", MODLOG_DFLT(INFO, "connection %s; status=%d\n",
event->connect.status == 0 ? "established" : "failed", event->connect.status == 0 ? "established" : "failed",

View File

@ -235,7 +235,7 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
int rc; int rc;
switch (event->type) { switch (event->type) {
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed. */ /* A new connection was established or a connection attempt failed. */
MODLOG_DFLT(INFO, "connection %s; status=%d ", MODLOG_DFLT(INFO, "connection %s; status=%d ",
event->connect.status == 0 ? "established" : "failed", event->connect.status == 0 ? "established" : "failed",

View File

@ -223,7 +223,7 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
int rc; int rc;
switch (event->type) { switch (event->type) {
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed. */ /* A new connection was established or a connection attempt failed. */
MODLOG_DFLT(INFO, "connection %s; status=%d ", MODLOG_DFLT(INFO, "connection %s; status=%d ",
event->connect.status == 0 ? "established" : "failed", event->connect.status == 0 ? "established" : "failed",

View File

@ -119,7 +119,7 @@ void wifi_init_sta(void)
.ssid = EXAMPLE_ESP_WIFI_SSID, .ssid = EXAMPLE_ESP_WIFI_SSID,
.password = EXAMPLE_ESP_WIFI_PASS, .password = EXAMPLE_ESP_WIFI_PASS,
/* Setting a password implies station will connect to all security modes including WEP/WPA. /* Setting a password implies station will connect to all security modes including WEP/WPA.
* However these modes are deprecated and not advisable to be used. Incase your Access point * However these modes are deprecated and not advisable to be used. In case your Access point
* doesn't support WPA2, these mode can be enabled by commenting below line */ * doesn't support WPA2, these mode can be enabled by commenting below line */
.threshold.authmode = WIFI_AUTH_WPA2_PSK, .threshold.authmode = WIFI_AUTH_WPA2_PSK,
}, },
@ -389,7 +389,7 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
int rc; int rc;
switch (event->type) { switch (event->type) {
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed. */ /* A new connection was established or a connection attempt failed. */
ESP_LOGI(TAG, "connection %s; status=%d ", ESP_LOGI(TAG, "connection %s; status=%d ",
event->connect.status == 0 ? "established" : "failed", event->connect.status == 0 ? "established" : "failed",

View File

@ -282,7 +282,7 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
int rc; int rc;
switch (event->type) { switch (event->type) {
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed. */ /* A new connection was established or a connection attempt failed. */
MODLOG_DFLT(INFO, "connection %s; status=%d ", MODLOG_DFLT(INFO, "connection %s; status=%d ",
event->connect.status == 0 ? "established" : "failed", event->connect.status == 0 ? "established" : "failed",

View File

@ -538,7 +538,7 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
blecent_connect_if_interesting(&event->disc); blecent_connect_if_interesting(&event->disc);
return 0; return 0;
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed. */ /* A new connection was established or a connection attempt failed. */
if (event->connect.status == 0) { if (event->connect.status == 0) {
/* Connection successfully established. */ /* Connection successfully established. */

View File

@ -239,7 +239,7 @@ gatts_gap_event(struct ble_gap_event *event, void *arg)
int rc; int rc;
switch (event->type) { switch (event->type) {
case BLE_GAP_EVENT_CONNECT: case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed */ /* A new connection was established or a connection attempt failed */
ESP_LOGI(tag, "connection %s; status = %d ", ESP_LOGI(tag, "connection %s; status = %d ",
event->connect.status == 0 ? "established" : "failed", event->connect.status == 0 ? "established" : "failed",