diff --git a/src/config.cpp b/src/config.cpp index 16b80dd..156c311 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -864,7 +864,7 @@ void serializeSysVarsToJson(const SysVarsStruct &vars, JsonObject obj) obj[disableLedsKey] = vars.disableLeds; // obj[zbLedStateKey] = vars.zbLedState; - // obj[zbFlashingKey] = vars.zbFlashing; + obj[zbFlashingKey] = vars.zbFlashing; obj[deviceIdKey] = vars.deviceId; @@ -899,6 +899,10 @@ bool loadFileConfigHW() if (!configFile) { + if (!LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED, "/lfs2", 10)) + { + LOGD("Error with LITTLEFS"); + } DynamicJsonDocument config(300); config[board] = ""; writeDefaultConfig(configFileHw, config); @@ -917,10 +921,11 @@ bool loadFileConfigHW() hwConfig.eth.mdiPin = config[mdiPin]; hwConfig.eth.phyType = config[phyType]; hwConfig.eth.clkMode = config[clkMode]; - if (hwConfig.eth.pwrPin == -1) { + if (hwConfig.eth.pwrPin == -1) + { hwConfig.eth.pwrPin = config[pwrAltPin]; } - //hwConfig.eth.pwrAltPin = config[pwrAltPin]; + // hwConfig.eth.pwrAltPin = config[pwrAltPin]; hwConfig.mist.btnPin = config[btnPin]; hwConfig.mist.btnPlr = config[btnPlr]; hwConfig.mist.uartSelPin = config[uartSelPin]; @@ -936,18 +941,24 @@ bool loadFileConfigHW() if (hwConfig.board[0] != '\0' && strlen(hwConfig.board) > 0) { - LOGD("LOAD - OK"); + LOGD("Load HW - OK"); return true; } else { - LOGI("LOAD - ERROR"); + LOGI("Load HW - ERROR"); int searchId = 0; if (config["searchId"]) { searchId = config["searchId"]; } + String chipId = ESP.getChipModel(); + LOGW("%s", chipId); + //if (chipId == "ESP32-D0WDQ6") + //{ + // searchId = 12; + //} ThisConfigStruct *newConfig = findBrdConfig(searchId); if (newConfig) { @@ -961,7 +972,7 @@ bool loadFileConfigHW() config[mdiPin] = newConfig->eth.mdiPin; config[phyType] = newConfig->eth.phyType; config[clkMode] = newConfig->eth.clkMode; - //config[pwrAltPin] = newConfig->eth.pwrAltPin; + // config[pwrAltPin] = newConfig->eth.pwrAltPin; config[btnPin] = newConfig->mist.btnPin; config[btnPlr] = newConfig->mist.btnPlr; config[uartSelPin] = newConfig->mist.uartSelPin; @@ -1020,7 +1031,7 @@ bool loadFileSystemVar() File configFile = LittleFS.open(configFileSystem, FILE_READ); if (!configFile) { - LOGD("%s %s", configFileSystem, msg_open_f); + // LOGD("%s %s", configFileSystem, msg_open_f); return false; } @@ -1055,7 +1066,7 @@ bool loadFileConfigWifi() File configFile = LittleFS.open(configFileWifi, FILE_READ); if (!configFile) { - LOGD("%s %s", configFileWifi, msg_open_f); + // LOGD("%s %s", configFileWifi, msg_open_f); return false; } @@ -1094,7 +1105,7 @@ bool loadFileConfigEther() File configFile = LittleFS.open(configFileEther, FILE_READ); if (!configFile) { - LOGD("%s %s", configFileEther, msg_open_f); + // LOGD("%s %s", configFileEther, msg_open_f); return false; } @@ -1125,7 +1136,7 @@ bool loadFileConfigGeneral() File configFile = LittleFS.open(configFileGeneral, FILE_READ); if (!configFile) { - LOGD("%s %s", configFileGeneral, msg_open_f); + // LOGD("%s %s", configFileGeneral, msg_open_f); return false; } @@ -1170,7 +1181,7 @@ bool loadFileConfigSecurity() File configFile = LittleFS.open(configFileSecurity, FILE_READ); if (!configFile) { - LOGD("%s %s", configFileSecurity, msg_open_f); + // LOGD("%s %s", configFileSecurity, msg_open_f); return false; } @@ -1205,7 +1216,7 @@ bool loadFileConfigSerial() File configFile = LittleFS.open(configFileSerial, FILE_READ); if (!configFile) { - LOGD("%s %s", configFileSerial, msg_open_f); + // LOGD("%s %s", configFileSerial, msg_open_f); return false; } @@ -1234,7 +1245,7 @@ bool loadFileConfigMqtt() File configFile = LittleFS.open(configFileMqtt, FILE_READ); if (!configFile) { - LOGD("%s %s", configFileMqtt, msg_open_f); + // LOGD("%s %s", configFileMqtt, msg_open_f); return false; } @@ -1276,7 +1287,7 @@ bool loadFileConfigWg() File configFile = LittleFS.open(configFileWg, FILE_READ); if (!configFile) { - LOGD("%s %s", configFileWg, msg_open_f); + // LOGD("%s %s", configFileWg, msg_open_f); return false; } diff --git a/src/config.h b/src/config.h index 53f27f7..3fc44fa 100644 --- a/src/config.h +++ b/src/config.h @@ -100,7 +100,7 @@ struct SysVarsStruct bool disableLeds; // bool zbLedState; - // bool zbFlashing; + bool zbFlashing; char deviceId[MAX_DEV_ID_LONG]; diff --git a/src/const/hw.cpp b/src/const/hw.cpp index 602815d..2ac6816 100644 --- a/src/const/hw.cpp +++ b/src/const/hw.cpp @@ -3,9 +3,9 @@ // Ethernet configurations // !!! Don't forget to edit ETH_CFG_CNT !!! EthConfig ethConfigs[] = { - {.addr = 0, .pwrPin = 12, .mdcPin = 23, .mdiPin = 18, .phyType = ETH_PHY_LAN8720, .clkMode = ETH_CLOCK_GPIO17_OUT}, // .pwrAltPin = -1}, // 0 Olimex-ESP32-POE - {.addr = 1, .pwrPin = 16, .mdcPin = 23, .mdiPin = 18, .phyType = ETH_PHY_LAN8720, .clkMode = ETH_CLOCK_GPIO0_IN}, // .pwrAltPin = -1}, // 1 WT32-ETH01 - {.addr = 0, .pwrPin = 5, .mdcPin = 23, .mdiPin = 18, .phyType = ETH_PHY_LAN8720, .clkMode = ETH_CLOCK_GPIO17_OUT}, // .pwrAltPin = -1}, // 2 T-Internet-POE / UZG01 / HamGeek POE Plus + {.addr = 0, .pwrPin = 12, .mdcPin = 23, .mdiPin = 18, .phyType = ETH_PHY_LAN8720, .clkMode = ETH_CLOCK_GPIO17_OUT}, // .pwrAltPin = -1}, // 0 Olimex-ESP32-POE + {.addr = 1, .pwrPin = 16, .mdcPin = 23, .mdiPin = 18, .phyType = ETH_PHY_LAN8720, .clkMode = ETH_CLOCK_GPIO0_IN}, // .pwrAltPin = -1}, // 1 WT32-ETH01 + {.addr = 0, .pwrPin = 5, .mdcPin = 23, .mdiPin = 18, .phyType = ETH_PHY_LAN8720, .clkMode = ETH_CLOCK_GPIO17_OUT}, // .pwrAltPin = -1}, // 2 T-Internet-POE / UZG01 / HamGeek POE Plus }; // ZigBee configurations @@ -33,18 +33,18 @@ MistConfig mistConfigs[] = { // Board configurations // !!! Don't forget to edit BOARD_CFG_CNT !!! BrdConfigStruct brdConfigs[] = { - {"UZG-01", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 1}, // 0 - {"SLZB-06", .ethConfigIndex = 1, .zbConfigIndex = 1, .mistConfigIndex = 2}, // 1 - {"WT32-ETH01", .ethConfigIndex = 1, .zbConfigIndex = 1, .mistConfigIndex = 0}, // 2 - {"T-Internet-POE", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 0}, // 3 - {"Olimex-ESP32-POE", .ethConfigIndex = 0, .zbConfigIndex = 0, .mistConfigIndex = 0}, // 4 - {"China-GW", .ethConfigIndex = 0, .zbConfigIndex = 2, .mistConfigIndex = 0}, // 5 - {"TubesZB-eth", .ethConfigIndex = 1, .zbConfigIndex = 1, .mistConfigIndex = 0}, // 6 - {"TubesZB-eth_usb", .ethConfigIndex = 1, .zbConfigIndex = 3, .mistConfigIndex = 0}, // 7 - {"TubesZB-poe", .ethConfigIndex = 0, .zbConfigIndex = 4, .mistConfigIndex = 0}, // 8 - {"TubesZB-poe-2022", .ethConfigIndex = 0, .zbConfigIndex = 5, .mistConfigIndex = 0}, // 9 - {"TubesZB-poe-2023", .ethConfigIndex = 0, .zbConfigIndex = 6, .mistConfigIndex = 0}, // 10 - {"CZC-1.0", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 1}, // 11 - {"SLS-classic", .ethConfigIndex = -1, .zbConfigIndex = 7, .mistConfigIndex = 3}, // 12 - {"HG POE Plus", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 1}, // 13 + {"SLS-classic", .ethConfigIndex = -1, .zbConfigIndex = 7, .mistConfigIndex = 3}, // 0 + {"UZG-01", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 1}, // 1 + {"SLZB-06", .ethConfigIndex = 1, .zbConfigIndex = 1, .mistConfigIndex = 2}, // 2 + {"WT32-ETH01", .ethConfigIndex = 1, .zbConfigIndex = 1, .mistConfigIndex = 0}, // 3 + {"T-Internet-POE", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 0}, // 4 DON'T MOVE + {"Olimex-ESP32-POE", .ethConfigIndex = 0, .zbConfigIndex = 0, .mistConfigIndex = 0}, // 5 + {"China-GW", .ethConfigIndex = 0, .zbConfigIndex = 2, .mistConfigIndex = 0}, // 6 + {"TubesZB-eth", .ethConfigIndex = 1, .zbConfigIndex = 1, .mistConfigIndex = 0}, // 7 + {"TubesZB-eth_usb", .ethConfigIndex = 1, .zbConfigIndex = 3, .mistConfigIndex = 0}, // 8 + {"TubesZB-poe", .ethConfigIndex = 0, .zbConfigIndex = 4, .mistConfigIndex = 0}, // 9 + {"TubesZB-poe-2022", .ethConfigIndex = 0, .zbConfigIndex = 5, .mistConfigIndex = 0}, // 10 + {"TubesZB-poe-2023", .ethConfigIndex = 0, .zbConfigIndex = 6, .mistConfigIndex = 0}, // 11 + {"CZC-1.0", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 1}, // 12 + {"HG POE Plus", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 1}, // 13 }; \ No newline at end of file diff --git a/src/const/keys.cpp b/src/const/keys.cpp index a490ef0..068455c 100644 --- a/src/const/keys.cpp +++ b/src/const/keys.cpp @@ -101,7 +101,7 @@ const char *mqttConnKey = "mqttConn"; const char *mqttReconnectTimeKey = "mqttReconnectTime"; const char *mqttHeartbeatTimeKey = "mqttHeartbeatTime"; // const char *zbLedStateKey = "zbLedState"; -// const char *zbFlashingKey = "zbFlashing"; +const char *zbFlashingKey = "zbFlashing"; const char *deviceIdKey = "deviceId"; const char *timeZoneNameKey = "timeZoneName"; const char *zbRoleKey = "zbRole"; diff --git a/src/etc.cpp b/src/etc.cpp index 7063a62..fe233fd 100644 --- a/src/etc.cpp +++ b/src/etc.cpp @@ -293,10 +293,12 @@ void factoryReset() delay(1000); } + LittleFS.format(); if (!LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED, "/lfs2", 10)) // change to format anyway { LOGD("Error with LITTLEFS"); } + LittleFS.remove(configFileSerial); LittleFS.remove(configFileSecurity); LittleFS.remove(configFileGeneral); @@ -641,7 +643,7 @@ ThisConfigStruct *findBrdConfig(int searchId = 0) LOGI("Try brd: %d - %s", brdIdx, brdConfigs[brdIdx].board); - /*if (brdIdx == 3) // T-Internet-POE + if (brdIdx == 4) // T-Internet-POE { pinMode(ethConfigs[ethIdx].pwrPin, OUTPUT); delay(50); @@ -655,7 +657,7 @@ ThisConfigStruct *findBrdConfig(int searchId = 0) LOGW("%s", "Looks like not T-Internet-POE!"); continue; } - }*/ + } if (ethIdx == -1) { diff --git a/src/main.cpp b/src/main.cpp index f153213..d6250a2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -74,7 +74,6 @@ MDNSResponder mDNS; void initLan() { - LOGD("Load cfg %s", hwConfig.board); if (ETH.begin(hwConfig.eth.addr, hwConfig.eth.pwrPin, hwConfig.eth.mdcPin, hwConfig.eth.mdiPin, hwConfig.eth.phyType, hwConfig.eth.clkMode)) // hwConfig.eth.pwrAltPin)) { @@ -147,9 +146,12 @@ void handleTmrNetworkOverseer() // case WORK_MODE_NETWORK: if (!networkCfg.wifiEnable && !networkCfg.ethEnable) { - LOGD("Both interfaces disabled. Start AP"); - startAP(true); - connectWifi(); + if (!vars.apStarted) + { + LOGD("Both interfaces disabled. Start AP"); + startAP(true); + connectWifi(); + } } if (networkCfg.wifiEnable) { @@ -181,6 +183,10 @@ void handleTmrNetworkOverseer() { LOGD("LAN CONNECTED"); tmrNetworkOverseer.stop(); + if (vars.apStarted) + { + startAP(false); + } if (!vars.firstUpdCheck) { checkUpdateAvail(); @@ -303,7 +309,7 @@ void NetworkEvent(WiFiEvent_t event) void startAP(const bool start) { String tag = "sAP"; - LOGD("begin s=%d, v=%d", start, vars.apStarted); + LOGD("begin cmd=%d, state=%d", start, vars.apStarted); if (vars.apStarted) { @@ -614,6 +620,7 @@ void setup() } LOGI("[ESP] FW: %s", String(VERSION)); + LOGD("Load cfg %s", hwConfig.board); LOGD("done"); } @@ -734,117 +741,121 @@ void loop(void) } } - if (systemCfg.workMode == WORK_MODE_USB) + if (!vars.zbFlashing) { - if (Serial2.available()) - { - Serial.write(Serial2.read()); - Serial.flush(); - } - if (Serial.available()) + + if (systemCfg.workMode == WORK_MODE_USB) { - Serial2.write(Serial.read()); - Serial2.flush(); + if (Serial2.available()) + { + Serial.write(Serial2.read()); + Serial.flush(); + } + if (Serial.available()) + { + Serial2.write(Serial.read()); + Serial2.flush(); + } + return; } - return; - } - - else if (systemCfg.workMode == WORK_MODE_NETWORK) - { - uint16_t net_bytes_read = 0; - uint8_t net_buf[BUFFER_SIZE]; - uint16_t serial_bytes_read = 0; - uint8_t serial_buf[BUFFER_SIZE]; - if (server.hasClient()) + else if (systemCfg.workMode == WORK_MODE_NETWORK) { - for (byte i = 0; i < MAX_SOCKET_CLIENTS; i++) + uint16_t net_bytes_read = 0; + uint8_t net_buf[BUFFER_SIZE]; + uint16_t serial_bytes_read = 0; + uint8_t serial_buf[BUFFER_SIZE]; + + if (server.hasClient()) { - if (!client[i] || !client[i].connected()) + for (byte i = 0; i < MAX_SOCKET_CLIENTS; i++) { - if (client[i]) - { - client[i].stop(); - } - if (systemCfg.fwEnabled) + if (!client[i] || !client[i].connected()) { - WiFiClient TempClient2 = server.available(); - if (TempClient2.remoteIP() == systemCfg.fwIp) + if (client[i]) { - printLogMsg(String("[SOCK IP WHITELIST] Accepted connection from IP: ") + TempClient2.remoteIP().toString()); - client[i] = TempClient2; - continue; + client[i].stop(); + } + if (systemCfg.fwEnabled) + { + WiFiClient TempClient2 = server.available(); + if (TempClient2.remoteIP() == systemCfg.fwIp) + { + printLogMsg(String("[SOCK IP WHITELIST] Accepted connection from IP: ") + TempClient2.remoteIP().toString()); + client[i] = TempClient2; + continue; + } + else + { + printLogMsg(String("[SOCK IP WHITELIST] Rejected connection from unknown IP: ") + TempClient2.remoteIP().toString()); + } } else { - printLogMsg(String("[SOCK IP WHITELIST] Rejected connection from unknown IP: ") + TempClient2.remoteIP().toString()); + client[i] = server.available(); + continue; } } - else - { - client[i] = server.available(); - continue; - } } + WiFiClient TempClient = server.available(); + TempClient.stop(); } - WiFiClient TempClient = server.available(); - TempClient.stop(); - } - for (byte cln = 0; cln < MAX_SOCKET_CLIENTS; cln++) - { - if (client[cln]) + for (byte cln = 0; cln < MAX_SOCKET_CLIENTS; cln++) { - socketClientConnected(cln, client[cln].remoteIP()); - while (client[cln].available()) - { // read from LAN - net_buf[net_bytes_read] = client[cln].read(); - if (net_bytes_read < BUFFER_SIZE - 1) - net_bytes_read++; - } // send to Zigbee - Serial2.write(net_buf, net_bytes_read); - // print to web console - printRecvSocket(net_bytes_read, net_buf); - net_bytes_read = 0; + if (client[cln]) + { + socketClientConnected(cln, client[cln].remoteIP()); + while (client[cln].available()) + { // read from LAN + net_buf[net_bytes_read] = client[cln].read(); + if (net_bytes_read < BUFFER_SIZE - 1) + net_bytes_read++; + } // send to Zigbee + Serial2.write(net_buf, net_bytes_read); + // print to web console + printRecvSocket(net_bytes_read, net_buf); + net_bytes_read = 0; + } + else + { + socketClientDisconnected(cln); + } } - else + + if (Serial2.available()) { - socketClientDisconnected(cln); + while (Serial2.available()) + { // read from Zigbee + serial_buf[serial_bytes_read] = Serial2.read(); + if (serial_bytes_read < BUFFER_SIZE - 1) + serial_bytes_read++; + } + // send to LAN + for (byte cln = 0; cln < MAX_SOCKET_CLIENTS; cln++) + { + if (client[cln]) + client[cln].write(serial_buf, serial_bytes_read); + } + // print to web console + printSendSocket(serial_bytes_read, serial_buf); + serial_bytes_read = 0; } - } - if (Serial2.available()) - { - while (Serial2.available()) - { // read from Zigbee - serial_buf[serial_bytes_read] = Serial2.read(); - if (serial_bytes_read < BUFFER_SIZE - 1) - serial_bytes_read++; - } - // send to LAN - for (byte cln = 0; cln < MAX_SOCKET_CLIENTS; cln++) + /*if (mqttCfg.enable) { - if (client[cln]) - client[cln].write(serial_buf, serial_bytes_read); - } - // print to web console - printSendSocket(serial_bytes_read, serial_buf); - serial_bytes_read = 0; + // mqttLoop(); + }*/ } - - /*if (mqttCfg.enable) + if (vpnCfg.wgEnable && vars.vpnWgInit) { - // mqttLoop(); - }*/ - } - if (vpnCfg.wgEnable && vars.vpnWgInit) - { - wgLoop(); - } + wgLoop(); + } - if (WiFi.getMode() == WIFI_MODE_AP || WiFi.getMode() == WIFI_MODE_APSTA) - { - dnsServer.processNextRequest(); + if (WiFi.getMode() == WIFI_MODE_AP || WiFi.getMode() == WIFI_MODE_APSTA) + { + dnsServer.processNextRequest(); + } + Cron.delay(); } - Cron.delay(); } diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 7e0089e..db7c18f 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -344,8 +344,15 @@ void mqttConnectSetup() void connectToMqtt() { - LOGD("Connecting to MQTT..."); - mqttClient.connect(); + if (!vars.zbFlashing) + { + LOGD("Connecting..."); + mqttClient.connect(); + } + else + { + LOGD("only after ZB flash"); + } } void onMqttConnect(bool sessionPresent) @@ -445,26 +452,32 @@ void mqttPublishIo(const String &io, bool st) void mqttPublishState() { - DynamicJsonDocument buffJson(512); - for (const auto &item : mqttTopicsConfigs) + if (!vars.zbFlashing) { - if (item.getSensorValue != nullptr) + DynamicJsonDocument buffJson(512); + for (const auto &item : mqttTopicsConfigs) { - String sensorValue = item.getSensorValue(); - if (sensorValue.length() > 0) + if (item.getSensorValue != nullptr) { - buffJson[item.sensorId] = sensorValue; + String sensorValue = item.getSensorValue(); + if (sensorValue.length() > 0) + { + buffJson[item.sensorId] = sensorValue; + } } } - } - String topic = mqttCfg.topic + String(stateTopic); - String mqttBuffer; - serializeJson(buffJson, mqttBuffer); - - LOGD("%s", mqttBuffer.c_str()); + String topic = mqttCfg.topic + String(stateTopic); + String mqttBuffer; + serializeJson(buffJson, mqttBuffer); - mqttClient.publish(topic.c_str(), 0, true, mqttBuffer.c_str()); + LOGD("%s", mqttBuffer.c_str()); + mqttClient.publish(topic.c_str(), 0, true, mqttBuffer.c_str()); + } + else + { + LOGD("only after ZB flash"); + } xTimerStart(mqttPubStateTimer, 0); } diff --git a/src/version.h b/src/version.h index b8d1988..80102e7 100644 --- a/src/version.h +++ b/src/version.h @@ -1,4 +1,4 @@ // AUTO GENERATED FILE #ifndef VERSION - #define VERSION "20240609.1" + #define VERSION "20240610" #endif diff --git a/src/websrc/js/functions.js b/src/websrc/js/functions.js index 86fa947..0df4b5f 100644 --- a/src/websrc/js/functions.js +++ b/src/websrc/js/functions.js @@ -1011,7 +1011,7 @@ function dataReplace(values, navOnly = false) { updateProgressBar("prgTemp", valueToSet, 15, 85) break; case "wifiRssi": - updateProgressBar("prgRssi", valueToSet, 0, -105) + updateProgressBar("prgRssi", valueToSet, -105, 0) valueToSet = valueToSet + " " + "dBm"; break; case "connectedSocket": // socket time diff --git a/src/zb.cpp b/src/zb.cpp index 8b39919..ea3e124 100644 --- a/src/zb.cpp +++ b/src/zb.cpp @@ -14,6 +14,7 @@ #include "log.h" #include "etc.h" #include "zb.h" +#include "mqtt.h" #include "const/keys.h" extern struct SysVarsStruct vars; @@ -128,9 +129,11 @@ void nvPrgs(const String &inputMsg) void zbEraseNV(void *pvParameters) { + vars.zbFlashing = true; CCTool.nvram_reset(nvPrgs); logClear(); printLogMsg("NVRAM erase finish! Restart CC2652!"); + vars.zbFlashing = false; vTaskDelete(NULL); } @@ -138,6 +141,7 @@ void flashZbUrl(String url) { // zbFwCheck(); ledControl.modeLED.mode = LED_BLINK_3Hz; + vars.zbFlashing = true; checkDNS(); delay(250); @@ -264,6 +268,11 @@ void flashZbUrl(String url) sendEvent(tagZB_FW_err, eventLen, String("Failed!")); } ledControl.modeLED.mode = LED_OFF; + vars.zbFlashing = false; + if (mqttCfg.enable && !vars.mqttConn) + { + connectToMqtt(); + } } /*void printBufferAsHex(const byte *buffer, size_t length)