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:53:44 -07:00
committed by h2zero
parent a85ac6ad5a
commit 7ed962d963
3 changed files with 6 additions and 3 deletions

View File

@@ -473,9 +473,10 @@ void NimBLECharacteristic::setValue(const uint8_t* data, size_t length) {
return;
}
time_t t = time(nullptr);
portENTER_CRITICAL(&m_valMux);
m_value = std::string((char*)data, length);
m_timestamp = time(nullptr);
m_timestamp = t;
portEXIT_CRITICAL(&m_valMux);
NIMBLE_LOGD(LOG_TAG, "<< setValue");