fix(nimble): Bugfixes for various issues

This commit is contained in:
Rahul Tank
2026-02-16 11:22:53 +05:30
parent e5930c154c
commit 32cd231a95
16 changed files with 39 additions and 30 deletions
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@@ -132,13 +132,13 @@ void ble_receive_apple_data_source(uint8_t *message, uint16_t message_len)
return;
}
uint32_t NotificationUID = (message[1]) | (message[2]<< 8) | (message[3]<< 16) | (message[4] << 24);
uint32_t remian_attr_len = message_len - 5;
uint32_t remain_attr_len = message_len - 5;
uint8_t *attrs = &message[5];
ESP_LOGI(NimBLE_ANCS_TAG, "recevice Notification Attributes response Command_id %d NotificationUID %" PRIu32, Command_id, NotificationUID);
while(remian_attr_len >= 3) {
while(remain_attr_len > 0) {
uint8_t AttributeID = attrs[0];
uint16_t len = attrs[1] | (attrs[2] << 8);
if(len > remian_attr_len - 3) {
if(len > (remain_attr_len -3)) {
ESP_LOGE(NimBLE_ANCS_TAG, "data error");
break;
}
@@ -175,16 +175,16 @@ void ble_receive_apple_data_source(uint8_t *message, uint16_t message_len)
}
attrs += (1 + 2 + len);
remian_attr_len -= (1 + 2 + len);
remain_attr_len -= (1 + 2 + len);
}
break;
}
case CommandIDGetAppAttributes:
ESP_LOGI(NimBLE_ANCS_TAG, "recevice APP Attributes response");
ESP_LOGI(NimBLE_ANCS_TAG, "received APP Attributes response");
break;
case CommandIDPerformNotificationAction:
ESP_LOGI(NimBLE_ANCS_TAG, "recevice Perform Notification Action");
ESP_LOGI(NimBLE_ANCS_TAG, "received Perform Notification Action");
break;
default:
ESP_LOGI(NimBLE_ANCS_TAG, "unknown Command ID");
@@ -213,5 +213,4 @@ char *Errcode_to_String(uint16_t status)
break;
}
return Errstr;
}
@@ -24,7 +24,6 @@ union ble_store_key;
#define BLE_HCI_LE_CS_SUBEVENT_DONE_STATUS_ABORTED 0xF
#define LOCAL_PROCEDURE_MEM 1024 // Replace with an appropriate constant value
struct ble_hs_cfg;
struct ble_gatt_register_ctxt;
/** GATT server. */
@@ -520,7 +520,7 @@ ble_cts_cent_gap_event(struct ble_gap_event *event, void *arg)
(event->cache_assoc.cache_state == 0) ? "INVALID" : "LOADED");
/* Perform service discovery */
rc = peer_disc_all(event->cache_assoc.conn_handle,
blecent_on_disc_complete, NULL);
ble_cts_cent_on_disc_complete, NULL);
if(rc != 0) {
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
return 0;
@@ -348,7 +348,7 @@ blecoex_gap_event(struct ble_gap_event *event, void *arg)
case BLE_GAP_EVENT_CONNECT:
MODLOG_DFLT(INFO, "%s connection %s; status=%d ",
client_connect == 1 ? "Client" : "Server",
client_connect == 1 ? "Client" : "Server",
event->connect.status == 0 ? "established" : "failed",
event->connect.status);
@@ -628,8 +628,8 @@ ble_htp_cent_gap_event(struct ble_gap_event *event, void *arg)
event->cache_assoc.status,
(event->cache_assoc.cache_state == 0) ? "INVALID" : "LOADED");
/* Perform service discovery */
rc = peer_disc_all(event->cache_assoc.conn_handle,
blecent_on_disc_complete, NULL);
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);
return 0;
@@ -581,8 +581,8 @@ ble_prox_cent_gap_event(struct ble_gap_event *event, void *arg)
event->cache_assoc.status,
(event->cache_assoc.cache_state == 0) ? "INVALID" : "LOADED");
/* Perform service discovery */
rc = peer_disc_all(event->cache_assoc.conn_handle,
blecent_on_disc_complete, NULL);
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);
return 0;
+1 -1
View File
@@ -165,7 +165,7 @@ The following configuration flags can be adjusted to significantly reduce RAM us
| CONFIG_COMPILER_OPTIMIZATION_SIZE | n → y | 8408 |
| CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE | n → y | 5896 |
| CONFIG_ESP_COEX_SW_COEXIST_ENABLE | y → n | 896 |
| ESP_TASK_WDT_EN | y → n | 528 |
| CONFIG_ESP_TASK_WDT_EN | y → n | 528 |
| CONFIG_LOG_DEFAULT_LEVEL_NONE | n → y | 2592 |
## Troubleshooting
+1 -1
View File
@@ -103,7 +103,7 @@ Notification sent successfully
The following configuration flags can be adjusted to significantly reduce RAM usage in your ESP-IDF project while retaining basic BLE functionality.
| Config Option | Old → New Value | RAM Saved (Bytes) |
|--------------------------------------------------|-----------------|--------------------|
| -------------------------------------------------|---------------- | ------------------ |
| CONFIG_BT_NIMBLE_SM_SC | y → n | 2016 |
| CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_ENCRYPTION | y → n | 32 |
| CONFIG_BT_NIMBLE_GATT_MAX_PROCS | 4 → 2 | 112 |
@@ -515,7 +515,7 @@ peer_inc_add(struct peer *peer, uint16_t svc_start_handle,
}
}
/* Including the services into inlucding list */
/* Including the services into including list */
cur_svc = peer_svc_find_range(peer, gatt_incl_svc->handle);