Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BT] More aggressive memory release when stopping process #1626

Merged
merged 1 commit into from
Apr 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions main/ZgatewayBT.ino
Original file line number Diff line number Diff line change
Expand Up @@ -821,14 +821,16 @@ void BLEconnect() {
}

void stopProcessing() {
Log.notice(F("Stop BLE processing" CR));
ProcessLock = true;
delay(BTConfig.scanDuration < 2000 ? BTConfig.scanDuration : 2000);
//Suspending and deleting tasks to free memory for OTA operations
//Suspending, deleting tasks and stopping BT to free memory
vTaskSuspend(xCoreTaskHandle);
vTaskDelete(xCoreTaskHandle);
vTaskSuspend(xProcBLETaskHandle);
vTaskDelete(xProcBLETaskHandle);
if (BLEDevice::getInitialized()) BLEDevice::deinit(true);
esp_bt_mem_release(ESP_BT_MODE_BTDM);
Log.notice(F("BLE gateway stopped, free heap: %d" CR), ESP.getFreeHeap());
}

void coreTask(void* pvParameters) {
Expand Down Expand Up @@ -886,8 +888,7 @@ void deepSleep(uint64_t time_in_us) {
# endif

Log.trace(F("Deactivating ESP32 components" CR));
if (BLEDevice::getInitialized()) BLEDevice::deinit(true);
esp_bt_mem_release(ESP_BT_MODE_BTDM);
stopProcessing();
// Ignore the deprecated warning, this call is necessary here.
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
Expand Down