mirror of
https://github.com/HendrikRauh/dmx-interface.git
synced 2025-07-05 05:38:54 +00:00
switched status logic to separate file
This commit is contained in:
parent
2c25932e3c
commit
4ac0681a9a
5 changed files with 42 additions and 38 deletions
|
@ -16,6 +16,7 @@
|
||||||
#include "ESPDMX.h"
|
#include "ESPDMX.h"
|
||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
#include "routes/config.h"
|
#include "routes/config.h"
|
||||||
|
#include "routes/status.h"
|
||||||
|
|
||||||
DMXESPSerial dmx1;
|
DMXESPSerial dmx1;
|
||||||
DMXESPSerial dmx2;
|
DMXESPSerial dmx2;
|
||||||
|
|
|
@ -69,18 +69,6 @@ Direction parseDirection(uint8_t direction)
|
||||||
throw ::std::invalid_argument("Invalid direction value: " + direction);
|
throw ::std::invalid_argument("Invalid direction value: " + direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t getWiFiStrength()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return WiFi.RSSI();
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
void onGetConfig(AsyncWebServerRequest *request)
|
void onGetConfig(AsyncWebServerRequest *request)
|
||||||
|
@ -202,27 +190,3 @@ void onGetNetworks(AsyncWebServerRequest *request)
|
||||||
serializeJson(doc, jsonString);
|
serializeJson(doc, jsonString);
|
||||||
request->send(200, "application/json", jsonString);
|
request->send(200, "application/json", jsonString);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onGetStatus(AsyncWebServerRequest *request)
|
|
||||||
{
|
|
||||||
JsonDocument doc;
|
|
||||||
|
|
||||||
doc["uptime"] = millis();
|
|
||||||
doc["chip"]["model"] = ESP.getChipModel();
|
|
||||||
doc["chip"]["mac"] = ESP.getEfuseMac();
|
|
||||||
doc["chip"]["revision"] = ESP.getChipRevision();
|
|
||||||
doc["chip"]["cpuFreqMHz"] = ESP.getCpuFreqMHz();
|
|
||||||
doc["chip"]["cycleCount"] = ESP.getCycleCount();
|
|
||||||
doc["sdkVersion"] = ESP.getSdkVersion();
|
|
||||||
doc["sketch"]["size"] = ESP.getSketchSize();
|
|
||||||
doc["sketch"]["md5"] = ESP.getSketchMD5();
|
|
||||||
doc["heap"]["free"] = ESP.getFreeHeap();
|
|
||||||
doc["heap"]["total"] = ESP.getHeapSize();
|
|
||||||
doc["psram"]["free"] = ESP.getFreePsram();
|
|
||||||
doc["psram"]["total"] = ESP.getPsramSize();
|
|
||||||
doc["connection"]["signalStrength"] = getWiFiStrength();
|
|
||||||
|
|
||||||
String jsonString;
|
|
||||||
serializeJson(doc, jsonString);
|
|
||||||
request->send(200, "application/json", jsonString);
|
|
||||||
}
|
|
||||||
|
|
|
@ -37,6 +37,4 @@ void onPutConfig(AsyncWebServerRequest *request, uint8_t *data, size_t len, size
|
||||||
|
|
||||||
void onGetNetworks(AsyncWebServerRequest *request);
|
void onGetNetworks(AsyncWebServerRequest *request);
|
||||||
|
|
||||||
void onGetStatus(AsyncWebServerRequest *request);
|
|
||||||
|
|
||||||
// #endif
|
// #endif
|
37
src/routes/status.cpp
Normal file
37
src/routes/status.cpp
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#include "status.h"
|
||||||
|
|
||||||
|
int8_t getWiFiStrength()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return WiFi.RSSI();
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void onGetStatus(AsyncWebServerRequest *request)
|
||||||
|
{
|
||||||
|
JsonDocument doc;
|
||||||
|
|
||||||
|
doc["uptime"] = millis();
|
||||||
|
doc["chip"]["model"] = ESP.getChipModel();
|
||||||
|
doc["chip"]["mac"] = ESP.getEfuseMac();
|
||||||
|
doc["chip"]["revision"] = ESP.getChipRevision();
|
||||||
|
doc["chip"]["cpuFreqMHz"] = ESP.getCpuFreqMHz();
|
||||||
|
doc["chip"]["cycleCount"] = ESP.getCycleCount();
|
||||||
|
doc["sdkVersion"] = ESP.getSdkVersion();
|
||||||
|
doc["sketch"]["size"] = ESP.getSketchSize();
|
||||||
|
doc["sketch"]["md5"] = ESP.getSketchMD5();
|
||||||
|
doc["heap"]["free"] = ESP.getFreeHeap();
|
||||||
|
doc["heap"]["total"] = ESP.getHeapSize();
|
||||||
|
doc["psram"]["free"] = ESP.getFreePsram();
|
||||||
|
doc["psram"]["total"] = ESP.getPsramSize();
|
||||||
|
doc["connection"]["signalStrength"] = getWiFiStrength();
|
||||||
|
|
||||||
|
String jsonString;
|
||||||
|
serializeJson(doc, jsonString);
|
||||||
|
request->send(200, "application/json", jsonString);
|
||||||
|
}
|
4
src/routes/status.h
Normal file
4
src/routes/status.h
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#include <AsyncWebServer_ESP32_W5500.h>
|
||||||
|
#include <ArduinoJson.h>
|
||||||
|
|
||||||
|
void onGetStatus(AsyncWebServerRequest *request);
|
Loading…
Add table
Add a link
Reference in a new issue