Fix crashing caused by calling time() in a critical section (#159)

* Fix for random notify crash in ISR context

Tested for stability over 30 minutes with a daisy chain of 3 esp32

Co-authored-by: h2zero <powellperalta@gmail.com>
This commit is contained in:
Anthony Doud
2020-12-19 21:58:37 -07:00
committed by h2zero
co-authored by h2zero
parent a85ac6ad5a
commit 7ed962d963
3 changed files with 6 additions and 3 deletions
+2 -1
View File
@@ -447,9 +447,10 @@ std::string NimBLERemoteCharacteristic::readValue(time_t *timestamp) {
}
} while(rc != 0 && retryCount--);
time_t t = time(nullptr);
portENTER_CRITICAL(&m_valMux);
m_value = value;
m_timestamp = time(nullptr);
m_timestamp = t;
if(timestamp != nullptr) {
*timestamp = m_timestamp;
}