Корректируем сообщение об ошибке в модулях датчиков

для возможности генерации события об ошибке
This commit is contained in:
2022-10-28 16:26:13 +03:00
parent 305a5f5ccb
commit dfd24dc1f6
10 changed files with 26 additions and 26 deletions

View File

@@ -7,30 +7,30 @@
std::map<String, AHTxx*> ahts;
void printStatus(AHTxx *aht) {
String getStatus(AHTxx *aht) {
switch (aht->getStatus()) {
case AHTXX_NO_ERROR:
Serial.println(F("no error"));
return F("no error");
break;
case AHTXX_BUSY_ERROR:
Serial.println(F("sensor AHT busy, increase polling time"));
return F("sensor AHT busy, increase polling time");
break;
case AHTXX_ACK_ERROR:
Serial.println(F("sensor AHT didn't return ACK, not connected, broken, long wires (reduce speed), bus locked by slave (increase stretch limit)"));
return F("sensor AHT didn't return ACK, not connected, broken, long wires (reduce speed), bus locked by slave (increase stretch limit)");
break;
case AHTXX_DATA_ERROR:
Serial.println(F(" AHT: received data smaller than expected, not connected, broken, long wires (reduce speed), bus locked by slave (increase stretch limit)"));
return F(" AHT: received data smaller than expected, not connected, broken, long wires (reduce speed), bus locked by slave (increase stretch limit)");
break;
case AHTXX_CRC8_ERROR:
Serial.println(F("AHT: computed CRC8 not match received CRC8, this feature supported only by AHT2x sensors"));
return F("AHT: computed CRC8 not match received CRC8, this feature supported only by AHT2x sensors");
break;
default:
Serial.println(F("AHT: unknown status"));
return F("AHT: unknown status");
break;
}
}
@@ -49,7 +49,7 @@ class AhtXXt : public IoTItem {
if (value.valD != AHTXX_ERROR) {
regEvent(value.valD, "AhtXXt");
} else {
printStatus(_aht); //print temperature command status
SerialPrint("E", "Sensor AHTXX", getStatus(_aht), _id);
}
}
@@ -70,7 +70,7 @@ class AhtXXh : public IoTItem {
if (value.valD != AHTXX_ERROR) {
regEvent(value.valD, "AhtXXh");
} else {
printStatus(_aht); //print temperature command status
SerialPrint("E", "Sensor AHTXX", getStatus(_aht), _id);
}
}

View File

@@ -26,7 +26,7 @@ class Bme280t : public IoTItem {
if (value.valD != NAN && value.valD < 145)
regEvent(value.valD, "Bme280t");
else
SerialPrint("E", "Sensor Bme280t", "Error");
SerialPrint("E", "Sensor Bme280t", "Error", _id);
}
~Bme280t(){};
@@ -46,7 +46,7 @@ class Bme280h : public IoTItem {
if (value.valD != NAN && value.valD < 100)
regEvent(value.valD, "Bme280h");
else
SerialPrint("E", "Sensor Bme280h", "Error");
SerialPrint("E", "Sensor Bme280h", "Error", _id);
}
~Bme280h(){};
@@ -67,7 +67,7 @@ class Bme280p : public IoTItem {
value.valD = value.valD / 1.333224 / 100;
regEvent(value.valD, "Bme280p");
} else
SerialPrint("E", "Sensor Bme280p", "Error");
SerialPrint("E", "Sensor Bme280p", "Error", _id);
}
~Bme280p(){};

View File

@@ -26,7 +26,7 @@ class Bmp280t : public IoTItem {
if (value.valD != NAN && value.valD < 150)
regEvent(value.valD, "Bmp280t");
else
SerialPrint("E", "Sensor Bmp280t", "Error");
SerialPrint("E", "Sensor Bmp280t", "Error", _id);
}
~Bmp280t(){};
@@ -47,7 +47,7 @@ class Bmp280p : public IoTItem {
value.valD = value.valD / 1.333224 / 100;
regEvent(value.valD, "Bmp280p");
} else
SerialPrint("E", "Sensor Bmp280p", "Error");
SerialPrint("E", "Sensor Bmp280p", "Error", _id);
}
~Bmp280p(){};

View File

@@ -26,7 +26,7 @@ class Dht1122t : public IoTItem {
if (String(value.valD) != "nan")
regEvent(value.valD, "Dht1122t");
else
SerialPrint("E", "Sensor DHTt", "Error");
SerialPrint("E", "Sensor DHTt", "Error", _id);
}
~Dht1122t(){};
@@ -46,7 +46,7 @@ class Dht1122h : public IoTItem {
if (String(value.valD) != "nan")
regEvent(value.valD, "Dht1122h");
else
SerialPrint("E", "Sensor DHTh", "Error");
SerialPrint("E", "Sensor DHTh", "Error", _id);
}
~Dht1122h(){};

View File

@@ -71,7 +71,7 @@ class Ds18b20 : public IoTItem {
if (value.valD != DEVICE_DISCONNECTED_C)
regEvent(value.valD, ""); //обязательный вызов для отправки результата работы
else
SerialPrint("E", "Sensor Ds18b20", "Error");
SerialPrint("E", "Sensor Ds18b20", "Error", _id);
}
//=======================================================================================================

View File

@@ -23,7 +23,7 @@ class GY21t : public IoTItem {
if (value.valD < 300)
regEvent(value.valD, "GY21"); // TODO: найти способ понимания ошибки получения данных
else
SerialPrint("E", "Sensor GY21t", "Error");
SerialPrint("E", "Sensor GY21t", "Error", _id);
}
~GY21t(){};
@@ -39,7 +39,7 @@ class GY21h : public IoTItem {
if (value.valD != 0)
regEvent(value.valD, "GY21h"); // TODO: найти способ понимания ошибки получения данных
else
SerialPrint("E", "Sensor GY21h", "Error");
SerialPrint("E", "Sensor GY21h", "Error", _id);
}
~GY21h(){};

View File

@@ -24,7 +24,7 @@ class Hdc1080t : public IoTItem {
if (value.valD < 124)
regEvent(value.valD, "Hdc1080t");
else
SerialPrint("E", "Sensor Hdc1080t", "Error");
SerialPrint("E", "Sensor Hdc1080t", "Error", _id);
}
~Hdc1080t(){};
@@ -39,7 +39,7 @@ class Hdc1080h : public IoTItem {
if (value.valD < 99)
regEvent(value.valD, "Hdc1080h");
else
SerialPrint("E", "Sensor Hdc1080h", "Error");
SerialPrint("E", "Sensor Hdc1080h", "Error", _id);
}
~Hdc1080h(){};

View File

@@ -29,7 +29,7 @@ class MAX6675t : public IoTItem {
if (String(value.valD) != "nan") {
regEvent(value.valD, "Max6675t");
} else {
SerialPrint("E", "Sensor Max6675t", "Error");
SerialPrint("E", "Sensor Max6675t", "Error", _id);
}
}

View File

@@ -16,7 +16,7 @@ class Sht20t : public IoTItem {
if (value.valD > -46.85F)
regEvent(value.valD, "Sht20t");
else
SerialPrint("E", "Sensor Sht20t", "Error");
SerialPrint("E", "Sensor Sht20t", "Error", _id);
}
~Sht20t(){};
@@ -32,7 +32,7 @@ class Sht20h : public IoTItem {
if (value.valD != -6)
regEvent(value.valD, "Sht20h");
else
SerialPrint("E", "Sensor Sht20h", "Error");
SerialPrint("E", "Sensor Sht20h", "Error", _id);
}
~Sht20h(){};

View File

@@ -26,7 +26,7 @@ class Sht30t : public IoTItem {
SerialPrint("E", "Sensor Sht30t", "OK");
if (value.valD < -46.85F) regEvent(value.valD, "Sht30t"); // TODO: найти способ понимания ошибки получения данных
else SerialPrint("E", "Sensor Sht30t", "Error");
else SerialPrint("E", "Sensor Sht30t", "Error", _id);
}
}
~Sht30t() {};
@@ -42,7 +42,7 @@ class Sht30h : public IoTItem {
SerialPrint("E", "Sensor Sht30h", "OK");
if (value.valD != -6) regEvent(value.valD, "Sht30h"); // TODO: найти способ понимания ошибки получения данных
else SerialPrint("E", "Sensor Sht30h", "Error");
else SerialPrint("E", "Sensor Sht30h", "Error", _id);
}
}
~Sht30h() {};