resetReason and freeheap only for esp32 based mcu

This commit is contained in:
samuelbles07
2024-11-30 00:45:46 +07:00
parent c1f22674e2
commit 6312612ada
2 changed files with 17 additions and 4 deletions

View File

@ -27,6 +27,12 @@
#define json_prop_noxRaw "noxRaw"
#define json_prop_co2 "rco2"
Measurements::Measurements() {
#ifndef ESP8266
_resetReason = (int)ESP_RST_UNKNOWN;
#endif
}
void Measurements::maxPeriod(MeasurementType type, int max) {
switch (type) {
case Temperature:
@ -604,8 +610,6 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
root["boot"] = _bootCount;
root["bootCount"] = _bootCount;
root["wifi"] = rssi;
root["resetReason"] = _resetReason;
root["freeHeap"] = ESP.getFreeHeap();
if (localServer) {
if (ag.isOne()) {
@ -614,6 +618,11 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
root["serialno"] = ag.deviceId();
root["firmware"] = ag.getVersion();
root["model"] = AgFirmwareModeName(fwMode);
} else {
#ifndef ESP8266
root["resetReason"] = _resetReason;
root["freeHeap"] = ESP.getFreeHeap();
#endif
}
String result = JSON.stringify(root);
@ -1073,6 +1082,7 @@ int Measurements::bootCount() { return _bootCount; }
void Measurements::setBootCount(int bootCount) { _bootCount = bootCount; }
#ifndef ESP8266
void Measurements::setResetReason(esp_reset_reason_t reason) {
switch (reason) {
case ESP_RST_UNKNOWN:
@ -1111,4 +1121,5 @@ void Measurements::setResetReason(esp_reset_reason_t reason) {
}
_resetReason = (int)reason;
}
}
#endif

View File

@ -34,7 +34,7 @@ private:
};
public:
Measurements() {}
Measurements();
~Measurements() {}
// Enumeration for every AG measurements
@ -150,7 +150,9 @@ public:
int bootCount();
void setBootCount(int bootCount);
#ifndef ESP8266
void setResetReason(esp_reset_reason_t reason);
#endif
private:
// Some declared as an array (channel), because FW_MODE_O_1PPx has two PMS5003T