Closed paulelong closed 4 years ago
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.
[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.
Hardware:
Board: ?ESP32 Dev Module? ?node32? ?ttgo_lora? I (31) boot: ESP-IDF v4.1-dev-1795-gca8fac876 2nd stage bootloader I (31) boot: compile time 16:45:55 I (31) boot: chip revision: 1 I (35) boot.esp32: SPI Speed : 40MHz I (40) boot.esp32: SPI Mode : DIO I (44) boot.esp32: SPI Flash Size : 2MB
Core Installation version: Not sure how to easily get this info. IDE name: VSCode Upload Speed: 115200 Computer OS: Windows 10
Description:
I'm using BLE to communicate as a server to multiple BLE peripherals. When I call esp_ble_gattc_get_attr_count, I would sometimes get stack corruption. It depends on how/where I defined a local variable. The other symptom of this problem is that the local variable was initialized to 1, and reset to 0 afterwards.
I believe the issue is that it's accepts an int8 as an arg, but then casts as a int. If I make this code change it fixes my problem:
''' --- a/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c +++ b/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c @@ -551,12 +551,15 @@ esp_gatt_status_t btc_ble_gattc_get_attr_count(uint16_t conn_id, uint16_t char_handle, uint16_t *count) {
int c = *count; if (type == ESP_GATT_DB_ALL) {
BTA_GATTC_GetDBSize(conn_id, start_handle, end_handle, (int *)count);
BTA_GATTC_GetDBSize(conn_id, start_handle, end_handle, (int *)&c); } else {
BTA_GATTC_GetDBSizeByType(conn_id, type, start_handle, end_handle, char_handle, (int *)count);
BTA_GATTC_GetDBSizeByType(conn_id, type, start_handle, end_handle, char_handle, (int *)&c); }
*count = c;
return ESP_GATT_OK; } '''
I believe this problem is in other places, though haven't tried to search.