From 9ebfd5ef6733eb8efd615259dd6fca2924f55405 Mon Sep 17 00:00:00 2001 From: xyzroe Date: Wed, 29 May 2024 01:55:54 +0200 Subject: [PATCH 1/5] CCTools v0.0.6 --- lib/CCTools/library.json | 2 +- lib/CCTools/src/CCTools.cpp | 122 +++++++++++++++++------------------- lib/CCTools/src/CCTools.h | 2 + 3 files changed, 61 insertions(+), 65 deletions(-) diff --git a/lib/CCTools/library.json b/lib/CCTools/library.json index 38792b3..59339e3 100644 --- a/lib/CCTools/library.json +++ b/lib/CCTools/library.json @@ -18,5 +18,5 @@ "type": "git", "url": "https://github.com/xyzroe/CCTools" }, - "version": "0.0.5" + "version": "0.0.6" } \ No newline at end of file diff --git a/lib/CCTools/src/CCTools.cpp b/lib/CCTools/src/CCTools.cpp index 8d12500..3c20888 100644 --- a/lib/CCTools/src/CCTools.cpp +++ b/lib/CCTools/src/CCTools.cpp @@ -60,17 +60,17 @@ bool CommandInterface::_wait_for_ack(unsigned long timeout = 1) uint8_t received = _stream.read(); if (received == ACK_BYTE) { - // Serial.println("ACK received"); + // DEBUG_PRINTLN("ACK received"); return true; } else if (received == NACK_BYTE) { - // Serial.println("NACK received"); + // DEBUG_PRINTLN("NACK received"); return false; } } } - Serial.println("Timeout waiting for ACK/NACK"); + DEBUG_PRINTLN("Timeout waiting for ACK/NACK"); return false; } @@ -119,7 +119,7 @@ uint32_t CommandInterface::_cmdGetChipId() { // 4 byte answ, the 2 LSB hold chip ID byte *version = _receivePacket(); - // Serial.println("size " + String(sizeof(version))); + // DEBUG_PRINTLN("size " + String(sizeof(version))); if (_checkLastCmd()) { @@ -128,12 +128,12 @@ uint32_t CommandInterface::_cmdGetChipId() value |= uint32_t(version[2]) << 8; value |= uint32_t(version[1]) << 16; value |= uint32_t(version[0]) << 24; // Most significant byte - // Serial.print("ChipId "); - // Serial.println(value, HEX); + // DEBUG_PRINT("ChipId "); + // DEBUG_PRINTLN(value, HEX); if (sizeof(version) != 4) { - Serial.println("Unreasonable chip. Looks upper"); // repr(version) ? + DEBUG_PRINTLN("Unreasonable chip. Looks upper"); // repr(version) ? return uint32_t(0); } @@ -160,7 +160,7 @@ byte *CommandInterface::_cmdGetStatus() byte *stat = _receivePacket(); return stat; } - Serial.print("Error _cmdGetStatus"); + DEBUG_PRINT("Error _cmdGetStatus"); return nullptr; } @@ -170,15 +170,15 @@ bool CommandInterface::_checkLastCmd() byte *stat = _cmdGetStatus(); if (stat == nullptr) { - Serial.println("No response from target on status request."); - Serial.println("(Did you disable the bootloader?)"); + DEBUG_PRINTLN("No response from target on status request."); + DEBUG_PRINTLN("(Did you disable the bootloader?)"); return 0; } else { if (stat[0] == COMMAND_RET_SUCCESS) { - // Serial.println("Command Successful"); + // DEBUG_PRINTLN("Command Successful"); return 1; } else @@ -186,11 +186,11 @@ bool CommandInterface::_checkLastCmd() const char *stat_str = _getStatusString(stat[0]); if (stat_str == "Unknown") { - Serial.println("Warning: unrecognized status returned 0x" + String(stat[0])); + DEBUG_PRINTLN("Warning: unrecognized status returned 0x" + String(stat[0])); } else { - Serial.println("Target returned: 0x" + String(stat[0]) + " " + String(stat_str)); + DEBUG_PRINTLN("Target returned: 0x" + String(stat[0]) + " " + String(stat_str)); } return 0; } @@ -241,9 +241,9 @@ bool CommandInterface::_cmdDownload(uint32_t address, unsigned long size) if (size % 4 != 0) { // If size is not a multiple of 4, handle the error - Serial.print("Invalid data size: "); - Serial.print(size); - Serial.println(". Size must be a multiple of 4."); + DEBUG_PRINT("Invalid data size: "); + DEBUG_PRINT(size); + DEBUG_PRINTLN(". Size must be a multiple of 4."); return false; } @@ -265,7 +265,7 @@ bool CommandInterface::_cmdDownload(uint32_t address, unsigned long size) _stream.write(sizeBytes[2]); // # send size _stream.write(sizeBytes[3]); // # send size - // Serial.println("*** Mem Read (0x2A)"); + // DEBUG_PRINTLN("*** Mem Read (0x2A)"); if (_wait_for_ack()) { byte *data = _receivePacket(); @@ -285,9 +285,9 @@ bool CommandInterface::_cmdSendData(byte *data, unsigned int dataSize) // Check if data size exceeds maximum limit if (dataSize > maxDataSize) { - Serial.print("Data size too large: "); - Serial.print(dataSize); - Serial.println(". Maximum size allowed is 252 bytes."); + DEBUG_PRINT("Data size too large: "); + DEBUG_PRINT(dataSize); + DEBUG_PRINTLN(". Maximum size allowed is 252 bytes."); return false; } @@ -310,7 +310,7 @@ bool CommandInterface::_cmdSendData(byte *data, unsigned int dataSize) } // Optionally print debug information to the serial monitor - // Serial.println("*** Send Data (0x24)"); + // DEBUG_PRINTLN("*** Send Data (0x24)"); // Assume _wait_for_ack() and _checkLastCmd() are implemented similarly to your previous method if (_wait_for_ack()) @@ -348,7 +348,7 @@ byte *CommandInterface::_cmdMemRead(uint32_t address) _stream.write(1); // # send width, 4 bytes _stream.write(1); // # send number of reads - // Serial.println("*** Mem Read (0x2A)"); + // DEBUG_PRINTLN("*** Mem Read (0x2A)"); if (_wait_for_ack()) { byte *data = _receivePacket(); @@ -379,10 +379,10 @@ byte *CommandInterface::_receivePacket() return nullptr; } - // Debugging output, might use Serial.print in Arduino - // Serial.print(F("*** received ")); - // Serial.print(size, HEX); - // Serial.println(F(" bytes")); + // Debugging output, might use DEBUG_PRINT in Arduino + // DEBUG_PRINT(F("*** received ")); + // DEBUG_PRINT(size, HEX); + // DEBUG_PRINTLN(F(" bytes")); // Calculate checksum byte calculatedChks = 0; @@ -475,7 +475,7 @@ bool CommandInterface::_ledToggle(bool ledState) bool CommandInterface::_nvram_osal_delete(uint16_t nvid) { // DEBUG_PRINT("Checking OsalNvIds ID: "); - // Serial.print(nvid, HEX); + // DEBUG_PRINT(nvid, HEX); // DEBUG_PRINT(" - "); const uint8_t cmd1 = 0x21; @@ -504,21 +504,21 @@ bool CommandInterface::_nvram_osal_delete(uint16_t nvid) _stream.flush(); - // Serial.println(""); - // Serial.println("> " + String(cmd1, HEX) + " " + String(cmd2, HEX) + " " + String(lowByte, HEX) + " " + String(highByte, HEX) + " " + String(fcs, HEX)); + // DEBUG_PRINTLN(""); + // DEBUG_PRINTLN("> " + String(cmd1, HEX) + " " + String(cmd2, HEX) + " " + String(lowByte, HEX) + " " + String(highByte, HEX) + " " + String(fcs, HEX)); std::unique_ptr data(_receive_SRSP()); if (!data) { return false; } - // Serial.println("< " + String(data[0], HEX) + " " + String(data[1], HEX) + " " + String(data[2], HEX) + " " + String(data[3], HEX) + " " + String(data[4], HEX)); + // DEBUG_PRINTLN("< " + String(data[0], HEX) + " " + String(data[1], HEX) + " " + String(data[2], HEX) + " " + String(data[3], HEX) + " " + String(data[4], HEX)); if (data[2] > 0 || data[3] > 0) { /* DEBUG_PRINT("* Deleting OsalNvIds ID: "); - Serial.print(nvid, HEX); + DEBUG_PRINT(nvid, HEX); DEBUG_PRINT(" - "); */ @@ -547,15 +547,15 @@ bool CommandInterface::_nvram_osal_delete(uint16_t nvid) _stream.flush(); - // Serial.println(""); - // Serial.println("> " + String(cmd1, HEX) + " " + String(cmd2, HEX) + " " + String(lowByte, HEX) + " " + String(highByte, HEX) + " " + String(data[2], HEX) + " " + String(data[3], HEX) + " " + String(fcs, HEX)); + // DEBUG_PRINTLN(""); + // DEBUG_PRINTLN("> " + String(cmd1, HEX) + " " + String(cmd2, HEX) + " " + String(lowByte, HEX) + " " + String(highByte, HEX) + " " + String(data[2], HEX) + " " + String(data[3], HEX) + " " + String(fcs, HEX)); std::unique_ptr data(_receive_SRSP()); if (!data) { return false; } - // Serial.println("< " + String(data[0], HEX) + " " + String(data[1], HEX) + " " + String(data[2], HEX) + " " + String(data[3], HEX)); + // DEBUG_PRINTLN("< " + String(data[0], HEX) + " " + String(data[1], HEX) + " " + String(data[2], HEX) + " " + String(data[3], HEX)); } return true; } @@ -565,9 +565,9 @@ bool CommandInterface::_nvram_ex_delete(uint16_t nvid, uint16_t subID) /* DEBUG_PRINT("Deleting ExNvIds sub ID: "); - Serial.print(nvid, HEX); + DEBUG_PRINT(nvid, HEX); DEBUG_PRINT(" "); - Serial.print(subID, HEX); + DEBUG_PRINT(subID, HEX); DEBUG_PRINT(" - "); */ const uint8_t cmd1 = 0x21; @@ -611,7 +611,7 @@ bool CommandInterface::_nvram_ex_delete(uint16_t nvid, uint16_t subID) { return false; } - // Serial.println(String(data[2], HEX)); + // DEBUG_PRINTLN(String(data[2], HEX)); if (data[2] == 0x0A) { // error @@ -735,10 +735,10 @@ bool CCTools::detectChipInfo() uint32_t chip_id = _cmdGetChipId(); - // Serial.println(chip_id, HEX); + // DEBUG_PRINTLN(chip_id, HEX); byte *device_id = _cmdMemRead(ICEPICK_DEVICE_ID); - // Serial.println(sizeof(device_id)); + // DEBUG_PRINTLN(sizeof(device_id)); uint32_t wafer_id = (((device_id[3] & 0x0F) << 16) + (device_id[2] << 8) + @@ -748,33 +748,33 @@ bool CCTools::detectChipInfo() // We can now detect the exact device - // Serial.print("wafer_id: "); - // Serial.println(wafer_id, HEX); - // Serial.print("pg_rev: "); - // Serial.println(pg_rev, HEX); + // DEBUG_PRINT("wafer_id: "); + // DEBUG_PRINTLN(wafer_id, HEX); + // DEBUG_PRINT("pg_rev: "); + // DEBUG_PRINTLN(pg_rev, HEX); byte *user_id = _cmdMemRead(FCFG_USER_ID); - // Serial.println("Package: " + _getPackageString(user_id[2])); + // DEBUG_PRINTLN("Package: " + _getPackageString(user_id[2])); byte protocols = user_id[1] >> 4; - // Serial.print("protocols: "); - // Serial.println(protocols, HEX); + // DEBUG_PRINT("protocols: "); + // DEBUG_PRINTLN(protocols, HEX); byte *flash_size = _cmdMemRead(FLASH_SIZE); - // Serial.print("flash_size: "); - // Serial.println(flash_size[0], HEX); + // DEBUG_PRINT("flash_size: "); + // DEBUG_PRINTLN(flash_size[0], HEX); // byte *ram_size = _cmdMemRead(PRCM_RAMHWOPT); - // Serial.print("ram_size: "); - // Serial.println(ram_size[0], HEX); + // DEBUG_PRINT("ram_size: "); + // DEBUG_PRINTLN(ram_size[0], HEX); byte *ieee_b1 = _cmdMemRead(addr_ieee_address_primary + 4); byte *ieee_b2 = _cmdMemRead(addr_ieee_address_primary); if (ieee_b1 == nullptr || ieee_b2 == nullptr) { - Serial.println("Error read IEEE"); + DEBUG_PRINTLN("Error read IEEE"); return false; } @@ -799,7 +799,7 @@ bool CCTools::detectChipInfo() if (protocols & PROTO_MASK_IEEE == PROTO_MASK_IEEE) { uint32_t test = 360372; - // Serial.print(test, HEX); + // DEBUG_PRINT(test, HEX); byte *b_val = _cmdMemRead(test); chip.hwRev = _getChipDescription(chip_id, wafer_id, pg_rev, b_val[1]); @@ -811,22 +811,16 @@ bool CCTools::detectChipInfo() chip.flashSize = flash_size[0] * page_size; test = chip.flashSize - 88 + 0xC; - Serial.print(test, HEX); + //DEBUG_PRINT(test, HEX); b_val = _cmdMemRead(test); - Serial.print(" MODE_CONF: "); - Serial.print(b_val[0], HEX); - Serial.print(b_val[1], HEX); - Serial.print(b_val[2], HEX); - Serial.println(b_val[3], HEX); + + chip.modeCfg = _decodeAddr(b_val[3], b_val[2], b_val[1], b_val[0]); uint32_t bsl_adr = chip.flashSize - 88 + 0x30; - Serial.print(bsl_adr, HEX); + //DEBUG_PRINT(bsl_adr, HEX); byte *bsl_val = _cmdMemRead(bsl_adr); - Serial.print(" bsl_val: "); - Serial.print(bsl_val[0], HEX); - Serial.print(bsl_val[1], HEX); - Serial.print(bsl_val[2], HEX); - Serial.println(bsl_val[3], HEX); + + chip.bslCfg = _decodeAddr(bsl_val[3], bsl_val[2], bsl_val[1], bsl_val[0]); return true; } diff --git a/lib/CCTools/src/CCTools.h b/lib/CCTools/src/CCTools.h index 0e139f7..375730f 100644 --- a/lib/CCTools/src/CCTools.h +++ b/lib/CCTools/src/CCTools.h @@ -416,6 +416,8 @@ class CommandInterface uint8_t majorrel; uint8_t product; uint8_t transportrev; + unsigned long modeCfg; + unsigned long bslCfg; }; static const uint8_t ACK_BYTE = 0xCC; From 9341f53c6e013fd35e8e42249b84cf1313eb84e4 Mon Sep 17 00:00:00 2001 From: xyzroe Date: Wed, 29 May 2024 02:01:27 +0200 Subject: [PATCH 2/5] CCTools v0.0.6 --- lib/CCTools/src/CCTools.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/CCTools/src/CCTools.cpp b/lib/CCTools/src/CCTools.cpp index 3c20888..d250535 100644 --- a/lib/CCTools/src/CCTools.cpp +++ b/lib/CCTools/src/CCTools.cpp @@ -649,7 +649,7 @@ CommandInterface::zbInfoStruct CommandInterface::_checkFwVer() chip.transportrev = zbVerBuf[0]; _cleanBuffer(); - DEBUG_PRINTLN("ZB v: " + String(chip.fwRev) + " Main: " + chip.maintrel + " Min: " + chip.minorrel + " Maj: " + chip.majorrel + " T: " + chip.transportrev + " P: " + chip.product); + // DEBUG_PRINTLN("ZB v: " + String(chip.fwRev) + " Main: " + chip.maintrel + " Min: " + chip.minorrel + " Maj: " + chip.majorrel + " T: " + chip.transportrev + " P: " + chip.product); return chip; } From cf93aab7e68c4f0a16f46adb0b4096b78556610f Mon Sep 17 00:00:00 2001 From: xyzroe Date: Wed, 29 May 2024 02:20:56 +0200 Subject: [PATCH 3/5] Faster Zigbee flashing --- src/zb.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/zb.cpp b/src/zb.cpp index f2df539..8dd4998 100644 --- a/src/zb.cpp +++ b/src/zb.cpp @@ -36,36 +36,35 @@ extern CCTools CCTool; bool zbFwCheck() { - if (CCTool.checkFirmwareVersion()) + const int maxAttempts = 3; + for (int attempt = 0; attempt < maxAttempts; attempt++) { - printLogMsg(tag_ZB + " fw: " + String(CCTool.chip.fwRev)); - return true; - } - else - { - delay(250); if (CCTool.checkFirmwareVersion()) { printLogMsg(tag_ZB + " fw: " + String(CCTool.chip.fwRev)); return true; } else - { - printLogMsg(tag_ZB + " fw: unknown!"); - return false; + { + CCTool.restart(); + LOGD("Try: %d", attempt); + delay(250); } } + printLogMsg(tag_ZB + " fw: unknown!"); + return false; } void zbHwCheck() { - int BSL_PIN_MODE = 0; ledControl.modeLED.mode = LED_BLINK_1Hz; if (CCTool.detectChipInfo()) { printLogMsg(tag_ZB + " Chip: " + CCTool.chip.hwRev); printLogMsg(tag_ZB + " IEEE: " + CCTool.chip.ieee); + LOGI("modeCfg %s", String((CCTool.chip.modeCfg), HEX)); + LOGI("bslCfg %s", String((CCTool.chip.bslCfg), HEX)); printLogMsg(tag_ZB + " Flash size: " + String(CCTool.chip.flashSize / 1024) + " KB"); vars.hwZigbeeIs = true; @@ -135,7 +134,7 @@ void zbEraseNV(void *pvParameters) void flashZbUrl(String url) { - + Serial2.updateBaudRate(460800); float last_percent = 0; const char *tagZB_FW_info = "ZB_FW_info"; @@ -184,6 +183,7 @@ void flashZbUrl(String url) printLogMsg("Failed to flash Zigbee"); sendEvent(tagZB_FW_err, eventLen, String("Failed!")); } + Serial2.updateBaudRate(systemCfg.serialSpeed); } void printBufferAsHex(const byte *buffer, size_t length) From ffee52c5ef4a960f9df2dece4287d4242505639c Mon Sep 17 00:00:00 2001 From: luisetex84 Date: Wed, 29 May 2024 10:35:41 +0200 Subject: [PATCH 4/5] Update es.json Correct some translations --- src/websrc/json/es.json | 151 ++++++++++++++++++++-------------------- 1 file changed, 74 insertions(+), 77 deletions(-) diff --git a/src/websrc/json/es.json b/src/websrc/json/es.json index 47ee878..981e1b9 100644 --- a/src/websrc/json/es.json +++ b/src/websrc/json/es.json @@ -5,10 +5,10 @@ "conn": "Conectado", "csp": "Velocidad de conexión", "cst": "Estado de conexión", - "drm": "no recordar", + "drm": "No recordar", "enable": "Permitir", - "ercn": "Error. \nRevisa tu red", - "erss": "Error al guardar la configuración. \nRevisa tu red", + "ercn": "Error. Revisa tu red", + "erss": "Error al guardar la configuración. Revisa tu red", "host": "Nombre de host", "init": "Inicializado", "inst": "Instalar", @@ -18,22 +18,22 @@ "now": "Instalar ahora", "pass": "Contraseña", "proj": "Creado con ❤️ por", - "save": "Ahorrar", - "sure": "Estoy seguro de que", + "save": "Guardar", + "sure": "Estoy seguro", "user": "Nombre de usuario", - "ok": "DE ACUERDO", + "ok": "De acuerdo", "connecting": "Conectando", "dis": "Desactivado", "disconn": "Desconectado", "en": "Activado", "err": "Error", "nc": "Sin conexión", - "cl": "Cerca", + "cl": "Cerrar", "t": { "e": "Hora de finalización", "s": "Hora de inicio" }, - "cerp": "Se alcanzó el número máximo de reintentos de reconexión de eventos. \nActualiza la página para continuar." + "cerp": "Se alcanzó el número máximo de reintentos de reconexión de eventos. Actualiza la página para continuar." }, "md": { "esp": { @@ -50,15 +50,15 @@ "lgds": "Descargando la última versión de GitHub...", "prgs": "Actualización: {{per}}%", "tt": "ACTUALIZACIÓN DEL FIRMWARE XZG", - "ucr": "¡Actualizacion completa! \n¡Reiniciando!", + "ucr": "¡Actualizacion completa! ¡Reiniciando!", "vgds": "Descargando la versión {{ver}} de GitHub...", - "wdm": "Esperando por el dispositivo...", - "wm": "Desconectará TODAS las conexiones del enchufe.", - "bil": "Instalar lo último" + "wdm": "Esperando al dispositivo...", + "wm": "Desconectará TODAS las conexiones del socket.", + "bil": "Instalar última versión" }, "rst": { - "msg": "Esperando reinicio. \nSe cerrará automáticamente.", - "nrps": "Ninguna respuesta; \ncompruebe si el modo IP o USB cambió.", + "msg": "Esperando reinicio. Se cerrará automáticamente.", + "nrps": "Ninguna respuesta; compruebe si el modo IP o USB cambió.", "tt": "REINICIAR EL DIPOSITIVO" }, "ws": { @@ -66,13 +66,13 @@ "err": "Error de conexión, verifique SSID, CONTRASEÑA y vuelva a intentarlo", "msg": "Conectándose a la red en curso... Espere el resultado.", "nip": "La nueva dirección IP es {{ip}} El dispositivo ahora se reiniciará para que la nueva configuración surta efecto.", - "tt": "Conexión de red wifi" + "tt": "Conexión de red Wifi" } }, "zb": { "fu": { "vc": "¡Validación completa!", - "vt": "validar: {{per}} %" + "vt": "validación: {{per}} %" }, "cfv": "Su revisión de firmware actual: {{ver}}", "dtc": "Coordinador", @@ -84,11 +84,11 @@ "nrf": "No hay firmware del enrutador disponible.", "ot": "Actualización Zigbee OTA", "rfm": "Obteniendo información del firmware...", - "dtt": "hilo abierto", + "dtt": "OpenThread", "ntf": "Falta el firmware de Thread." }, "kw": { - "msg": "Esta función le permite dejar activo uno de los canales de comunicación y tener acceso a la interfaz web. \nEl propio dispositivo seleccionará un canal disponible según la prioridad: WIFI, ETHERNET, WIFI AP" + "msg": "Esta función le permite dejar activo uno de los canales de comunicación y tener acceso a la interfaz web. El propio dispositivo seleccionará un canal disponible según la prioridad: WIFI, ETHERNET, WIFI AP" }, "ss": { "msg": "Nuevos parámetros guardados.", @@ -97,16 +97,13 @@ "rr": "Algunas configuraciones requieren un reinicio.", "tt": "AJUSTES GUARDADOS" }, - "zgb": { - "fu": {} - }, "zg": { "fu": { "f": "Va a flashear: {{archivo}}", - "fn": "¡Flasheado exitosamente!", + "fn": "¡El firmware se ha instalado con éxito!", "nv": "Nueva versión: {{ver}}", - "st": "CC2652 flash iniciando...", - "er": "Borrar terminado" + "st": "Iniciando CC2652 flash...", + "er": "Borrado terminado" } } }, @@ -130,19 +127,19 @@ "ph": "Acceda al dispositivo a través de la red usando este nombre.local", "tt": "Letras y números latinos, sin espacios." }, - "kw": "Mantener la red", + "kw": "Mantener la red y servidor web", "led": { "desc": "Configuración de LED", "dis": "Desactivación total", "mode": "LED de modo de trabajo", - "night": "Modo nocturno: control de LED basado en el tiempo", - "pwr": "LED de encendido" + "night": "Modo nocturno - control de LED basado en la hora", + "pwr": "LED de alimentación" }, "ntp": { - "desc": "configuración NTP", + "desc": "Configuración NTP", "server": { - "n": "servidor NTP", - "ph": "piscina.ntp.org", + "n": "Servidor NTP", + "ph": "pool.ntp.org", "tt": "Introduzca un nombre de dominio válido" }, "zone": "Zona horaria" @@ -156,21 +153,21 @@ "mode": { "desc": "Seleccione el modo de funcionamiento del dispositivo", "net": "Modo de red", - "usb": "modo USB" + "usb": "Modo USB" } } }, "lo": { - "btn": "cantar", + "btn": "Iniciar sesión", "lbl": "Por favor, registrese", "pt": "Iniciar sesión - XZG", - "mlo": "Cerrado exitosamente", - "mnl": "Necesito iniciar sesión", + "mlo": "Cerrada sesión con éxito", + "mnl": "Es necesario iniciar sesión", "mwc": "Credenciales incorrectas" }, "mq": { "broker": { - "n": "Corredor", + "n": "Broker", "ph": "Nombre de dominio o dirección IP", "tt": "Ingrese un dominio o IP válido" }, @@ -187,8 +184,8 @@ "tt": "Ingrese la frecuencia con la que enviar actualizaciones (en segundos)" }, "pass": { - "ph": "contraseña MQTT", - "tt": "Ingrese la contraseña de su corredor" + "ph": "Contraseña MQTT", + "tt": "Ingrese la contraseña de su broker" }, "port": { "n": "Puerto", @@ -201,33 +198,33 @@ "tt": "Ingrese el tema MQTT del dispositivo X/Y/Z o X/Y o X. Sin espacios." }, "user": { - "ph": "nombre de usuario MQTT", - "tt": "Ingrese el nombre de usuario de su corredor" + "ph": "Nombre de usuario MQTT", + "tt": "Ingrese el nombre de usuario de su broker" }, "reconnect": { "n": "Reconectar", "ph": "Intervalo de reconexión en segundos", - "tt": "Ingrese un intento rápido para volver a conectarse al corredor (en segundos)" + "tt": "Ingrese un intento rápido para volver a conectarse al broker (en segundos)" } }, "ne": { "descEth": "Configuración de Ethernet", - "descWifi": "configuración wifi", + "descWifi": "Configuración Wifi", "dhcp": "DHCP", - "dns": "servidor DNS", - "gw": "Puerta", + "dns": "Servidor DNS", + "gw": "Puerta de enlace", "ip": "IP", - "mask": "Mascarilla", + "mask": "Máscara de red", "wifi": { "btn": { "man": "Ingresar manualmente", - "scan": "Buscar redes Wi-Fi" + "scan": "Buscar redes Wifi" }, "ch": "Canal", "rssi": "RSSI", "sc": "Seguridad", "ssid": "SSID", - "nnf": "Redes WiFi no encontradas" + "nnf": "Redes Wifi no encontradas" } }, "st": { @@ -236,16 +233,16 @@ "dm": "Modelo de dispositivo", "ef": "Procesador", "efs": "Memoria", - "ehs": "Montón", + "ehs": "Pila", "et": "Temperatura", "kb": "Kib", - "mb": "megabyte", - "mhz": "megahercio", + "mb": "Mb", + "mhz": "MHz", "tt": "Información del dispositivo", "efte": "externo", "efti": "interno", "efss": "Sistema de archivos", - "ens": "almacenamiento NV", + "ens": "Almacenamiento NV", "ent": "entradas", "du": "Tiempo de actividad del dispositivo", "lt": "Hora local" @@ -255,10 +252,10 @@ "tvh": "Husarnet", "tw": "Wifi", "wgc": { - "ed": "Dirección de punto final", + "ed": "Dirección del endpoint", "lip": "Dirección IP local", - "pip": "Dirección IP del mismo nivel", - "tt": "AlambreGuardia" + "pip": "Dirección IP del peer", + "tt": "WireGuard" }, "wc": { "map": "AP", @@ -266,12 +263,12 @@ }, "zbc": { "tt": "Estado del dispositivo", - "op": "Modo operacional", + "op": "Modo de operación", "opn": "Red Zigbee", "opu": "Zigbee-USB", "scc": "Cliente de socket conectado", "sccn": "Sin conexión", - "su": "Tiempo de conección", + "su": "Tiempo de conexión", "sccy": "Sí, {{count}} clientes", "zie": "IEEE", "zfs": "Tamaño del flash" @@ -293,7 +290,7 @@ } }, "to": { - "cc": "Consola limpia", + "cc": "Limpiar consola", "cf": "Elija el archivo...", "csc": "Control de periféricos", "czc": "Verifique la conexión Zigbee", @@ -304,24 +301,24 @@ "egu": "Actualización de Git ESP32", "esp": "ESP32", "fb": "Explorador de archivos", - "fm": "Modo destello", + "fm": "Modo flash", "fn": "Nombre del archivo", "fr": "Restablecimiento de fábrica", "fu": "Actualización de firmware", - "ilfg": "Instalar lo último", - "lb": "parpadeo...", - "ls": "a partir de...", - "lt": "Los LED alternan", + "ilfg": "Instalar última versión", + "lb": "parpadeando...", + "ls": "comenzando...", + "lt": "Conmutar LEDs", "mc": "Control de módulos", "mode": "Modo", "ms": "Seleccionar modo", "ntw": "Red", - "pwr": "Fuerza", + "pwr": "Alimentación", "rd": "Datos sin procesar", "rr": "Reconexión del enrutador", - "rst": "Reanudar", + "rst": "Reiniciar", "s": "Tamaño", - "sc": "Control de sistema", + "sc": "Control del sistema", "usb": "USB", "zb": "Zigbee", "zfu": "Actualización de archivos Zigbee", @@ -340,9 +337,9 @@ "tt": "Configuración de Husarnet (en desarrollo)" }, "wg": { - "ea": "Dirección del par del punto final", - "ep": "Puerto del par del punto final", - "epk": "Clave pública del par del punto final", + "ea": "Dirección del endpoint", + "ep": "Puerto del endpoint", + "epk": "Clave pública del endpoint", "lip": "Dirección IP de la interfaz local", "lpk": "Clave privada de la interfaz local.", "tt": "Configuración de WireGuard", @@ -357,29 +354,29 @@ }, "zi": { "cfg": { - "alarm": "Parece que XZG funciona en modo punto de acceso (IP 192.168.1.1). \nLa dirección IP cambiará después de conectarse a Ethernet o Wi-Fi; luego, la configuración deberá generarse nuevamente.", - "dp": "INSERT_DEVICE_PATCH_HERE", + "alarm": "Parece que XZG funciona en modo punto de acceso (IP 192.168.1.1). La dirección IP cambiará después de conectarse a Ethernet o Wi-Fi; luego, la configuración deberá generarse nuevamente.", + "dp": "INSERTE_PATCH_DEL_DISPOSITIVO_AQUI", "dzl": "¿Desactivar el LED Zigbee?", "ha": "Para Home Assistant: Vaya a \"Configuración\" → \"Sistema\" → \"Hardware\" → Seleccione el menú de 3 puntos en la esquina superior derecha → \"Todo el hardware\" → Desplácese hasta ttyUSB y busque su adaptador → Copiar ruta del dispositivo como \"/dev/ \nttyUSB0\"", "lin": "Listar dispositivos USB en Linux: ls /dev/ttyUSB*", "lxzg": "Ubicación de XZG", "sel": "Generar configuración para", "sopm": "Establezca la potencia de salida al máximo 20", - "ss": "Configuración en serie", + "ss": "Configuración por puerto serie", "tt": "Generador de configuración" }, - "so": "Configuración en serie", - "sp": "Puerto de enchufe", - "ss": "Velocidad del zócalo", + "so": "Configuración por puerto serie", + "sp": "Puerto del socket", + "ss": "Velocidad del socket", "fws": { - "alarm": "¡Cambiar el firmware en una red en funcionamiento provoca que la red se averíe!", - "tt": "Role" + "alarm": "¡Cambiar el firmware en una red en funcionamiento provoca que la red se rompa!", + "tt": "Rol" } }, "ab": { "c": { "l": "Repositorio de proyectos", - "m": "Únase a nosotros para mejorar la traducción, mejorar la documentación o codificar nuevas funciones. \n💻", + "m": "Únase a nosotros para mejorar la traducción, mejorar la documentación o codificar nuevas funciones. 💻", "t": "Contribuir" }, "cm": { @@ -415,7 +412,7 @@ "ts": { "esp": { "ane": { - "msg": "No hay interfaces de red habilitadas. \nActive al menos una interfaz para continuar.", + "msg": "No hay interfaces de red habilitadas. Active al menos una interfaz para continuar.", "tt": "Error de configuración de red" }, "beta": { From a56604088e0b2188a1e1e926bb3205e54ce6b00e Mon Sep 17 00:00:00 2001 From: xyzroe Date: Wed, 29 May 2024 18:32:17 +0200 Subject: [PATCH 5/5] 20240529 - Add support **USB mode for ALL boards** - Move device mode selection to Zigbee page - Increase Zigbee firmware flashing speed (115200 vs 460800) - Improve Zigbee FW detection mechanism, fix #47 - Remove configSys.keepWeb - network is always active - Remove vars.hwUartSelIs - no need to check - Add DNS check logs to web console, could help with #11, #24, #42, #43 - Add cod.m CZC-v1.0 config to boards list (but cause it's the same as UZG-01 ones, it has no sense right now) - Some code cleanup, and of course a lot of new garbage :) --- src/config.cpp | 28 ++++++---- src/config.h | 20 ++++++-- src/const/hw.cpp | 3 +- src/const/hw.h | 2 +- src/const/keys.cpp | 4 +- src/etc.cpp | 67 +++++++++++++----------- src/main.cpp | 85 +++++++++++++++++++------------ src/version.h | 2 +- src/web.cpp | 21 ++++++-- src/websrc/html/PAGE_GENERAL.html | 4 +- src/websrc/html/PAGE_ZIGBEE.html | 11 ++++ src/websrc/js/functions.js | 22 ++++---- src/zb.cpp | 9 ++-- 13 files changed, 175 insertions(+), 103 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index 7d700ab..9fc07bd 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -23,8 +23,6 @@ extern struct NetworkConfigStruct networkCfg; extern struct VpnConfigStruct vpnCfg; extern struct MqttConfigStruct mqttCfg; -String tag = "NVS"; - void getNvsStats(int *total, int *used) { nvs_stats_t nvsStats; @@ -262,7 +260,7 @@ void saveSystemConfig(const SystemConfigStruct &config) { preferences.begin(systemConfigKey, false); - preferences.putBool(keepWebKey, config.keepWeb); + //preferences.putBool(keepWebKey, config.keepWeb); preferences.putBool(disableWebKey, config.disableWeb); preferences.putBool(webAuthKey, config.webAuth); preferences.putString(webUserKey, config.webUser); @@ -292,7 +290,7 @@ void loadSystemConfig(SystemConfigStruct &config) { preferences.begin(systemConfigKey, true); - config.keepWeb = preferences.getBool(keepWebKey, true); + //config.keepWeb = preferences.getBool(keepWebKey, true); config.disableWeb = preferences.getBool(disableWebKey, false); config.webAuth = preferences.getBool(webAuthKey, false); strlcpy(config.webUser, preferences.getString(webUserKey, "").c_str(), sizeof(config.webUser)); @@ -348,7 +346,7 @@ void updateConfiguration(WebServer &serverWeb, SystemConfigStruct &configSys, Ne { case API_PAGE_GENERAL: { - if (serverWeb.hasArg(coordMode)) + /*if (serverWeb.hasArg(coordMode)) { const uint8_t mode = serverWeb.arg(coordMode).toInt(); if (mode <= 2 && mode >= 0) @@ -360,7 +358,7 @@ void updateConfiguration(WebServer &serverWeb, SystemConfigStruct &configSys, Ne } } - configSys.keepWeb = serverWeb.hasArg(keepWebKey) == true; + configSys.keepWeb = serverWeb.hasArg(keepWebKey) == true;*/ configSys.disableLedPwr = serverWeb.hasArg(disableLedPwrKey) == true; @@ -507,13 +505,22 @@ void updateConfiguration(WebServer &serverWeb, SystemConfigStruct &configSys, Ne break; case API_PAGE_ZIGBEE: { + if (serverWeb.hasArg(coordMode)) + { + const uint8_t mode = serverWeb.arg(coordMode).toInt(); + if (mode <= 2 && mode >= 0) + { + configSys.workMode = static_cast(mode); + } + } + const char *baud = "baud"; if (serverWeb.hasArg(baud)) { configSys.serialSpeed = serverWeb.arg(baud).toInt(); } - if (serverWeb.hasArg(baud)) + if (serverWeb.hasArg(portKey)) { configSys.socketPort = serverWeb.arg(portKey).toInt(); } @@ -754,7 +761,7 @@ void serializeMqttConfigToJson(const MqttConfigStruct &config, JsonObject obj) // Serialization SystemConfigStruct into JSON void serializeSystemConfigToJson(const SystemConfigStruct &config, JsonObject obj) { - obj[keepWebKey] = config.keepWeb; + //obj[keepWebKey] = config.keepWeb; obj[disableWebKey] = config.disableWeb; obj[webAuthKey] = config.webAuth; obj[webUserKey] = config.webUser; @@ -784,7 +791,7 @@ void serializeSysVarsToJson(const SysVarsStruct &vars, JsonObject obj) obj[hwBtnIsKey] = vars.hwBtnIs; obj[hwLedUsbIsKey] = vars.hwLedUsbIs; obj[hwLedPwrIsKey] = vars.hwLedPwrIs; - obj[hwUartSelIsKey] = vars.hwUartSelIs; + //obj[hwUartSelIsKey] = vars.hwUartSelIs; obj[hwZigbeeIsKey] = vars.hwZigbeeIs; obj[connectedClientsKey] = vars.connectedClients; @@ -812,7 +819,6 @@ void serializeSysVarsToJson(const SysVarsStruct &vars, JsonObject obj) bool loadFileConfigHW() { - String tag = "HW"; const char *board = "board"; const char *addr = "addr"; const char *pwrPin = "pwrPin"; @@ -1091,7 +1097,7 @@ bool loadFileConfigGeneral() systemCfg.disableLedPwr = (uint8_t)doc[disableLedPwrKey]; systemCfg.disableLedUSB = (uint8_t)doc[disableLedUSBKey]; vars.disableLeds = (uint8_t)doc[disableLedsKey]; - systemCfg.keepWeb = (uint8_t)doc[keepWebKey]; + //systemCfg.keepWeb = (uint8_t)doc[keepWebKey]; strlcpy(systemCfg.timeZone, doc[timeZoneKey] | NTP_TIME_ZONE, sizeof(systemCfg.timeZone)); configFile.close(); diff --git a/src/config.h b/src/config.h index a7a8cb5..64ae536 100644 --- a/src/config.h +++ b/src/config.h @@ -66,7 +66,7 @@ struct SysVarsStruct bool hwBtnIs = false; bool hwLedUsbIs = false; bool hwLedPwrIs = false; - bool hwUartSelIs = false; + //bool hwUartSelIs = false; bool hwZigbeeIs = false; bool connectedSocket[MAX_SOCKET_CLIENTS]; //[10] @@ -175,7 +175,7 @@ void loadMqttConfig(MqttConfigStruct &config); struct SystemConfigStruct { - bool keepWeb; // when usb mode active + //bool keepWeb; // when usb mode active bool disableWeb; // when socket connected bool webAuth; @@ -297,23 +297,33 @@ uint8_t temprature_sens_read(); // Conditional logging macros #if CURRENT_LOG_LEVEL >= LOG_LEVEL_WARN -#define LOGW(format, ...) Serial.printf(ANSI_COLOR_PURPLE "%d " ANSI_COLOR_RESET ANSI_COLOR_RED "[%s] " ANSI_COLOR_RESET format "\n", millis(), __func__, ##__VA_ARGS__) +#define LOGW(format, ...) \ + if (systemCfg.workMode == WORK_MODE_NETWORK) { \ + Serial.printf(ANSI_COLOR_PURPLE "%d " ANSI_COLOR_RESET ANSI_COLOR_RED "[%s] " ANSI_COLOR_RESET format "\n", millis(), __func__, ##__VA_ARGS__); \ + } #else #define LOGW(format, ...) // Nothing #endif #if CURRENT_LOG_LEVEL >= LOG_LEVEL_INFO -#define LOGI(format, ...) Serial.printf(ANSI_COLOR_PURPLE "%d " ANSI_COLOR_RESET ANSI_COLOR_GREEN "[%s] " ANSI_COLOR_RESET format "\n", millis(), __func__, ##__VA_ARGS__) +#define LOGI(format, ...) \ + if (systemCfg.workMode == WORK_MODE_NETWORK) { \ + Serial.printf(ANSI_COLOR_PURPLE "%d " ANSI_COLOR_RESET ANSI_COLOR_GREEN "[%s] " ANSI_COLOR_RESET format "\n", millis(), __func__, ##__VA_ARGS__); \ + } #else #define LOGI(format, ...) // Nothing #endif #if CURRENT_LOG_LEVEL >= LOG_LEVEL_DEBUG -#define LOGD(format, ...) Serial.printf(ANSI_COLOR_PURPLE "%d " ANSI_COLOR_RESET ANSI_COLOR_YELLOW "[%s] " ANSI_COLOR_RESET format "\n", millis(), __func__, ##__VA_ARGS__) +#define LOGD(format, ...) \ + if (systemCfg.workMode == WORK_MODE_NETWORK) { \ + Serial.printf(ANSI_COLOR_PURPLE "%d " ANSI_COLOR_RESET ANSI_COLOR_YELLOW "[%s] " ANSI_COLOR_RESET format "\n", millis(), __func__, ##__VA_ARGS__); \ + } #else #define LOGD(format, ...) // Nothing #endif + /* ----- Define functions | END -----*/ enum LEDMode diff --git a/src/const/hw.cpp b/src/const/hw.cpp index f47991f..222c16f 100644 --- a/src/const/hw.cpp +++ b/src/const/hw.cpp @@ -43,4 +43,5 @@ BrdConfigStruct brdConfigs[] = { {"TubesZB-poe", .ethConfigIndex = 0, .zbConfigIndex = 5, .mistConfigIndex = 0}, {"TubesZB-poe-2022", .ethConfigIndex = 0, .zbConfigIndex = 6, .mistConfigIndex = 0}, {"TubesZB-poe-2023", .ethConfigIndex = 0, .zbConfigIndex = 7, .mistConfigIndex = 0}, -}; + {"CZC-1.0", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 1}, +}; \ No newline at end of file diff --git a/src/const/hw.h b/src/const/hw.h index 357307b..11da41c 100644 --- a/src/const/hw.h +++ b/src/const/hw.h @@ -46,7 +46,7 @@ struct BrdConfigStruct #define ETH_CFG_CNT 3 #define ZB_CFG_CNT 8 #define MIST_CFG_CNT 3 -#define BOARD_CFG_CNT 13 +#define BOARD_CFG_CNT 14 struct ThisConfigStruct { diff --git a/src/const/keys.cpp b/src/const/keys.cpp index a7d2d4e..4faa6ca 100644 --- a/src/const/keys.cpp +++ b/src/const/keys.cpp @@ -51,7 +51,7 @@ const char *discoveryKey = "discovery"; const char *reconnectIntKey = "reconnectInt"; const char *systemConfigKey = "system-config"; -const char *keepWebKey = "keepWeb"; +//const char *keepWebKey = "keepWeb"; const char *disableWebKey = "disableWeb"; const char *webAuthKey = "webAuth"; const char *webUserKey = "webUser"; @@ -77,7 +77,7 @@ const char *systemVarsKey = "system-vars"; const char *hwBtnIsKey = "hwBtnIs"; const char *hwLedUsbIsKey = "hwLedUsbIs"; const char *hwLedPwrIsKey = "hwLedPwrIs"; -const char *hwUartSelIsKey = "hwUartSelIs"; +//const char *hwUartSelIsKey = "hwUartSelIs"; const char *hwZigbeeIsKey = "hwZigbeeIs"; const char *workModeKey = "workMode"; const char *connectedSocketKey = "connectedSocket"; diff --git a/src/etc.cpp b/src/etc.cpp index c621682..80ad87f 100644 --- a/src/etc.cpp +++ b/src/etc.cpp @@ -178,26 +178,35 @@ void zigbeeRestart() void usbModeSet(usbMode mode) { - if (vars.hwUartSelIs) - { - String modeStr = (mode == ZIGBEE) ? "ZIGBEE" : "ESP"; - bool pinValue = (mode == ZIGBEE) ? HIGH : LOW; - String msg = "Switched USB to " + modeStr + ""; - printLogMsg(msg); - digitalWrite(hwConfig.mist.uartSelPin, pinValue); - if (pinValue) - { - ledControl.modeLED.mode = LED_ON; - } - else - { - ledControl.modeLED.mode = LED_OFF; - } + // if (vars.hwUartSelIs) + //{ + // String modeStr = (mode == ZIGBEE) ? "ZIGBEE" : "ESP"; + bool pinValue = (mode == ZIGBEE) ? HIGH : LOW; + // String msg = "Switched USB to " + modeStr + ""; + // printLogMsg(msg); + + if (mode == ZIGBEE) + { + Serial.updateBaudRate(systemCfg.serialSpeed); + } + else + { + Serial.updateBaudRate(115200); + } + // digitalWrite(hwConfig.mist.uartSelPin, pinValue); + if (pinValue) + { + ledControl.modeLED.mode = LED_ON; } else { - LOGD("NO vars.hwUartSelIs"); + ledControl.modeLED.mode = LED_OFF; } + //} + // else + //{ + // LOGD("NO vars.hwUartSelIs"); + //} } void getDeviceID(char *arr) @@ -387,6 +396,10 @@ void checkDNS(bool setup = false) { const char *wifiKey = "WiFi"; const char *ethKey = "ETH"; + const char *savedKey = "Saved"; + const char *restoredKey = "Restored"; + const char *dnsTagKey = "[DNS]"; + char buffer[100]; if (networkCfg.wifiEnable) { @@ -394,18 +407,16 @@ void checkDNS(bool setup = false) if (setup) { savedWifiDNS = currentWifiDNS; - LOGI("Saved %s DNS - %s", wifiKey, savedWifiDNS.toString().c_str()); + snprintf(buffer, sizeof(buffer), "%s %s %s - %s", dnsTagKey, savedKey, wifiKey, savedWifiDNS.toString().c_str()); + printLogMsg(buffer); } else { if (currentWifiDNS != savedWifiDNS) { WiFi.config(WiFi.localIP(), WiFi.gatewayIP(), WiFi.subnetMask(), savedWifiDNS); - LOGI("Updated %s DNS - %s", wifiKey, savedWifiDNS.toString().c_str()); - } - else - { - //LOGD("No update on %s DNS", wifiKey); + snprintf(buffer, sizeof(buffer), "%s %s %s - %s", dnsTagKey, restoredKey, wifiKey, savedWifiDNS.toString().c_str()); + printLogMsg(buffer); } } } @@ -416,18 +427,16 @@ void checkDNS(bool setup = false) if (setup) { savedEthDNS = currentEthDNS; - LOGI("Saved %s DNS - %s", ethKey, savedEthDNS.toString().c_str()); + snprintf(buffer, sizeof(buffer), "%s %s %s - %s", dnsTagKey, savedKey, ethKey, savedEthDNS.toString().c_str()); + printLogMsg(buffer); } else { if (currentEthDNS != savedEthDNS) { ETH.config(ETH.localIP(), ETH.gatewayIP(), ETH.subnetMask(), savedEthDNS); - LOGI("Updated %s DNS - %s", ethKey, savedEthDNS.toString().c_str()); - } - else - { - //LOGD("No update on %s DNS", ethKey); + snprintf(buffer, sizeof(buffer), "%s %s %s - %s", dnsTagKey, restoredKey, ethKey, savedEthDNS.toString().c_str()); + printLogMsg(buffer); } } } @@ -507,7 +516,7 @@ void setTimezone(String timezone) String timeNow = asctime(&timeinfo); timeNow.remove(timeNow.length() - 1); - printLogMsg("Local time: " + timeNow); + printLogMsg("[Time] " + timeNow); } const char *getGmtOffsetForZone(const char *zone) diff --git a/src/main.cpp b/src/main.cpp index d52724a..74c880c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -382,20 +382,20 @@ void connectWifi() } else { - if (!(systemCfg.workMode == WORK_MODE_USB && systemCfg.keepWeb)) - { // dont start ap in keepWeb - LOGD("NO SSID & PASS "); - if (!vars.connectedEther) - { - LOGD("and problem with LAN"); - startAP(true); - LOGD("so setupWifiAP"); - } - else - { - LOGD("but LAN is OK"); - } + // if (!(systemCfg.workMode == WORK_MODE_USB && systemCfg.keepWeb)) + //{ // dont start ap in keepWeb + LOGD("NO SSID & PASS "); + if (!vars.connectedEther) + { + LOGD("and problem with LAN"); + startAP(true); + LOGD("so setupWifiAP"); } + else + { + LOGD("but LAN is OK"); + } + // } } } @@ -434,37 +434,41 @@ void setupCoordinatorMode() String workModeString = systemCfg.workMode ? "USB" : "Network"; LOGI("%s", workModeString); - if ((systemCfg.workMode != WORK_MODE_USB) || systemCfg.keepWeb) - { // start network overseer - if (tmrNetworkOverseer.state() == STOPPED) - { - tmrNetworkOverseer.start(); - } - WiFi.onEvent(NetworkEvent); - if (networkCfg.ethEnable) - initLan(); - if (networkCfg.wifiEnable) - connectWifi(); + // if ((systemCfg.workMode != WORK_MODE_USB) || systemCfg.keepWeb) + //{ // start network overseer + if (tmrNetworkOverseer.state() == STOPPED) + { + tmrNetworkOverseer.start(); } + WiFi.onEvent(NetworkEvent); + if (networkCfg.ethEnable) + initLan(); + if (networkCfg.wifiEnable) + connectWifi(); + //} switch (systemCfg.workMode) { case WORK_MODE_USB: ledControl.modeLED.mode = LED_ON; - delay(500); + delay(100); usbModeSet(ZIGBEE); break; case WORK_MODE_NETWORK: ledControl.powerLED.mode = LED_BLINK_1Hz; + delay(100); + usbModeSet(XZG); break; default: break; } - if (!systemCfg.disableWeb && ((systemCfg.workMode != WORK_MODE_USB) || systemCfg.keepWeb)) + // if (!systemCfg.disableWeb && ((systemCfg.workMode != WORK_MODE_USB) || systemCfg.keepWeb)) + // updWeb = true; // handle web server + if (!systemCfg.disableWeb) updWeb = true; // handle web server - if (systemCfg.workMode == WORK_MODE_USB && systemCfg.keepWeb) - connectWifi(); // try 2 connect wifi + // if (systemCfg.workMode == WORK_MODE_USB && systemCfg.keepWeb) + // connectWifi(); // try 2 connect wifi } void setup() @@ -528,8 +532,10 @@ void setup() if (hwConfig.mist.uartSelPin > 0) { pinMode(hwConfig.mist.uartSelPin, OUTPUT); - vars.hwUartSelIs = true; - usbModeSet(XZG); + //vars.hwUartSelIs = true; + // usbModeSet(XZG); + bool fixState = (hwConfig.mist.uartSelPlr == 1) ? LOW : HIGH; + digitalWrite(hwConfig.mist.uartSelPin, fixState); } if ((hwConfig.zb.txPin > 0) && (hwConfig.zb.rxPin > 0) && (hwConfig.zb.rstPin > 0) && (hwConfig.zb.bslPin > 0)) @@ -563,7 +569,7 @@ void setup() printNVSFreeSpace(); zbFwCheck(); - + LOGD("done"); } @@ -684,7 +690,22 @@ void loop(void) } } - if (systemCfg.workMode != WORK_MODE_USB) + if (systemCfg.workMode == WORK_MODE_USB) + { + if (Serial2.available()) + { + Serial.write(Serial2.read()); + Serial.flush(); + } + if (Serial.available()) + { + Serial2.write(Serial.read()); + Serial2.flush(); + } + return; + } + + else if (systemCfg.workMode == WORK_MODE_NETWORK) { uint16_t net_bytes_read = 0; uint8_t net_buf[BUFFER_SIZE]; diff --git a/src/version.h b/src/version.h index 94baff3..9db3115 100644 --- a/src/version.h +++ b/src/version.h @@ -1,4 +1,4 @@ // AUTO GENERATED FILE #ifndef VERSION - #define VERSION "20240528" + #define VERSION "20240529" #endif diff --git a/src/web.cpp b/src/web.cpp index 1a7ed39..0913fd8 100644 --- a/src/web.cpp +++ b/src/web.cpp @@ -1006,11 +1006,11 @@ void handleGeneral() String result; doc[hwBtnIsKey] = vars.hwBtnIs; - doc[hwUartSelIsKey] = vars.hwUartSelIs; + //doc[hwUartSelIsKey] = vars.hwUartSelIs; doc[hwLedPwrIsKey] = vars.hwLedPwrIs; doc[hwLedUsbIsKey] = vars.hwLedUsbIs; - switch (systemCfg.workMode) + /*switch (systemCfg.workMode) { case WORK_MODE_USB: doc["checkedUsbMode"] = checked; @@ -1025,7 +1025,7 @@ void handleGeneral() if (systemCfg.keepWeb) { doc[keepWebKey] = checked; - } + }*/ if (systemCfg.disableLedPwr) { @@ -1142,6 +1142,18 @@ void handleSerial() String result; DynamicJsonDocument doc(1024); + switch (systemCfg.workMode) + { + case WORK_MODE_USB: + doc["usbMode"] = checked; + break; + case WORK_MODE_NETWORK: + doc["lanMode"] = checked; + break; + default: + break; + } + if (systemCfg.serialSpeed == 9600) { doc["9600"] = checked; @@ -1174,6 +1186,7 @@ void handleSerial() { doc["115200"] = checked; } + doc[socketPortKey] = String(systemCfg.socketPort); serializeJson(doc, result); @@ -1475,7 +1488,7 @@ void handleTools() DynamicJsonDocument doc(512); doc[hwBtnIsKey] = vars.hwBtnIs; - doc[hwUartSelIsKey] = vars.hwUartSelIs; + //doc[hwUartSelIsKey] = vars.hwUartSelIs; doc[hwLedPwrIsKey] = vars.hwLedPwrIs; doc[hwLedUsbIsKey] = vars.hwLedUsbIs; // doc["hostname"] = systemCfg.hostname; diff --git a/src/websrc/html/PAGE_GENERAL.html b/src/websrc/html/PAGE_GENERAL.html index 1b969ee..2d4fee7 100644 --- a/src/websrc/html/PAGE_GENERAL.html +++ b/src/websrc/html/PAGE_GENERAL.html @@ -24,7 +24,7 @@ - diff --git a/src/websrc/html/PAGE_ZIGBEE.html b/src/websrc/html/PAGE_ZIGBEE.html index d843609..3711a3b 100644 --- a/src/websrc/html/PAGE_ZIGBEE.html +++ b/src/websrc/html/PAGE_ZIGBEE.html @@ -51,6 +51,17 @@
+
+
+
+ + +
+
+
diff --git a/src/websrc/js/functions.js b/src/websrc/js/functions.js index e5f6c6b..dfa0a25 100644 --- a/src/websrc/js/functions.js +++ b/src/websrc/js/functions.js @@ -395,11 +395,11 @@ function loadPage(url) { apiGetPage(api.pages.API_PAGE_ROOT); break; case api.pages.API_PAGE_GENERAL.str: - apiGetPage(api.pages.API_PAGE_GENERAL, () => { - if (!$("#usbMode").prop(chck)) { - KeepWebDsbl(true); - } - }); + apiGetPage(api.pages.API_PAGE_GENERAL);//, () => { + //if (!$("#usbMode").prop(chck)) { + // KeepWebDsbl(true); + //} + //}); break; case api.pages.API_PAGE_MQTT.str: apiGetPage(api.pages.API_PAGE_MQTT, () => { @@ -668,7 +668,7 @@ function apiGetPage(page, doneCall, loader = true) { //hwBtnIs continue; } - if (property === "hwUartSelIs") { + /*if (property === "hwUartSelIs") { if (values[property]) { showDivById('modeSelCard'); showDivById('curModeSelCard'); @@ -676,7 +676,7 @@ function apiGetPage(page, doneCall, loader = true) { //hwBtnIs continue; - } + }*/ } dataReplace(values); } @@ -1976,7 +1976,7 @@ function modalConstructor(type, params) { } }); break; - case "keepWeb": + /*case "keepWeb": $(headerText).text(i18next.t('p.ge.kw')); $(modalBody).text(i18next.t('md.kw.msg')); $('