From 4d8191d6b0cbff42ef299266083cc819d8901805 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 19 Nov 2020 15:43:47 +0100 Subject: [PATCH] Refactor file upload --- tasmota/language/bg_BG.h | 2 +- tasmota/language/cs_CZ.h | 2 +- tasmota/language/de_DE.h | 2 +- tasmota/language/el_GR.h | 2 +- tasmota/language/en_GB.h | 2 +- tasmota/language/es_ES.h | 2 +- tasmota/language/fr_FR.h | 2 +- tasmota/language/he_HE.h | 2 +- tasmota/language/hu_HU.h | 2 +- tasmota/language/it_IT.h | 2 +- tasmota/language/ko_KO.h | 2 +- tasmota/language/nl_NL.h | 2 +- tasmota/language/pl_PL.h | 2 +- tasmota/language/pt_BR.h | 2 +- tasmota/language/pt_PT.h | 2 +- tasmota/language/ro_RO.h | 2 +- tasmota/language/ru_RU.h | 2 +- tasmota/language/sk_SK.h | 2 +- tasmota/language/sv_SE.h | 2 +- tasmota/language/tr_TR.h | 2 +- tasmota/language/uk_UA.h | 2 +- tasmota/language/vi_VN.h | 2 +- tasmota/language/zh_CN.h | 2 +- tasmota/language/zh_TW.h | 2 +- tasmota/tasmota_globals.h | 6 +- tasmota/xdrv_01_webserver.ino | 151 +++++++++++---------------- tasmota/xdrv_23_zigbee_9a_upload.ino | 50 ++------- tasmota/xdrv_31_tasmota_client.ino | 35 +------ 28 files changed, 104 insertions(+), 186 deletions(-) diff --git a/tasmota/language/bg_BG.h b/tasmota/language/bg_BG.h index 5c1fa49ff..d91d81aa1 100644 --- a/tasmota/language/bg_BG.h +++ b/tasmota/language/bg_BG.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer started" #define D_UPLOAD_ERR_1 "Не е избран файл" #define D_UPLOAD_ERR_2 "Недостатъчно свободно място" -#define D_UPLOAD_ERR_3 "Magic байтът не е 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "Размерът на програмата е по-голям от реалния размер на флаш паметта" #define D_UPLOAD_ERR_5 "Грешка при зареждането в буфера" #define D_UPLOAD_ERR_6 "Грешка при зареждането. Включено е ниво 3 на лога" diff --git a/tasmota/language/cs_CZ.h b/tasmota/language/cs_CZ.h index 709f124e3..b4f96c30a 100644 --- a/tasmota/language/cs_CZ.h +++ b/tasmota/language/cs_CZ.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer started" #define D_UPLOAD_ERR_1 "Soubor nebyl vybrán" #define D_UPLOAD_ERR_2 "Málo místa" -#define D_UPLOAD_ERR_3 "Magický byte má hodnotu jinou než 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "Velikost programu je větší než skutečná velikost paměti flash" #define D_UPLOAD_ERR_5 "Chyba nahrávání, nesouhlasí porovnávané bity" #define D_UPLOAD_ERR_6 "Chyba nahrávání. Spuštěn zápis do logu na úrovni 3" diff --git a/tasmota/language/de_DE.h b/tasmota/language/de_DE.h index e15fbc0f3..103a4d330 100644 --- a/tasmota/language/de_DE.h +++ b/tasmota/language/de_DE.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer gestartet" #define D_UPLOAD_ERR_1 "Keine Datei ausgewählt" #define D_UPLOAD_ERR_2 "Ungenügend Speicherplatz" -#define D_UPLOAD_ERR_3 "Magic Byte ist nicht 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "Datei überschreitet vorhdn. Flashspeicher" #define D_UPLOAD_ERR_5 "Upload Buffer Vergleich weicht ab" #define D_UPLOAD_ERR_6 "Upload fehlgeschlagen. Aktiviere logging 3" diff --git a/tasmota/language/el_GR.h b/tasmota/language/el_GR.h index 98542801c..f9147b13c 100644 --- a/tasmota/language/el_GR.h +++ b/tasmota/language/el_GR.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer started" #define D_UPLOAD_ERR_1 "Δεν έχει επιλεγεί αρχείο" #define D_UPLOAD_ERR_2 "Δεν υπάρχει επαρκής χώρος" -#define D_UPLOAD_ERR_3 "Magic byte is not 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "Το μέγεθος προγράμματος είναι μεγαλύτερο από την πραγματική μνήμη Flash" #define D_UPLOAD_ERR_5 "Upload buffer miscompare" #define D_UPLOAD_ERR_6 "Η μεταφόρτωση απέτυχε. Επιλέξτε επίπεδο καταγραφής 3" diff --git a/tasmota/language/en_GB.h b/tasmota/language/en_GB.h index 97bbbbf73..169f03c44 100644 --- a/tasmota/language/en_GB.h +++ b/tasmota/language/en_GB.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer started" #define D_UPLOAD_ERR_1 "No file selected" #define D_UPLOAD_ERR_2 "Not enough space" -#define D_UPLOAD_ERR_3 "Magic byte is not 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "Program flash size is larger than real flash size" #define D_UPLOAD_ERR_5 "Upload buffer miscompare" #define D_UPLOAD_ERR_6 "Upload failed. Enable logging 3" diff --git a/tasmota/language/es_ES.h b/tasmota/language/es_ES.h index 5b6766be9..77fd91a7e 100644 --- a/tasmota/language/es_ES.h +++ b/tasmota/language/es_ES.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer started" #define D_UPLOAD_ERR_1 "Ningún archivo seleccionado" #define D_UPLOAD_ERR_2 "Espacio insuficiente" -#define D_UPLOAD_ERR_3 "Magic byte no corresponde a 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "El tamaño de la memoria de programa es mayor que la de la flash" #define D_UPLOAD_ERR_5 "Error de comparación del buffer de carga" #define D_UPLOAD_ERR_6 "Carga fallida. Habilitar logging 3" diff --git a/tasmota/language/fr_FR.h b/tasmota/language/fr_FR.h index d67a0e10a..f9b46ce87 100644 --- a/tasmota/language/fr_FR.h +++ b/tasmota/language/fr_FR.h @@ -357,7 +357,7 @@ #define D_TRANSFER_STARTED "Transfert lancé" #define D_UPLOAD_ERR_1 "Aucun fichier sélectionné" #define D_UPLOAD_ERR_2 "Espace insuffisant" -#define D_UPLOAD_ERR_3 "L'octet magique n'est pas 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "La taille du programme à flasher est plus grande que la taille réelle de la mémoire flash" #define D_UPLOAD_ERR_5 "Erreur de comparaison du buffer de téléchargement" #define D_UPLOAD_ERR_6 "Téléchargement échoué. Activer WebLog 3" diff --git a/tasmota/language/he_HE.h b/tasmota/language/he_HE.h index a370dde84..aa60ec036 100644 --- a/tasmota/language/he_HE.h +++ b/tasmota/language/he_HE.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer started" #define D_UPLOAD_ERR_1 "לא נבחר קובץ" #define D_UPLOAD_ERR_2 "אין מספיק מקום" -#define D_UPLOAD_ERR_3 "Magic byte is not 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "גודל קובץ השדרוג גדול מנפח האחסון של הפלאש" #define D_UPLOAD_ERR_5 "מאגר העלאה לא תקין" #define D_UPLOAD_ERR_6 "העלאה נכשלה. אפשר רישום 3" diff --git a/tasmota/language/hu_HU.h b/tasmota/language/hu_HU.h index 8fc5fbc58..7f82fce6c 100644 --- a/tasmota/language/hu_HU.h +++ b/tasmota/language/hu_HU.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer started" #define D_UPLOAD_ERR_1 "Nincs fájl kijelölve" #define D_UPLOAD_ERR_2 "Nincs elég memória" -#define D_UPLOAD_ERR_3 "A \"magic byte\" nem 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "A program flashméret nagyobb a valós flashméretnél" #define D_UPLOAD_ERR_5 "Feltöltési buffer hiba" #define D_UPLOAD_ERR_6 "Feltöltés sikertelen. Endegélyezd a 3. szintű naplózást" diff --git a/tasmota/language/it_IT.h b/tasmota/language/it_IT.h index ad1fe8394..c0fa5566b 100644 --- a/tasmota/language/it_IT.h +++ b/tasmota/language/it_IT.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Trasferimento avviato" #define D_UPLOAD_ERR_1 "Nessun file selezionato" #define D_UPLOAD_ERR_2 "Spazio insufficiente" -#define D_UPLOAD_ERR_3 "Magic byte non corrispondente a 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "Dimensione memoria programma maggiore della dimensione reale della flash" #define D_UPLOAD_ERR_5 "Errore comparazione buffer upload" #define D_UPLOAD_ERR_6 "Invio fallito. Abilita registrazione logging 3" diff --git a/tasmota/language/ko_KO.h b/tasmota/language/ko_KO.h index 9d5e1e479..56b86e4a7 100644 --- a/tasmota/language/ko_KO.h +++ b/tasmota/language/ko_KO.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer started" #define D_UPLOAD_ERR_1 "파일이 선택되지 않았습니다" #define D_UPLOAD_ERR_2 "용량이 충분하지 않습니다" -#define D_UPLOAD_ERR_3 "Magic 바이트가 0xE9가 아닙니다" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "플래시 프로그램이 실제 플래시 용량보다 큽니다" #define D_UPLOAD_ERR_5 "업로드 버퍼가 일치하지 않습니다" #define D_UPLOAD_ERR_6 "업로드 실패. 로그 3 사용" diff --git a/tasmota/language/nl_NL.h b/tasmota/language/nl_NL.h index cf7e2cf46..ed49b15a1 100644 --- a/tasmota/language/nl_NL.h +++ b/tasmota/language/nl_NL.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer started" #define D_UPLOAD_ERR_1 "Geen bestand gekozen" #define D_UPLOAD_ERR_2 "Onvoldoende geheugen ruimte" -#define D_UPLOAD_ERR_3 "Magische byte is niet 0xE9" +#define D_UPLOAD_ERR_3 "Ongeldig bestandssoort" #define D_UPLOAD_ERR_4 "Programma flash grootte is groter dan werkelijke flash grootte" #define D_UPLOAD_ERR_5 "Opwaardeer buffer verschil" #define D_UPLOAD_ERR_6 "Opwaarderen mislukt. Schakel logging 3 in" diff --git a/tasmota/language/pl_PL.h b/tasmota/language/pl_PL.h index d10b3aecf..a4bd3bd0c 100644 --- a/tasmota/language/pl_PL.h +++ b/tasmota/language/pl_PL.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer started" #define D_UPLOAD_ERR_1 "Nie wybrano pliku" #define D_UPLOAD_ERR_2 "Niewystarczająca ilość miejsca" -#define D_UPLOAD_ERR_3 "Magiczny bajt jest inny niz 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "Rozmiar programu jest większy niż rzeczywisty rozmiar pamięci flash" #define D_UPLOAD_ERR_5 "Wgrywanie, bufor niezgodności stanu porównywanych bitow" #define D_UPLOAD_ERR_6 "Błąd wgrywania. Uruchomiono zapis do dziennika na poziomie 3" diff --git a/tasmota/language/pt_BR.h b/tasmota/language/pt_BR.h index e9a70b25f..91734fe5a 100644 --- a/tasmota/language/pt_BR.h +++ b/tasmota/language/pt_BR.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer started" #define D_UPLOAD_ERR_1 "Nenhum arquivo selecionado" #define D_UPLOAD_ERR_2 "Não existe memória disponível" -#define D_UPLOAD_ERR_3 "Byte mágico não é 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "O tamanho do programa é maior do que o tamanho da memória" #define D_UPLOAD_ERR_5 "Buffer de envio insuficiente" #define D_UPLOAD_ERR_6 "Falha no envio. Habilitar logging 3" diff --git a/tasmota/language/pt_PT.h b/tasmota/language/pt_PT.h index 5f78f779f..a5beb34e4 100644 --- a/tasmota/language/pt_PT.h +++ b/tasmota/language/pt_PT.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer started" #define D_UPLOAD_ERR_1 "Nenhum ficheiro selecionado" #define D_UPLOAD_ERR_2 "Não existe espaço disponível" -#define D_UPLOAD_ERR_3 "O Byte mágico não é 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "O tamanho do programa e maior do que o tamanho real da flash" #define D_UPLOAD_ERR_5 "Comparação incorreta do buffer de upload" #define D_UPLOAD_ERR_6 "Falha no envio. Habilitar registro 3" diff --git a/tasmota/language/ro_RO.h b/tasmota/language/ro_RO.h index 1de2927f4..bce599724 100644 --- a/tasmota/language/ro_RO.h +++ b/tasmota/language/ro_RO.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer started" #define D_UPLOAD_ERR_1 "Nici un fișier selectat" #define D_UPLOAD_ERR_2 "Spațiu insuficient" -#define D_UPLOAD_ERR_3 "Magic byte nu este 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "Dimensiunea programului este mai mare decât mărimea memoriei" #define D_UPLOAD_ERR_5 "Încărcare buffer necomparabil" #define D_UPLOAD_ERR_6 "Încărcare eșuată. Activează logging 3" diff --git a/tasmota/language/ru_RU.h b/tasmota/language/ru_RU.h index bbefa9b4e..3ef6aad6b 100644 --- a/tasmota/language/ru_RU.h +++ b/tasmota/language/ru_RU.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer started" #define D_UPLOAD_ERR_1 "Файл не выбран" #define D_UPLOAD_ERR_2 "Недостаточно места" -#define D_UPLOAD_ERR_3 "Magic байт не 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "Размер прошивки больше, чем реальный размер флеш памяти" #define D_UPLOAD_ERR_5 "Ошибка загрузки буфера" #define D_UPLOAD_ERR_6 "Ошибка загрузки. Включено лог уровня 3" diff --git a/tasmota/language/sk_SK.h b/tasmota/language/sk_SK.h index ea050d415..acbc05b06 100644 --- a/tasmota/language/sk_SK.h +++ b/tasmota/language/sk_SK.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer started" #define D_UPLOAD_ERR_1 "Súbor nebol vybraný" #define D_UPLOAD_ERR_2 "Málo miesta" -#define D_UPLOAD_ERR_3 "Magický byte má hodnotu inú než 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "Veľkosť programu je väčšia než skutočná veľkosť flash pamäte" #define D_UPLOAD_ERR_5 "Chyba nahrávania, nesúhlasia porovnávané bity" #define D_UPLOAD_ERR_6 "Chyba nahrávania. Spustený zápis do logu na úrovni 3" diff --git a/tasmota/language/sv_SE.h b/tasmota/language/sv_SE.h index 59588ca4b..1316c9110 100644 --- a/tasmota/language/sv_SE.h +++ b/tasmota/language/sv_SE.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer started" #define D_UPLOAD_ERR_1 "Ingen fil vald" #define D_UPLOAD_ERR_2 "Inte tillräckligt med ledigt utrymme" -#define D_UPLOAD_ERR_3 "Magisk byte är inte 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "Programmets flashstorlek är större än den verkliga flashstorleken" #define D_UPLOAD_ERR_5 "Uppladdningbuffert stämmer inte överens" #define D_UPLOAD_ERR_6 "Uppladdning misslyckad. Aktivera loggning 3" diff --git a/tasmota/language/tr_TR.h b/tasmota/language/tr_TR.h index d388abfb5..2c682530e 100644 --- a/tasmota/language/tr_TR.h +++ b/tasmota/language/tr_TR.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer started" #define D_UPLOAD_ERR_1 "Dosya seçilmedi" #define D_UPLOAD_ERR_2 "Boş yer yok" -#define D_UPLOAD_ERR_3 "Magic byte is not 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "Yazılımın boyutu gerçek boyutundan fazla" #define D_UPLOAD_ERR_5 "Upload buffer miscompare" #define D_UPLOAD_ERR_6 "Yükleme başarısız. Enable logging 3" diff --git a/tasmota/language/uk_UA.h b/tasmota/language/uk_UA.h index 6f077b13a..c8f57a26b 100644 --- a/tasmota/language/uk_UA.h +++ b/tasmota/language/uk_UA.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer started" #define D_UPLOAD_ERR_1 "Файл не вибраний" #define D_UPLOAD_ERR_2 "Недостатньо місця" -#define D_UPLOAD_ERR_3 "Магічний байт не 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "Размір прошивки більший, ніж размір Flash пам'яті" #define D_UPLOAD_ERR_5 "Помилка завантаження буферу" #define D_UPLOAD_ERR_6 "Помилка завантаження. Увімкнено лог рівень 3" diff --git a/tasmota/language/vi_VN.h b/tasmota/language/vi_VN.h index 963a27e9a..49deee770 100644 --- a/tasmota/language/vi_VN.h +++ b/tasmota/language/vi_VN.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Bắt đầu truyền tải" #define D_UPLOAD_ERR_1 "Không có tệp được chọn" #define D_UPLOAD_ERR_2 "Không đủ bộ nhớ" -#define D_UPLOAD_ERR_3 "Magic byte is not 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "Chương trình nâng cấp kích thước lớn hơn bộ nhớ thực tế" #define D_UPLOAD_ERR_5 "Bộ nhớ đệm tải lên không đủ" #define D_UPLOAD_ERR_6 "Tải lên thất bại. Bật bản ghi hệ thống mức 3" diff --git a/tasmota/language/zh_CN.h b/tasmota/language/zh_CN.h index 81ff1421d..c7dbd0140 100644 --- a/tasmota/language/zh_CN.h +++ b/tasmota/language/zh_CN.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer started" #define D_UPLOAD_ERR_1 "没有选择任何文件" #define D_UPLOAD_ERR_2 "没有足够空间" -#define D_UPLOAD_ERR_3 "固件头不是 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "固件大小超过 flash 容量" #define D_UPLOAD_ERR_5 "上传缓冲区不足,请先刷入精简固件再升级" #define D_UPLOAD_ERR_6 "上传失败。 启用日志级别 3 调试" diff --git a/tasmota/language/zh_TW.h b/tasmota/language/zh_TW.h index 1ac516dff..641cfdadb 100644 --- a/tasmota/language/zh_TW.h +++ b/tasmota/language/zh_TW.h @@ -361,7 +361,7 @@ #define D_TRANSFER_STARTED "Transfer started" #define D_UPLOAD_ERR_1 "沒選擇任何檔案" #define D_UPLOAD_ERR_2 "可用空間不足" -#define D_UPLOAD_ERR_3 "魔術數字(Magic byte)不是 0xE9" +#define D_UPLOAD_ERR_3 "Invalid file signature" #define D_UPLOAD_ERR_4 "軟體刷入(Program flash)的大小超出實際記憶體的大小" #define D_UPLOAD_ERR_5 "上傳緩衝器不相符" #define D_UPLOAD_ERR_6 "上傳失敗。 啟用日誌記錄 3" diff --git a/tasmota/tasmota_globals.h b/tasmota/tasmota_globals.h index 2a88b4131..fc2fbf34d 100644 --- a/tasmota/tasmota_globals.h +++ b/tasmota/tasmota_globals.h @@ -128,8 +128,6 @@ String EthernetMacAddress(void); #undef USE_HM10 // Disable support for HM-10 as a BLE-bridge as an alternative is using the internal ESP32 BLE #undef USE_KEELOQ // Disable support for Jarolift rollers by Keeloq algorithm as it's library cc1101 is not compatible with ESP32 -//#undef USE_DISPLAY_ILI9488 // Disable as it's library JaretBurkett_ILI9488-gemu-1.0 is not compatible with ESP32 -//#undef USE_DISPLAY_SSD1351 // Disable as it's library Adafruit_SSD1351_gemu-1.0 is not compatible with ESP32 #endif // ESP32 @@ -162,6 +160,10 @@ String EthernetMacAddress(void); #undef USE_RF_FLASH // Disable RF firmware flash when Sonoff Rf is disabled #endif +#ifndef USE_ZIGBEE +#undef USE_ZIGBEE_EZSP // Disable Zigbee EZSP firmware flash +#endif + #ifndef USE_LIGHT #undef SHELLY_FW_UPGRADE // Disable Shelly Dimmer firmware flash when lights are disabled #endif diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 565dd3379..aae381c2a 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -2569,7 +2569,7 @@ void HandleInformation(void) /*-------------------------------------------------------------------------------------------*/ -#if defined(SHELLY_FW_UPGRADE) +#if defined(USE_TASMOTA_CLIENT) || defined(SHELLY_FW_UPGRADE) struct { size_t spi_hex_size; @@ -2658,15 +2658,15 @@ void HandleUploadDone(void) { if (!HttpCheckPriviledgedAccess()) { return; } -#if defined(USE_ZIGBEE) && defined(USE_ZIGBEE_EZSP) - if (!Web.upload_error) { +#if defined(USE_ZIGBEE_EZSP) + if ((UPL_EFR32 == Web.upload_file_type) && !Web.upload_error && BUpload.ready) { + BUpload.ready = false; // Make sure not to follow thru again // GUI xmodem - if (ZigbeeUploadOtaReady()) { - HandleZigbeeXfer(); - return; - } + ZigbeeUploadStep1Done(BUploadStartSector(), BUpload.spi_hex_size); + HandleZigbeeXfer(); + return; } -#endif +#endif // USE_ZIGBEE_EZSP AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_UPLOAD_DONE)); @@ -2682,11 +2682,11 @@ void HandleUploadDone(void) WSContentStart_P(PSTR(D_INFORMATION)); if (!Web.upload_error) { uint32_t javascript_settimeout = HTTP_OTA_RESTART_RECONNECT_TIME; -#if defined(USE_ZIGBEE) && defined(USE_ZIGBEE_EZSP) +#if defined(USE_ZIGBEE_EZSP) if (ZigbeeUploadFinish()) { javascript_settimeout = 10000; // Refesh main web ui after transfer upgrade } -#endif +#endif // USE_ZIGBEE_EZSP WSContentSend_P(HTTP_SCRIPT_RELOAD_TIME, javascript_settimeout); // Refesh main web ui after OTA upgrade } WSContentSendStyle(); @@ -2709,19 +2709,12 @@ void HandleUploadDone(void) WSContentSend_P(PSTR("%06x'>" D_SUCCESSFUL "
"), WebColor(COL_TEXT_SUCCESS)); TasmotaGlobal.restart_flag = 2; // Always restart to re-enable disabled features during update -#ifdef SHELLY_FW_UPGRADE +#if defined(USE_TASMOTA_CLIENT) || defined(SHELLY_FW_UPGRADE) if (BUpload.ready) { WSContentSend_P(PSTR("
" D_TRANSFER_STARTED " ...
")); TasmotaGlobal.restart_flag = 0; // Hold restart as code still needs to be transferred to STM } -#endif // SHELLY_FW_UPGRADE - -#ifdef USE_TASMOTA_CLIENT - if (TasmotaClient_GetFlagFlashing()) { - WSContentSend_P(PSTR("
" D_TRANSFER_STARTED " ...
")); - TasmotaGlobal.restart_flag = 0; // Hold restart as code still needs to be transferred to Atmega - } -#endif // USE_TASMOTA_CLIENT +#endif // USE_TASMOTA_CLIENT or SHELLY_FW_UPGRADE if (TasmotaGlobal.restart_flag) { WSContentSend_P(HTTP_MSG_RSTRT); @@ -2733,17 +2726,21 @@ void HandleUploadDone(void) WSContentSpaceButton(BUTTON_MAIN); WSContentStop(); -#ifdef SHELLY_FW_UPGRADE +#if defined(USE_TASMOTA_CLIENT) || defined(SHELLY_FW_UPGRADE) if (BUpload.ready) { - ShdFlash(BUploadStartSector() * SPI_FLASH_SEC_SIZE, BUpload.spi_hex_size); - } -#endif // SHELLY_FW_UPGRADE - +#ifdef SHELLY_FW_UPGRADE + if (UPL_SHD == Web.upload_file_type) { + ShdFlash(BUploadStartSector() * SPI_FLASH_SEC_SIZE, BUpload.spi_hex_size); + } +#endif #ifdef USE_TASMOTA_CLIENT - if (TasmotaClient_GetFlagFlashing()) { - TasmotaClient_Flash(); + if (UPL_TASMOTACLIENT == Web.upload_file_type) { + TasmotaClient_Flash(BUploadStartSector() * SPI_FLASH_SEC_SIZE, BUpload.spi_hex_size); + } +#endif } -#endif // USE_TASMOTA_CLIENT +#endif // USE_TASMOTA_CLIENT or SHELLY_FW_UPGRADE + Web.upload_file_type = UPL_TASMOTA; } void HandleUploadLoop(void) @@ -2809,21 +2806,8 @@ void HandleUploadLoop(void) Web.config_block_count = 0; } else { -#if defined(USE_ZIGBEE) && defined(USE_ZIGBEE_EZSP) -#ifdef ESP8266 - if ((SONOFF_ZB_BRIDGE == TasmotaGlobal.module_type) && (upload.buf[0] == 0xEB)) { // Check if this is a Zigbee bridge FW file -#else // ESP32 - if (PinUsed(GPIO_ZIGBEE_RX) && PinUsed(GPIO_ZIGBEE_TX) && (upload.buf[0] == 0xEB)) { // Check if this is a Zigbee bridge FW file -#endif // ESP8266 or ESP32 - Update.end(); // End esp8266 update session - Web.upload_file_type = UPL_EFR32; - - Web.upload_error = ZigbeeUploadInit(); // 15 - if (Web.upload_error != 0) { return; } - } else -#endif // USE_ZIGBEE and USE_ZIGBEE_EZSP #ifdef USE_RF_FLASH - if ((SONOFF_BRIDGE == TasmotaGlobal.module_type) && (upload.buf[0] == ':')) { // Check if this is a RF bridge FW file + if ((SONOFF_BRIDGE == TasmotaGlobal.module_type) && (':' == upload.buf[0])) { // Check if this is a RF bridge FW file Update.end(); // End esp8266 update session Web.upload_file_type = UPL_EFM8BB1; @@ -2831,24 +2815,41 @@ void HandleUploadLoop(void) if (Web.upload_error != 0) { return; } } else #endif // USE_RF_FLASH -#ifdef SHELLY_FW_UPGRADE +#if defined(USE_ZIGBEE_EZSP) || defined(USE_TASMOTA_CLIENT) || defined(SHELLY_FW_UPGRADE) +#if defined(USE_ZIGBEE_EZSP) +#ifdef ESP8266 + if ((SONOFF_ZB_BRIDGE == TasmotaGlobal.module_type) && (0xEB == upload.buf[0])) { // Check if this is a Zigbee bridge FW file +#else // ESP32 + if (PinUsed(GPIO_ZIGBEE_RX) && PinUsed(GPIO_ZIGBEE_TX) && (0xEB == upload.buf[0])) { // Check if this is a Zigbee bridge FW file +#endif // ESP8266 or ESP32 + // Read complete file into ESP8266 flash + // Current files are about 200k + Web.upload_file_type = UPL_EFR32; + + Web.upload_error = ZigbeeUploadStep1Init(); // 1 + if (Web.upload_error != 0) { + Update.end(); // End esp8266 update session + return; + } + } +#endif +#if defined(USE_TASMOTA_CLIENT) + if (TasmotaClient_Available() && (':' == upload.buf[0])) { // Check if this is a ARDUINO CLIENT hex file + Web.upload_file_type = UPL_TASMOTACLIENT; + } +#endif +#if defined(SHELLY_FW_UPGRADE) if (ShdPresent() && (0x00 == upload.buf[0]) && (0x10 == upload.buf[1])) { - Update.end(); // End esp8266 update session Web.upload_file_type = UPL_SHD; + } +#endif + if ((UPL_TASMOTACLIENT == Web.upload_file_type) || (UPL_SHD == Web.upload_file_type) || (UPL_EFR32 == Web.upload_file_type)) { + Update.end(); // End esp8266 update session Web.upload_error = BUploadInit(); if (Web.upload_error != 0) { return; } } else -#endif // SHELLY_FW_UPGRADE -#ifdef USE_TASMOTA_CLIENT - if (TasmotaClient_Available() && (upload.buf[0] == ':')) { // Check if this is a ARDUINO CLIENT hex file - Update.end(); // End esp8266 update session - Web.upload_file_type = UPL_TASMOTACLIENT; - - Web.upload_error = TasmotaClient_UpdateInit(); // 0 - if (Web.upload_error != 0) { return; } - } else -#endif +#endif // USE_ZIGBEE_EZSP or USE_TASMOTA_CLIENT or SHELLY_FW_UPGRADE { if ((upload.buf[0] != 0xE9) && (upload.buf[0] != 0x1F)) { // 0x1F is gzipped 0xE9 Web.upload_error = 3; // Magic byte is not 0xE9 @@ -2876,15 +2877,6 @@ void HandleUploadLoop(void) Web.config_block_count++; } } -#if defined(USE_ZIGBEE) && defined(USE_ZIGBEE_EZSP) - else if (UPL_EFR32 == Web.upload_file_type) { - // Write buffers to MCU EFR32 - if (!ZigbeeUploadWriteBuffer(upload.buf, upload.currentSize)) { - Web.upload_error = 9; // File too large - return; - } - } -#endif // USE_ZIGBEE and USE_ZIGBEE_EZSP #ifdef USE_RF_FLASH else if (UPL_EFM8BB1 == Web.upload_file_type) { if (efm8bb1_update != nullptr) { // We have carry over data since last write, i. e. a start but not an end @@ -2919,18 +2911,13 @@ void HandleUploadLoop(void) } } #endif // USE_RF_FLASH -#ifdef SHELLY_FW_UPGRADE - else if (UPL_SHD == Web.upload_file_type) { +#if defined(USE_ZIGBEE_EZSP) || defined(USE_TASMOTA_CLIENT) || defined(SHELLY_FW_UPGRADE) + else if ((UPL_EFR32 == Web.upload_file_type) || (UPL_TASMOTACLIENT == Web.upload_file_type) || (UPL_SHD == Web.upload_file_type)) { // Write a block Web.upload_error = BUploadWriteBuffer(upload.buf, upload.currentSize); if (Web.upload_error != 0) { return; } } -#endif // SHELLY_FW_UPGRADE -#ifdef USE_TASMOTA_CLIENT - else if (UPL_TASMOTACLIENT == Web.upload_file_type) { - TasmotaClient_WriteBuffer(upload.buf, upload.currentSize); - } -#endif +#endif // USE_ZIGBEE_EZSP or USE_TASMOTA_CLIENT or SHELLY_FW_UPGRADE else { // firmware if (!Web.upload_error && (Update.write(upload.buf, upload.currentSize) != upload.currentSize)) { Web.upload_error = 5; // Upload buffer miscompare @@ -2989,33 +2976,19 @@ void HandleUploadLoop(void) return; } } -#if defined(USE_ZIGBEE) && defined(USE_ZIGBEE_EZSP) - else if (UPL_EFR32 == Web.upload_file_type) { - // Zigbee FW upload to ESP8266 flash is done - ZigbeeUploadDone(); // Signal upload done and ready for delayed upload to MCU EFR32 - Web.upload_file_type = UPL_TASMOTA; - } -#endif #ifdef USE_RF_FLASH else if (UPL_EFM8BB1 == Web.upload_file_type) { // RF FW flash done - Web.upload_file_type = UPL_TASMOTA; +// Web.upload_file_type = UPL_TASMOTA; } #endif // USE_RF_FLASH -#ifdef SHELLY_FW_UPGRADE - else if (UPL_SHD == Web.upload_file_type) { +#if defined(USE_ZIGBEE_EZSP) || defined(USE_TASMOTA_CLIENT) || defined(SHELLY_FW_UPGRADE) + else if ((UPL_EFR32 == Web.upload_file_type) || (UPL_TASMOTACLIENT == Web.upload_file_type) || (UPL_SHD == Web.upload_file_type)) { // Done writing the hex to SPI flash BUpload.ready = true; // So we know on upload success page if it needs to flash hex or do a normal restart - Web.upload_file_type = UPL_TASMOTA; +// Web.upload_file_type = UPL_TASMOTA; } -#endif // SHELLY_FW_UPGRADE -#ifdef USE_TASMOTA_CLIENT - else if (UPL_TASMOTACLIENT == Web.upload_file_type) { - // Done writing the hex to SPI flash - TasmotaClient_SetFlagFlashing(true); // So we know on upload success page if it needs to flash hex or do a normal restart - Web.upload_file_type = UPL_TASMOTA; - } -#endif +#endif // USE_ZIGBEE_EZSP or USE_TASMOTA_CLIENT or SHELLY_FW_UPGRADE else { if (!Update.end(true)) { // true to set the size to the current progress if (_serialoutput) { Update.printError(Serial); } diff --git a/tasmota/xdrv_23_zigbee_9a_upload.ino b/tasmota/xdrv_23_zigbee_9a_upload.ino index a4fcbf1ac..d3fff537d 100644 --- a/tasmota/xdrv_23_zigbee_9a_upload.ino +++ b/tasmota/xdrv_23_zigbee_9a_upload.ino @@ -46,7 +46,6 @@ const uint8_t PIN_ZIGBEE_BOOTLOADER = 5; struct ZBUPLOAD { uint32_t ota_size = 0; - uint32_t sector_cursor = 0; uint32_t sector_counter = 0; uint32_t byte_counter = 0; char *buffer; @@ -56,13 +55,9 @@ struct ZBUPLOAD { } ZbUpload; /*********************************************************************************************\ - * Flash + * Flash from ESP8266 to EZSP \*********************************************************************************************/ -uint32_t ZigbeeUploadFlashStart(void) { - return (ESP.getSketchSize() / SPI_FLASH_SEC_SIZE) + 2; -} - uint32_t ZigbeeUploadAvailable(void) { int available = ZbUpload.ota_size - ZbUpload.byte_counter; if (available < 0) { available = 0; } @@ -74,7 +69,6 @@ char ZigbeeUploadFlashRead(void) { if (!(ZbUpload.buffer = (char *)malloc(SPI_FLASH_SEC_SIZE))) { return (-1); // Not enough (memory) space } - ZbUpload.sector_counter = ZigbeeUploadFlashStart(); } uint32_t index = ZbUpload.byte_counter % SPI_FLASH_SEC_SIZE; @@ -461,50 +455,26 @@ bool ZigbeeUploadXmodem(void) { * Step 1 - Upload MCU firmware in ESP8266 flash free space (current size is about 200k) \*********************************************************************************************/ -bool ZigbeeUploadOtaReady(void) { - return (ZBU_INIT == ZbUpload.ota_step); -} +#ifdef USE_WEBSERVER -bool ZigbeeUploadFinish(void) { - return (ZBU_FINISH == ZbUpload.ota_step); -} - -uint8_t ZigbeeUploadInit(void) { +uint8_t ZigbeeUploadStep1Init(void) { if (!PinUsed(GPIO_ZIGBEE_RST) && (ZigbeeSerial == nullptr)) { return 1; } // Wrong pin configuration - No file selected - ZbUpload.sector_counter = ZigbeeUploadFlashStart(); - ZbUpload.sector_cursor = 0; - ZbUpload.ota_size = 0; ZbUpload.ota_step = ZBU_IDLE; ZbUpload.state = ZBU_IDLE; return 0; } -bool ZigbeeUploadWriteBuffer(uint8_t *buf, size_t size) { - // Read complete file into ESP8266 flash - // Current files are about 200k - if (0 == ZbUpload.sector_cursor) { // Starting a new sector write so we need to erase it first - ESP.flashEraseSector(ZbUpload.sector_counter); - } - ZbUpload.sector_cursor++; - ESP.flashWrite((ZbUpload.sector_counter * SPI_FLASH_SEC_SIZE) + ((ZbUpload.sector_cursor-1) * 2048), (uint32_t*)buf, size); - ZbUpload.ota_size += size; - if (2 == ZbUpload.sector_cursor) { // The web upload sends 2048 bytes at a time so keep track of the cursor position to reset it for the next flash sector erase - ZbUpload.sector_cursor = 0; - ZbUpload.sector_counter++; - if (ZbUpload.sector_counter > (SPIFFS_END -2)) { - return false; // File too large - Not enough free space - } - } - return true; -} - -void ZigbeeUploadDone(void) { +void ZigbeeUploadStep1Done(uint32_t data, size_t size) { + ZbUpload.sector_counter = data; + ZbUpload.ota_size = size; ZbUpload.ota_step = ZBU_INIT; - ZbUpload.state = ZBU_UPLOAD; + ZbUpload.state = ZBU_UPLOAD; // Signal upload done and ready for delayed upload to MCU EFR32 } -#ifdef USE_WEBSERVER +bool ZigbeeUploadFinish(void) { + return (ZBU_FINISH == ZbUpload.ota_step); +} #define WEB_HANDLE_ZIGBEE_XFER "zx" diff --git a/tasmota/xdrv_31_tasmota_client.ino b/tasmota/xdrv_31_tasmota_client.ino index 9ba136b8f..8df82703a 100644 --- a/tasmota/xdrv_31_tasmota_client.ino +++ b/tasmota/xdrv_31_tasmota_client.ino @@ -132,9 +132,6 @@ uint8_t SimpleHexParse::getByte(char* hexline, uint8_t idx) { */ struct TCLIENT { - uint32_t spi_hex_size = 0; - uint32_t spi_sector_counter = 0; - uint8_t spi_sector_cursor = 0; uint8_t inverted = LOW; bool type = false; bool flashing = false; @@ -200,17 +197,6 @@ struct TCLIENT_COMMAND { TasmotaSerial *TasmotaClient_Serial; -uint32_t TasmotaClient_FlashStart(void) { - return (ESP.getSketchSize() / SPI_FLASH_SEC_SIZE) + 2; // Stay on the safe side -} - -uint8_t TasmotaClient_UpdateInit(void) { - TClient.spi_hex_size = 0; - TClient.spi_sector_counter = TasmotaClient_FlashStart(); // Reset the pre-defined write address where firmware will temporarily be stored - TClient.spi_sector_cursor = 0; - return 0; -} - void TasmotaClient_Reset(void) { if (TClient.SerialEnabled) { digitalWrite(Pin(GPIO_TASMOTACLIENT_RST), !TClient.inverted); @@ -334,7 +320,7 @@ void TasmotaClient_FlashPage(uint8_t addr_h, uint8_t addr_l, uint8_t* data) { TasmotaClient_Serial->read(); } -void TasmotaClient_Flash(void) { +void TasmotaClient_Flash(uint32_t data, size_t size) { bool reading = true; uint32_t read = 0; uint32_t processed = 0; @@ -352,16 +338,16 @@ void TasmotaClient_Flash(void) { } flash_buffer = new char[SPI_FLASH_SEC_SIZE]; - uint32_t flash_start = TasmotaClient_FlashStart() * SPI_FLASH_SEC_SIZE; + uint32_t flash_start = data; while (reading) { ESP.flashRead(flash_start + read, (uint32_t*)flash_buffer, SPI_FLASH_SEC_SIZE); read = read + SPI_FLASH_SEC_SIZE; - if (read >= TClient.spi_hex_size) { + if (read >= size) { reading = false; } for (uint32_t ca = 0; ca < SPI_FLASH_SEC_SIZE; ca++) { processed++; - if ((processed <= TClient.spi_hex_size) && (!hexParse.EndOfFile)) { + if ((processed <= size) && (!hexParse.EndOfFile)) { if (':' == flash_buffer[ca]) { position = 0; } @@ -396,19 +382,6 @@ bool TasmotaClient_GetFlagFlashing(void) { return TClient.flashing; } -void TasmotaClient_WriteBuffer(uint8_t *buf, size_t size) { - if (0 == TClient.spi_sector_cursor) { // Starting a new sector write so we need to erase it first - ESP.flashEraseSector(TClient.spi_sector_counter); - } - TClient.spi_sector_cursor++; - ESP.flashWrite((TClient.spi_sector_counter * SPI_FLASH_SEC_SIZE) + ((TClient.spi_sector_cursor-1)*2048), (uint32_t*)buf, size); - TClient.spi_hex_size = TClient.spi_hex_size + size; - if (2 == TClient.spi_sector_cursor) { // The web upload sends 2048 bytes at a time so keep track of the cursor position to reset it for the next flash sector erase - TClient.spi_sector_cursor = 0; - TClient.spi_sector_counter++; - } -} - void TasmotaClient_Init(void) { if (TClient.type) { return;