diff --git a/bin/XZG_20240509.full.bin b/bin/XZG_20240510.full.bin similarity index 60% rename from bin/XZG_20240509.full.bin rename to bin/XZG_20240510.full.bin index 46cb163..8943983 100644 Binary files a/bin/XZG_20240509.full.bin and b/bin/XZG_20240510.full.bin differ diff --git a/bin/XZG_20240509.ota.bin b/bin/XZG_20240510.ota.bin similarity index 58% rename from bin/XZG_20240509.ota.bin rename to bin/XZG_20240510.ota.bin index 2c9f18d..9a63dde 100644 Binary files a/bin/XZG_20240509.ota.bin and b/bin/XZG_20240510.ota.bin differ diff --git a/lib/CCTools/src/CCTools.cpp b/lib/CCTools/src/CCTools.cpp index fe63b6f..1fdc0a5 100644 --- a/lib/CCTools/src/CCTools.cpp +++ b/lib/CCTools/src/CCTools.cpp @@ -903,7 +903,7 @@ bool CCTools::ledToggle() return false; } -bool CCTools::nvram_reset(void (*logFunction)(String)) +bool CCTools::nvram_reset(void (*logFunction)(const String&)) { bool success = true; @@ -965,7 +965,7 @@ bool CCTools::nvram_reset(void (*logFunction)(String)) } } - logFunction("NVRAM erase finish. Restarting..."); + logFunction("NVRAM erase finish. Restart CC2652"); restart(); diff --git a/lib/CCTools/src/CCTools.h b/lib/CCTools/src/CCTools.h index fdea4fe..910987a 100644 --- a/lib/CCTools/src/CCTools.h +++ b/lib/CCTools/src/CCTools.h @@ -613,7 +613,7 @@ class CCTools : public CommandInterface void processFlash(byte *data, int size); bool checkFirmwareVersion(); bool ledToggle(); - bool nvram_reset(void (*logFunction)(String)); + bool nvram_reset(void (*logFunction)(const String&)); }; #endif // CCTools_DETECT_H \ No newline at end of file diff --git a/src/version.h b/src/version.h index e11c1c0..d9ca160 100644 --- a/src/version.h +++ b/src/version.h @@ -1,4 +1,4 @@ // AUTO GENERATED FILE #ifndef VERSION - #define VERSION "20240509" + #define VERSION "20240510" #endif diff --git a/src/web.cpp b/src/web.cpp index bb68558..c128a42 100644 --- a/src/web.cpp +++ b/src/web.cpp @@ -498,71 +498,6 @@ void handleApi() const uint8_t action = serverWeb.arg(action).toInt(); switch (action) { - /*case API_FLASH_ZB: - { - vars.zbFlashing = 1; - const char *fwurlArg = "fwurl"; - const uint8_t eventLen = 11; - const char *tagZB_FW_info = "ZB_FW_info"; - const char *tagZB_FW_err = "ZB_FW_err"; - const char *tagZB_FW_progress = "ZB_FW_prgs"; - if (serverWeb.hasArg(fwurlArg)) - { - String fwUrl = serverWeb.arg(fwurlArg); - serverWeb.send(HTTP_CODE_OK, contTypeText, ok); - uint8_t evWaitCount = 0; - while (!eventsClient.connected() && evWaitCount < 200) - { // wait for events - webServerHandleClient(); - delay(25); - evWaitCount++; - } - // sendEvent(eventLen, String("FW Url: ") + fwUrl); - // setClock(); - HTTPClient https; - WiFiClientSecure client; - client.setInsecure(); - https.begin(client, fwUrl); // https://raw.githubusercontent.com/Tarik2142/devHost/main/coordinator_20211217.bin - https.addHeader("Content-Type", "application/octet-stream"); - const int16_t httpsCode = https.GET(); - // sendEvent(eventLen, String("REQ result: ") + httpsCode); - if (httpsCode == HTTP_CODE_OK) - { - const uint32_t fwSize = https.getSize(); - DEBUG_PRINTLN(F("[start] Downloading firmware...")); - sendEvent(tagZB_FW_info, eventLen, "[start]"); - sendEvent(tagZB_FW_info, eventLen, "Downloading firmware..."); - const char *tempFile2 = "/config/coordinator.bin"; - LittleFS.remove(tempFile2); - File fwFile = LittleFS.open(tempFile2, "w", 1); - uint8_t buff[4]; - uint32_t downloaded = 0; - while (client.readBytes(buff, sizeof(buff))) - { - downloaded += fwFile.write(buff, sizeof(buff)); - if (!(downloaded % 8192)) - { - const uint8_t d = ((float)downloaded / fwSize) * 100; - sendEvent(tagZB_FW_progress, eventLen, String(d)); - } - } - fwFile.close(); - // in development - } - else - { - LOGD("REQ error: http_code " + String(httpsCode)); - serverWeb.send(HTTP_CODE_BAD_REQUEST, contTypeText, String(httpsCode)); - sendEvent(tagZB_FW_err, eventLen, "REQ error: http_code " + String(httpsCode)); - } - } - else - { - serverWeb.send(HTTP_CODE_BAD_REQUEST, contTypeText, "missing arg 1"); - } - vars.zbFlashing = 0; - } - break;*/ case API_GET_LOG: { String result; @@ -1003,30 +938,24 @@ void handleSaveParams() void printEachKeyValuePair(const String &jsonString) { - DynamicJsonDocument doc(1024); // Создаём JSON документ с достаточным размером буфера - - // Десериализация JSON строки в JSON объект + DynamicJsonDocument doc(1024); DeserializationError error = deserializeJson(doc, jsonString); - // Проверяем на ошибки десериализации if (error) { - // Serial.print(F("deserializeJson() failed with code ")); - // Serial.println(error.c_str()); + return; } const uint8_t eventLen = 100; - // Перебираем все ключи и значения в корневом объекте + for (JsonPair kv : doc.as()) { - DynamicJsonDocument pairDoc(256); // Создаем маленький JSON документ для каждой пары - pairDoc[kv.key().c_str()] = kv.value(); // Добавляем текущую пару в новый документ + DynamicJsonDocument pairDoc(256); + pairDoc[kv.key().c_str()] = kv.value(); - // Сериализуем новый JSON документ и печатаем его String output; - serializeJson(pairDoc, output); // Сериализуем пару в строку - // Serial.println(output); + serializeJson(pairDoc, output); sendEvent("root_update", eventLen, String(output)); } @@ -1691,6 +1620,25 @@ void printLogMsg(String msg) LOGI("%s", msg.c_str()); } +void progressNvRamFunc(unsigned int progress, unsigned int total) +{ + + const char *tagESP_FW_progress = "ESP_FW_prgs"; + const uint8_t eventLen = 11; + + float percent = ((float)progress / total) * 100.0; + + sendEvent(tagESP_FW_progress, eventLen, String(percent)); + // printLogMsg(String(percent)); + +#ifdef DEBUG + if (int(percent) % 5 == 0) + { + LOGD("Update ESP32 progress: %s of %s | %s%", String(progress), String(total), String(percent)); + } +#endif +}; + void progressFunc(unsigned int progress, unsigned int total) { diff --git a/src/websrc/js/functions.js b/src/websrc/js/functions.js index 40fdb4c..2efa59c 100644 --- a/src/websrc/js/functions.js +++ b/src/websrc/js/functions.js @@ -1305,11 +1305,18 @@ function updateRootEvents(callback) { }); source.addEventListener('ZB_FW_prgs', function (e) { - //console.log(val); + //console.log(e.data); $('#zbFlshPgsTxt').html(i18next.t('md.esp.fu.prgs', { per: e.data })); $("#zbFlshPrgs").css("width", e.data + '%'); }, false); + source.addEventListener('NV', function (e) { + //console.log(e.data); + let currentContent = $("#console").val(); + let newContent = currentContent + "\n" + e.data; + $("#console").val(newContent); + }, false); + source.addEventListener('ZB_FW_info', function (e) { let data = e.data.replaceAll("`", "
"); console.log(data); diff --git a/src/websrc/json/de.json b/src/websrc/json/de.json index 661fd69..bd8479e 100644 --- a/src/websrc/json/de.json +++ b/src/websrc/json/de.json @@ -329,7 +329,8 @@ "saf": "Verfügbare Firmwares anzeigen", "clzv": "Überprüfen Sie die neuesten Zigbee-Firmwares", "zgu": "Git CC2652-Update", - "sri": "Version auswählen" + "sri": "Version auswählen", + "eznr": "NVRAM löschen" }, "vp": { "hn": { diff --git a/src/websrc/json/es.json b/src/websrc/json/es.json index f18f853..35af3ff 100644 --- a/src/websrc/json/es.json +++ b/src/websrc/json/es.json @@ -329,7 +329,8 @@ "saf": "Mostrar firmwares disponibles", "clzv": "Verifique los últimos firmwares de Zigbee", "zgu": "Actualización de Git CC2652", - "sri": "Seleccionar versión" + "sri": "Seleccionar versión", + "eznr": "Borrar NVRAM" }, "vp": { "hn": { diff --git a/src/websrc/json/fr.json b/src/websrc/json/fr.json index db081cb..847cbc6 100644 --- a/src/websrc/json/fr.json +++ b/src/websrc/json/fr.json @@ -329,7 +329,8 @@ "saf": "Afficher les firmwares disponibles", "clzv": "Vérifiez les derniers firmwares Zigbee", "zgu": "Mise à jour Git CC2652", - "sri": "Sélectionnez la version" + "sri": "Sélectionnez la version", + "eznr": "Effacer la NVRAM" }, "vp": { "hn": { diff --git a/src/websrc/json/it.json b/src/websrc/json/it.json index ceaa5ce..0081629 100644 --- a/src/websrc/json/it.json +++ b/src/websrc/json/it.json @@ -329,7 +329,8 @@ "saf": "Mostra i firmware disponibili", "clzv": "Controlla gli ultimi firmware Zigbee", "zgu": "Aggiornamento Git CC2652", - "sri": "Seleziona la versione" + "sri": "Seleziona la versione", + "eznr": "Cancella NVRAM" }, "vp": { "hn": { diff --git a/src/websrc/json/ja.json b/src/websrc/json/ja.json index 9203207..e9d9e6d 100644 --- a/src/websrc/json/ja.json +++ b/src/websrc/json/ja.json @@ -329,7 +329,8 @@ "saf": "利用可能なファームウェアを表示する", "clzv": "最新の Zigbee ファームウェアを確認する", "zgu": "Git CC2652 アップデート", - "sri": "バージョンの選択" + "sri": "バージョンの選択", + "eznr": "NVRAMの消去" }, "vp": { "hn": { diff --git a/src/websrc/json/pl.json b/src/websrc/json/pl.json index 38b0b10..5be569f 100644 --- a/src/websrc/json/pl.json +++ b/src/websrc/json/pl.json @@ -329,7 +329,8 @@ "saf": "Pokaż dostępne oprogramowanie sprzętowe", "clzv": "Sprawdź najnowsze oprogramowanie sprzętowe Zigbee", "zgu": "Aktualizacja Gita CC2652", - "sri": "Wybierz wersję" + "sri": "Wybierz wersję", + "eznr": "Wymaż NVRAM" }, "vp": { "hn": { diff --git a/src/websrc/json/pt.json b/src/websrc/json/pt.json index af7c19e..6a221b0 100644 --- a/src/websrc/json/pt.json +++ b/src/websrc/json/pt.json @@ -329,7 +329,8 @@ "saf": "Mostrar firmwares disponíveis", "clzv": "Verifique os firmwares Zigbee mais recentes", "zgu": "Atualização do Git CC2652", - "sri": "Selecione a versão" + "sri": "Selecione a versão", + "eznr": "Apagar NVRAM" }, "vp": { "hn": { diff --git a/src/websrc/json/ru.json b/src/websrc/json/ru.json index 82579fe..2323953 100644 --- a/src/websrc/json/ru.json +++ b/src/websrc/json/ru.json @@ -329,7 +329,8 @@ "saf": "Показать доступную прошивку", "clzv": "Проверить последнюю версию прошивки Zigbee", "zgu": "Обновление Git CC2652", - "sri": "Выберите версию" + "sri": "Выберите версию", + "eznr": "Стереть NVRAM" }, "vp": { "hn": { diff --git a/src/websrc/json/tr.json b/src/websrc/json/tr.json index 6cefe18..f77a783 100644 --- a/src/websrc/json/tr.json +++ b/src/websrc/json/tr.json @@ -329,7 +329,8 @@ "saf": "Mevcut ürün yazılımlarını göster", "clzv": "En yeni Zigbee yazılımlarını kontrol edin", "zgu": "Git CC2652 güncellemesi", - "sri": "Sürümü seçin" + "sri": "Sürümü seçin", + "eznr": "NVRAM'ı sil" }, "vp": { "hn": { diff --git a/src/websrc/json/uk.json b/src/websrc/json/uk.json index d6a10aa..bd6de5a 100644 --- a/src/websrc/json/uk.json +++ b/src/websrc/json/uk.json @@ -254,7 +254,8 @@ "clzv": "Перевірити останню прошивку Zigbee", "saf": "Показати доступну прошивку", "zgu": "Оновлення Git CC2652", - "ls": "запуск..." + "ls": "запуск...", + "eznr": "Очистити NVRAM" }, "lo": { "pt": "Логін - XZG", diff --git a/src/websrc/json/zh.json b/src/websrc/json/zh.json index 89e0b0d..7b272a0 100644 --- a/src/websrc/json/zh.json +++ b/src/websrc/json/zh.json @@ -329,7 +329,8 @@ "saf": "显示可用固件", "clzv": "检查最新的 Zigbee 固件", "zgu": "Git CC2652 更新", - "sri": "选择版本" + "sri": "选择版本", + "eznr": "擦除NVRAM" }, "vp": { "hn": { diff --git a/src/zb.cpp b/src/zb.cpp index 3f99847..2413a65 100644 --- a/src/zb.cpp +++ b/src/zb.cpp @@ -103,10 +103,24 @@ bool zigbeeErase() } return false; } +void nvPrgs(const String &inputMsg) +{ + const char *tagZB_NV_progress = "NV"; + const uint8_t eventLen = 30; + String msg = inputMsg; + if (msg.length() > 25) + { + msg = msg.substring(0, 25); + } + sendEvent(tagZB_NV_progress, eventLen, msg); + LOGD("%s", msg.c_str()); +} void zbEraseNV(void *pvParameters) { - CCTool.nvram_reset(printLogMsg); + CCTool.nvram_reset(nvPrgs); + logClear(); + printLogMsg("NVRAM erase finish! Restart CC2652!"); vTaskDelete(NULL); } diff --git a/src/zb.h b/src/zb.h index 636d965..24437d7 100644 --- a/src/zb.h +++ b/src/zb.h @@ -2,6 +2,7 @@ bool zbFwCheck(); void zbHwCheck(); bool zbLedToggle(); bool zigbeeErase(); +void nvPrgs(const String &inputMsg); void zbEraseNV(void *pvParameters); void flashZbUrl(String url); bool eraseWriteZbUrl(const char *url, std::function progressShow, CCTools &CCTool);