From d90dfe346dd77e2ef6b87f3efa25fbff61b412c4 Mon Sep 17 00:00:00 2001 From: Marcus Date: Fri, 10 May 2024 23:27:19 +0200 Subject: [PATCH] firmware wip - add simple json /api/debug which returns all values from eeprom and sensors --- Arduino/CanGrow/CanGrow_WebFunctions.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Arduino/CanGrow/CanGrow_WebFunctions.h b/Arduino/CanGrow/CanGrow_WebFunctions.h index 816dd09..4efbb8f 100644 --- a/Arduino/CanGrow/CanGrow_WebFunctions.h +++ b/Arduino/CanGrow/CanGrow_WebFunctions.h @@ -1017,21 +1017,20 @@ void APIgetDebug() { JsonObject objSensors = jsonDebug["sensors"].add(); // Chirp - JsonObject objSensorsChirp = jsonDebug["sensors"]["chirp"].add(); - objSensorsChirp["temperature"] = getTemperature(2); - objSensorsChirp["soilmoisture"] = getSoilmoisture(2); - objSensorsChirp["light"] = getLightchirp(); + objSensors["chirp"]["temperature"] = getTemperature(2); + objSensors["chirp"]["soilmoisture"] = getSoilmoisture(2); + objSensors["chirp"]["light"] = getLightchirp(); // DHT11/22 - JsonObject objSensorsDht = jsonDebug["sensors"]["dht"].add(); - objSensorsDht["temperature"] = getTemperature(1); - objSensorsDht["humidity"] = getHumidity(); + objSensors["dht"]["temperature"] = getTemperature(1); + objSensors["dht"]["humidity"] = getHumidity(); // Analog - JsonObject objSensorsAnalog = jsonDebug["sensors"]["analog"].add(); - objSensorsAnalog["soilmoisture"] = getSoilmoisture(1); - objSensorsAnalog["waterlevel"] = getWaterlevel(); + objSensors["analog"]["soilmoisture"] = getSoilmoisture(1); + objSensors["analog"]["waterlevel"] = getWaterlevel(); + String body; + serializeJsonPretty(jsonDebug, body); webserver.send(200, "text/json", body);