mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-03 10:30:58 +02:00
Merge branch 'fix/adding_missing_apis_nimble' into 'master'
fix(nimble): Added helper APIs in NimBLE Closes BLERP-2126 and BLERP-2138 See merge request espressif/esp-idf!40223
This commit is contained in:
@@ -873,6 +873,12 @@ config BT_NIMBLE_GATT_CACHING_DISABLE_AUTO
|
|||||||
help
|
help
|
||||||
When client receives ATT out-of-sync error message, it will not automatically start the discovery procedure
|
When client receives ATT out-of-sync error message, it will not automatically start the discovery procedure
|
||||||
to correct the invalid cache.
|
to correct the invalid cache.
|
||||||
|
config BT_NIMBLE_GATT_CACHING_ASSOC_ENABLE
|
||||||
|
bool "Enable association-based GATT caching"
|
||||||
|
depends on BT_NIMBLE_GATT_CACHING
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
Enable this option to use associated address caching instead of performing service discovery.
|
||||||
|
|
||||||
config BT_NIMBLE_WHITELIST_SIZE
|
config BT_NIMBLE_WHITELIST_SIZE
|
||||||
int "BLE white list size"
|
int "BLE white list size"
|
||||||
|
Submodule components/bt/host/nimble/nimble updated: 550ce6a646...db2f236ec1
@@ -196,6 +196,14 @@
|
|||||||
#define MYNEWT_VAL_BLE_GATT_CACHING_DISABLE_AUTO (0)
|
#define MYNEWT_VAL_BLE_GATT_CACHING_DISABLE_AUTO (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MYNEWT_VAL_BLE_GATT_CACHING_ASSOC_ENABLE
|
||||||
|
#ifdef CONFIG_BT_NIMBLE_GATT_CACHING_ASSOC_ENABLE
|
||||||
|
#define MYNEWT_VAL_BLE_GATT_CACHING_ASSOC_ENABLE (CONFIG_BT_NIMBLE_GATT_CACHING_ASSOC_ENABLE)
|
||||||
|
#else
|
||||||
|
#define MYNEWT_VAL_BLE_GATT_CACHING_ASSOC_ENABLE (0)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MYNEWT_VAL_BLE_GATT_CSFC_SIZE
|
#ifndef MYNEWT_VAL_BLE_GATT_CSFC_SIZE
|
||||||
|
@@ -426,6 +426,13 @@ ble_cts_cent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
} else {
|
} else {
|
||||||
MODLOG_DFLT(INFO, "Connection secured\n");
|
MODLOG_DFLT(INFO, "Connection secured\n");
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#if MYNEWT_VAL(BLE_GATT_CACHING_ASSOC_ENABLE)
|
||||||
|
rc = ble_gattc_cache_assoc(desc.peer_id_addr);
|
||||||
|
if (rc != 0) {
|
||||||
|
MODLOG_DFLT(ERROR, "Cache Association Failed; rc=%d\n", rc);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* Perform service discovery */
|
/* Perform service discovery */
|
||||||
rc = peer_disc_all(event->connect.conn_handle,
|
rc = peer_disc_all(event->connect.conn_handle,
|
||||||
@@ -434,6 +441,7 @@ ble_cts_cent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif // BLE_GATT_CACHING_ASSOC_ENABLE
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
/* Connection attempt failed; resume scanning. */
|
/* Connection attempt failed; resume scanning. */
|
||||||
@@ -470,6 +478,13 @@ ble_cts_cent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
print_conn_desc(&desc);
|
print_conn_desc(&desc);
|
||||||
#if CONFIG_EXAMPLE_ENCRYPTION
|
#if CONFIG_EXAMPLE_ENCRYPTION
|
||||||
|
#if MYNEWT_VAL(BLE_GATT_CACHING_ASSOC_ENABLE)
|
||||||
|
rc = ble_gattc_cache_assoc(desc.peer_id_addr);
|
||||||
|
if (rc != 0) {
|
||||||
|
MODLOG_DFLT(ERROR, "Cache Association Failed; rc=%d\n", rc);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
/*** Go for service discovery after encryption has been successfully enabled ***/
|
/*** Go for service discovery after encryption has been successfully enabled ***/
|
||||||
rc = peer_disc_all(event->connect.conn_handle,
|
rc = peer_disc_all(event->connect.conn_handle,
|
||||||
ble_cts_cent_on_disc_complete, NULL);
|
ble_cts_cent_on_disc_complete, NULL);
|
||||||
@@ -477,9 +492,27 @@ ble_cts_cent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif // BLE_GATT_CACHING_ASSOC_ENABLE
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
case BLE_GAP_EVENT_CACHE_ASSOC:
|
||||||
|
#if MYNEWT_VAL(BLE_GATT_CACHING_ASSOC_ENABLE)
|
||||||
|
/* Cache association result for this connection */
|
||||||
|
MODLOG_DFLT(INFO, "cache association; conn_handle=%d status=%d cache_state=%s\n",
|
||||||
|
event->cache_assoc.conn_handle,
|
||||||
|
event->cache_assoc.status,
|
||||||
|
(event->cache_assoc.cache_state == 0) ? "INVALID" : "LOADED");
|
||||||
|
/* Perform service discovery */
|
||||||
|
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);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
|
||||||
case BLE_GAP_EVENT_NOTIFY_RX:
|
case BLE_GAP_EVENT_NOTIFY_RX:
|
||||||
/* Peer sent us a notification or indication. */
|
/* Peer sent us a notification or indication. */
|
||||||
MODLOG_DFLT(INFO, "received %s; conn_handle=%d attr_handle=%d "
|
MODLOG_DFLT(INFO, "received %s; conn_handle=%d attr_handle=%d "
|
||||||
|
@@ -540,6 +540,13 @@ ble_htp_cent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
} else {
|
} else {
|
||||||
MODLOG_DFLT(INFO, "Connection secured\n");
|
MODLOG_DFLT(INFO, "Connection secured\n");
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#if MYNEWT_VAL(BLE_GATT_CACHING_ASSOC_ENABLE)
|
||||||
|
rc = ble_gattc_cache_assoc(desc.peer_id_addr);
|
||||||
|
if (rc != 0) {
|
||||||
|
MODLOG_DFLT(ERROR, "Cache Association Failed; rc=%d\n", rc);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* Perform service discovery */
|
/* Perform service discovery */
|
||||||
rc = peer_disc_all(event->connect.conn_handle,
|
rc = peer_disc_all(event->connect.conn_handle,
|
||||||
@@ -548,6 +555,7 @@ ble_htp_cent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif // BLE_GATT_CACHING_ASSOC_ENABLE
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
/* Connection attempt failed; resume scanning. */
|
/* Connection attempt failed; resume scanning. */
|
||||||
@@ -584,6 +592,13 @@ ble_htp_cent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
print_conn_desc(&desc);
|
print_conn_desc(&desc);
|
||||||
#if CONFIG_EXAMPLE_ENCRYPTION
|
#if CONFIG_EXAMPLE_ENCRYPTION
|
||||||
|
#if MYNEWT_VAL(BLE_GATT_CACHING_ASSOC_ENABLE)
|
||||||
|
rc = ble_gattc_cache_assoc(desc.peer_id_addr);
|
||||||
|
if (rc != 0) {
|
||||||
|
MODLOG_DFLT(ERROR, "Cache Association Failed; rc=%d\n", rc);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
/*** Go for service discovery after encryption has been successfully enabled ***/
|
/*** Go for service discovery after encryption has been successfully enabled ***/
|
||||||
rc = peer_disc_all(event->connect.conn_handle,
|
rc = peer_disc_all(event->connect.conn_handle,
|
||||||
ble_htp_cent_on_disc_complete, NULL);
|
ble_htp_cent_on_disc_complete, NULL);
|
||||||
@@ -591,9 +606,27 @@ ble_htp_cent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif // BLE_GATT_CACHING_ASSOC_ENABLE
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
case BLE_GAP_EVENT_CACHE_ASSOC:
|
||||||
|
#if MYNEWT_VAL(BLE_GATT_CACHING_ASSOC_ENABLE)
|
||||||
|
/* Cache association result for this connection */
|
||||||
|
MODLOG_DFLT(INFO, "cache association; conn_handle=%d status=%d cache_state=%s\n",
|
||||||
|
event->cache_assoc.conn_handle,
|
||||||
|
event->cache_assoc.status,
|
||||||
|
(event->cache_assoc.cache_state == 0) ? "INVALID" : "LOADED");
|
||||||
|
/* Perform service discovery */
|
||||||
|
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);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
|
||||||
case BLE_GAP_EVENT_NOTIFY_RX:
|
case BLE_GAP_EVENT_NOTIFY_RX:
|
||||||
/* Peer sent us a notification or indication. */
|
/* Peer sent us a notification or indication. */
|
||||||
MODLOG_DFLT(INFO, "received %s; conn_handle=%d attr_handle=%d "
|
MODLOG_DFLT(INFO, "received %s; conn_handle=%d attr_handle=%d "
|
||||||
|
@@ -472,6 +472,13 @@ ble_prox_cent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
} else {
|
} else {
|
||||||
MODLOG_DFLT(INFO, "Connection secured\n");
|
MODLOG_DFLT(INFO, "Connection secured\n");
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#if MYNEWT_VAL(BLE_GATT_CACHING_ASSOC_ENABLE)
|
||||||
|
rc = ble_gattc_cache_assoc(desc.peer_id_addr);
|
||||||
|
if (rc != 0) {
|
||||||
|
MODLOG_DFLT(ERROR, "Cache Association Failed; rc=%d\n", rc);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* Perform service discovery */
|
/* Perform service discovery */
|
||||||
rc = peer_disc_all(event->connect.conn_handle,
|
rc = peer_disc_all(event->connect.conn_handle,
|
||||||
@@ -480,6 +487,7 @@ ble_prox_cent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif // BLE_GATT_CACHING_ASSOC_ENABLE
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
/* Connection attempt failed; resume scanning. */
|
/* Connection attempt failed; resume scanning. */
|
||||||
@@ -532,6 +540,13 @@ ble_prox_cent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
print_conn_desc(&desc);
|
print_conn_desc(&desc);
|
||||||
#if CONFIG_EXAMPLE_ENCRYPTION
|
#if CONFIG_EXAMPLE_ENCRYPTION
|
||||||
|
#if MYNEWT_VAL(BLE_GATT_CACHING_ASSOC_ENABLE)
|
||||||
|
rc = ble_gattc_cache_assoc(desc.peer_id_addr);
|
||||||
|
if (rc != 0) {
|
||||||
|
MODLOG_DFLT(ERROR, "Cache Association Failed; rc=%d\n", rc);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
/*** Go for service discovery after encryption has been successfully enabled ***/
|
/*** Go for service discovery after encryption has been successfully enabled ***/
|
||||||
rc = peer_disc_all(event->connect.conn_handle,
|
rc = peer_disc_all(event->connect.conn_handle,
|
||||||
ble_prox_cent_on_disc_complete, NULL);
|
ble_prox_cent_on_disc_complete, NULL);
|
||||||
@@ -539,9 +554,27 @@ ble_prox_cent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif // BLE_GATT_CACHING_ASSOC_ENABLE
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
case BLE_GAP_EVENT_CACHE_ASSOC:
|
||||||
|
#if MYNEWT_VAL(BLE_GATT_CACHING_ASSOC_ENABLE)
|
||||||
|
/* Cache association result for this connection */
|
||||||
|
MODLOG_DFLT(INFO, "cache association; conn_handle=%d status=%d cache_state=%s\n",
|
||||||
|
event->cache_assoc.conn_handle,
|
||||||
|
event->cache_assoc.status,
|
||||||
|
(event->cache_assoc.cache_state == 0) ? "INVALID" : "LOADED");
|
||||||
|
/* Perform service discovery */
|
||||||
|
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);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
|
||||||
case BLE_GAP_EVENT_NOTIFY_RX:
|
case BLE_GAP_EVENT_NOTIFY_RX:
|
||||||
/* Peer sent us a notification or indication. */
|
/* Peer sent us a notification or indication. */
|
||||||
MODLOG_DFLT(INFO, "received %s; conn_handle=%d attr_handle=%d "
|
MODLOG_DFLT(INFO, "received %s; conn_handle=%d attr_handle=%d "
|
||||||
|
@@ -789,6 +789,13 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#if MYNEWT_VAL(BLE_GATTC)
|
#if MYNEWT_VAL(BLE_GATTC)
|
||||||
|
#if MYNEWT_VAL(BLE_GATT_CACHING_ASSOC_ENABLE)
|
||||||
|
rc = ble_gattc_cache_assoc(desc.peer_id_addr);
|
||||||
|
if (rc != 0) {
|
||||||
|
MODLOG_DFLT(ERROR, "Cache Association Failed; rc=%d\n", rc);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
/* Perform service discovery */
|
/* Perform service discovery */
|
||||||
rc = peer_disc_all(event->connect.conn_handle,
|
rc = peer_disc_all(event->connect.conn_handle,
|
||||||
blecent_on_disc_complete, NULL);
|
blecent_on_disc_complete, NULL);
|
||||||
@@ -796,8 +803,9 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // BLE_GATT_CACHING_ASSOC_ENABLE
|
||||||
#endif
|
#endif // BLE_GATTC
|
||||||
|
#endif // EXAMPLE_ENCRYPTION
|
||||||
} else {
|
} else {
|
||||||
/* Connection attempt failed; resume scanning. */
|
/* Connection attempt failed; resume scanning. */
|
||||||
MODLOG_DFLT(ERROR, "Error: Connection failed; status=%d\n",
|
MODLOG_DFLT(ERROR, "Error: Connection failed; status=%d\n",
|
||||||
@@ -842,6 +850,13 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
print_conn_desc(&desc);
|
print_conn_desc(&desc);
|
||||||
#if !MYNEWT_VAL(BLE_EATT_CHAN_NUM)
|
#if !MYNEWT_VAL(BLE_EATT_CHAN_NUM)
|
||||||
#if CONFIG_EXAMPLE_ENCRYPTION && MYNEWT_VAL(BLE_GATTC)
|
#if CONFIG_EXAMPLE_ENCRYPTION && MYNEWT_VAL(BLE_GATTC)
|
||||||
|
#if MYNEWT_VAL(BLE_GATT_CACHING_ASSOC_ENABLE)
|
||||||
|
rc = ble_gattc_cache_assoc(desc.peer_id_addr);
|
||||||
|
if (rc != 0) {
|
||||||
|
MODLOG_DFLT(ERROR, "Cache Association Failed; rc=%d\n", rc);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
/*** Go for service discovery after encryption has been successfully enabled ***/
|
/*** Go for service discovery after encryption has been successfully enabled ***/
|
||||||
rc = peer_disc_all(event->enc_change.conn_handle,
|
rc = peer_disc_all(event->enc_change.conn_handle,
|
||||||
blecent_on_disc_complete, NULL);
|
blecent_on_disc_complete, NULL);
|
||||||
@@ -849,10 +864,28 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // BLE_GATT_CACHING_ASSOC_ENABLE
|
||||||
|
#endif // EXAMPLE_ENCRYPTION
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
case BLE_GAP_EVENT_CACHE_ASSOC:
|
||||||
|
#if MYNEWT_VAL(BLE_GATT_CACHING_ASSOC_ENABLE)
|
||||||
|
/* Cache association result for this connection */
|
||||||
|
MODLOG_DFLT(INFO, "cache association; conn_handle=%d status=%d cache_state=%s\n",
|
||||||
|
event->cache_assoc.conn_handle,
|
||||||
|
event->cache_assoc.status,
|
||||||
|
(event->cache_assoc.cache_state == 0) ? "INVALID" : "LOADED");
|
||||||
|
/* Perform service discovery */
|
||||||
|
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);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
|
||||||
case BLE_GAP_EVENT_NOTIFY_RX:
|
case BLE_GAP_EVENT_NOTIFY_RX:
|
||||||
/* Peer sent us a notification or indication. */
|
/* Peer sent us a notification or indication. */
|
||||||
MODLOG_DFLT(INFO, "received %s; conn_handle=%d attr_handle=%d "
|
MODLOG_DFLT(INFO, "received %s; conn_handle=%d attr_handle=%d "
|
||||||
|
Reference in New Issue
Block a user