diff --git a/Arduino/CanGrow/CanGrow_WebFunctions.h b/Arduino/CanGrow/CanGrow_WebFunctions.h index 4379156..c824f83 100644 --- a/Arduino/CanGrow/CanGrow_WebFunctions.h +++ b/Arduino/CanGrow/CanGrow_WebFunctions.h @@ -967,7 +967,75 @@ void APIgetSensors() { } - +void APIgetDebug() { + + JsonDocument jsonDebug; + + + // WiFi + JsonObject objWiFi = jsonDebug.add(); + 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(); + 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(); + 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(); + + // Chirp + JsonObject objSensorsChirp = jsonDebug["sensors"]["chirp"].add(); + objSensorsChirp["temperature"] = getTemperature(2); + objSensorsChirp["soilmoisture"] = getSoilmoisture(2); + objSensorsChirp["light"] = getLightchirp(); + + // DHT11/22 + JsonObject objSensorsDht = jsonDebug["sensors"]["dht"].add(); + objSensorsDht["temperature"] = getTemperature(1); + objSensorsDht["humidity"] = getHumidity(); + + // Analog + JsonObject objSensorsAnalog = jsonDebug["sensors"]["analog"].add(); + 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);