Closed rpsainio closed 5 months ago
@caveman99 So, I had finally time to look into this and I got it working by commenting out like following in https://github.com/meshtastic/firmware/blob/master/src/modules/Telemetry/Sensor/BME680Sensor.cpp#L104
if (update) {
bme680.getState(bsecState);
// std::string filenameTmp = bsecConfigFileName;
// filenameTmp += ".tmp";
auto file = FSCom.open(bsecConfigFileName, FILE_O_WRITE);
if (file) {
LOG_INFO("%s state write to %s.\n", sensorName, bsecConfigFileName);
file.write((uint8_t *)&bsecState, BSEC_MAX_STATE_BLOB_SIZE);
file.flush();
file.close();
// brief window of risk here ;-)
// if (FSCom.exists(bsecConfigFileName) && !FSCom.remove(bsecConfigFileName)) {
// LOG_WARN("Can't remove old state file\n");
// }
// if (!renameFile(filenameTmp.c_str(), bsecConfigFileName)) {
// LOG_ERROR("Error: can't rename new state file\n");
// }
} else {
LOG_INFO("Can't write %s state (File: %s).\n", sensorName, bsecConfigFileName);
}
}
Seems that you initially thought writing first to temp, delete original and rename temp to original. Unfortunately filenameTmp is not used for opening the file for writing rather the original file is written to. I guess you copied and pasted this from NodeDB handling and then thought that something going wrong here when writing is not so disastrous and cut the corners.
Another Topic is that you wait until "First state update when IAQ accuracy is >= 3" - you might consider lowering it to 2 as the startup time is then faster. Still, matter of taste.
Category
Other
Hardware
T-Beam
Firmware Version
2.1.17.7ca2e81
Description
This is a TBeam with the latest FW installed (not updated) with web installer. Once the initialization is over and the status is 3, FW is supposed to write the state of the BSEC calculation on persistent storage so that after next reset/reboot the starting of IAQ calculation goes faster. Unfortunately it seems that this does not succeed. To verify this I made a reset afterwards and logs show that state file is not present.
Besides there seems to a typeconversion error in BME680 state update every 21600000 minutes
Relevant log output