WebUI - First Release (#1586)

* WebUI - First Release

* Lint / Build Issues

* Add WebUI as a default module

* Fix ESP8266 builds
This commit is contained in:
Northern Man authored and GitHub committed 2023-04-05 14:17:08 -05:00
1 parent bf004b078b
commit 9b6133ff03
12 files changed
+1937 -612

No files matched your search

+3
View File
@@ -664,6 +664,9 @@ CRGB leds2[FASTLED_IND_NUM_LEDS];
# endif
#endif
/*-----------PLACEHOLDERS FOR WebUI DISPLAY--------------*/
#define pubWebUI(...) // display the published message onto the OLED display
/*-----------PLACEHOLDERS FOR OLED/LCD DISPLAY--------------*/
// The real definitions are in config_M5.h / config_SSD1306.h
#define pubOled(...) // display the published message onto the OLED display
+8 -552
View File
@@ -40,10 +40,9 @@
# include "config_SSD1306.h"
SemaphoreHandle_t semaphoreOLEDOperation;
QueueHandle_t displayQueue;
boolean logToOLEDDisplay = LOG_TO_OLED;
boolean jsonDisplay = JSON_TO_OLED;
boolean displayMetric = DISPLAY_METRIC;
boolean displayFlip = DISPLAY_FLIP;
boolean displayState = DISPLAY_STATE;
boolean idlelogo = DISPLAY_IDLE_LOGO;
@@ -61,17 +60,15 @@ void logToOLED(bool display) {
module setup, for use in Arduino setup
*/
void setupSSD1306() {
SSD1306Config_init();
SSD1306Config_load();
Log.trace(F("Setup SSD1306 Display" CR));
Log.trace(F("ZdisplaySSD1306 command topic: %s" CR), subjectMQTTtoSSD1306set);
Log.trace(F("ZdisplaySSD1306 log-oled: %T" CR), logToOLEDDisplay);
Log.trace(F("ZdisplaySSD1306 json-oled: %T" CR), jsonDisplay);
Log.trace(F("ZdisplaySSD1306 DISPLAY_PAGE_INTERVAL: %d" CR), DISPLAY_PAGE_INTERVAL);
Log.trace(F("ZdisplaySSD1306 DISPLAY_IDLE_LOGO: %T" CR), DISPLAY_IDLE_LOGO);
Log.trace(F("ZdisplaySSD1306 DISPLAY_METRIC: %T" CR), displayMetric);
Log.trace(F("ZdisplaySSD1306 DISPLAY_IDLE_LOGO: %T" CR), idlelogo);
Log.trace(F("ZdisplaySSD1306 DISPLAY_FLIP: %T" CR), displayFlip);
SSD1306Config_init();
SSD1306Config_load();
Oled.begin();
Log.notice(F("Setup SSD1306 Display end" CR));
@@ -96,16 +93,10 @@ void loopSSD1306() {
long enough since the last message and display not being used and a queue message waiting
*/
if (jsonDisplay && displayState) {
if (uptime() >= nextDisplayPage && uxSemaphoreGetCount(semaphoreOLEDOperation) && uxQueueMessagesWaiting(displayQueue)) {
displayQueueMessage* message = nullptr;
xQueueReceive(displayQueue, &message, portMAX_DELAY);
if (!Oled.displayPage(message)) {
Log.warning(F("[ssd1306] displayPage failed: %s" CR), message->title);
if (uptime() >= nextDisplayPage && uxSemaphoreGetCount(semaphoreOLEDOperation) && currentWebUIMessage) {
if (!Oled.displayPage(currentWebUIMessage)) {
Log.warning(F("[ssd1306] displayPage failed: %s" CR), currentWebUIMessage->title);
}
if (currentOledMessage) {
free(currentOledMessage);
}
currentOledMessage = message;
nextDisplayPage = uptime() + DISPLAY_PAGE_INTERVAL;
logoDisplayed = false;
}
@@ -158,11 +149,6 @@ void MQTTtoSSD1306(char* topicOri, JsonObject& SSD1306data) { // json object dec
Log.notice(F("Set json-oled: %T" CR), jsonDisplay);
success = true;
}
if (SSD1306data.containsKey("displaymetric")) {
displayMetric = SSD1306data["displaymetric"].as<bool>();
Log.notice(F("Set displaymetric: %T" CR), displayMetric);
success = true;
}
if (SSD1306data.containsKey("idlelogo")) {
idlelogo = SSD1306data["idlelogo"].as<bool>();
success = true;
@@ -212,7 +198,6 @@ void SSD1306Config_save() {
jo["brightness"] = displayBrightness;
jo["log-oled"] = logToOLEDDisplay;
jo["json-oled"] = jsonDisplay;
jo["displaymetric"] = displayMetric;
jo["idlelogo"] = idlelogo;
jo["display-flip"] = displayFlip;
// Save config into NVS (non-volatile storage)
@@ -229,7 +214,6 @@ void SSD1306Config_init() {
displayBrightness = DISPLAY_BRIGHTNESS;
logToOLEDDisplay = LOG_TO_OLED;
jsonDisplay = JSON_TO_OLED;
displayMetric = DISPLAY_METRIC;
idlelogo = DISPLAY_IDLE_LOGO;
displayFlip = DISPLAY_FLIP;
Log.notice(F("SSD1306 config initialised" CR));
@@ -255,7 +239,6 @@ bool SSD1306Config_load() {
displayBrightness = jo["brightness"].as<int>();
logToOLEDDisplay = jo["log-oled"].as<bool>();
jsonDisplay = jo["json-oled"].as<bool>();
displayMetric = jo["displaymetric"].as<bool>();
idlelogo = jo["idlelogo"].as<bool>();
displayFlip = jo["display-flip"].as<bool>();
Log.notice(F("Saved SSD1306 config loaded" CR));
@@ -267,531 +250,6 @@ bool SSD1306Config_load() {
}
}
/*
Workaround for c not having a string based switch/case function
*/
constexpr unsigned int hash(const char* s, int off = 0) { // workaround for switching on a string https://stackoverflow.com/a/46711735/18643696
return !s[off] ? 5381 : (hash(s, off + 1) * 33) ^ s[off];
}
/*
Parse json message from module into a format for displaying on screen, and queue for display
*/
void ssd1306PubPrint(const char* topicori, JsonObject& data) {
if (jsonDisplay && displayState) {
displayQueueMessage* message = (displayQueueMessage*)malloc(sizeof(displayQueueMessage));
if (message != NULL) {
char* topic = strdup(topicori);
strlcpy(message->title, strtok(topic, "/"), OLED_TEXT_WIDTH);
free(topic);
Oled.display->normalDisplay();
switch (hash(message->title)) {
case hash("SYStoMQTT"): {
// {"uptime":456356,"version":"lilygo-rtl_433-test-A-v1.1.1-25-g574177d[lily-cloud]","freemem":125488,"mqttport":"1883","mqttsecure":false,"freestack":3752,"rssi":-36,"SSID":"The_Beach","BSSID":"64:A5:C3:69:C3:38","ip":"192.168.1.239","mac":"4C:75:25:A8:D5:D8","actRec":3,"mhz":433.92,"RTLRssiThresh":-98,"RTLRssi":-108,"RTLAVGRssi":-107,"RTLCnt":121707,"RTLOOKThresh":90,"modules":["LILYGO_OLED","CLOUD","rtl_433"]}
// Line 1
strlcpy(message->line1, data["version"], OLED_TEXT_WIDTH);
// Line 2
String uptime = data["uptime"];
String line2 = "uptime: " + uptime;
line2.toCharArray(message->line2, OLED_TEXT_WIDTH);
// Line 3
String freemem = data["freemem"];
String line3 = "freemem: " + freemem;
line3.toCharArray(message->line3, OLED_TEXT_WIDTH);
// Line 4
String ip = data["ip"];
String line4 = "ip: " + ip;
line4.toCharArray(message->line4, OLED_TEXT_WIDTH);
// Queue completed message
if (xQueueSend(displayQueue, (void*)&message, 0) != pdTRUE) {
Log.error(F("[ SSD1306 ] ERROR: displayQueue full, discarding signal %s" CR), message->title);
} else {
// Log.notice(F("Queued %s" CR), message->title);
}
break;
}
# ifdef ZgatewayRTL_433
case hash("RTL_433toMQTT"): {
// {"model":"Acurite-Tower","id":2043,"channel":"B","battery_ok":1,"temperature_C":5.3,"humidity":81,"mic":"CHECKSUM","protocol":"Acurite 592TXR Temp/Humidity, 5n1 Weather Station, 6045 Lightning, 3N1, Atlas","rssi":-81,"duration":121060}
// Line 1
strlcpy(message->line1, data["model"], OLED_TEXT_WIDTH);
// Line 2
String id = data["id"];
String channel = data["channel"];
String line2 = "id: " + id + " channel: " + channel;
line2.toCharArray(message->line2, OLED_TEXT_WIDTH);
// Line 3
String line3 = "";
if (data.containsKey("temperature_C")) {
float temperature_C = data["temperature_C"];
char temp[5];
if (displayMetric) {
dtostrf(temperature_C, 3, 1, temp);
line3 = "temp: " + (String)temp + "°C ";
} else {
dtostrf(convertTemp_CtoF(temperature_C), 3, 1, temp);
line3 = "temp: " + (String)temp + "°F ";
}
}
float humidity = data["humidity"];
if (data.containsKey("humidity") && humidity <= 100 && humidity >= 0) {
char hum[5];
dtostrf(humidity, 3, 1, hum);
line3 += "hum: " + (String)hum + "% ";
}
if (data.containsKey("wind_avg_km_h")) {
float wind_avg_km_h = data["wind_avg_km_h"];
char wind[6];
if (displayMetric) {
dtostrf(wind_avg_km_h, 3, 1, wind);
line3 += "wind: " + (String)wind + "km/h ";
} else {
dtostrf(convert_kmph2mph(wind_avg_km_h), 3, 1, wind);
line3 += "wind: " + (String)wind + "mp/h ";
}
}
line3.toCharArray(message->line3, OLED_TEXT_WIDTH);
// Line 4
String rssi = data["rssi"];
String battery_ok = data["battery_ok"];
String line4 = "batt: " + battery_ok + " rssi: " + rssi;
line4.toCharArray(message->line4, OLED_TEXT_WIDTH);
// Queue completed message
if (xQueueSend(displayQueue, (void*)&message, 0) != pdTRUE) {
Log.error(F("[ SSD1306 ] displayQueue full, discarding signal %s" CR), message->title);
free(message);
} else {
// Log.notice(F("Queued %s" CR), message->title);
}
break;
}
# endif
# ifdef ZsensorBME280
case hash("CLIMAtoMQTT"): {
// {"tempc":17.06,"tempf":62.708,"hum":50.0752,"pa":98876.14,"altim":205.8725,"altift":675.4348}
// Line 1
strlcpy(message->line1, "bme280", OLED_TEXT_WIDTH);
// Line 2
String line2 = "";
if (data.containsKey("tempc")) {
char temp[5];
float temperature_C = data["tempc"];
if (displayMetric) {
dtostrf(temperature_C, 3, 1, temp);
line2 = "temp: " + (String)temp + "°C ";
} else {
dtostrf(convertTemp_CtoF(temperature_C), 3, 1, temp);
line2 = "temp: " + (String)temp + "°F ";
}
}
line2.toCharArray(message->line2, OLED_TEXT_WIDTH);
// Line 3
String line3 = "";
float humidity = data["hum"];
if (data.containsKey("hum") && humidity <= 100 && humidity >= 0) {
char hum[5];
dtostrf(humidity, 3, 1, hum);
line3 += "hum: " + (String)hum + "% ";
}
line3.toCharArray(message->line3, OLED_TEXT_WIDTH);
// Line 4
float pa = (int)data["pa"] / 100;
char pressure[6];
String line4 = "";
if (displayMetric) {
dtostrf(pa, 3, 1, pressure);
line4 = "pressure: " + (String)pressure + " hPa";
} else {
dtostrf(convert_hpa2inhg(pa), 3, 1, pressure);
line4 = "pressure: " + (String)pressure + " inHg";
}
line4.toCharArray(message->line4, OLED_TEXT_WIDTH);
// Queue completed message
if (xQueueSend(displayQueue, (void*)&message, 0) != pdTRUE) {
Log.error(F("[ SSD1306 ] displayQueue full, discarding signal %s" CR), message->title);
free(message);
} else {
// Log.notice(F("Queued %s" CR), message->title);
}
break;
}
# endif
# ifdef ZgatewayBT
case hash("BTtoMQTT"): {
// {"id":"AA:BB:CC:DD:EE:FF","mac_type":0,"adv_type":0,"name":"sps","manufacturerdata":"de071f1000b1612908","rssi":-70,"brand":"Inkbird","model":"T(H) Sensor","model_id":"IBS-TH1/TH2/P01B","type":"THBX","cidc":false,"acts":true,"tempc":20.14,"tempf":68.252,"hum":41.27,"batt":41}
if (data["model_id"] != "MS-CDP" && data["model_id"] != "GAEN" && data["model_id"] != "APPLE_CONT" && data["model_id"] != "IBEACON") {
// Line 2, 3, 4
String line2 = "";
String line3 = "";
String line4 = "";
// Properties
String properties[6] = {"", "", "", "", "", ""};
int property = -1;
if (data["type"] == "THB" || data["type"] == "THBX" || data["type"] == "PLANT" || data["type"] == "AIR" || data["type"] == "BATT" || data["type"] == "ACEL" || (data["type"] == "UNIQ" && data["model_id"] == "SDLS")) {
if (data.containsKey("tempc")) {
property++;
char temp[5];
if (displayMetric) {
float temperature = data["tempc"];
dtostrf(temperature, 3, 1, temp);
properties[property] = "temp: " + (String)temp + "°C ";
} else {
float temperature = data["tempf"];
dtostrf(temperature, 3, 1, temp);
properties[property] = "temp: " + (String)temp + "°F ";
}
}
if (data.containsKey("tempc2_dp")) {
property++;
char tempdp[5];
if (displayMetric) {
float temperature = data["tempc2_dp"];
dtostrf(temperature, 3, 1, tempdp);
properties[property] = "dewp: " + (String)tempdp + "°C ";
} else {
float temperature = data["tempf2_dp"];
dtostrf(temperature, 3, 1, tempdp);
properties[property] = "dewp: " + (String)tempdp + "°F ";
}
}
if (data.containsKey("extprobe")) {
property++;
properties[property] = " ext. probe";
}
if (data.containsKey("hum")) {
property++;
float humidity = data["hum"];
char hum[5];
dtostrf(humidity, 3, 1, hum);
properties[property] = "hum: " + (String)hum + "% ";
}
if (data.containsKey("pm25")) {
property++;
int pm25int = data["pm25"];
char pm25[3];
itoa(pm25int, pm25, 10);
if ((data.containsKey("pm10"))) {
properties[property] = "PM 2.5: " + (String)pm25 + " ";
} else {
properties[property] = "pm2.5: " + (String)pm25 + "μg/m³ ";
}
}
if (data.containsKey("pm10")) {
property++;
int pm10int = data["pm10"];
char pm10[3];
itoa(pm10int, pm10, 10);
if ((data.containsKey("pm25"))) {
properties[property] = "/ 10: " + (String)pm10 + "μg/m³ ";
} else {
properties[property] = "pm10: " + (String)pm10 + "μg/m³ ";
}
}
if (data.containsKey("for")) {
property++;
int formint = data["for"];
char form[3];
itoa(formint, form, 10);
properties[property] = "CH₂O: " + (String)form + "mg/m³ ";
}
if (data.containsKey("co2")) {
property++;
int co2int = data["co2"];
char co2[4];
itoa(co2int, co2, 10);
properties[property] = "co2: " + (String)co2 + "ppm ";
}
if (data.containsKey("moi")) {
property++;
int moiint = data["moi"];
char moi[4];
itoa(moiint, moi, 10);
properties[property] = "moi: " + (String)moi + "% ";
}
if (data.containsKey("lux")) {
property++;
int luxint = data["lux"];
char lux[5];
itoa(luxint, lux, 10);
properties[property] = "lux: " + (String)lux + "lx ";
}
if (data.containsKey("fer")) {
property++;
int ferint = data["fer"];
char fer[7];
itoa(ferint, fer, 10);
properties[property] = "fer: " + (String)fer + "µS/cm ";
}
if (data.containsKey("pres")) {
property++;
int presint = data["pres"];
char pres[4];
itoa(presint, pres, 10);
properties[property] = "pres: " + (String)pres + "hPa ";
}
if (data.containsKey("batt")) {
property++;
int battery = data["batt"];
char batt[5];
itoa(battery, batt, 10);
properties[property] = "batt: " + (String)batt + "% ";
}
if (data.containsKey("shake")) {
property++;
int shakeint = data["shake"];
char shake[3];
itoa(shakeint, shake, 10);
properties[property] = "shake: " + (String)shake + " ";
}
if (data.containsKey("volt")) {
property++;
float voltf = data["volt"];
char volt[5];
dtostrf(voltf, 3, 1, volt);
properties[property] = "volt: " + (String)volt + "V ";
}
if (data.containsKey("wake")) {
property++;
String wakestr = data["wake"];
properties[property] = "wake: " + wakestr + " ";
}
} else if (data["type"] == "BBQ") {
String tempcstr = "";
int j = 7;
if (data["model_id"] == "IBT-2X(S)") {
j = 3;
} else if (data["model_id"] == "IBT-4X(S/C)") {
j = 5;
}
for (int i = 0; i < j; i++) {
if (i == 0) {
if (displayMetric) {
tempcstr = "tempc";
} else {
tempcstr = "tempf";
}
i++;
} else {
if (displayMetric) {
tempcstr = "tempc" + (String)i;
} else {
tempcstr = "tempf" + (String)i;
}
}
if (data.containsKey(tempcstr)) {
char temp[5];
float temperature = data[tempcstr];
dtostrf(temperature, 3, 1, temp);
properties[i - 1] = "tp" + (String)i + ": " + (String)temp;
if (displayMetric) {
properties[i - 1] += "°C ";
} else {
properties[i - 1] += "°F ";
}
} else {
properties[i - 1] = "tp" + (String)i + ": " + "off ";
}
}
} else if (data["type"] == "BODY") {
if (data.containsKey("steps")) {
property++;
int stepsint = data["steps"];
char steps[5];
itoa(stepsint, steps, 10);
properties[property] = "steps: " + (String)steps + " ";
// next line
property++;
}
if (data.containsKey("act_bpm")) {
property++;
int actbpmint = data["act_bpm"];
char actbpm[3];
itoa(actbpmint, actbpm, 10);
properties[property] = "activity bpm: " + (String)actbpm + " ";
}
if (data.containsKey("bpm")) {
property++;
int bpmint = data["bpm"];
char bpm[3];
itoa(bpmint, bpm, 10);
properties[property] = "bpm: " + (String)bpm + " ";
}
} else if (data["type"] == "SCALE") {
if (data.containsKey("weighing_mode")) {
property++;
String mode = data["weighing_mode"];
properties[property] = mode + " ";
// next line
property++;
}
if (data.containsKey("weight")) {
property++;
float weightf = data["weight"];
char weight[7];
dtostrf(weightf, 3, 1, weight);
if (data.containsKey("unit")) {
String unit = data["unit"];
properties[property] = "weight: " + (String)weight + unit + " ";
} else {
properties[property] = "weight: " + (String)weight;
}
// next line
property++;
}
if (data.containsKey("impedance")) {
property++;
int impint = data["impedance"];
char imp[3];
itoa(impint, imp, 10);
properties[property] = "impedance: " + (String)imp + "ohm ";
}
} else if (data["type"] == "UNIQ") {
if (data["model_id"] == "M1017") {
if (data.containsKey("lvl_cm")) {
property++;
char lvl[5];
if (displayMetric) {
float lvlf = data["lvl_cm"];
dtostrf(lvlf, 3, 1, lvl);
properties[property] = "level: " + (String)lvl + "cm ";
} else {
float lvlf = data["lvl_in"];
dtostrf(lvlf, 3, 1, lvl);
properties[property] = "level: " + (String)lvl + "\" ";
}
}
if (data.containsKey("quality")) {
property++;
int qualint = data["quality"];
char qual[3];
itoa(qualint, qual, 10);
properties[property] = "qy: " + (String)qual + " ";
}
if (data.containsKey("batt")) {
property++;
int battery = data["batt"];
char batt[5];
itoa(battery, batt, 10);
properties[property] = "batt: " + (String)batt + "% ";
}
}
}
line2 = properties[0] + properties[1];
line3 = properties[2] + properties[3];
line4 = properties[4] + properties[5];
if (!(line2 == "" && line3 == "" && line4 == "")) {
// Titel
char* topic = strdup(topicori);
String heading = strtok(topic, "/");
String line0 = heading + " " + data["id"].as<String>().substring(9, 17);
line0.toCharArray(message->title, OLED_TEXT_WIDTH);
free(topic);
// Line 1
strlcpy(message->line1, data["model"], OLED_TEXT_WIDTH);
line2.toCharArray(message->line2, OLED_TEXT_WIDTH);
line3.toCharArray(message->line3, OLED_TEXT_WIDTH);
line4.toCharArray(message->line4, OLED_TEXT_WIDTH);
if (xQueueSend(displayQueue, (void*)&message, 0) != pdTRUE) {
Log.error(F("[ SSD1306 ] displayQueue full, discarding signal %s" CR), message->title);
free(message);
} else {
// Log.notice(F("Queued %s" CR), message->title);
}
} else {
free(message);
}
break;
} else {
free(message);
}
}
# endif
default:
Log.error(F("[ SSD1306 ] unhandled topic %s" CR), message->title);
}
} else {
Log.error(F("[ SSD1306 ] insufficent memory " CR));
}
}
}
// Simple print methonds
/*
@@ -825,7 +283,6 @@ void ssd1306Print(char* line1) {
OledSerial Oled(0); // Not sure about this, came from Hardwareserial
OledSerial::OledSerial(int x) {
displayQueue = xQueueCreate(5, sizeof(displayQueueMessage*));
# if defined(WIFI_Kit_32) || defined(WIFI_LoRa_32) || defined(WIFI_LoRa_32_V2)
pinMode(RST_OLED, OUTPUT); // https://github.com/espressif/arduino-esp32/issues/4278
digitalWrite(RST_OLED, LOW);
@@ -939,7 +396,7 @@ size_t OledSerial::write(const uint8_t* buffer, size_t size) {
Display full page message on the display.
- Used to display JSON messages published from each gateway module
*/
boolean OledSerial::displayPage(displayQueueMessage* message) {
boolean OledSerial::displayPage(webUIQueueMessage* message) {
if (xPortGetCoreID() == CONFIG_ARDUINO_RUNNING_CORE) {
if (xSemaphoreTake(semaphoreOLEDOperation, pdMS_TO_TICKS(30000)) == pdTRUE) {
display->normalDisplay();
@@ -1004,7 +461,6 @@ String stateSSD1306Display() {
JsonObject DISPLAYdata = jsonBuffer.to<JsonObject>();
DISPLAYdata["onstate"] = (bool)displayState;
DISPLAYdata["brightness"] = (int)displayBrightness;
DISPLAYdata["displaymetric"] = (bool)displayMetric;
DISPLAYdata["display-flip"] = (bool)displayFlip;
DISPLAYdata["idlelogo"] = (bool)idlelogo;
DISPLAYdata["log-oled"] = (bool)logToOLEDDisplay;
+6 -6
View File
@@ -104,7 +104,7 @@ void BTConfig_init() {
unsigned long timeBetweenConnect = 0;
unsigned long timeBetweenActive = 0;
void stateBTMeasures(bool start) {
String stateBTMeasures(bool start) {
StaticJsonDocument<JSON_MSG_BUFFER> jsonBuffer;
JsonObject jo = jsonBuffer.to<JsonObject>();
jo["bleconnect"] = BTConfig.bleConnect;
@@ -135,9 +135,12 @@ void stateBTMeasures(bool start) {
Log.notice(F("BT sys: "));
serializeJsonPretty(jsonBuffer, Serial);
Serial.println();
return; // Do not try to erase/write/send config at startup
return ""; // Do not try to erase/write/send config at startup
}
String output;
serializeJson(jo, output);
pub(subjectBTtoMQTT, jo);
return (output);
}
void BTConfig_fromJson(JsonObject& BTdata, bool startup = false) {
@@ -1091,9 +1094,6 @@ void PublishDeviceData(JsonObject& BLEdata, bool processBLEData) {
if (!BTConfig.pubRandomMACs && (BLEdata["type"].as<string>()).compare("RMAC") == 0) {
return;
}
if (BLEdata.containsKey("type") && (BLEdata.containsKey("model") || BLEdata.containsKey("distance"))) { // Only display sensor data with type
pubOled(subjectBTtoMQTT, BLEdata);
}
if (!BTConfig.pubAdvData) {
BLEdata.remove("servicedatauuid");
BLEdata.remove("servicedata");
@@ -1101,7 +1101,7 @@ void PublishDeviceData(JsonObject& BLEdata, bool processBLEData) {
BLEdata.remove("mac_type");
BLEdata.remove("adv_type");
// tag device properties
BLEdata.remove("type");
// BLEdata.remove("type"); type is used by the WebUI module to determine the template used to display the signal
BLEdata.remove("cidc");
BLEdata.remove("acts");
BLEdata.remove("cont");
-1
View File
@@ -193,7 +193,6 @@ void MeasureTempHumAndPressure() {
}
if (BME280data.size() > 0) {
pub(BMETOPIC, BME280data);
pubOled(BMETOPIC, BME280data);
}
}
+1632
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -34,7 +34,7 @@ extern void launchBTDiscovery(bool overrideDiscovery);
extern void stopProcessing();
extern void startProcessing();
extern void lowPowerESP32();
extern void stateBTMeasures(bool);
extern String stateBTMeasures(bool);
#ifdef ESP32
extern int btQueueBlocked;
-2
View File
@@ -246,8 +246,6 @@ bool validFrequency(float mhz) {
int currentReceiver = -1;
extern void stateMeasures(); // Send a status message
# if !defined(ZgatewayRFM69) && !defined(ZactuatorSomfy)
# if defined(ESP8266) || defined(ESP32)
// Check if a receiver is available
+10 -49
View File
@@ -39,6 +39,7 @@
#include <Wire.h>
#include "SSD1306Wire.h"
#include "config_WebUI.h"
/*-------------------DEFINE LOG LEVEL----------------------*/
@@ -50,8 +51,14 @@
# define LOG_TO_OLED false // Default to not display log messages on display
#endif
#ifndef JSON_TO_OLED
# define JSON_TO_OLED true // Default to displaying JSON messages on the display
#ifndef ZwebUI
# ifndef JSON_TO_OLED
# define JSON_TO_OLED true // Default to displaying JSON messages on the display
# endif
#else
# ifndef JSON_TO_OLED
# define JSON_TO_OLED false // If WebUI is NOT included within the build, the JSON message parser is not included within the build and the JSON messages are not available for display
# endif
#endif
#ifndef DISPLAY_PAGE_INTERVAL
@@ -62,10 +69,6 @@
# define DISPLAY_IDLE_LOGO true // Display the OMG logo when idle
#endif
#ifndef DISPLAY_METRIC
# define DISPLAY_METRIC true // Units used for display of sensor data
#endif
#ifndef DISPLAY_FLIP
# define DISPLAY_FLIP true // Flip display orientation
#endif
@@ -119,30 +122,6 @@ void ssd1306Print(char*, char*, char*);
void ssd1306Print(char*, char*);
void ssd1306Print(char*);
#define pubOled(...) ssd1306PubPrint(__VA_ARGS__)
void ssd1306PubPrint(const char*, JsonObject&);
// Structure for queueing OMG messages to the display
/*
Structure for queueing OMG messages to the display.
Length of each line is OLED_TEXT_WIDTH
- title
- line1
- line2
- line3
- line4
*/
struct displayQueueMessage {
char title[OLED_TEXT_WIDTH];
char line1[OLED_TEXT_WIDTH];
char line2[OLED_TEXT_WIDTH];
char line3[OLED_TEXT_WIDTH];
char line4[OLED_TEXT_WIDTH];
};
displayQueueMessage* currentOledMessage;
/*-------------------End of Global Variables----------------------*/
// This pattern was borrowed from HardwareSerial and modified to support the ssd1306 display
@@ -152,7 +131,7 @@ public:
OledSerial(int);
void begin();
void drawLogo(int xshift, int yshift);
boolean displayPage(displayQueueMessage*);
boolean displayPage(webUIQueueMessage*);
SSD1306Wire* display;
@@ -194,22 +173,4 @@ protected:
extern OledSerial Oled;
/*------------------- Unit Conversion Functions ----------------------*/
#define convert_kmph2mph(kmph) (kmph * (1.0f / 1.609344f))
#define convert_mph2kmph(mph) (mph * 1.609344f)
#define convert_mm2inch(mm) (mm * 0.039370f)
#define convert_inch2mm(inch) (inch * 25.4f)
#define convert_kpa2psi(kpa) (kpa * (1.0f / 6.89475729f))
#define convert_psi2kpa(psi) (psi * 6.89475729f)
#define convert_hpa2inhg(hpa) (hpa * (1.0f / 33.8639f))
#define convert_inhg2hpa(inhg) (inhg * 33.8639f)
#endif
+94
View File
@@ -0,0 +1,94 @@
/*
OpenMQTTGateway - ESP8266 or Arduino program for home automation
Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker
Send and receiving command by MQTT
This files enables to set your parameter for the DHT11/22 sensor
Copyright: (c)Florian ROBERT
This file is part of OpenMQTTGateway.
OpenMQTTGateway is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenMQTTGateway is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef config_WebContent_h
#define config_WebContent_h
/*------------------- ----------------------*/
// TODO: Create a script to generate these from WebPack
#define body_footer_main_menu "<div id=but2d style=\"display: block;\"></div><p><form id=but2 style=\"display: block;\" action='.' method='get'><button>Main Menu</button></form></p>"
#define body_footer_config_menu "<div id=but3d style=\"display: block;\"></div><p><form id=but3 style=\"display: block;\" action='cn' method='get'><button>Configuration</button></form></p>";
#define body_header "<body><div style='text-align:left;display:inline-block;min-width:340px;'><div style='text-align:center;'><noscript> To use, please enable JavaScript <br></noscript><h3>%s</h3><h2>%s</h2></div>"
#define button_upgrade "<p><form id=but5 style='display: block;' action='up' method='get'><button>Firmware Upgrade</button></form></p>"
// Configuration Menu
#define configure_1 "<p><form action='wi' method='get'><button>Configure WiFi</button></form></p>"
#define configure_2 "<p><form action='mq' method='get'><button>Configure MQTT</button></form></p>"
#if defined(ZgatewayCloud)
# define configure_3 "<p><form action='cl' method='get'><button>Configure Cloud</button></form></p>"
#else
# define configure_3
#endif
#define configure_4
#define configure_5
#define configure_6
#define configure_7
#define configure_8
/*------------------- ----------------------*/
const char header_html[] = "<!DOCTYPE html><html lang=\"en\" class= \" \"><head><meta charset='utf-8'><meta name= \"viewport \" content= \"width=device-width,initial-scale=1,user-scalable=no \"/><title>%s</title><script> var x = null, lt, to, tp, pc = ''; function eb(s) { return document.getElementById(s); } function qs(s) { return document.querySelector(s); } function sp(i) { eb(i).type = (eb(i).type === 'text' ? 'password' : 'text'); } function wl(f) { window.addEventListener('load', f); }";
const char root_script[] = "var ft; function la(p) {a = p || '';clearTimeout(ft);clearTimeout(lt);if (x != null) { x.abort()}x = new XMLHttpRequest();x.onreadystatechange = function() { if (x.readyState == 4 && x.status == 200) {var s = x.responseText.replace(/{t}/g,\"<table style='width:100%'> \").replace(/{s}/g,\"<tr><th> \").replace(/{m}/g,\"</th><td style='width:20px;white-space:nowrap'> \").replace(/{e}/g,\"</td></tr> \");eb('l1').innerHTML = s;clearTimeout(ft);clearTimeout(lt);lt = setTimeout(la, 2345); }};x.open('GET', '.?m=1' + a, true);x.send();ft = setTimeout(la, 20000); } function lc(v, i, p) {if (eb('s')) { if (v == 'h' || v == 'd') {var sl = eb('sl4').value;eb('s').style.background = 'linear-gradient(to right,rgb(' + sl + '%,' + sl + '%,' + sl + '%),hsl(' + eb('sl2').value + ',100%%,50%%))'; }}la('&' + v + i + '=' + p); } wl(la);";
const char restart_script[] = "setTimeout(function() { location.href = '.'; }, 15000);";
const char information_script[] = "function i() { var s, o = \"<table style='width:100%%'><tr><th>%s</td></tr></table>\"; s = o.replace(/}1/g, \"</td></tr><tr><th>\").replace(/}2/g, \"</th><td>\"); eb('i').innerHTML = s; } wl(i);";
const char console_script[] = " var sn = 0, id = 0, ft, ltm = 2345; function l(p) { var c, o = ''; clearTimeout(lt); clearTimeout(ft); t = eb('t1'); if (p == 1) { c = eb('c1'); o = '&c1=' + encodeURIComponent(c.value); c.value = ''; t.scrollTop = 99999; sn = t.scrollTop; } if (t.scrollTop >= sn) { if (x != null) { x.abort(); } x = new XMLHttpRequest(); x.onreadystatechange = function() { if (x.readyState == 4 && x.status == 200) { var z, d; d = x.responseText.split(/}1/); id = d.shift(); if (d.shift() == 0) { t.value = ''; } z = d.shift(); if (z.length > 0) { t.value += z; } t.scrollTop = 99999; sn = t.scrollTop; clearTimeout(ft); lt = setTimeout(l, ltm); } }; x.open('GET', 'cs?c2=' + id + o, true); x.send(); ft = setTimeout(l, 20000); } else { lt = setTimeout(l, ltm); } return false; } wl(l); var hc = [], cn = 0; function h() { eb('c1').addEventListener('keydown', function(e) { var b = eb('c1'), c = e.keyCode; if (38 == c || 40 == c) { b.autocomplete = 'off'; } 38 == c ? (++cn > hc.length && (cn = hc.length), b.value = hc[cn - 1] || '') : 40 == c ? (0 > --cn && (cn = 0), b.value = hc[cn - 1] || '') : 13 == c && (hc.length > 19 && hc.pop(), hc.unshift(b.value), cn = 0) }); } wl(h);";
const char script[] = "function jd() { var t = 0, i = document.querySelectorAll('input,button,textarea,select'); while (i.length >= t) { if (i[t]) { i[t]['name'] = (i[t].hasAttribute('id') && (!i[t].hasAttribute('name'))) ? i[t]['id'] : i[t]['name']; } t++; } } wl(jd); </script>";
const char style[] = "<style> div, fieldset, input, select { padding: 5px; font-size: 1em; } fieldset { background: #DDDDDD; } p { margin: 0.5em 0; } input { width: 100%; box-sizing: border-box; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; background: #EEEEEE; color: #2F2F2F; } input[type=checkbox], input[type=radio] { width: 1em; margin-right: 6px; vertical-align: -1px; } input[type=range] { width: 99%; } select { width: 100%; background: #EEEEEE; color: #2F2F2F; } textarea { resize: vertical; width: 98%; height: 318px; padding: 5px; overflow: auto; background: #2F2F2F; color: #7BB461; } body { text-align: center; font-family: verdana, sans-serif; background: #EEEEEE; color:#2E2F2F;} td { padding: 0px; } button { border: 0; border-radius: 0.3rem; background: #4B98D1; color: #faffff; line-height: 2.4rem; font-size: 1.2rem; width: 100%; -webkit-transition-duration: 0.4s; transition-duration: 0.4s; cursor: pointer; } button:hover { background: #025880;font-weight: bold; } .bred { background: #FFA900; } .bred:hover { background: #FF8000; font-weight: bold;} .bgrn { background: #7BB461; } .bgrn:hover { background: #3A772A;font-weight: bold; } a { color: #4B98D1; text-decoration: none; } .p { float: left; text-align: left; } .q { float: right; text-align: right; } .r { border-radius: 0.3em; padding: 2px; margin: 6px 2px; } </style></head>";
const char root_body[] = body_header "<fieldset><div style='padding:0;' id='l1' name='l1'></div></fieldset><div id=but3d style='display: block;'></div><p><form id=but3 style='display: block;' action='cn' method='get'><button>Configuration</button></form></p><p><form id=but4 style='display: block;' action='in' method='get'><button>Information</button></form></p>" button_upgrade "<p><form id=but14 style='display: block;' action='cs' method='get'><button>Console</button></form></p><p><form id=but0 style='display: block;' action='.' method='get' onsubmit='return confirm(\"Confirm Restart\");'><button name='rst' class='button bred'>Restart</button></form></p>";
const char config_body[] = body_header "" configure_1 "" configure_2 "" configure_3 "" configure_4 "" configure_5 "" configure_6 "" configure_7 "" configure_8 "<div id=but1d style='display: block;'></div><p><form id=but1 style='display: block;' action='rt' method='get' onsubmit='return confirm(\"Confirm Reset Configuration\");'><button name='non' class='button bred'>Reset Configuration</button></form>" body_footer_main_menu;
const char reset_body[] = body_header "<div style='text-align:center;'>%s</div><br><div style='text-align:center;'>Device will restart in a few seconds</div><br>" body_footer_main_menu;
const char config_cloud_body[] = body_header "<fieldset><legend><b>&nbsp;Cloud Configuration&nbsp;</b></legend><form method='get' action='cl'><p><label><input id='cl-en' type='checkbox' %s><b>Enable Cloud Connection</b></label></p><br><p><label><input id='cl-lk' type='checkbox' disabled><b>Cloud Account%s Linked</b></label></p><br><button name='save' type='submit' class='button bgrn'>Save</button></form></fieldset><p><form action='%s' method='get'><input type='hidden' name='macAddress' value='%s'/><input type='hidden' name='redirect_uri' value='%s'/><input type='hidden' name='gateway_name' value='%s'/><input type='hidden' name='uptime' value='%d'/><input type='hidden' name='RT' value='%d'/><button>Link Cloud Account</button></form></p>" body_footer_config_menu;
const char token_body[] = body_header "div style='text-align:center;'>Link Cloud Account</div><br><div style='text-align:center;'>Cloud was successfully linked</div><br><div id=but2d style=\"display: block;\"></div><p><form id=but2 style=\"display: block;\" action='cn' method='get'><button>Configuration</button></form></p>";
const char console_body[] = body_header "<br><textarea readonly id='t1' cols='340' wrap='off'></textarea><br><br><form method='get' onsubmit='return l(1);'><input id='c1' placeholder='Enter topic and command' autofocus><br></form>" body_footer_main_menu;
const char information_body[] = body_header "<style>td {padding: 0px 5px;}</style><div id='i' name='i'></div>" body_footer_main_menu;
const char upgrade_body[] = body_header " <div id='f1' style='display:block;'><fieldset><legend><b>&nbsp;Upgrade by web server&nbsp;</b></legend><form method='get' action='u1'><br><b>OTA Url</b><br><input id='o' placeholder=\"OTA_URL\" value=\"%s\"><br><br><button type='submit'>Start upgrade</button></form></fieldset><br><br><fieldset><legend><b>&nbsp;Upgrade by file upload&nbsp;</b></legend><form method='post' action='u2' enctype='multipart/form-data'><br><input type='file' name='u2'><br><br><button type='submit' onclick='eb(\"f1\").style.display=\"none\";eb(\"f2\").style.display=\"block\";this.form.submit();'>Start upgrade</button></form></fieldset></div><div id='f2' style='display:none;text-align:center;'><b>Upload started ...</b></div><div id=but2d style=\"display: block;\"></div><p>" body_footer_main_menu;
const char config_wifi_body[] = body_header "<div title='-43 dBm (100%)'><a href='#p' onclick='c(this)'>%s</a><span class='q'><div class='si'><i class='b0'></i><i class='b1'></i><i class='b2'></i><i class='b3'></i></span></div></div><div title='-84 dBm (32%)'><a href='#p' onclick='c(this)'>BELL634</a><span class='q'><div class='si'><i class='b0'></i><i class='b1'></i><i class='b2 o30'></i><i class='b3 o30'></i></span></div></div><div title='-86 dBm (28%)'><a href='#p' onclick='c(this)'>MRC</a><span class='q'><div class='si'><i class='b0'></i><i class='b1'></i><i class='b2 o30'></i><i class='b3 o30'></i></span></div></div><br><div><a href='/wi?scan='>Scan for all WiFi Networks</a></div><br><fieldset><legend><b>&nbsp;Wifi parameters&nbsp;</b></legend><form method='get' action='wi'><p><b>WiFi Network</b> () <br><input id='s1' placeholder=\"Type or Select your WiFi Network\" value=\"%s\"></p><p><label><b>WiFi Password</b><input type='checkbox' onclick='sp(\"p1\")'></label><br><input id='p1' type='password' placeholder=\"Enter your WiFi Password\" value=\"****\"></p><p><b>WiFi Network 2</b> () <br><input id='s2' placeholder=\"Type your Alternative WiFi Network\" value=\"\"></p><p><label><b>WiFi Password</b><input type='checkbox' onclick='sp(\"p2\")'></label><br><input id='p2' type='password' placeholder=\"Enter your WiFi Password\" value=\"****\"></p><p><b>Hostname</b>%s<br><input id='h' placeholder=\"%s\" value=\"%s\"></p><p><b>CORS Domain</b><input id='c' placeholder=\"\" value=\"%s\"></p><br><button name='save' type='submit' class='button bgrn'>Save</button></form></fieldset>" body_footer_config_menu;
// mqtt server, mqtt port, client id, mqtt username, mqtt password, topic, Full Topic
const char config_mqtt_body[] = body_header "<fieldset><legend><b>&nbsp;MQTT parameters&nbsp;</b></legend><form method='get' action='mq'><p><b>Host</b> () <br><input id='mh' placeholder=" MQTT_SERVER " value='%s'></p><p><b>Port</b> (1883) <br><input id='ml' placeholder=" MQTT_PORT " value='%s'></p><p><b>Client</b> <br><input id='mc' placeholder='' value='%s'></p><p><b>User</b> " MQTT_USER " <br><input id='mu' placeholder=" MQTT_USER " value='%s'></p><p><label><b>Password</b><input type='checkbox' onclick='sp(\"mp\")'></label><br><input id='mp' type='password' placeholder=\"Password\" value='%s'></p><p><b>Topic</b> <br><input id='mt' placeholder='' value='%s'></p><p><b>Full Topic</b> <br><input id='mf' placeholder=\"\" value='%s'></p><br><button name='save' type='submit' class='button bgrn'>Save</button></form></fieldset>" body_footer_config_menu;
const char footer[] = "<div style='text-align:right;font-size:11px;'><hr/><a href='https://community.openmqttgateway.com' target='_blank' style='color:#aaa;'>%s</a></div></div></body></html>";
#endif
+161
View File
@@ -0,0 +1,161 @@
/*
OpenMQTTGateway - ESP8266 or Arduino program for home automation
Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker
Send and receiving command by MQTT
This files enables to set your parameter for the DHT11/22 sensor
Copyright: (c)Florian ROBERT
This file is part of OpenMQTTGateway.
OpenMQTTGateway is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenMQTTGateway is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef config_WebUI_h
#define config_WebUI_h
#include <Wire.h>
#define WEBUI_TEXT_WIDTH 128
/*------------------- Optional Compiler Directives ----------------------*/
#ifndef WEB_TEMPLATE_BUFFER_MAX_SIZE
# define WEB_TEMPLATE_BUFFER_MAX_SIZE 2000
#endif
#ifndef DISPLAY_METRIC
# define DISPLAY_METRIC true // Units used for display of sensor data
#endif
#ifndef DISPLAY_WEBUI_INTERVAL
# define DISPLAY_WEBUI_INTERVAL 3 // Number of seconds between json message displays
#endif
#ifdef WEBUI_DEVELOPMENT
# pragma message("[WebUI] Usage of SPIFFS for missing WebUI content enabled")
# define FILESYSTEM SPIFFS
# define WEBUI_TRACE_LOGGING
#endif
#ifdef WEBUI_TRACE_LOGGING
# define WEBUI_TRACE_LOG(...) Log.trace(__VA_ARGS__)
#else
# define WEBUI_TRACE_LOG(...)
#endif
/*------------------- End of Compiler Directives ----------------------*/
// Structure for queueing OMG messages to the display
/*
Structure for queueing OMG messages to the display.
Length of each line is WEBUI_TEXT_WIDTH
- title
- line1
- line2
- line3
- line4
*/
struct webUIQueueMessage {
char title[WEBUI_TEXT_WIDTH];
char line1[WEBUI_TEXT_WIDTH];
char line2[WEBUI_TEXT_WIDTH];
char line3[WEBUI_TEXT_WIDTH];
char line4[WEBUI_TEXT_WIDTH];
} webUIQueueMessage_t;
/*------------------- Global Functions and Variables ----------------------*/
#ifdef ZwebUI
# define pubWebUI(...) webUIPubPrint(__VA_ARGS__)
void webUIPubPrint(const char*, JsonObject&);
#endif
void WebUISetup();
void WebUILoop();
void MQTTtoWebUI(char*, JsonObject&);
String stateWebUIStatus();
webUIQueueMessage* currentWebUIMessage;
/*------------------- End of Global Functions ----------------------*/
#define subjectMQTTtoWebUIset "/commands/MQTTtoWebUI/config"
#define subjectWebUItoMQTT "/WebUItoMQTT"
/*------------------- Unit Conversion Functions ----------------------*/
#define convert_kmph2mph(kmph) (kmph * (1.0f / 1.609344f))
#define convert_mph2kmph(mph) (mph * 1.609344f)
#define convert_mm2inch(mm) (mm * 0.039370f)
#define convert_inch2mm(inch) (inch * 25.4f)
#define convert_kpa2psi(kpa) (kpa * (1.0f / 6.89475729f))
#define convert_psi2kpa(psi) (psi * 6.89475729f)
#define convert_hpa2inhg(hpa) (hpa * (1.0f / 33.8639f))
#define convert_inhg2hpa(inhg) (inhg * 33.8639f)
/*------------------- Take over serial output and split to ----------------------*/
class SerialWeb : public Stream {
public:
SerialWeb(int);
void begin();
int available(void); // Dummy functions
int peek(void); // Dummy functions
int read(void); // Dummy functions
void flush(void); // Dummy functions
inline size_t write(uint8_t x) {
return write(&x, 1);
}
size_t write(const uint8_t* buffer, size_t size);
inline size_t write(const char* buffer, size_t size) {
return write((uint8_t*)buffer, size);
}
inline size_t write(const char* s) {
return write((uint8_t*)s, strlen(s));
}
inline size_t write(unsigned long n) {
return write((uint8_t)n);
}
inline size_t write(long n) {
return write((uint8_t)n);
}
inline size_t write(unsigned int n) {
return write((uint8_t)n);
}
inline size_t write(int n) {
return write((uint8_t)n);
}
protected:
};
extern SerialWeb WebLog;
/*------------------- Take over serial output and split to ----------------------*/
#endif
+21 -1
View File
@@ -70,6 +70,9 @@ struct GfSun2000Data {};
#endif
// Modules config inclusion
#if defined(ZwebUI) && defined(ESP32)
# include "config_WebUI.h"
#endif
#if defined(ZgatewayRF) || defined(ZgatewayRF2) || defined(ZgatewayPilight) || defined(ZactuatorSomfy) || defined(ZgatewayRTL_433)
# include "config_RF.h"
#endif
@@ -396,6 +399,7 @@ void pub(const char* topicori, JsonObject& data) {
#if jsonPublishing
Log.trace(F("jsonPubl - ON" CR));
pubMQTT(topic, dataAsString.c_str());
pubWebUI(topicori, data);
#endif
#if simplePublishing
@@ -811,6 +815,11 @@ void setup() {
setup_ethernet();
#endif
#if defined(ZwebUI) && defined(ESP32)
WebUISetup();
modules.add(ZwebUI);
#endif
#if defined(ESP8266) || defined(ESP32)
if (mqtt_secure) {
eClient = new WiFiClientSecure;
@@ -1184,6 +1193,7 @@ void setup_wifi() {
# endif
}
Log.notice(F("WiFi ok with manual config credentials" CR));
displayPrint("Wifi connected");
}
#elif defined(ESP8266) || defined(ESP32)
@@ -1610,6 +1620,9 @@ void loop() {
# endif
# ifdef ZdisplaySSD1306
stateSSD1306Display();
# endif
# if defined(ZwebUI) && defined(ESP32)
stateWebUIStatus();
# endif
}
if (now > (timer_sys_checks + (TimeBetweenCheckingSYS * 1000)) || !timer_sys_checks) {
@@ -1729,6 +1742,9 @@ void loop() {
if (disc)
launchRTL_433Discovery(publishDiscovery);
# endif
#endif
#if defined(ZwebUI) && defined(ESP32)
WebUILoop();
#endif
} else {
// MQTT disconnected
@@ -1827,7 +1843,7 @@ String UTCtimestamp() {
#endif
#if defined(ESP8266) || defined(ESP32) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
void stateMeasures() {
String stateMeasures() {
StaticJsonDocument<JSON_MSG_BUFFER> jsonBuffer;
JsonObject SYSdata = jsonBuffer.to<JsonObject>();
SYSdata["uptime"] = uptime();
@@ -1919,8 +1935,12 @@ void stateMeasures() {
}
# endif
SYSdata["modules"] = modules;
String output;
serializeJson(SYSdata, output);
pub(subjectSYStoMQTT, SYSdata);
pubOled(subjectSYStoMQTT, SYSdata);
return output;
}
#endif
+1
View File
@@ -187,6 +187,7 @@ build_flags =
'-DMQTTsetMQTT'
'-DMQTT_HTTPS_FW_UPDATE'
;'-DCORE_DEBUG_LEVEL=4'
'-DZwebUI="WebUI"' ; enable WebUI as a default for all ESP32 builds ( the module only enables for ESP32 based builds )
[com-arduino]
lib_deps =