firmware wip - add simple json /api/debug which returns all values from eeprom and sensors
This commit is contained in:
parent
b08900a394
commit
7a939205a8
1 changed files with 70 additions and 2 deletions
|
@ -967,7 +967,75 @@ void APIgetSensors() {
|
|||
|
||||
}
|
||||
|
||||
|
||||
void APIgetDebug() {
|
||||
|
||||
JsonDocument jsonDebug;
|
||||
|
||||
|
||||
// WiFi
|
||||
JsonObject objWiFi = jsonDebug.add<JsonObject>();
|
||||
objWiFi["ssid"] = WIFIssid;
|
||||
objWiFi["dhcp"] = WIFIuseDHCP;
|
||||
objWiFi["ip"] = WiFi.localIP().toString();
|
||||
objWiFi["netmask"] = WiFi.subnetMask().toString();
|
||||
objWiFi["gateway"] = WiFi.gatewayIP().toString();
|
||||
objWiFi["dns"] = WiFi.dnsIP().toString();
|
||||
|
||||
// System
|
||||
JsonObject objSystem = jsonDebug.add<JsonObject>();
|
||||
objSystem["UseFan"] = UseFan;
|
||||
objSystem["UsePump"] = UsePump;
|
||||
objSystem["UseLEDrelais"] = UseLEDrelais;
|
||||
objSystem["UseFANrelais"] = UseFANrelais;
|
||||
objSystem["PumpOnTime"] = PumpOnTime;
|
||||
objSystem["MoistureSensor_Type"] = MoistureSensor_Type;
|
||||
objSystem["SoilmoistureLow"] = SoilmoistureLow;
|
||||
objSystem["TemperatureSensor_Type"] = TemperatureSensor_Type;
|
||||
objSystem["NtpOffset"] = NtpOffset;
|
||||
objSystem["MaintenanceDuration"] = MaintenanceDuration;
|
||||
|
||||
// Grow
|
||||
JsonObject objGrow = jsonDebug.add<JsonObject>();
|
||||
objSystem["GrowName"] = GrowName;
|
||||
objSystem["GrowStart"] = GrowStart;
|
||||
objSystem["GrowStartDate"] = returnStrDateFromEpoch(GrowStart);
|
||||
objSystem["DaysVeg"] = DaysVeg;
|
||||
objSystem["DaysBloom"] = DaysBloom;
|
||||
objSystem["LighthoursVeg"] = LighthoursVeg;
|
||||
objSystem["LighthoursBloom"] = LighthoursBloom;
|
||||
objSystem["SunriseHour"] = SunriseHour;
|
||||
objSystem["SunriseMinute"] = SunriseMinute;
|
||||
objSystem["SunFade"] = SunFade;
|
||||
objSystem["SunFadeDuration"] = SunFadeDuration;
|
||||
objSystem["PinLEDPWM"] = PinLEDPWM;
|
||||
objSystem["PinFANPWM"] = PinFANPWM;
|
||||
objSystem["DayOfGrow"] = DayOfGrow;
|
||||
|
||||
|
||||
|
||||
// Sensors
|
||||
JsonObject objSensors = jsonDebug["sensors"].add<JsonObject>();
|
||||
|
||||
// Chirp
|
||||
JsonObject objSensorsChirp = jsonDebug["sensors"]["chirp"].add<JsonObject>();
|
||||
objSensorsChirp["temperature"] = getTemperature(2);
|
||||
objSensorsChirp["soilmoisture"] = getSoilmoisture(2);
|
||||
objSensorsChirp["light"] = getLightchirp();
|
||||
|
||||
// DHT11/22
|
||||
JsonObject objSensorsDht = jsonDebug["sensors"]["dht"].add<JsonObject>();
|
||||
objSensorsDht["temperature"] = getTemperature(1);
|
||||
objSensorsDht["humidity"] = getHumidity();
|
||||
|
||||
// Analog
|
||||
JsonObject objSensorsAnalog = jsonDebug["sensors"]["analog"].add<JsonObject>();
|
||||
objSensorsAnalog["soilmoisture"] = getSoilmoisture(1);
|
||||
objSensorsAnalog["waterlevel"] = getWaterlevel();
|
||||
String body;
|
||||
serializeJsonPretty(jsonDebug, body);
|
||||
webserver.send(200, "text/json", body);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -1024,7 +1092,7 @@ void WebHandler() {
|
|||
|
||||
// api stuff
|
||||
webserver.on("/api/sensors", HTTP_GET, APIgetSensors);
|
||||
|
||||
webserver.on("/api/debug", HTTP_GET, APIgetDebug);
|
||||
|
||||
// gauge meter stuff
|
||||
webserver.on("/gauge.css", HTTP_GET, WEBgaugeCss);
|
||||
|
|
Loading…
Reference in a new issue