From f8d38a030644718e019f4ec7a53ab06d2bce5742 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 2 Nov 2023 02:08:46 +0100 Subject: [PATCH] Increase stack size for the BLE task (#1069) * Add telemetry for BLE stack usage * Increase stack size for the BLE task --- platformio.ini | 3 ++- src/main.cpp | 2 ++ src/main.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 7fe9168..4ee4b4a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -32,7 +32,8 @@ build_flags = -Wno-stringop-overflow -Wformat-truncation -D ARDUINOJSON_ENABLE_NAN=0 - -D CONFIG_BT_NIMBLE_TASK_STACK_SIZE=4096 + -D CONFIG_BT_NIMBLE_TASK_STACK_SIZE=5632 + -D CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE=5632 -D SCAN_TASK_STACK_SIZE=2562 -D ARDUINO_LOOP_STACK_SIZE=6500 -D MQTT_MIN_FREE_MEMORY=12192 diff --git a/src/main.cpp b/src/main.cpp index de2a0b4..5e16239 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -114,6 +114,7 @@ bool sendTelemetry(unsigned int totalSeen, unsigned int totalFpSeen, int unsigne doc["maxHeap"] = maxHeap; doc["scanStack"] = uxTaskGetStackHighWaterMark(scanTaskHandle); doc["loopStack"] = uxTaskGetStackHighWaterMark(nullptr); + doc["bleStack"] = bleStack; String buffer; serializeJson(doc, buffer); @@ -480,6 +481,7 @@ void reportLoop() { class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks { void onResult(BLEAdvertisedDevice *advertisedDevice) { + bleStack = uxTaskGetStackHighWaterMark(nullptr); BleFingerprintCollection::Seen(advertisedDevice); } }; diff --git a/src/main.h b/src/main.h index 485e99b..f62c068 100644 --- a/src/main.h +++ b/src/main.h @@ -56,6 +56,7 @@ int reconnectTries = 0; int teleFails = 0; bool online = false; // Have we successfully sent status=online bool sentDiscovery = false; // Have we successfully sent discovery +UBaseType_t bleStack = 0; int ethernetType = 0; String mqttHost, mqttUser, mqttPass;