mirror of
https://github.com/1technophile/OpenMQTTGateway.git
synced 2026-03-08 00:07:11 +01:00
* Update arduino core to 3.1.1 * Fix Blufi build * Update arduinojson, fix build errors with idf * Fix narrowing * fix RF builds * WIP-Convert ino files to cpp * Fix pilight build * Fix Somfy actuator build. * Update esp32dev-rf partition * Fix Weatherstation build * Fix GFSunInverter build * Fix esp32dev-ir build * Fix ble-aws build * Fix eth builds * Fix m5Stack missing pins_arduino.h * Fix build errors for M5 stack/tough, others are upstream issues. * Fix RTL 433 build - remaining errors are from radolib * Fix nodemcu build * fix 2g builds * Fix serial build * Fix actuator on off builds * Fix SSD1306 build - remaining errors are from radiolib * Fix multiple definition of OTAserver_cert * Fix nodemcu rf2 build * Fix ADC builds * Fix sensor builds * Fix LORA builds * Fix multi-receiver builds - remaining errors are in radiolib * Fix fastled builds * Fix theegns board builds * Fix broker builds * Update fastled - old version failed all-test build * Fix RN8209 builds * Fix max temp actuator builds * Fix PWM builds * Fix C37 sensor builds * Fix HTU21 builds * Fix INA266 builds * Fix undefined variables in mqtt discovery * Fix webui build * Fix fastled invalid pin error * Fix wifi manual setup builds * Fix onewire/all-test build - bin too big error remaining * Fix theengs plug build * Fix rfbridge builds * Fix blufi builds * Fix undefined functions in serial * Fix preprocessor definition checks * Set IDF log level to erre * Add delay in loop to prevent watchdog timeout * Use xTaskCreateUniveral to support single core processors * Remove old HTTPUpdate files - upsteam fixed. * Cleanup and move common declarations to header file * Use custom partiton table to fix builds where bin is too large * Update M5StickC - fixs esp32-m5stick-c-ble build * Revert to Arduino core 2.x for builds with incompatible libs * Remove "Z" from file names and rename omg_common to TheengsCommon * Fix gateway name when using MAC with new Arduino core * Update IDF config to reduce loop task stack use * Update esp-nimble-cpp version, corrects BLE uppercase ID's * Update wifi manager to fix watchdog timeout error
99 lines
3.2 KiB
C++
99 lines
3.2 KiB
C++
#if SELF_TEST
|
|
# include <Arduino.h>
|
|
# include <ETH.h>
|
|
# include <LEDManager.h>
|
|
# include <WiFi.h>
|
|
# include <esp_chip_info.h>
|
|
# include <esp_system.h>
|
|
|
|
# include "TheengsCommon.h"
|
|
# include "User_config.h"
|
|
|
|
extern LEDManager ledManager;
|
|
extern void ESPRestart(byte reason);
|
|
|
|
String getChipModel() {
|
|
esp_chip_info_t chip_info;
|
|
esp_chip_info(&chip_info);
|
|
|
|
switch (chip_info.model) {
|
|
case CHIP_ESP32:
|
|
return "ESP32";
|
|
case CHIP_ESP32S2:
|
|
return "ESP32-S2";
|
|
case CHIP_ESP32S3:
|
|
return "ESP32-S3";
|
|
case CHIP_ESP32C3:
|
|
return "ESP32-C3";
|
|
case CHIP_ESP32H2:
|
|
return "ESP32-H2";
|
|
default:
|
|
return "Unknown";
|
|
}
|
|
}
|
|
|
|
// From https://github.com/ThingPulse/espgateway-ethernet-testbed
|
|
|
|
void addTestMessage(JsonArray& data, String name, String value, String result) {
|
|
JsonObject object = data.createNestedObject();
|
|
object["name"] = name;
|
|
object["value"] = value;
|
|
object["result"] = result;
|
|
}
|
|
|
|
void testDevice() {
|
|
StaticJsonDocument<1280> doc;
|
|
JsonArray data = doc.to<JsonArray>();
|
|
|
|
addTestMessage(data, "Mac Address", String(WiFi.macAddress()), "OK");
|
|
addTestMessage(data, "Chip Model", String(ESP.getChipModel()), "OK");
|
|
addTestMessage(data, "Chip Revision", String(ESP.getChipRevision()), "OK");
|
|
addTestMessage(data, "Available Cores", String(ESP.getChipCores()), ESP.getChipCores() == 2 ? "OK" : "NOK");
|
|
addTestMessage(data, "Heap Size", String(ESP.getHeapSize() / 1024) + "kb", ESP.getHeapSize() > 100000 ? "OK" : "NOK");
|
|
addTestMessage(data, "Free Heap", String(ESP.getFreeHeap() / 1024) + "kb", ESP.getFreeHeap() > 100000 ? "OK" : "NOK");
|
|
addTestMessage(data, "ETH MAC Address", String(ETH.macAddress()), ETH.macAddress() ? "OK" : "NOK");
|
|
addTestMessage(data, "ETH Local IP", ETH.localIP().toString(), ETH.localIP() ? "OK" : "NOK");
|
|
addTestMessage(data, "ETH Full Duplex", ETH.fullDuplex() ? "true" : "false", ETH.fullDuplex() ? "OK" : "NOK");
|
|
addTestMessage(data, "ETH Link Speed", String(ETH.linkSpeed()) + "Mbs", ETH.linkSpeed() ? "OK" : "NOK");
|
|
addTestMessage(data, "Build Date", String(__DATE__), "OK");
|
|
addTestMessage(data, "Build Time", String(__TIME__), "OK");
|
|
Serial.println();
|
|
serializeJson(doc, Serial);
|
|
Serial.println();
|
|
}
|
|
|
|
void testLeds() {
|
|
Log.notice(F("LED Test" CR));
|
|
ledManager.setMode(0, 0, LEDManager::Mode::STATIC, LED_NETWORK_OK_COLOR, -1);
|
|
delay(1000);
|
|
ledManager.setMode(0, 1, LEDManager::Mode::STATIC, LED_NETWORK_OK_COLOR, -1);
|
|
delay(1000);
|
|
ledManager.setMode(0, 2, LEDManager::Mode::STATIC, LED_NETWORK_OK_COLOR, -1);
|
|
delay(1000);
|
|
ledManager.setMode(0, 3, LEDManager::Mode::STATIC, LED_NETWORK_OK_COLOR, -1);
|
|
Log.notice(F("LED Test Finished" CR));
|
|
}
|
|
|
|
void checkSerial() {
|
|
Log.notice(F("READY_FOR_SELFTEST" CR));
|
|
unsigned long start = millis();
|
|
while (millis() - start < 1000) {
|
|
if (Serial.available() > 0) {
|
|
String input = Serial.readStringUntil('\n');
|
|
input.trim(); // Remove any extra whitespace
|
|
if (input == "SELFTEST") {
|
|
Log.notice(F("SELFTEST Launched" CR));
|
|
testLeds();
|
|
// Print 20 times the test data
|
|
for (int i = 0; i < 20; i++) {
|
|
testDevice();
|
|
delay(1000);
|
|
}
|
|
Log.notice(F("SELFTEST Finished" CR));
|
|
// Restart
|
|
ESPRestart(9);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endif |