versioning + update '/esp_status'
* Start of versioning v2.1, added version support * '/esp_status' returns lot more info
This commit is contained in:
parent
de5f11bab8
commit
d842c6293f
3 changed files with 46 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
|||
#include "definitions.h"
|
||||
|
||||
#include "version.h"
|
||||
// ***************************************************************************
|
||||
// Load libraries for: WebServer / WiFiManager / WebSockets
|
||||
// ***************************************************************************
|
||||
|
@ -488,14 +488,46 @@ void setup() {
|
|||
}, handleFileUpload);
|
||||
//get heap status, analog input value and all GPIO statuses in one json call
|
||||
server.on("/esp_status", HTTP_GET, []() {
|
||||
String json = "{";
|
||||
json += "\"heap\":" + String(ESP.getFreeHeap());
|
||||
// json += ", \"analog\":" + String(analogRead(A0));
|
||||
// json += ", \"gpio\":" + String((uint32_t)(((GPI | GPO) & 0xFFFF) | ((GP16I & 0x01) << 16)));
|
||||
json += "}";
|
||||
//String json = "{";
|
||||
//json += "\"heap\":" + String(ESP.getFreeHeap());
|
||||
//// json += ", \"analog\":" + String(analogRead(A0));
|
||||
//// json += ", \"gpio\":" + String((uint32_t)(((GPI | GPO) & 0xFFFF) | ((GP16I & 0x01) << 16)));
|
||||
//json += "}";
|
||||
|
||||
DynamicJsonBuffer jsonBuffer(JSON_OBJECT_SIZE(9));
|
||||
JsonObject& json = jsonBuffer.createObject();
|
||||
|
||||
json["HOSTNAME"] = HOSTNAME;
|
||||
json["version"] = SKETCH_VERSION;
|
||||
json["heap"] = ESP.getFreeHeap();
|
||||
#ifndef USE_NEOANIMATIONFX
|
||||
json["animation_lib"] = "WS2812FX";
|
||||
json["pin"] = PIN;
|
||||
#else
|
||||
json["animation_lib"] = "NeoAnimationFX";
|
||||
json["pin"] = "Ignored, check NEOMETHOD";
|
||||
#endif
|
||||
json["number_leds"] = NUMLEDS;
|
||||
#ifdef ENABLE_BUTTON
|
||||
json["button_mode"] = "ON";
|
||||
#else
|
||||
json["button_mode"] = "OFF";
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
json["mqtt"] = "ON";
|
||||
#else
|
||||
json["mqtt"] = "OFF";
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
json["home_assistant"] = "ON";
|
||||
#else
|
||||
json["home_assistant"] = "OFF";
|
||||
#endif
|
||||
char buffer[json.measureLength() + 1];
|
||||
json.printTo(buffer, sizeof(buffer));
|
||||
server.sendHeader("Access-Control-Allow-Origin", "*");
|
||||
server.send(200, "text/json", json);
|
||||
json = String();
|
||||
server.send(200, "application/json", String(buffer));
|
||||
//json = String();
|
||||
});
|
||||
|
||||
|
||||
|
|
1
Arduino/McLighting/version.h
Normal file
1
Arduino/McLighting/version.h
Normal file
|
@ -0,0 +1 @@
|
|||
#define SKETCH_VERSION "2.1.0"
|
5
Arduino/McLighting/version_info.ino
Normal file
5
Arduino/McLighting/version_info.ino
Normal file
|
@ -0,0 +1,5 @@
|
|||
/*
|
||||
* 07 May 2018
|
||||
* - Start of versioning v2.1, added version support
|
||||
* - '/esp_status' returns lot more info
|
||||
*/
|
Loading…
Reference in a new issue