From 14b00196de88a04b5d46122ceb67c8f7265fd7ec Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Fri, 11 May 2018 19:07:48 +0200 Subject: [PATCH] experimental bug fix memory threshold --- src/blecsan.cpp | 7 ++----- src/lorawan.cpp | 1 + src/main.cpp | 5 ++++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/blecsan.cpp b/src/blecsan.cpp index 4c2bb9af..3524e0af 100644 --- a/src/blecsan.cpp +++ b/src/blecsan.cpp @@ -99,17 +99,16 @@ static void gap_callback_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_pa switch (event) { case ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT: - { // restart scan + // restart scan status = esp_ble_gap_start_scanning(cfg.blescantime); if (status != ESP_OK) { ESP_LOGE(TAG, "esp_ble_gap_start_scanning: rc=%d", status); } - } break; case ESP_GAP_BLE_SCAN_RESULT_EVT: - { + // evaluate scan results if ( p->scan_rst.search_evt == ESP_GAP_SEARCH_INQ_CMPL_EVT) // Inquiry complete, scan is done { // restart scan status = esp_ble_gap_start_scanning (cfg.blescantime); @@ -177,8 +176,6 @@ static void gap_callback_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_pa */ } - - } break; default: diff --git a/src/lorawan.cpp b/src/lorawan.cpp index a5e3e90a..b2269571 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -136,6 +136,7 @@ void do_send(osjob_t* j){ if (cfg.countermode != 1) { reset_counters(); // clear macs container and reset all counters reset_salt(); // get new salt for salting hashes + ESP_LOGI(TAG, "Counter cleared (countermode = %d)", cfg.countermode); } } diff --git a/src/main.cpp b/src/main.cpp index 5f360faa..3cdd289e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -627,7 +627,10 @@ void loop() { #endif // check free memory - if (ESP.getFreeHeap() <= MEM_LOW) { + //if (ESP.getFreeHeap() <= MEM_LOW) { + if (esp_get_minimum_free_heap_size() <= MEM_LOW) { + // ESP_LOGI(TAG, "Counter cleared (memory low = %d Bytes)", ESP.getFreeHeap()); + ESP_LOGI(TAG, "Counter cleared (memory low water mark = %d Bytes)", esp_get_minimum_free_heap_size()); do_send(&sendjob); // send count reset_counters(); // clear macs container and reset all counters reset_salt(); // get new salt for salting hashes