forked from airgradienthq/arduino
resetReason and freeheap only for esp32 based mcu
This commit is contained in:
@ -27,6 +27,12 @@
|
|||||||
#define json_prop_noxRaw "noxRaw"
|
#define json_prop_noxRaw "noxRaw"
|
||||||
#define json_prop_co2 "rco2"
|
#define json_prop_co2 "rco2"
|
||||||
|
|
||||||
|
Measurements::Measurements() {
|
||||||
|
#ifndef ESP8266
|
||||||
|
_resetReason = (int)ESP_RST_UNKNOWN;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void Measurements::maxPeriod(MeasurementType type, int max) {
|
void Measurements::maxPeriod(MeasurementType type, int max) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Temperature:
|
case Temperature:
|
||||||
@ -604,8 +610,6 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
|
|||||||
root["boot"] = _bootCount;
|
root["boot"] = _bootCount;
|
||||||
root["bootCount"] = _bootCount;
|
root["bootCount"] = _bootCount;
|
||||||
root["wifi"] = rssi;
|
root["wifi"] = rssi;
|
||||||
root["resetReason"] = _resetReason;
|
|
||||||
root["freeHeap"] = ESP.getFreeHeap();
|
|
||||||
|
|
||||||
if (localServer) {
|
if (localServer) {
|
||||||
if (ag.isOne()) {
|
if (ag.isOne()) {
|
||||||
@ -614,6 +618,11 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
|
|||||||
root["serialno"] = ag.deviceId();
|
root["serialno"] = ag.deviceId();
|
||||||
root["firmware"] = ag.getVersion();
|
root["firmware"] = ag.getVersion();
|
||||||
root["model"] = AgFirmwareModeName(fwMode);
|
root["model"] = AgFirmwareModeName(fwMode);
|
||||||
|
} else {
|
||||||
|
#ifndef ESP8266
|
||||||
|
root["resetReason"] = _resetReason;
|
||||||
|
root["freeHeap"] = ESP.getFreeHeap();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
String result = JSON.stringify(root);
|
String result = JSON.stringify(root);
|
||||||
@ -1073,6 +1082,7 @@ int Measurements::bootCount() { return _bootCount; }
|
|||||||
|
|
||||||
void Measurements::setBootCount(int bootCount) { _bootCount = bootCount; }
|
void Measurements::setBootCount(int bootCount) { _bootCount = bootCount; }
|
||||||
|
|
||||||
|
#ifndef ESP8266
|
||||||
void Measurements::setResetReason(esp_reset_reason_t reason) {
|
void Measurements::setResetReason(esp_reset_reason_t reason) {
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case ESP_RST_UNKNOWN:
|
case ESP_RST_UNKNOWN:
|
||||||
@ -1111,4 +1121,5 @@ void Measurements::setResetReason(esp_reset_reason_t reason) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_resetReason = (int)reason;
|
_resetReason = (int)reason;
|
||||||
}
|
}
|
||||||
|
#endif
|
@ -34,7 +34,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Measurements() {}
|
Measurements();
|
||||||
~Measurements() {}
|
~Measurements() {}
|
||||||
|
|
||||||
// Enumeration for every AG measurements
|
// Enumeration for every AG measurements
|
||||||
@ -150,7 +150,9 @@ public:
|
|||||||
int bootCount();
|
int bootCount();
|
||||||
void setBootCount(int bootCount);
|
void setBootCount(int bootCount);
|
||||||
|
|
||||||
|
#ifndef ESP8266
|
||||||
void setResetReason(esp_reset_reason_t reason);
|
void setResetReason(esp_reset_reason_t reason);
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Some declared as an array (channel), because FW_MODE_O_1PPx has two PMS5003T
|
// Some declared as an array (channel), because FW_MODE_O_1PPx has two PMS5003T
|
||||||
|
Reference in New Issue
Block a user