Date: Fri, 20 Dec 2019 12:45:29 +0100
Subject: [PATCH 27/43] Update xdrv_29_deepsleep.ino
---
tasmota/xdrv_29_deepsleep.ino | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tasmota/xdrv_29_deepsleep.ino b/tasmota/xdrv_29_deepsleep.ino
index 78479bd5b..f0a8de685 100644
--- a/tasmota/xdrv_29_deepsleep.ino
+++ b/tasmota/xdrv_29_deepsleep.ino
@@ -103,7 +103,7 @@ void DeepSleepPrepare(void)
// if more then 10% timeslip = 0 == non valid wakeup; maybe manual
timeslip = (timeslip < -(int32_t)Settings.deepsleep) ? 0 : (timeslip > (int32_t)Settings.deepsleep) ? 0 : 1;
if (timeslip) {
- RtcSettings.deepsleep_slip = (Settings.deepsleep + RtcSettings.nextwakeup - UtcTime()) * RtcSettings.deepsleep_slip / tmax((Settings.deepsleep - (millis() / 1000),5));
+ RtcSettings.deepsleep_slip = (Settings.deepsleep + RtcSettings.nextwakeup - UtcTime()) * RtcSettings.deepsleep_slip / tmax((Settings.deepsleep - (millis() / 1000)),5);
// Avoid crazy numbers. Again maximum 10% deviation.
RtcSettings.deepsleep_slip = tmin(tmax(RtcSettings.deepsleep_slip, 9000), 11000);
RtcSettings.nextwakeup += Settings.deepsleep;
From 7459a8a4248c2991b6d39d066f1760d1dc66956c Mon Sep 17 00:00:00 2001
From: Theo Arends <11044339+arendst@users.noreply.github.com>
Date: Fri, 20 Dec 2019 15:12:44 +0100
Subject: [PATCH 28/43] Add restriction if fallback firmware is incompatible
Add restriction if fallback firmware is incompatible with settings resulting in unreachable device
---
RELEASENOTES.md | 1 +
tasmota/CHANGELOG.md | 1 +
tasmota/i18n.h | 4 ++++
tasmota/language/bg-BG.h | 1 +
tasmota/language/cs-CZ.h | 1 +
tasmota/language/de-DE.h | 1 +
tasmota/language/el-GR.h | 1 +
tasmota/language/en-GB.h | 3 ++-
tasmota/language/es-ES.h | 1 +
tasmota/language/fr-FR.h | 1 +
tasmota/language/he-HE.h | 1 +
tasmota/language/hu-HU.h | 1 +
tasmota/language/it-IT.h | 1 +
tasmota/language/ko-KO.h | 1 +
tasmota/language/nl-NL.h | 1 +
tasmota/language/pl-PL.h | 1 +
tasmota/language/pt-BR.h | 1 +
tasmota/language/pt-PT.h | 1 +
tasmota/language/ru-RU.h | 1 +
tasmota/language/sk-SK.h | 1 +
tasmota/language/sv-SE.h | 1 +
tasmota/language/tr-TR.h | 1 +
tasmota/language/uk-UK.h | 1 +
tasmota/language/zh-CN.h | 1 +
tasmota/language/zh-TW.h | 1 +
tasmota/settings.ino | 38 +++++++++++++++++++++++++++++++++++
tasmota/support_tasmota.ino | 14 ++++++++++---
tasmota/tasmota.ino | 2 ++
tasmota/tasmota_version.h | 3 +++
tasmota/xdrv_01_webserver.ino | 10 +++++++--
30 files changed, 91 insertions(+), 6 deletions(-)
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index 4360e8ee3..9224a1825 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -73,3 +73,4 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
- Add Zigbee support for Xiaomi Aqara Vibration Sensor and Presence Sensor by Stefan Hadinger
- Add Shutter functions ramp up/down and MQTT reporting by Stefan Bode
- Add fallback support from version 8.x
+- Add restriction if fallback firmware is incompatible with settings resulting in unreachable device
diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md
index 1bf38a0ec..2d5ae9077 100644
--- a/tasmota/CHANGELOG.md
+++ b/tasmota/CHANGELOG.md
@@ -7,6 +7,7 @@
- Add Zigbee send automatic ZigbeeRead after sending a command
- Add Zigbee improving Occupancy:false detection for Aqara sensor
- Add fallback support from version 8.x
+- Add restriction if fallback firmware is incompatible with settings resulting in unreachable device
### 7.1.2.5 20191213
diff --git a/tasmota/i18n.h b/tasmota/i18n.h
index fed6930d7..1844dd44b 100644
--- a/tasmota/i18n.h
+++ b/tasmota/i18n.h
@@ -635,4 +635,8 @@ const char S_INFORMATION[] PROGMEM = D_INFORMATION;
const char S_RESTART[] PROGMEM = D_RESTART;
#endif // USE_WEBSERVER
+const uint32_t MARKER_START = 0x5AA55AA5;
+const uint32_t MARKER_END = 0xA55AA55A;
+const uint32_t VERSION_MARKER[] PROGMEM = { MARKER_START, VERSION, MARKER_END };
+
#endif // _I18N_H_
diff --git a/tasmota/language/bg-BG.h b/tasmota/language/bg-BG.h
index 1f18d8efb..251a840e8 100644
--- a/tasmota/language/bg-BG.h
+++ b/tasmota/language/bg-BG.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "Грешка при изтриване на RF чипа"
#define D_UPLOAD_ERR_12 "Грешка при записване в RF чипа"
#define D_UPLOAD_ERR_13 "Грешка при декодиране на RF фърмуера"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "Код на грешка при зареждането"
#define D_ENTER_COMMAND "Въвеждане на команда"
diff --git a/tasmota/language/cs-CZ.h b/tasmota/language/cs-CZ.h
index 1d7c6f381..79ba068ab 100644
--- a/tasmota/language/cs-CZ.h
+++ b/tasmota/language/cs-CZ.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "Chyba smazání RF chipu"
#define D_UPLOAD_ERR_12 "Chyba při zápisu do RF chipu"
#define D_UPLOAD_ERR_13 "Chyba dekódování RF firmwaru"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "Chyba nahrávání"
#define D_ENTER_COMMAND "Vlož příkaz"
diff --git a/tasmota/language/de-DE.h b/tasmota/language/de-DE.h
index 6569dd232..3cb7786af 100644
--- a/tasmota/language/de-DE.h
+++ b/tasmota/language/de-DE.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "RF Chip löschen fehlgeschlagen"
#define D_UPLOAD_ERR_12 "RF Chip beschreiben fehlgeschlagen"
#define D_UPLOAD_ERR_13 "RF Firmware ungültig"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "Upload Fehler Nummer"
#define D_ENTER_COMMAND "Befehl eingeben"
diff --git a/tasmota/language/el-GR.h b/tasmota/language/el-GR.h
index f8b9c9614..3bea69d8f 100644
--- a/tasmota/language/el-GR.h
+++ b/tasmota/language/el-GR.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "Αποτυχία σβησίματος στο RF chip"
#define D_UPLOAD_ERR_12 "Αποτυχία εγγραφής στο RF chip"
#define D_UPLOAD_ERR_13 "Failed to decode RF firmware"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "Κωδικός λάθους στη μεταφόρτωση"
#define D_ENTER_COMMAND "Εισαγωγή εντολής"
diff --git a/tasmota/language/en-GB.h b/tasmota/language/en-GB.h
index 257a34c86..d64632603 100644
--- a/tasmota/language/en-GB.h
+++ b/tasmota/language/en-GB.h
@@ -28,7 +28,7 @@
* Use online command StateText to translate ON, OFF, HOLD and TOGGLE.
* Use online command Prefix to translate cmnd, stat and tele.
*
- * Updated until v6.2.1.11
+ * Updated until v8.0.0.0
\*********************************************************************/
//#define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English)
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "Failed to erase RF chip"
#define D_UPLOAD_ERR_12 "Failed to write to RF chip"
#define D_UPLOAD_ERR_13 "Failed to decode RF firmware"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "Upload error code"
#define D_ENTER_COMMAND "Enter command"
diff --git a/tasmota/language/es-ES.h b/tasmota/language/es-ES.h
index 7527bb77a..b0c9477de 100644
--- a/tasmota/language/es-ES.h
+++ b/tasmota/language/es-ES.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "No se pudo borrar en el chip RF"
#define D_UPLOAD_ERR_12 "No se puedo escribir en el chip RF"
#define D_UPLOAD_ERR_13 "No se pudo decodificar firmware RF"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "Código de error de carga"
#define D_ENTER_COMMAND "Ingresar comando"
diff --git a/tasmota/language/fr-FR.h b/tasmota/language/fr-FR.h
index e107409e3..48576002e 100644
--- a/tasmota/language/fr-FR.h
+++ b/tasmota/language/fr-FR.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "Erreur d'effacement du chip RF"
#define D_UPLOAD_ERR_12 "Erreur d'accès en écriture au chip RF"
#define D_UPLOAD_ERR_13 "Erreur de décodage du firmware RF"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "Code d'erreur téléchargement"
#define D_ENTER_COMMAND "Saisir une commande"
diff --git a/tasmota/language/he-HE.h b/tasmota/language/he-HE.h
index ac4dadb8e..1d4a1b549 100644
--- a/tasmota/language/he-HE.h
+++ b/tasmota/language/he-HE.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "נכשלה RF מחיקת שבב"
#define D_UPLOAD_ERR_12 "נכשלה RF כתיבת שבב"
#define D_UPLOAD_ERR_13 "נכשלה RF קידוד קושחת שבב"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "שגיאת קוד העלאה"
#define D_ENTER_COMMAND "הקש פקודה"
diff --git a/tasmota/language/hu-HU.h b/tasmota/language/hu-HU.h
index 62806fa46..111558516 100644
--- a/tasmota/language/hu-HU.h
+++ b/tasmota/language/hu-HU.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "Az RF chip törlése sikertelen"
#define D_UPLOAD_ERR_12 "Az RF chip írása sikertelen"
#define D_UPLOAD_ERR_13 "Az RF firmware dekódolása sikertelen"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "Feltöltési hibakód"
#define D_ENTER_COMMAND "Kérem a parancsot..."
diff --git a/tasmota/language/it-IT.h b/tasmota/language/it-IT.h
index 0585c12d8..edf9b92c2 100644
--- a/tasmota/language/it-IT.h
+++ b/tasmota/language/it-IT.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "Cancellazione fallita del chip RF"
#define D_UPLOAD_ERR_12 "Scrittura fallita del chip RF"
#define D_UPLOAD_ERR_13 "Decodifica fallita del firmware RF"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "Codice errore invio"
#define D_ENTER_COMMAND "Inserire comando"
diff --git a/tasmota/language/ko-KO.h b/tasmota/language/ko-KO.h
index bff508474..4e20860f5 100644
--- a/tasmota/language/ko-KO.h
+++ b/tasmota/language/ko-KO.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "RF 칩 삭제 실패"
#define D_UPLOAD_ERR_12 "RF 칩 쓰기 실패"
#define D_UPLOAD_ERR_13 "RF 펌웨어 decode 실패"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "업로드 에러 코드"
#define D_ENTER_COMMAND "커맨드 입력"
diff --git a/tasmota/language/nl-NL.h b/tasmota/language/nl-NL.h
index 75d841ddc..e49b71ca1 100644
--- a/tasmota/language/nl-NL.h
+++ b/tasmota/language/nl-NL.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "Wissen RF chip mislukt"
#define D_UPLOAD_ERR_12 "Opwaarderen RF chip mislukt"
#define D_UPLOAD_ERR_13 "Decoderen RF bestand mislukt"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "Opwaardeer foutcode"
#define D_ENTER_COMMAND "Geef opdracht"
diff --git a/tasmota/language/pl-PL.h b/tasmota/language/pl-PL.h
index 8f5af6813..a2aada42b 100644
--- a/tasmota/language/pl-PL.h
+++ b/tasmota/language/pl-PL.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "Błąd kasowania układu RF"
#define D_UPLOAD_ERR_12 "Błąd zapisu układu RF"
#define D_UPLOAD_ERR_13 "Błąd dekodowania oprrogramowania układu RF"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "Błąd wgrywania"
#define D_ENTER_COMMAND "Wprowadź polecenie"
diff --git a/tasmota/language/pt-BR.h b/tasmota/language/pt-BR.h
index 0efa57789..ae808ef9e 100644
--- a/tasmota/language/pt-BR.h
+++ b/tasmota/language/pt-BR.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "Falha ao apagar o chip RF"
#define D_UPLOAD_ERR_12 "Falha ao escrever o chip RF"
#define D_UPLOAD_ERR_13 "Falha ao decodificar o firmware de RF"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "Código de erro do envio"
#define D_ENTER_COMMAND "Inserir comando"
diff --git a/tasmota/language/pt-PT.h b/tasmota/language/pt-PT.h
index a6299c0c8..e6684232c 100644
--- a/tasmota/language/pt-PT.h
+++ b/tasmota/language/pt-PT.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "Falha ao apagar o chip de RF"
#define D_UPLOAD_ERR_12 "Falha ao escrever no chip de RF"
#define D_UPLOAD_ERR_13 "Falha ao descodificar o firmware RF"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "Código de erro do envio"
#define D_ENTER_COMMAND "Inserir comando"
diff --git a/tasmota/language/ru-RU.h b/tasmota/language/ru-RU.h
index 3bd788ede..cd5c072aa 100644
--- a/tasmota/language/ru-RU.h
+++ b/tasmota/language/ru-RU.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "Failed to erase RF chip"
#define D_UPLOAD_ERR_12 "Failed to write to RF chip"
#define D_UPLOAD_ERR_13 "Failed to decode RF firmware"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "Код ошибки загрузки"
#define D_ENTER_COMMAND "Введите команду"
diff --git a/tasmota/language/sk-SK.h b/tasmota/language/sk-SK.h
index a64e49e01..ef16212ca 100644
--- a/tasmota/language/sk-SK.h
+++ b/tasmota/language/sk-SK.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "Chyba zmazania RF chipu"
#define D_UPLOAD_ERR_12 "Chyba pri zápise do RF chipu"
#define D_UPLOAD_ERR_13 "Chyba dekódovania RF firmwaru"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "Chyba nahrávania"
#define D_ENTER_COMMAND "Vlož príkaz"
diff --git a/tasmota/language/sv-SE.h b/tasmota/language/sv-SE.h
index 51ffc2ae3..971ee42b1 100644
--- a/tasmota/language/sv-SE.h
+++ b/tasmota/language/sv-SE.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "Misslyckades rensa RF chip"
#define D_UPLOAD_ERR_12 "Misslyckades skriva till RF chip"
#define D_UPLOAD_ERR_13 "Misslyckades avkoda RF firmware"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "Uppladdningsfelkod"
#define D_ENTER_COMMAND "Ange kommando"
diff --git a/tasmota/language/tr-TR.h b/tasmota/language/tr-TR.h
index 6bc48c40f..67400d1cc 100644
--- a/tasmota/language/tr-TR.h
+++ b/tasmota/language/tr-TR.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "Failed to erase RF chip"
#define D_UPLOAD_ERR_12 "Failed to write to RF chip"
#define D_UPLOAD_ERR_13 "Failed to decode RF firmware"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "Upload error code"
#define D_ENTER_COMMAND "Komut girişi"
diff --git a/tasmota/language/uk-UK.h b/tasmota/language/uk-UK.h
index b4a314630..b81f30012 100644
--- a/tasmota/language/uk-UK.h
+++ b/tasmota/language/uk-UK.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "Помилка стирання чипу RF"
#define D_UPLOAD_ERR_12 "Помилка запису чипу RF"
#define D_UPLOAD_ERR_13 "Помилка розкодування прошивки RF"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "Код помилки завантаження"
#define D_ENTER_COMMAND "Уведіть команду"
diff --git a/tasmota/language/zh-CN.h b/tasmota/language/zh-CN.h
index 21aa63be3..665f39fc3 100644
--- a/tasmota/language/zh-CN.h
+++ b/tasmota/language/zh-CN.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "擦除 RF 芯片失败"
#define D_UPLOAD_ERR_12 "写入 RF 芯片失败"
#define D_UPLOAD_ERR_13 "解码 RF 固件失败"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "上传错误代码"
#define D_ENTER_COMMAND "输入命令"
diff --git a/tasmota/language/zh-TW.h b/tasmota/language/zh-TW.h
index 1d78f181e..6f56e03df 100644
--- a/tasmota/language/zh-TW.h
+++ b/tasmota/language/zh-TW.h
@@ -353,6 +353,7 @@
#define D_UPLOAD_ERR_11 "Failed to erase RF chip"
#define D_UPLOAD_ERR_12 "Failed to write to RF chip"
#define D_UPLOAD_ERR_13 "Failed to decode RF firmware"
+#define D_UPLOAD_ERR_14 "Not compatible"
#define D_UPLOAD_ERROR_CODE "上傳錯誤代碼"
#define D_ENTER_COMMAND "輸入命令"
diff --git a/tasmota/settings.ino b/tasmota/settings.ino
index d921e4957..b572ca645 100644
--- a/tasmota/settings.ino
+++ b/tasmota/settings.ino
@@ -343,6 +343,44 @@ void SetFlashModeDout(void)
delete[] _buffer;
}
+uint32_t OtaVersion(void)
+{
+ eboot_command ebcmd;
+ eboot_command_read(&ebcmd);
+ uint32_t start_address = ebcmd.args[0];
+ uint32_t end_address = start_address + (ebcmd.args[2] & 0xFFFFF000) + FLASH_SECTOR_SIZE;
+ uint32_t* buffer = new uint32_t[FLASH_SECTOR_SIZE / 4];
+
+ uint32_t version[3] = { 0 };
+ bool found = false;
+ for (uint32_t address = start_address; address < end_address; address = address + FLASH_SECTOR_SIZE) {
+ ESP.flashRead(address, (uint32_t*)buffer, FLASH_SECTOR_SIZE);
+ for (uint32_t i = 0; i < (FLASH_SECTOR_SIZE / 4); i++) {
+ version[0] = version[1];
+ version[1] = version[2];
+ version[2] = buffer[i];
+ if ((version[0] == MARKER_START) && (version[2] == MARKER_END)) {
+ found = true;
+ break;
+ }
+ }
+ if (found) { break; }
+ }
+ delete[] buffer;
+
+ if (!found) { version[1] = 0; }
+
+ AddLog_P2(LOG_LEVEL_DEBUG, PSTR("OTA: Version 0x%08X, Compatible 0x%08X"), version[1], VERSION_COMPATIBLE);
+
+ return version[1];
+}
+
+void AbandonOta(void)
+{
+ uint32_t eboot_magic = 0;
+ ESP.rtcUserMemoryWrite(0, (uint32_t*)&eboot_magic, sizeof(eboot_magic));
+}
+
void SettingsBufferFree(void)
{
if (settings_buffer != nullptr) {
diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino
index 0935d9a28..08b898efb 100644
--- a/tasmota/support_tasmota.ino
+++ b/tasmota/support_tasmota.ino
@@ -866,13 +866,21 @@ void Every250mSeconds(void)
}
if (90 == ota_state_flag) { // Allow MQTT to reconnect
ota_state_flag = 0;
+ Response_P(PSTR("{\"" D_CMND_UPGRADE "\":\""));
if (ota_result) {
// SetFlashModeDout(); // Force DOUT for both ESP8266 and ESP8285
- Response_P(PSTR(D_JSON_SUCCESSFUL ". " D_JSON_RESTARTING));
+ if (OtaVersion() < VERSION_COMPATIBLE) {
+ AbandonOta();
+ ResponseAppend_P(PSTR(D_JSON_FAILED " " D_UPLOAD_ERR_14));
+ } else {
+ ResponseAppend_P(PSTR(D_JSON_SUCCESSFUL ". " D_JSON_RESTARTING));
+ restart_flag = 2;
+ }
} else {
- Response_P(PSTR(D_JSON_FAILED " %s"), ESPhttpUpdate.getLastErrorString().c_str());
+ ResponseAppend_P(PSTR(D_JSON_FAILED " %s"), ESPhttpUpdate.getLastErrorString().c_str());
}
- restart_flag = 2; // Restart anyway to keep memory clean webserver
+ ResponseAppend_P(PSTR("\"}"));
+// restart_flag = 2; // Restart anyway to keep memory clean webserver
MqttPublishPrefixTopic_P(STAT, PSTR(D_CMND_UPGRADE));
}
}
diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino
index 3b9e64a25..67be9d35f 100644
--- a/tasmota/tasmota.ino
+++ b/tasmota/tasmota.ino
@@ -334,6 +334,8 @@ void setup(void)
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_WARNING_MINIMAL_VERSION));
#endif // FIRMWARE_MINIMAL
+ memcpy_P(log_data, VERSION_MARKER, 1); // Dummy for compiler saving VERSION_MARKER
+
RtcInit();
#ifdef USE_ARDUINO_OTA
diff --git a/tasmota/tasmota_version.h b/tasmota/tasmota_version.h
index a083dad4b..84ff6d905 100644
--- a/tasmota/tasmota_version.h
+++ b/tasmota/tasmota_version.h
@@ -22,4 +22,7 @@
const uint32_t VERSION = 0x07010206;
+// Lowest compatible version
+const uint32_t VERSION_COMPATIBLE = 0x06000000;
+
#endif // _TASMOTA_VERSION_H_
diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino
index 9c8131ad3..fe10e4cd3 100644
--- a/tasmota/xdrv_01_webserver.ino
+++ b/tasmota/xdrv_01_webserver.ino
@@ -511,6 +511,8 @@ const char kUploadErrors[] PROGMEM =
D_UPLOAD_ERR_1 "|" D_UPLOAD_ERR_2 "|" D_UPLOAD_ERR_3 "|" D_UPLOAD_ERR_4 "|" D_UPLOAD_ERR_5 "|" D_UPLOAD_ERR_6 "|" D_UPLOAD_ERR_7 "|" D_UPLOAD_ERR_8 "|" D_UPLOAD_ERR_9
#ifdef USE_RF_FLASH
"|" D_UPLOAD_ERR_10 "|" D_UPLOAD_ERR_11 "|" D_UPLOAD_ERR_12 "|" D_UPLOAD_ERR_13
+#else
+ "|" D_UPLOAD_ERR_14
#endif
;
@@ -2137,12 +2139,11 @@ void HandleUploadDone(void)
WSContentSendStyle();
WSContentSend_P(PSTR("" D_UPLOAD " " D_FAILED "
"));
WSContentSend_P(PSTR("%06x'>" D_FAILED "
"), WebColor(COL_TEXT_WARNING));
#ifdef USE_RF_FLASH
if (Web.upload_error < 14) {
#else
- if (Web.upload_error < 10) {
+ if (Web.upload_error < 11) {
#endif
GetTextIndexed(error, sizeof(error), Web.upload_error -1, kUploadErrors);
} else {
@@ -2376,6 +2377,11 @@ void HandleUploadLoop(void)
Web.upload_error = 6; // Upload failed. Enable logging 3
return;
}
+ if (OtaVersion() < VERSION_COMPATIBLE) {
+ AbandonOta();
+ Web.upload_error = 10; // Not compatible
+ return;
+ }
}
if (!Web.upload_error) {
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD D_SUCCESSFUL " %u bytes. " D_RESTARTING), upload.totalSize);
From 72849f672e907ca5ed43c697fb13cf57a065c1f5 Mon Sep 17 00:00:00 2001
From: Theo Arends <11044339+arendst@users.noreply.github.com>
Date: Fri, 20 Dec 2019 15:48:40 +0100
Subject: [PATCH 29/43] Add support for DHT12
- Fix DeepSleep in case there is no wifi by Stefan Bode (#7213)
- Add support for DHT12 Temperature and Humidity sensor by Stefan Oskamp
---
BUILDS.md | 1 +
RELEASENOTES.md | 2 ++
tasmota/CHANGELOG.md | 2 ++
tasmota/support_features.ino | 4 +++-
tools/decode-status.py | 2 +-
5 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/BUILDS.md b/BUILDS.md
index d21fd9f15..3b311a6eb 100644
--- a/BUILDS.md
+++ b/BUILDS.md
@@ -106,6 +106,7 @@
| USE_PAJ7620 | - | - | - | - | - | - | - |
| USE_PCF8574 | - | - | - | - | - | - | - |
| USE_HIH6 | - | - | - | - | x | - | - |
+| USE_DHT12 | - | - | - | - | x | - | - |
| | | | | | | | |
| Feature or Sensor | minimal | lite | tasmota | knx | sensors | ir | display | Remarks
| USE_SPI | - | - | - | - | - | - | x |
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index 9224a1825..234258dab 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -58,6 +58,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
- Fix flashing H801 led at boot by Stefan Hadinger (#7165, #649)
- Fix duplicated ``Backlog`` when using Event inside a Backlog by Adrian Scillato (#7178, #7147)
- Fix Gui Timer when using a negative zero offset of -00:00 by Peter Ooms (#7174)
+- Fix DeepSleep in case there is no wifi by Stefan Bode (#7213)
- Add command ``SerialConfig 0..23`` or ``SerialConfig 8N1`` to select Serial Config based in PR by Luis Teixeira (#7108)
- Add command ``Sensor34 9 `` to set minimum delta to trigger JSON message by @tobox (#7188)
- Add rule var ``%topic%`` by Adrian Scillato (#5522)
@@ -74,3 +75,4 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
- Add Shutter functions ramp up/down and MQTT reporting by Stefan Bode
- Add fallback support from version 8.x
- Add restriction if fallback firmware is incompatible with settings resulting in unreachable device
+- Add support for DHT12 Temperature and Humidity sensor by Stefan Oskamp
diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md
index 2d5ae9077..2b32857c2 100644
--- a/tasmota/CHANGELOG.md
+++ b/tasmota/CHANGELOG.md
@@ -4,10 +4,12 @@
- Change some more Settings locations freeing up space for future single char allowing variable length text
- Change tasmota-basic.bin and FIRMWARE_BASIC to tasmota-lite.bin and FIRMWARE_LITE
+- Fix DeepSleep in case there is no wifi by Stefan Bode (#7213)
- Add Zigbee send automatic ZigbeeRead after sending a command
- Add Zigbee improving Occupancy:false detection for Aqara sensor
- Add fallback support from version 8.x
- Add restriction if fallback firmware is incompatible with settings resulting in unreachable device
+- Add support for DHT12 Temperature and Humidity sensor by Stefan Oskamp
### 7.1.2.5 20191213
diff --git a/tasmota/support_features.ino b/tasmota/support_features.ino
index be4c8f6a4..31428d03b 100644
--- a/tasmota/support_features.ino
+++ b/tasmota/support_features.ino
@@ -489,7 +489,9 @@ void GetFeatures(void)
#ifdef USE_TSL2591
feature5 |= 0x00080000;
#endif
-// feature5 |= 0x00100000;
+#ifdef USE_DHT12
+ feature5 |= 0x00100000;
+#endif
// feature5 |= 0x00200000;
// feature5 |= 0x00400000;
// feature5 |= 0x00800000;
diff --git a/tools/decode-status.py b/tools/decode-status.py
index be79cf921..e6751ae92 100755
--- a/tools/decode-status.py
+++ b/tools/decode-status.py
@@ -187,7 +187,7 @@ a_features = [[
"USE_SHUTTER","USE_PCF8574","USE_DDSU666","USE_DEEPSLEEP",
"USE_SONOFF_SC","USE_SONOFF_RF","USE_SONOFF_L1","USE_EXS_DIMMER",
"USE_ARDUINO_SLAVE","USE_HIH6","USE_HPMA","USE_TSL2591",
- "","","","",
+ "USE_DHT12","","","",
"","","","",
"","","",""
]]
From 18bc158bc84ca2d3c7c713e106dabf8329fa0920 Mon Sep 17 00:00:00 2001
From: Hadinger
Date: Fri, 20 Dec 2019 16:01:24 +0100
Subject: [PATCH 30/43] Fix Fade would ignore ``savedata 0`` and store to flash
anyways (#7262)
---
tasmota/CHANGELOG.md | 1 +
tasmota/xdrv_04_light.ino | 12 +++++++-----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md
index 2b32857c2..f14c46658 100644
--- a/tasmota/CHANGELOG.md
+++ b/tasmota/CHANGELOG.md
@@ -10,6 +10,7 @@
- Add fallback support from version 8.x
- Add restriction if fallback firmware is incompatible with settings resulting in unreachable device
- Add support for DHT12 Temperature and Humidity sensor by Stefan Oskamp
+- Fix Fade would ignore ``savedata 0`` and store to flash anyways (#7262)
### 7.1.2.5 20191213
diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino
index 7f1e66fc6..6148a9aad 100644
--- a/tasmota/xdrv_04_light.ino
+++ b/tasmota/xdrv_04_light.ino
@@ -1766,11 +1766,13 @@ void LightApplyFade(void) {
// Note: Settings.light_speed is the number of half-seconds for a 100% fade,
// i.e. light_speed=1 means 1024 steps in 10 ticks (500ms)
Light.fade_duration = (distance * Settings.light_speed * 10) / 1024;
- // Also postpone the save_data for the duration of the Fade (in seconds)
- uint32_t delay_seconds = 1 + (Light.fade_duration + 19) / 20; // add one more second
- // AddLog_P2(LOG_LEVEL_INFO, PSTR("delay_seconds %d, save_data_counter %d"), delay_seconds, save_data_counter);
- if (save_data_counter < delay_seconds) {
- save_data_counter = delay_seconds; // pospone
+ if (Settings.save_data) {
+ // Also postpone the save_data for the duration of the Fade (in seconds)
+ uint32_t delay_seconds = 1 + (Light.fade_duration + 19) / 20; // add one more second
+ // AddLog_P2(LOG_LEVEL_INFO, PSTR("delay_seconds %d, save_data_counter %d"), delay_seconds, save_data_counter);
+ if (save_data_counter < delay_seconds) {
+ save_data_counter = delay_seconds; // pospone
+ }
}
} else {
// no fade needed, we keep the duration at zero, it will fallback directly to end of fade
From 70a2c2cd20cb5a6003151f1cdf05a9232bd7a1da Mon Sep 17 00:00:00 2001
From: Theo Arends <11044339+arendst@users.noreply.github.com>
Date: Fri, 20 Dec 2019 16:22:49 +0100
Subject: [PATCH 31/43] Fix Fade
---
RELEASENOTES.md | 3 +++
tasmota/CHANGELOG.md | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index 234258dab..56c4e2c07 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -14,6 +14,8 @@ See [migration path](https://tasmota.github.io/docs/#/Upgrading?id=migration-pat
4. Migrate to **Sonoff-Tasmota 6.x**
5. Migrate to **Tasmota 7.x**
+Only this version will support fallback from version 8.x.
+
## Supported Core versions
This release will be supported from ESP8266/Arduino library Core version **2.6.1** due to reported security and stability issues on previous Core version.
@@ -59,6 +61,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
- Fix duplicated ``Backlog`` when using Event inside a Backlog by Adrian Scillato (#7178, #7147)
- Fix Gui Timer when using a negative zero offset of -00:00 by Peter Ooms (#7174)
- Fix DeepSleep in case there is no wifi by Stefan Bode (#7213)
+- Fix Fade would ignore ``savedata 0`` and store to flash anyways (#7262)
- Add command ``SerialConfig 0..23`` or ``SerialConfig 8N1`` to select Serial Config based in PR by Luis Teixeira (#7108)
- Add command ``Sensor34 9 `` to set minimum delta to trigger JSON message by @tobox (#7188)
- Add rule var ``%topic%`` by Adrian Scillato (#5522)
diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md
index f14c46658..d847aef5b 100644
--- a/tasmota/CHANGELOG.md
+++ b/tasmota/CHANGELOG.md
@@ -5,12 +5,12 @@
- Change some more Settings locations freeing up space for future single char allowing variable length text
- Change tasmota-basic.bin and FIRMWARE_BASIC to tasmota-lite.bin and FIRMWARE_LITE
- Fix DeepSleep in case there is no wifi by Stefan Bode (#7213)
+- Fix Fade would ignore ``savedata 0`` and store to flash anyways (#7262)
- Add Zigbee send automatic ZigbeeRead after sending a command
- Add Zigbee improving Occupancy:false detection for Aqara sensor
- Add fallback support from version 8.x
- Add restriction if fallback firmware is incompatible with settings resulting in unreachable device
- Add support for DHT12 Temperature and Humidity sensor by Stefan Oskamp
-- Fix Fade would ignore ``savedata 0`` and store to flash anyways (#7262)
### 7.1.2.5 20191213
From 74d0f55ce725f578de6ab27b0d0f4ff68eb9cb82 Mon Sep 17 00:00:00 2001
From: Theo Arends <11044339+arendst@users.noreply.github.com>
Date: Fri, 20 Dec 2019 16:36:08 +0100
Subject: [PATCH 32/43] Update languages
---
tasmota/language/de-DE.h | 4 ++--
tasmota/language/nl-NL.h | 22 +++++++++++-----------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/tasmota/language/de-DE.h b/tasmota/language/de-DE.h
index 3cb7786af..c61da0932 100644
--- a/tasmota/language/de-DE.h
+++ b/tasmota/language/de-DE.h
@@ -28,7 +28,7 @@
* Use online command StateText to translate ON, OFF, HOLD and TOGGLE.
* Use online command Prefix to translate cmnd, stat and tele.
*
- * Updated until v6.6.0.21
+ * Updated until v8.0.0
\*********************************************************************/
//#define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English)
@@ -353,7 +353,7 @@
#define D_UPLOAD_ERR_11 "RF Chip löschen fehlgeschlagen"
#define D_UPLOAD_ERR_12 "RF Chip beschreiben fehlgeschlagen"
#define D_UPLOAD_ERR_13 "RF Firmware ungültig"
-#define D_UPLOAD_ERR_14 "Not compatible"
+#define D_UPLOAD_ERR_14 "Nicht kompatibel"
#define D_UPLOAD_ERROR_CODE "Upload Fehler Nummer"
#define D_ENTER_COMMAND "Befehl eingeben"
diff --git a/tasmota/language/nl-NL.h b/tasmota/language/nl-NL.h
index e49b71ca1..40222e65f 100644
--- a/tasmota/language/nl-NL.h
+++ b/tasmota/language/nl-NL.h
@@ -28,7 +28,7 @@
* Use online command StateText to translate ON, OFF, HOLD and TOGGLE.
* Use online command Prefix to translate cmnd, stat and tele.
*
- * Updated until v6.7.0
+ * Updated until v8.0.0
\*********************************************************************/
//#define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English)
@@ -353,7 +353,7 @@
#define D_UPLOAD_ERR_11 "Wissen RF chip mislukt"
#define D_UPLOAD_ERR_12 "Opwaarderen RF chip mislukt"
#define D_UPLOAD_ERR_13 "Decoderen RF bestand mislukt"
-#define D_UPLOAD_ERR_14 "Not compatible"
+#define D_UPLOAD_ERR_14 "Niet geschikt"
#define D_UPLOAD_ERROR_CODE "Opwaardeer foutcode"
#define D_ENTER_COMMAND "Geef opdracht"
@@ -479,12 +479,12 @@
#define D_PARTICALS_BEYOND "Stofdeeltjes"
// xsns_32_mpu6050.ino
-#define D_AX_AXIS "Accel. X-Axis"
-#define D_AY_AXIS "Accel. Y-Axis"
-#define D_AZ_AXIS "Accel. Z-Axis"
-#define D_GX_AXIS "Gyro X-Axis"
-#define D_GY_AXIS "Gyro Y-Axis"
-#define D_GZ_AXIS "Gyro Z-Axis"
+#define D_AX_AXIS "Versn. X-as"
+#define D_AY_AXIS "Versn. Y-as"
+#define D_AZ_AXIS "Versn. Z-as"
+#define D_GX_AXIS "Gyro X-as"
+#define D_GY_AXIS "Gyro Y-as"
+#define D_GZ_AXIS "Gyro Z-as"
// xsns_34_hx711.ino
#define D_HX_CAL_REMOVE "Verwijder gewicht"
@@ -627,9 +627,9 @@
#define D_SENSOR_SM2135_DAT "SM2135 Dat"
#define D_SENSOR_DEEPSLEEP "DeepSleep"
#define D_SENSOR_EXS_ENABLE "EXS Enable"
-#define D_SENSOR_SLAVE_TX "Slave TX"
-#define D_SENSOR_SLAVE_RX "Slave RX"
-#define D_SENSOR_SLAVE_RESET "Slave RST"
+#define D_SENSOR_SLAVE_TX "Slave TX"
+#define D_SENSOR_SLAVE_RX "Slave RX"
+#define D_SENSOR_SLAVE_RESET "Slave RST"
// Units
#define D_UNIT_AMPERE "A"
From 7e24ed9c2cd6886c80dadb3a35b70faea849c73c Mon Sep 17 00:00:00 2001
From: Theo Arends <11044339+arendst@users.noreply.github.com>
Date: Fri, 20 Dec 2019 18:24:20 +0100
Subject: [PATCH 33/43] Fix error message
---
tasmota/settings.h | 4 ++--
tasmota/settings.ino | 4 ++++
tasmota/xdrv_01_webserver.ino | 10 +++++-----
3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/tasmota/settings.h b/tasmota/settings.h
index af74422df..8b7fe2822 100644
--- a/tasmota/settings.h
+++ b/tasmota/settings.h
@@ -91,7 +91,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t grouptopic_mode : 1; // bit 25 (v7.0.0.1) - SetOption75 - GroupTopic replaces %topic% (0) or fixed topic cmnd/grouptopic (1)
uint32_t bootcount_update : 1; // bit 26 (v7.0.0.4) - SetOption76 - Enable incrementing bootcount when deepsleep is enabled
uint32_t slider_dimmer_stay_on : 1; // bit 27 (v7.0.0.6) - SetOption77 - Do not power off if slider moved to far left
- uint32_t spare28 : 1;
+ uint32_t compatibility_check : 1; // bit 28 (v7.1.2.6) - SetOption78 - Disable OTA compatibility check
uint32_t spare29 : 1;
uint32_t shutter_mode : 1; // bit 30 (v6.6.0.14) - SetOption80 - Enable shutter support
uint32_t pcf8574_ports_inverted : 1; // bit 31 (v6.6.0.14) - SetOption81 - Invert all ports on PCF8574 devices
@@ -428,7 +428,7 @@ struct SYSCFG {
unsigned long weight_calibration; // 7C4
unsigned long energy_frequency_calibration; // 7C8 also used by HX711 to save last weight
uint16_t web_refresh; // 7CC
- char mems[MAX_RULE_MEMS][10]; // 7CE
+ char mems[MAX_RULE_MEMS][10]; // 7CE - Used by scripter as script_pram
char rules[MAX_RULE_SETS][MAX_RULE_SIZE]; // 800 uses 512 bytes in v5.12.0m, 3 x 512 bytes in v5.14.0b
diff --git a/tasmota/settings.ino b/tasmota/settings.ino
index b572ca645..afbd7b223 100644
--- a/tasmota/settings.ino
+++ b/tasmota/settings.ino
@@ -345,6 +345,10 @@ void SetFlashModeDout(void)
uint32_t OtaVersion(void)
{
+ if (Settings.flag3.compatibility_check) {
+ return 0xFFFFFFFF;
+ }
+
eboot_command ebcmd;
eboot_command_read(&ebcmd);
uint32_t start_address = ebcmd.args[0];
diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino
index fe10e4cd3..6b0edd8cb 100644
--- a/tasmota/xdrv_01_webserver.ino
+++ b/tasmota/xdrv_01_webserver.ino
@@ -511,9 +511,8 @@ const char kUploadErrors[] PROGMEM =
D_UPLOAD_ERR_1 "|" D_UPLOAD_ERR_2 "|" D_UPLOAD_ERR_3 "|" D_UPLOAD_ERR_4 "|" D_UPLOAD_ERR_5 "|" D_UPLOAD_ERR_6 "|" D_UPLOAD_ERR_7 "|" D_UPLOAD_ERR_8 "|" D_UPLOAD_ERR_9
#ifdef USE_RF_FLASH
"|" D_UPLOAD_ERR_10 "|" D_UPLOAD_ERR_11 "|" D_UPLOAD_ERR_12 "|" D_UPLOAD_ERR_13
-#else
- "|" D_UPLOAD_ERR_14
#endif
+ "|" D_UPLOAD_ERR_14
;
const uint16_t DNS_PORT = 53;
@@ -2141,9 +2140,10 @@ void HandleUploadDone(void)
if (Web.upload_error) {
WSContentSend_P(PSTR("%06x'>" D_FAILED "
"), WebColor(COL_TEXT_WARNING));
#ifdef USE_RF_FLASH
- if (Web.upload_error < 14) {
+ if (Web.upload_error < 15) {
#else
- if (Web.upload_error < 11) {
+ if ((Web.upload_error < 10) || (14 == Web.upload_error)) {
+ if (14 == Web.upload_error) { Web.upload_error = 10; }
#endif
GetTextIndexed(error, sizeof(error), Web.upload_error -1, kUploadErrors);
} else {
@@ -2379,7 +2379,7 @@ void HandleUploadLoop(void)
}
if (OtaVersion() < VERSION_COMPATIBLE) {
AbandonOta();
- Web.upload_error = 10; // Not compatible
+ Web.upload_error = 14; // Not compatible
return;
}
}
From 42f25b1cfb928671460d7dd3f4cd131c4521e516 Mon Sep 17 00:00:00 2001
From: Theo Arends <11044339+arendst@users.noreply.github.com>
Date: Fri, 20 Dec 2019 18:37:14 +0100
Subject: [PATCH 34/43] Update xdrv_01_webserver.ino
---
tasmota/xdrv_01_webserver.ino | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino
index 6b0edd8cb..8aece2be8 100644
--- a/tasmota/xdrv_01_webserver.ino
+++ b/tasmota/xdrv_01_webserver.ino
@@ -2238,7 +2238,7 @@ void HandleUploadLoop(void)
Update.end(); // End esp8266 update session
Web.upload_file_type = UPL_EFM8BB1;
- Web.upload_error = SnfBrUpdateInit();
+ Web.upload_error = SnfBrUpdateInit(); // 10, 11
if (Web.upload_error != 0) { return; }
} else
#endif // USE_RF_FLASH
@@ -2246,7 +2246,7 @@ void HandleUploadLoop(void)
if ((WEMOS == my_module_type) && (upload.buf[0] == ':')) { // Check if this is a ARDUINO SLAVE hex file
Update.end(); // End esp8266 update session
Web.upload_file_type = UPL_TASMOTASLAVE;
- Web.upload_error = TasmotaSlave_UpdateInit();
+ Web.upload_error = TasmotaSlave_UpdateInit(); // 0
if (Web.upload_error != 0) { return; }
} else
#endif
@@ -2281,13 +2281,13 @@ void HandleUploadLoop(void)
free(efm8bb1_update);
efm8bb1_update = nullptr;
if (result != 0) {
- Web.upload_error = abs(result); // 2 = Not enough space, 8 = File invalid
+ Web.upload_error = abs(result); // 2 = Not enough space, 8 = File invalid, 12, 13
return;
}
}
ssize_t result = rf_search_and_write(upload.buf, upload.currentSize);
if (result < 0) {
- Web.upload_error = abs(result);
+ Web.upload_error = abs(result); // 8, 12, 13
return;
} else if (result > 0) {
if ((size_t)result > upload.currentSize) {
From e85f1560a22c514ff945257891a4d7a7d642fed6 Mon Sep 17 00:00:00 2001
From: Theo Arends <11044339+arendst@users.noreply.github.com>
Date: Sat, 21 Dec 2019 12:43:07 +0100
Subject: [PATCH 35/43] Refactor DHT12 sensor driver
---
tasmota/xsns_58_dht12.ino | 136 +++++++++++++++++++++-----------------
1 file changed, 74 insertions(+), 62 deletions(-)
diff --git a/tasmota/xsns_58_dht12.ino b/tasmota/xsns_58_dht12.ino
index 1c60329b8..88dfd3598 100644
--- a/tasmota/xsns_58_dht12.ino
+++ b/tasmota/xsns_58_dht12.ino
@@ -28,82 +28,94 @@
#define XSNS_58 58
#define XI2C_41 41 // See I2CDEVICES.md
-#define DHT12_ADDR (uint8_t) 0x5C
+#define DHT12_ADDR 0x5C
-char dht12_name[] = "DHT12-0x00";
-uint8_t dht12_count = 0;
-float dht12_temperature = NAN;
-float dht12_humidity = NAN;
+struct DHT12 {
+ float temperature = NAN;
+ float humidity = NAN;
+ uint8_t valid = 0;
+ uint8_t count = 0;
+ char name[6] = "DHT12";
+} Dht12;
bool Dht12Read(void)
{
- Wire.beginTransmission(DHT12_ADDR);
- Wire.write(0);
- if (Wire.endTransmission() != 0) {
- return false;
- }
- delay(50);
- Wire.requestFrom(DHT12_ADDR, (uint8_t) 5);
- delay(5);
- uint8_t humidity = Wire.read();
- uint8_t humidityTenth = Wire.read();
- uint8_t temp = Wire.read();
- uint8_t tempTenth = Wire.read();
- uint8_t checksum = Wire.read();
- dht12_humidity = (float) humidity + (float) humidityTenth/(float) 10.0;
- dht12_temperature = (float) temp + (float) tempTenth/(float) 10.0;
- return (!isnan(dht12_temperature) && !isnan(dht12_humidity));
+ if (Dht12.valid) { Dht12.valid--; }
+
+ Wire.beginTransmission(DHT12_ADDR);
+ Wire.write(0);
+ if (Wire.endTransmission() != 0) { return false; }
+
+ delay(50);
+
+ Wire.requestFrom(DHT12_ADDR, 5);
+ delay(5);
+ uint8_t humidity = Wire.read();
+ uint8_t humidityTenth = Wire.read();
+ uint8_t temp = Wire.read();
+ uint8_t tempTenth = Wire.read();
+ uint8_t checksum = Wire.read();
+
+ Dht12.humidity = ConvertHumidity( (float) humidity + (float) humidityTenth/(float) 10.0 );
+ Dht12.temperature = ConvertTemp( (float) temp + (float) tempTenth/(float) 10.0 );
+
+ if (isnan(Dht12.temperature) || isnan(Dht12.humidity)) { return false; }
+
+ Dht12.valid = SENSOR_MAX_MISS;
+ return true;
}
+/********************************************************************************************/
+
void Dht12Detect(void)
{
- if (Dht12Read()) {
- snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, dht12_name, DHT12_ADDR);
- AddLog(LOG_LEVEL_DEBUG);
- snprintf_P(dht12_name, sizeof(dht12_name), PSTR("%s%c0x%02X"), "DHT12", IndexSeparator(), DHT12_ADDR);
- dht12_count = 1;
- }
+ if (I2cActive(DHT12_ADDR)) { return; }
+
+ if (Dht12Read()) {
+ I2cSetActiveFound(DHT12_ADDR, Dht12.name);
+ Dht12.count = 1;
+ }
}
-void Dht12Show(bool json)
+void Dht12EverySecond(void)
{
- if (dht12_count > 0)
- {
- char temperature[33];
- dtostrfd(dht12_temperature, Settings.flag2.temperature_resolution, temperature);
- char humidity[33];
- dtostrfd(dht12_humidity, Settings.flag2.humidity_resolution, humidity);
-
- if (json)
- {
- ResponseAppend_P(JSON_SNS_TEMPHUM, dht12_name, temperature, humidity);
-#ifdef USE_DOMOTICZ
- if ((0 == tele_period))
- {
- DomoticzTempHumSensor(temperature, humidity);
- }
-#endif // USE_DOMOTICZ
-
-#ifdef USE_KNX
- if (0 == tele_period)
- {
- KnxSensor(KNX_TEMPERATURE, dht12_temperature);
- KnxSensor(KNX_HUMIDITY, dht12_humidity);
- }
-#endif // USE_KNX
-
-#ifdef USE_WEBSERVER
- }
- else
- {
- WSContentSend_PD(HTTP_SNS_TEMP, dht12_name, temperature, TempUnit());
- WSContentSend_PD(HTTP_SNS_HUM, dht12_name, humidity);
-#endif // USE_WEBSERVER
+ if (uptime &1) {
+ // DHT12: 55mS
+ if (!Dht12Read()) {
+ AddLogMissed(Dht12.name, Dht12.valid);
}
}
}
+void Dht12Show(bool json)
+{
+ if (Dht12.valid) {
+ char temperature[33];
+ dtostrfd(Dht12.temperature, Settings.flag2.temperature_resolution, temperature);
+ char humidity[33];
+ dtostrfd(Dht12.humidity, Settings.flag2.humidity_resolution, humidity);
+ if (json) {
+ ResponseAppend_P(JSON_SNS_TEMPHUM, Dht12.name, temperature, humidity);
+#ifdef USE_DOMOTICZ
+ if ((0 == tele_period)) {
+ DomoticzTempHumSensor(temperature, humidity);
+ }
+#endif // USE_DOMOTICZ
+#ifdef USE_KNX
+ if (0 == tele_period) {
+ KnxSensor(KNX_TEMPERATURE, Dht12.temperature);
+ KnxSensor(KNX_HUMIDITY, Dht12.humidity);
+ }
+#endif // USE_KNX
+#ifdef USE_WEBSERVER
+ } else {
+ WSContentSend_PD(HTTP_SNS_TEMP, Dht12.name, temperature, TempUnit());
+ WSContentSend_PD(HTTP_SNS_HUM, Dht12.name, humidity);
+#endif // USE_WEBSERVER
+ }
+ }
+}
/*********************************************************************************************\
* Interface
@@ -118,10 +130,10 @@ bool Xsns58(uint8_t function)
if (FUNC_INIT == function) {
Dht12Detect();
}
- else if (dht12_count > 0) {
+ else if (Dht12.count) {
switch (function) {
case FUNC_EVERY_SECOND:
- Dht12Read();
+ Dht12EverySecond();
break;
case FUNC_JSON_APPEND:
Dht12Show(1);
From d2ebefbb16405c53dd07b5a82ea27b81c8146ec2 Mon Sep 17 00:00:00 2001
From: Theo Arends <11044339+arendst@users.noreply.github.com>
Date: Sat, 21 Dec 2019 13:45:26 +0100
Subject: [PATCH 36/43] Bump version to 7.2.0.1
---
README.md | 2 +-
RELEASENOTES.md | 2 +-
tasmota/CHANGELOG.md | 10 ++++++++--
tasmota/tasmota_version.h | 2 +-
4 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index acb6430d5..9a9ff0e1c 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ In addition to the [release webpage](https://github.com/arendst/Tasmota/releases
## Development
-[](https://github.com/arendst/Tasmota)
+[](https://github.com/arendst/Tasmota)
[](http://thehackbox.org/tasmota/)
[](https://travis-ci.org/arendst/Tasmota)
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index 56c4e2c07..f3fff8860 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -49,7 +49,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
## Changelog
-### Version 7.1.2.6
+### Version 7.2.0 Constance
- Change Exception reporting removing exception details from ``Status 1`` and consolidated in ``Status 12`` if available
- Change HTTP CORS from command ``SetOption73 0/1`` to ``Cors `` allowing user control of specific CORS domain by Shantur Rathore (#7066)
diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md
index d847aef5b..e290e1909 100644
--- a/tasmota/CHANGELOG.md
+++ b/tasmota/CHANGELOG.md
@@ -1,5 +1,13 @@
## Unreleased (development)
+### 7.2.0.1 20191221
+
+## Released
+
+### 7.2.0 20191221
+
+- Release
+
### 7.1.2.6 20191214
- Change some more Settings locations freeing up space for future single char allowing variable length text
@@ -51,8 +59,6 @@
- Add experimental support for stepper motor shutter control by Stefan Bode
- Add optional USE_MQTT_TLS to tasmota-minimal.bin by Bohdan Kmit (#7115)
-## Released
-
### 7.1.2 20191206
- Maintenance Release
diff --git a/tasmota/tasmota_version.h b/tasmota/tasmota_version.h
index 84ff6d905..27480159d 100644
--- a/tasmota/tasmota_version.h
+++ b/tasmota/tasmota_version.h
@@ -20,7 +20,7 @@
#ifndef _TASMOTA_VERSION_H_
#define _TASMOTA_VERSION_H_
-const uint32_t VERSION = 0x07010206;
+const uint32_t VERSION = 0x07020001;
// Lowest compatible version
const uint32_t VERSION_COMPATIBLE = 0x06000000;
From f55e02e80041e58159c6480dde62bfe0d5a77ace Mon Sep 17 00:00:00 2001
From: Theo Arends <11044339+arendst@users.noreply.github.com>
Date: Sat, 21 Dec 2019 15:37:36 +0100
Subject: [PATCH 37/43] Bump version to 8.0.0.1
Change Settings text handling allowing variable length text within a total text pool of 699 characters
---
RELEASENOTES.md | 36 +----
tasmota/CHANGELOG.md | 4 +-
tasmota/settings.h | 9 --
tasmota/settings.ino | 258 ++++++++++++---------------------
tasmota/support_statistics.ino | 37 +----
tasmota/tasmota_version.h | 4 +-
6 files changed, 100 insertions(+), 248 deletions(-)
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index f3fff8860..bf21cf32b 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -2,8 +2,6 @@
# RELEASE NOTES
-### Sonoff-Tasmota is now Tasmota
-
## Migration Information
See [migration path](https://tasmota.github.io/docs/#/Upgrading?id=migration-path) for instructions how to migrate to a major version. Pay attention to the following version breaks due to dynamic settings updates:
@@ -13,8 +11,7 @@ See [migration path](https://tasmota.github.io/docs/#/Upgrading?id=migration-pat
3. Migrate to **Sonoff-Tasmota 5.14**
4. Migrate to **Sonoff-Tasmota 6.x**
5. Migrate to **Tasmota 7.x**
-
-Only this version will support fallback from version 8.x.
+6. Migrate to **Tasmota 8.x**
## Supported Core versions
@@ -49,33 +46,6 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
## Changelog
-### Version 7.2.0 Constance
+### Version 8.0.0.1
-- Change Exception reporting removing exception details from ``Status 1`` and consolidated in ``Status 12`` if available
-- Change HTTP CORS from command ``SetOption73 0/1`` to ``Cors `` allowing user control of specific CORS domain by Shantur Rathore (#7066)
-- Change GUI Shutter button text to Up and Down Arrows based on PR by Xavier Muller (#7166)
-- Change amount of supported DHT sensors from 3 to 4 by Xavier Muller (#7167)
-- Change some Settings locations freeing up space for future single char allowing variable length text
-- Change tasmota-basic.bin and FIRMWARE_BASIC to tasmota-lite.bin and FIRMWARE_LITE
-- Fix flashing H801 led at boot by Stefan Hadinger (#7165, #649)
-- Fix duplicated ``Backlog`` when using Event inside a Backlog by Adrian Scillato (#7178, #7147)
-- Fix Gui Timer when using a negative zero offset of -00:00 by Peter Ooms (#7174)
-- Fix DeepSleep in case there is no wifi by Stefan Bode (#7213)
-- Fix Fade would ignore ``savedata 0`` and store to flash anyways (#7262)
-- Add command ``SerialConfig 0..23`` or ``SerialConfig 8N1`` to select Serial Config based in PR by Luis Teixeira (#7108)
-- Add command ``Sensor34 9 `` to set minimum delta to trigger JSON message by @tobox (#7188)
-- Add rule var ``%topic%`` by Adrian Scillato (#5522)
-- Add rule triggers ``tele-wifi1#xxx`` by Adrian Scillato (#7093)
-- Add SML bus decoder syntax support for byte order by Gerhard Mutz (#7112)
-- Add experimental support for stepper motor shutter control by Stefan Bode
-- Add optional USE_MQTT_TLS to tasmota-minimal.bin by Bohdan Kmit (#7115)
-- Add save call stack in RTC memory in case of crash, command ``Status 12`` to dump the stack by Stefan Hadinger
-- Add Home Assistant force update by Frederico Leoni (#7140, #7074)
-- Add Wifi Signal Strength in dBm in addition to RSSI Wifi Experience by Andreas Schultz (#7145)
-- Add Yaw, Pitch and Roll support for MPU6050 by Philip Barclay (#7058)
-- Add reporting of raw weight to JSON from HX711 to overcome auto-tare functionality by @tobox (#7171)
-- Add Zigbee support for Xiaomi Aqara Vibration Sensor and Presence Sensor by Stefan Hadinger
-- Add Shutter functions ramp up/down and MQTT reporting by Stefan Bode
-- Add fallback support from version 8.x
-- Add restriction if fallback firmware is incompatible with settings resulting in unreachable device
-- Add support for DHT12 Temperature and Humidity sensor by Stefan Oskamp
+- Change Settings text handling allowing variable length text within a total text pool of 699 characters
diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md
index e290e1909..e8b70c0cd 100644
--- a/tasmota/CHANGELOG.md
+++ b/tasmota/CHANGELOG.md
@@ -1,6 +1,8 @@
## Unreleased (development)
-### 7.2.0.1 20191221
+### 8.0.0.1 20191221
+
+- Change Settings text handling allowing variable length text within a total text pool of 699 characters
## Released
diff --git a/tasmota/settings.h b/tasmota/settings.h
index 8b7fe2822..0b3990578 100644
--- a/tasmota/settings.h
+++ b/tasmota/settings.h
@@ -231,13 +231,6 @@ typedef struct {
const uint8_t MAX_TUYA_FUNCTIONS = 16;
-/*
-struct SYSCFG {
- unsigned long cfg_holder; // 000 Pre v6 header
- unsigned long save_flag; // 004
- unsigned long version; // 008
- unsigned long bootcount; // 00C
-*/
struct SYSCFG {
uint16_t cfg_holder; // 000 v6 header
uint16_t cfg_size; // 002
@@ -274,8 +267,6 @@ struct SYSCFG {
uint8_t ex_free_1d6[10]; // 1D6
- // End of single char array of 456 chars max (phase 3)
-
SysBitfield4 ex_flag4; // 1E0
uint8_t ex_serial_config; // 1E4
uint8_t ex_wifi_output_power; // 1E5
diff --git a/tasmota/settings.ino b/tasmota/settings.ino
index afbd7b223..9a0ea44f1 100644
--- a/tasmota/settings.ino
+++ b/tasmota/settings.ino
@@ -488,10 +488,7 @@ void UpdateQuickPowerCycle(bool update)
* Config Settings.text char array support
\*********************************************************************************************/
-char aws_mqtt_host[66];
-char aws_mqtt_user[1] { 0 };
-
-const uint32_t settings_text_size = 457; // Settings.flag4 (1E0) - Settings.ota_url (017)
+const uint32_t settings_text_size = 699; // Settings.flag4 (2D2) - Settings.ota_url (017)
uint32_t GetSettingsTextLen(void)
{
@@ -513,60 +510,43 @@ bool SettingsUpdateText(uint32_t index, const char* replace_me)
char replace[replace_len +1];
memcpy(replace, replace_me, sizeof(replace));
- uint32_t idx = 0;
- switch (index) {
- case SET_OTAURL: strlcpy(Settings.ota_url, replace, sizeof(Settings.ota_url)); break;
- case SET_MQTTPREFIX3: idx++;
- case SET_MQTTPREFIX2: idx++;
- case SET_MQTTPREFIX1: strlcpy(Settings.mqtt_prefix[idx], replace, sizeof(Settings.mqtt_prefix[idx])); break;
- case SET_STASSID2: idx++;
- case SET_STASSID1: strlcpy(Settings.sta_ssid[idx], replace, sizeof(Settings.sta_ssid[idx])); break;
- case SET_STAPWD2: idx++;
- case SET_STAPWD1: strlcpy(Settings.sta_pwd[idx], replace, sizeof(Settings.sta_pwd[idx])); break;
- case SET_HOSTNAME: strlcpy(Settings.hostname, replace, sizeof(Settings.hostname)); break;
- case SET_SYSLOG_HOST: strlcpy(Settings.syslog_host, replace, sizeof(Settings.syslog_host)); break;
- case SET_WEBPWD: strlcpy(Settings.web_password, replace, sizeof(Settings.web_password)); break;
-#if defined(USE_MQTT_TLS) && defined(USE_MQTT_AWS_IOT)
- case SET_MQTT_HOST:
- if (strlen(replace) <= sizeof(Settings.mqtt_host)) {
- strlcpy(Settings.mqtt_host, replace, sizeof(Settings.mqtt_host));
- Settings.mqtt_user[0] = 0;
- } else {
- // need to split in mqtt_user first then mqtt_host
- strlcpy(Settings.mqtt_user, replace, sizeof(Settings.mqtt_user));
- strlcpy(Settings.mqtt_host, &replace[sizeof(Settings.mqtt_user)-1], sizeof(Settings.mqtt_host));
- }
- break;
- case SET_MQTT_USER: break;
-#else
- case SET_MQTT_HOST: strlcpy(Settings.mqtt_host, replace, sizeof(Settings.mqtt_host)); break;
- case SET_MQTT_USER: strlcpy(Settings.mqtt_user, replace, sizeof(Settings.mqtt_user)); break;
-#endif
- case SET_MQTT_CLIENT: strlcpy(Settings.mqtt_client, replace, sizeof(Settings.mqtt_client)); break;
- case SET_MQTT_PWD: strlcpy(Settings.mqtt_pwd, replace, sizeof(Settings.mqtt_pwd)); break;
- case SET_MQTT_FULLTOPIC: strlcpy(Settings.mqtt_fulltopic, replace, sizeof(Settings.mqtt_fulltopic)); break;
- case SET_MQTT_TOPIC: strlcpy(Settings.mqtt_topic, replace, sizeof(Settings.mqtt_topic)); break;
- case SET_MQTT_BUTTON_TOPIC: strlcpy(Settings.button_topic, replace, sizeof(Settings.button_topic)); break;
- case SET_MQTT_SWITCH_TOPIC: strlcpy(Settings.switch_topic, replace, sizeof(Settings.switch_topic)); break;
- case SET_MQTT_GRP_TOPIC: strlcpy(Settings.mqtt_grptopic, replace, sizeof(Settings.mqtt_grptopic)); break;
- case SET_STATE_TXT4: idx++;
- case SET_STATE_TXT3: idx++;
- case SET_STATE_TXT2: idx++;
- case SET_STATE_TXT1: strlcpy(Settings.state_text[idx], replace, sizeof(Settings.state_text[idx])); break;
- case SET_NTPSERVER3: idx++;
- case SET_NTPSERVER2: idx++;
- case SET_NTPSERVER1: strlcpy(Settings.ntp_server[idx], replace, sizeof(Settings.ntp_server[idx])); break;
- case SET_MEM5: idx++;
- case SET_MEM4: idx++;
- case SET_MEM3: idx++;
- case SET_MEM2: idx++;
- case SET_MEM1: strlcpy(Settings.mems[idx], replace, sizeof(Settings.mems[idx])); break;
- case SET_CORS: strlcpy(Settings.cors_domain, replace, sizeof(Settings.cors_domain)); break;
- case SET_FRIENDLYNAME4: idx++;
- case SET_FRIENDLYNAME3: idx++;
- case SET_FRIENDLYNAME2: idx++;
- case SET_FRIENDLYNAME1: strlcpy(Settings.friendlyname[idx], replace, sizeof(Settings.friendlyname[idx])); break;
+ uint32_t start_pos = 0;
+ uint32_t end_pos = 0;
+ char* position = Settings.ota_url;
+ for (uint32_t size = 0; size < SET_MAX; size++) {
+ while (*position++ != '\0') { }
+ if (1 == index) {
+ start_pos = position - Settings.ota_url;
+ }
+ else if (0 == index) {
+ end_pos = position - Settings.ota_url -1;
+ }
+ index--;
}
+ uint32_t char_len = position - Settings.ota_url;
+
+ uint32_t current_len = end_pos - start_pos;
+ int diff = replace_len - current_len;
+
+// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TST: start %d, end %d, len %d, current %d, replace %d, diff %d"),
+// start_pos, end_pos, char_len, current_len, replace_len, diff);
+
+ int too_long = (char_len + diff) - settings_text_size;
+ if (too_long > 0) {
+// AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_CONFIG "Text too long by %d char(s)"), too_long);
+ return false; // Replace text too long
+ }
+
+ if (diff != 0) {
+ // Shift Settings.text up or down
+ memmove_P(Settings.ota_url + start_pos + replace_len, Settings.ota_url + end_pos, char_len - end_pos);
+ }
+ // Replace text
+ memmove_P(Settings.ota_url + start_pos, replace, replace_len);
+ // Fill for future use
+ memset(Settings.ota_url + char_len + diff, 0x00, settings_text_size - char_len - diff);
+
+ AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG "CR %d/%d"), GetSettingsTextLen(), settings_text_size);
return true;
}
@@ -578,61 +558,9 @@ char* SettingsText(uint32_t index)
}
char* position = Settings.ota_url;
-
- if (Settings.version < 0x08000000) {
- uint32_t idx = 0;
- switch (index) {
- case SET_MQTTPREFIX3: idx++;
- case SET_MQTTPREFIX2: idx++;
- case SET_MQTTPREFIX1: position = Settings.mqtt_prefix[idx]; break;
- case SET_STASSID2: idx++;
- case SET_STASSID1: position = Settings.sta_ssid[idx]; break;
- case SET_STAPWD2: idx++;
- case SET_STAPWD1: position = Settings.sta_pwd[idx]; break;
- case SET_HOSTNAME: position = Settings.hostname; break;
- case SET_SYSLOG_HOST: position = Settings.syslog_host; break;
- case SET_WEBPWD: position = Settings.web_password; break;
-#if defined(USE_MQTT_TLS) && defined(USE_MQTT_AWS_IOT)
- case SET_MQTT_HOST:
- snprintf_P(aws_mqtt_host, sizeof(aws_mqtt_host), PSTR("%s%s"), Settings.mqtt_user, Settings.mqtt_host);
- position = aws_mqtt_host; break;
- case SET_MQTT_USER: position = aws_mqtt_user; break;
-#else
- case SET_MQTT_HOST: position = Settings.mqtt_host; break;
- case SET_MQTT_USER: position = Settings.mqtt_user; break;
-#endif
- case SET_MQTT_CLIENT: position = Settings.mqtt_client; break;
- case SET_MQTT_PWD: position = Settings.mqtt_pwd; break;
- case SET_MQTT_FULLTOPIC: position = Settings.mqtt_fulltopic; break;
- case SET_MQTT_TOPIC: position = Settings.mqtt_topic; break;
- case SET_MQTT_BUTTON_TOPIC: position = Settings.button_topic; break;
- case SET_MQTT_SWITCH_TOPIC: position = Settings.switch_topic; break;
- case SET_MQTT_GRP_TOPIC: position = Settings.mqtt_grptopic; break;
- case SET_STATE_TXT4: idx++;
- case SET_STATE_TXT3: idx++;
- case SET_STATE_TXT2: idx++;
- case SET_STATE_TXT1: position = Settings.state_text[idx]; break;
- case SET_NTPSERVER3: idx++;
- case SET_NTPSERVER2: idx++;
- case SET_NTPSERVER1: position = Settings.ntp_server[idx]; break;
- case SET_MEM5: idx++;
- case SET_MEM4: idx++;
- case SET_MEM3: idx++;
- case SET_MEM2: idx++;
- case SET_MEM1: position = Settings.mems[idx]; break;
- case SET_CORS: position = Settings.cors_domain; break;
- case SET_FRIENDLYNAME4: idx++;
- case SET_FRIENDLYNAME3: idx++;
- case SET_FRIENDLYNAME2: idx++;
- case SET_FRIENDLYNAME1: position = Settings.friendlyname[idx]; break;
- }
-
- } else {
- for (;index > 0; index--) {
- while (*position++ != '\0') { }
- }
+ for (;index > 0; index--) {
+ while (*position++ != '\0') { }
}
-
return position;
}
@@ -1132,10 +1060,6 @@ void SettingsDefaultSet2(void)
memset(&Settings.monitors, 0xFF, 20); // Enable all possible monitors, displays and sensors
SettingsEnableAllI2cDrivers();
-
- if (VERSION < 0x08000000) {
- SettingsBackwardCompat();
- }
}
/********************************************************************************************/
@@ -1175,17 +1099,6 @@ void SettingsEnableAllI2cDrivers(void)
Settings.i2c_drivers[2] = 0xFFFFFFFF;
}
-void SettingsBackwardCompat(void)
-{
- Settings.ex_seriallog_level = Settings.seriallog_level; // 09E <- 452
- Settings.ex_sta_config = Settings.sta_config; // 09F <- EC7
- Settings.ex_sta_active = Settings.sta_active; // 0A0 <- EC8
- memcpy((char*)&Settings.ex_rule_stop, (char*)&Settings.rule_stop, 47); // 1A7 <- EC9
- Settings.ex_flag4 = Settings.flag4; // 1E0 <- EF8
- Settings.ex_mqtt_port = Settings.mqtt_port; // 20A <- EFC
- memcpy((char*)&Settings.ex_serial_config, (char*)&Settings.serial_config, 5); // 1E4 <- EFE
-}
-
/********************************************************************************************/
void SettingsDelta(void)
@@ -1405,46 +1318,26 @@ void SettingsDelta(void)
memcpy((char*)&Settings.serial_config, (char*)&Settings.ex_serial_config, 5); // 1E4 -> EFE
}
- if ((VERSION < 0x08000000) && (Settings.version >= 0x08000000)) {
- SettingsUpdateText(SET_WEBPWD, SettingsText(SET_WEBPWD));
- SettingsUpdateText(SET_CORS, SettingsText(SET_CORS));
- SettingsUpdateText(SET_MQTT_FULLTOPIC, SettingsText(SET_MQTT_FULLTOPIC));
- SettingsUpdateText(SET_MQTT_SWITCH_TOPIC, SettingsText(SET_MQTT_SWITCH_TOPIC));
- SettingsUpdateText(SET_STATE_TXT1, SettingsText(SET_STATE_TXT1));
- SettingsUpdateText(SET_STATE_TXT2, SettingsText(SET_STATE_TXT2));
- SettingsUpdateText(SET_STATE_TXT3, SettingsText(SET_STATE_TXT3));
- SettingsUpdateText(SET_STATE_TXT4, SettingsText(SET_STATE_TXT4));
- SettingsUpdateText(SET_NTPSERVER1, SettingsText(SET_NTPSERVER1));
- SettingsUpdateText(SET_NTPSERVER2, SettingsText(SET_NTPSERVER2));
- SettingsUpdateText(SET_NTPSERVER3, SettingsText(SET_NTPSERVER3));
- SettingsUpdateText(SET_MEM1, SettingsText(SET_MEM1));
- SettingsUpdateText(SET_MEM2, SettingsText(SET_MEM2));
- SettingsUpdateText(SET_MEM3, SettingsText(SET_MEM3));
- SettingsUpdateText(SET_MEM4, SettingsText(SET_MEM4));
- SettingsUpdateText(SET_MEM5, SettingsText(SET_MEM5));
- SettingsUpdateText(SET_FRIENDLYNAME1, SettingsText(SET_FRIENDLYNAME1));
- SettingsUpdateText(SET_FRIENDLYNAME2, SettingsText(SET_FRIENDLYNAME2));
- SettingsUpdateText(SET_FRIENDLYNAME3, SettingsText(SET_FRIENDLYNAME3));
- SettingsUpdateText(SET_FRIENDLYNAME4, SettingsText(SET_FRIENDLYNAME4));
-
- char temp[strlen(SettingsText(SET_OTAURL)) +1]; strncpy(temp, SettingsText(SET_OTAURL), sizeof(temp));
- char temp21[strlen(SettingsText(SET_MQTTPREFIX1)) +1]; strncpy(temp21, SettingsText(SET_MQTTPREFIX1), sizeof(temp21));
- char temp22[strlen(SettingsText(SET_MQTTPREFIX2)) +1]; strncpy(temp22, SettingsText(SET_MQTTPREFIX2), sizeof(temp22));
- char temp23[strlen(SettingsText(SET_MQTTPREFIX3)) +1]; strncpy(temp23, SettingsText(SET_MQTTPREFIX3), sizeof(temp23));
- char temp31[strlen(SettingsText(SET_STASSID1)) +1]; strncpy(temp31, SettingsText(SET_STASSID1), sizeof(temp31));
- char temp32[strlen(SettingsText(SET_STASSID2)) +1]; strncpy(temp32, SettingsText(SET_STASSID2), sizeof(temp32));
- char temp41[strlen(SettingsText(SET_STAPWD1)) +1]; strncpy(temp41, SettingsText(SET_STAPWD1), sizeof(temp41));
- char temp42[strlen(SettingsText(SET_STAPWD2)) +1]; strncpy(temp42, SettingsText(SET_STAPWD2), sizeof(temp42));
- char temp5[strlen(SettingsText(SET_HOSTNAME)) +1]; strncpy(temp5, SettingsText(SET_HOSTNAME), sizeof(temp5));
- char temp6[strlen(SettingsText(SET_SYSLOG_HOST)) +1]; strncpy(temp6, SettingsText(SET_SYSLOG_HOST), sizeof(temp6));
- char temp7[strlen(SettingsText(SET_MQTT_HOST)) +1]; strncpy(temp7, SettingsText(SET_MQTT_HOST), sizeof(temp7));
- char temp8[strlen(SettingsText(SET_MQTT_CLIENT)) +1]; strncpy(temp8, SettingsText(SET_MQTT_CLIENT), sizeof(temp8));
- char temp9[strlen(SettingsText(SET_MQTT_USER)) +1]; strncpy(temp9, SettingsText(SET_MQTT_USER), sizeof(temp9));
- char temp10[strlen(SettingsText(SET_MQTT_PWD)) +1]; strncpy(temp10, SettingsText(SET_MQTT_PWD), sizeof(temp10));
- char temp11[strlen(SettingsText(SET_MQTT_TOPIC)) +1]; strncpy(temp11, SettingsText(SET_MQTT_TOPIC), sizeof(temp11));
- char temp12[strlen(SettingsText(SET_MQTT_BUTTON_TOPIC)) +1]; strncpy(temp12, SettingsText(SET_MQTT_BUTTON_TOPIC), sizeof(temp12));
- char temp13[strlen(SettingsText(SET_MQTT_GRP_TOPIC)) +1]; strncpy(temp13, SettingsText(SET_MQTT_GRP_TOPIC), sizeof(temp13));
+ if (Settings.version < 0x08000000) {
+ char temp[strlen(Settings.ota_url) +1]; strncpy(temp, Settings.ota_url, sizeof(temp));
+ char temp21[strlen(Settings.mqtt_prefix[0]) +1]; strncpy(temp21, Settings.mqtt_prefix[0], sizeof(temp21));
+ char temp22[strlen(Settings.mqtt_prefix[1]) +1]; strncpy(temp22, Settings.mqtt_prefix[1], sizeof(temp22));
+ char temp23[strlen(Settings.mqtt_prefix[2]) +1]; strncpy(temp23, Settings.mqtt_prefix[2], sizeof(temp23));
+ char temp31[strlen(Settings.sta_ssid[0]) +1]; strncpy(temp31, Settings.sta_ssid[0], sizeof(temp31));
+ char temp32[strlen(Settings.sta_ssid[1]) +1]; strncpy(temp32, Settings.sta_ssid[1], sizeof(temp32));
+ char temp41[strlen(Settings.sta_pwd[0]) +1]; strncpy(temp41, Settings.sta_pwd[0], sizeof(temp41));
+ char temp42[strlen(Settings.sta_pwd[1]) +1]; strncpy(temp42, Settings.sta_pwd[1], sizeof(temp42));
+ char temp5[strlen(Settings.hostname) +1]; strncpy(temp5, Settings.hostname, sizeof(temp5));
+ char temp6[strlen(Settings.syslog_host) +1]; strncpy(temp6, Settings.syslog_host, sizeof(temp6));
+ char temp7[strlen(Settings.mqtt_host) +1]; strncpy(temp7, Settings.mqtt_host, sizeof(temp7));
+ char temp8[strlen(Settings.mqtt_client) +1]; strncpy(temp8, Settings.mqtt_client, sizeof(temp8));
+ char temp9[strlen(Settings.mqtt_user) +1]; strncpy(temp9, Settings.mqtt_user, sizeof(temp9));
+ char temp10[strlen(Settings.mqtt_pwd) +1]; strncpy(temp10, Settings.mqtt_pwd, sizeof(temp10));
+ char temp11[strlen(Settings.mqtt_topic) +1]; strncpy(temp11, Settings.mqtt_topic, sizeof(temp11));
+ char temp12[strlen(Settings.button_topic) +1]; strncpy(temp12, Settings.button_topic, sizeof(temp12));
+ char temp13[strlen(Settings.mqtt_grptopic) +1]; strncpy(temp13, Settings.mqtt_grptopic, sizeof(temp13));
+ memset(Settings.ota_url, 0x00, settings_text_size);
SettingsUpdateText(SET_OTAURL, temp);
SettingsUpdateText(SET_MQTTPREFIX1, temp21);
SettingsUpdateText(SET_MQTTPREFIX2, temp22);
@@ -1455,15 +1348,46 @@ void SettingsDelta(void)
SettingsUpdateText(SET_STAPWD2, temp42);
SettingsUpdateText(SET_HOSTNAME, temp5);
SettingsUpdateText(SET_SYSLOG_HOST, temp6);
+#if defined(USE_MQTT_TLS) && defined(USE_MQTT_AWS_IOT)
+ if (!strlen(Settings.mqtt_user)) {
+ SettingsUpdateText(SET_MQTT_HOST, temp7);
+ SettingsUpdateText(SET_MQTT_USER, temp9);
+ } else {
+ char aws_mqtt_host[66];
+ snprintf_P(aws_mqtt_host, sizeof(aws_mqtt_host), PSTR("%s%s"), temp9, temp7);
+ SettingsUpdateText(SET_MQTT_HOST, mqtt_host);
+ SettingsUpdateText(SET_MQTT_USER, "");
+ }
+#else
SettingsUpdateText(SET_MQTT_HOST, temp7);
- SettingsUpdateText(SET_MQTT_CLIENT, temp8);
SettingsUpdateText(SET_MQTT_USER, temp9);
+#endif
+ SettingsUpdateText(SET_MQTT_CLIENT, temp8);
SettingsUpdateText(SET_MQTT_PWD, temp10);
SettingsUpdateText(SET_MQTT_TOPIC, temp11);
SettingsUpdateText(SET_MQTT_BUTTON_TOPIC, temp12);
SettingsUpdateText(SET_MQTT_GRP_TOPIC, temp13);
- SettingsBackwardCompat();
+ SettingsUpdateText(SET_WEBPWD, Settings.web_password);
+ SettingsUpdateText(SET_CORS, Settings.cors_domain);
+ SettingsUpdateText(SET_MQTT_FULLTOPIC, Settings.mqtt_fulltopic);
+ SettingsUpdateText(SET_MQTT_SWITCH_TOPIC, Settings.switch_topic);
+ SettingsUpdateText(SET_STATE_TXT1, Settings.state_text[0]);
+ SettingsUpdateText(SET_STATE_TXT2, Settings.state_text[1]);
+ SettingsUpdateText(SET_STATE_TXT3, Settings.state_text[2]);
+ SettingsUpdateText(SET_STATE_TXT4, Settings.state_text[3]);
+ SettingsUpdateText(SET_NTPSERVER1, Settings.ntp_server[0]);
+ SettingsUpdateText(SET_NTPSERVER2, Settings.ntp_server[1]);
+ SettingsUpdateText(SET_NTPSERVER3, Settings.ntp_server[2]);
+ SettingsUpdateText(SET_MEM1, Settings.mems[0]);
+ SettingsUpdateText(SET_MEM2, Settings.mems[1]);
+ SettingsUpdateText(SET_MEM3, Settings.mems[2]);
+ SettingsUpdateText(SET_MEM4, Settings.mems[3]);
+ SettingsUpdateText(SET_MEM5, Settings.mems[4]);
+ SettingsUpdateText(SET_FRIENDLYNAME1, Settings.friendlyname[0]);
+ SettingsUpdateText(SET_FRIENDLYNAME2, Settings.friendlyname[1]);
+ SettingsUpdateText(SET_FRIENDLYNAME3, Settings.friendlyname[2]);
+ SettingsUpdateText(SET_FRIENDLYNAME4, Settings.friendlyname[3]);
}
Settings.version = VERSION;
diff --git a/tasmota/support_statistics.ino b/tasmota/support_statistics.ino
index b8f65bd20..1907b1edc 100644
--- a/tasmota/support_statistics.ino
+++ b/tasmota/support_statistics.ino
@@ -27,42 +27,7 @@
String GetStatistics(void)
{
char data[40];
-
- if (Settings.version < 0x08000000) {
- uint32_t str_len = 0;
- for (uint32_t i = 0; i < 2; i++) {
- str_len += strlen(Settings.sta_ssid[i]);
- str_len += strlen(Settings.sta_pwd[i]);
- }
- for (uint32_t i = 0; i < 3; i++) {
- str_len += strlen(Settings.mqtt_prefix[i]);
- str_len += strlen(Settings.ntp_server[i]);
- }
- for (uint32_t i = 0; i < 4; i++) {
- str_len += strlen(Settings.state_text[i]);
- str_len += strlen(Settings.friendlyname[i]);
- }
- for (uint32_t i = 0; i < MAX_RULE_MEMS; i++) {
- str_len += strlen(Settings.mems[i]);
- }
- str_len += strlen(Settings.ota_url);
- str_len += strlen(Settings.hostname);
- str_len += strlen(Settings.syslog_host);
- str_len += strlen(Settings.mqtt_host);
- str_len += strlen(Settings.mqtt_client);
- str_len += strlen(Settings.mqtt_user);
- str_len += strlen(Settings.mqtt_pwd);
- str_len += strlen(Settings.mqtt_topic);
- str_len += strlen(Settings.button_topic);
- str_len += strlen(Settings.switch_topic);
- str_len += strlen(Settings.mqtt_grptopic);
- str_len += strlen(Settings.web_password);
- str_len += strlen(Settings.mqtt_fulltopic);
- str_len += strlen(Settings.cors_domain);
- snprintf_P(data, sizeof(data), PSTR(",\"CR\":\"%d/1151\""), 37 + str_len); // Char Usage Ratio
- } else {
- snprintf_P(data, sizeof(data), PSTR(",\"CR\":\"%d/%d\""), GetSettingsTextLen(), settings_text_size); // Char Usage Ratio
- }
+ snprintf_P(data, sizeof(data), PSTR(",\"CR\":\"%d/%d\""), GetSettingsTextLen(), settings_text_size); // Char Usage Ratio
return String(data);
}
diff --git a/tasmota/tasmota_version.h b/tasmota/tasmota_version.h
index 27480159d..be2cfafe2 100644
--- a/tasmota/tasmota_version.h
+++ b/tasmota/tasmota_version.h
@@ -20,9 +20,9 @@
#ifndef _TASMOTA_VERSION_H_
#define _TASMOTA_VERSION_H_
-const uint32_t VERSION = 0x07020001;
+const uint32_t VERSION = 0x08000001;
// Lowest compatible version
-const uint32_t VERSION_COMPATIBLE = 0x06000000;
+const uint32_t VERSION_COMPATIBLE = 0x07010006;
#endif // _TASMOTA_VERSION_H_
From 9fc11270bad712d5f34823ce721bc5db25ecd390 Mon Sep 17 00:00:00 2001
From: Theo Arends <11044339+arendst@users.noreply.github.com>
Date: Sat, 21 Dec 2019 17:09:24 +0100
Subject: [PATCH 38/43] Fix Arduino IDE compile error
Fix Arduino IDE compile error (#7277)
---
tasmota/tasmota_post.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tasmota/tasmota_post.h b/tasmota/tasmota_post.h
index b095fdbf2..c54adfe82 100644
--- a/tasmota/tasmota_post.h
+++ b/tasmota/tasmota_post.h
@@ -21,7 +21,7 @@
#define _TASMOTA_POST_H_
/*********************************************************************************************\
- * Function declarations
+ * Function prototypes
\*********************************************************************************************/
// Needed for core 2.3.0 compilation (#6721)
@@ -39,6 +39,7 @@ void KNX_CB_Action(message_t const &msg, void *arg);
//#endif // USE_KNX
char* ToHex_P(const unsigned char * in, size_t insz, char * out, size_t outsz, char inbetween = '\0');
+extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack, uint32_t stack_end);
/*********************************************************************************************\
* Default global defines
From 281cef6763a26635ea872b8c860c07b463caa889 Mon Sep 17 00:00:00 2001
From: Theo Arends <11044339+arendst@users.noreply.github.com>
Date: Sat, 21 Dec 2019 17:57:54 +0100
Subject: [PATCH 39/43] Fix no AP on initial install
Fix no AP on initial install (#7282)
---
tasmota/support_tasmota.ino | 2 +-
tasmota/support_wifi.ino | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino
index 08b898efb..900ba3dd4 100644
--- a/tasmota/support_tasmota.ino
+++ b/tasmota/support_tasmota.ino
@@ -108,7 +108,7 @@ char* GetTopic_P(char *stopic, uint32_t prefix, char *topic, const char* subtopi
fulltopic += FPSTR(MQTT_TOKEN_PREFIX); // Need prefix for commands to handle mqtt topic loops
}
for (uint32_t i = 0; i < 3; i++) {
- if ('\0' == SettingsText(SET_MQTTPREFIX1 + i)) {
+ if (!strlen(SettingsText(SET_MQTTPREFIX1 + i))) {
char temp[TOPSZ];
SettingsUpdateText(SET_MQTTPREFIX1 + i, GetTextIndexed(temp, sizeof(temp), i, kPrefixes));
}
diff --git a/tasmota/support_wifi.ino b/tasmota/support_wifi.ino
index 86cc81dd8..c283f1bb5 100644
--- a/tasmota/support_wifi.ino
+++ b/tasmota/support_wifi.ino
@@ -191,7 +191,7 @@ void WifiBegin(uint8_t flag, uint8_t channel)
case 2: // Toggle
Settings.sta_active ^= 1;
} // 3: Current AP
- if ('\0' == SettingsText(SET_STASSID1 + Settings.sta_active)) {
+ if (!strlen(SettingsText(SET_STASSID1 + Settings.sta_active))) {
Settings.sta_active ^= 1; // Skip empty SSID
}
if (Settings.ip_address[0]) {
@@ -436,7 +436,7 @@ void WifiCheckIp(void)
if (!Wifi.retry || ((Wifi.retry_init / 2) == Wifi.retry)) {
AddLog_P(LOG_LEVEL_INFO, S_LOG_WIFI, PSTR(D_CONNECT_FAILED_AP_TIMEOUT));
} else {
- if (('\0' == SettingsText(SET_STASSID1)) && ('\0' == SettingsText(SET_STASSID2))) {
+ if (!strlen(SettingsText(SET_STASSID1)) && !strlen(SettingsText(SET_STASSID2))) {
wifi_config_tool = WIFI_MANAGER; // Skip empty SSIDs and start Wifi config tool
Wifi.retry = 0;
} else {
From 9a7d5346c457c288ea564dcb33ca47a8f643e39d Mon Sep 17 00:00:00 2001
From: Hadinger
Date: Sat, 21 Dec 2019 18:26:36 +0100
Subject: [PATCH 40/43] Change Smoother ``Fade`` using 100Hz instead of 20Hz
animation (#7179)
---
tasmota/CHANGELOG.md | 1 +
tasmota/xdrv_04_light.ino | 78 +++++++++++++++++++++++++--------------
2 files changed, 51 insertions(+), 28 deletions(-)
diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md
index e8b70c0cd..8d7a06812 100644
--- a/tasmota/CHANGELOG.md
+++ b/tasmota/CHANGELOG.md
@@ -3,6 +3,7 @@
### 8.0.0.1 20191221
- Change Settings text handling allowing variable length text within a total text pool of 699 characters
+- Change Smoother ``Fade`` using 100Hz instead of 20Hz animation (#7179)
## Released
diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino
index 6148a9aad..d6e71ab08 100644
--- a/tasmota/xdrv_04_light.ino
+++ b/tasmota/xdrv_04_light.ino
@@ -262,8 +262,8 @@ struct LIGHT {
uint16_t fade_start_10[LST_MAX] = {0,0,0,0,0};
uint16_t fade_cur_10[LST_MAX];
uint16_t fade_end_10[LST_MAX]; // 10 bits resolution target channel values
- uint16_t fade_counter = 0; // fade timer in ticks (50ms)
- uint16_t fade_duration = 0; // duration of fade in ticks (50ms)
+ uint16_t fade_duration = 0; // duration of fade in milliseconds
+ uint32_t fade_start = 0; // fade start time in milliseconds, compared to millis()
} Light;
power_t LightPower(void)
@@ -1574,20 +1574,25 @@ void LightAnimate(void)
bool power_off = false;
Light.strip_timer_counter++;
- if (!Light.power) { // All channels powered off
- Light.strip_timer_counter = 0;
- if (!Light.fade_running) {
- sleep = Settings.sleep;
- }
- if (Settings.light_scheme >= LS_MAX) {
- power_off = true;
- }
- } else {
+
+ // set sleep parameter: either settings,
+ // or set a maximum of PWM_MAX_SLEEP if light is on or Fade is running
+ if (Light.power || Light.fade_running) {
if (Settings.sleep > PWM_MAX_SLEEP) {
sleep = PWM_MAX_SLEEP; // set a maxumum value of 50 milliseconds to ensure that animations are smooth
} else {
sleep = Settings.sleep; // or keep the current sleep if it's lower than 50
}
+ } else {
+ sleep = Settings.sleep;
+ }
+
+ if (!Light.power) { // All channels powered off
+ Light.strip_timer_counter = 0;
+ if (Settings.light_scheme >= LS_MAX) {
+ power_off = true;
+ }
+ } else {
switch (Settings.light_scheme) {
case LS_POWER:
light_controller.calcLevels(Light.new_color);
@@ -1733,27 +1738,35 @@ void LightAnimate(void)
memcpy(Light.fade_end_8, cur_col, sizeof(Light.fade_start_8));
memcpy(Light.fade_end_10, cur_col_10bits, sizeof(Light.fade_start_10));
Light.fade_running = true;
- Light.fade_counter = 0;
Light.fade_duration = 0; // set the value to zero to force a recompute
+ Light.fade_start = 0;
// Fade will applied immediately below
}
}
if (Light.fade_running) {
- LightApplyFade();
- // AddLog_P2(LOG_LEVEL_INFO, PSTR("LightApplyFade %d %d %d %d %d - %d %d %d %d %d"),
- // Light.fade_cur_8[0], Light.fade_cur_8[1], Light.fade_cur_8[2], Light.fade_cur_8[3], Light.fade_cur_8[4],
- // Light.fade_cur_10[0], Light.fade_cur_10[1], Light.fade_cur_10[2], Light.fade_cur_10[3], Light.fade_cur_10[4]);
+ if (LightApplyFade()) {
+ // AddLog_P2(LOG_LEVEL_INFO, PSTR("LightApplyFade %d %d %d %d %d - %d %d %d %d %d"),
+ // Light.fade_cur_8[0], Light.fade_cur_8[1], Light.fade_cur_8[2], Light.fade_cur_8[3], Light.fade_cur_8[4],
+ // Light.fade_cur_10[0], Light.fade_cur_10[1], Light.fade_cur_10[2], Light.fade_cur_10[3], Light.fade_cur_10[4]);
- LightSetOutputs(Light.fade_cur_8, Light.fade_cur_10);
+ LightSetOutputs(Light.fade_cur_8, Light.fade_cur_10);
+ }
}
}
}
-void LightApplyFade(void) {
+bool LightApplyFade(void) { // did the value chanegd and needs to be applied
+ static uint32_t last_millis = 0;
+ uint32_t now = millis();
+
+ if ((now - last_millis) <= 5) {
+ return false; // the value was not changed in the last 5 milliseconds, ignore
+ }
+ last_millis = now;
// Check if we need to calculate the duration
if (0 == Light.fade_duration) {
- Light.fade_counter = 0;
+ Light.fade_start = now;
// compute the distance between start and and color (max of distance for each channel)
uint32_t distance = 0;
for (uint32_t i = 0; i < Light.subtype; i++) {
@@ -1764,11 +1777,11 @@ void LightApplyFade(void) {
if (distance > 0) {
// compute the duration of the animation
// Note: Settings.light_speed is the number of half-seconds for a 100% fade,
- // i.e. light_speed=1 means 1024 steps in 10 ticks (500ms)
- Light.fade_duration = (distance * Settings.light_speed * 10) / 1024;
+ // i.e. light_speed=1 means 1024 steps in 500ms
+ Light.fade_duration = (distance * Settings.light_speed * 500) / 1023;
if (Settings.save_data) {
// Also postpone the save_data for the duration of the Fade (in seconds)
- uint32_t delay_seconds = 1 + (Light.fade_duration + 19) / 20; // add one more second
+ uint32_t delay_seconds = 1 + (Light.fade_duration + 999) / 1000; // add one more second
// AddLog_P2(LOG_LEVEL_INFO, PSTR("delay_seconds %d, save_data_counter %d"), delay_seconds, save_data_counter);
if (save_data_counter < delay_seconds) {
save_data_counter = delay_seconds; // pospone
@@ -1776,16 +1789,18 @@ void LightApplyFade(void) {
}
} else {
// no fade needed, we keep the duration at zero, it will fallback directly to end of fade
+ Light.fade_running = false;
}
}
- Light.fade_counter++;
- if (Light.fade_counter <= Light.fade_duration) { // fade not finished
+ uint16_t fade_current = now - Light.fade_start; // number of milliseconds since start of fade
+ if (fade_current <= Light.fade_duration) { // fade not finished
+ //Serial.printf("Fade: %d / %d - ", fade_current, Light.fade_duration);
for (uint32_t i = 0; i < Light.subtype; i++) {
- Light.fade_cur_8[i] = changeUIntScale(Light.fade_counter,
+ Light.fade_cur_8[i] = changeUIntScale(fade_current,
0, Light.fade_duration,
Light.fade_start_8[i], Light.fade_end_8[i]);
- Light.fade_cur_10[i] = changeUIntScale(Light.fade_counter,
+ Light.fade_cur_10[i] = changeUIntScale(fade_current,
0, Light.fade_duration,
Light.fade_start_10[i], Light.fade_end_10[i]);
}
@@ -1793,7 +1808,7 @@ void LightApplyFade(void) {
// stop fade
//AddLop_P2(LOG_LEVEL_DEBUG, PSTR("Stop fade"));
Light.fade_running = false;
- Light.fade_counter = 0;
+ Light.fade_start = 0;
Light.fade_duration = 0;
// set light to target value
memcpy(Light.fade_cur_8, Light.fade_end_8, sizeof(Light.fade_end_8));
@@ -1802,7 +1817,7 @@ void LightApplyFade(void) {
memcpy(Light.fade_start_8, Light.fade_end_8, sizeof(Light.fade_start_8));
memcpy(Light.fade_start_10, Light.fade_end_10, sizeof(Light.fade_start_10));
}
-
+ return true;
}
// On entry we take the 5 channels 8 bits entry, and we apply Power modifiers
@@ -2428,6 +2443,13 @@ bool Xdrv04(uint8_t function)
case FUNC_SERIAL:
result = XlgtCall(FUNC_SERIAL);
break;
+ case FUNC_LOOP:
+ if (Light.fade_running) {
+ if (LightApplyFade()) {
+ LightSetOutputs(Light.fade_cur_8, Light.fade_cur_10);
+ }
+ }
+ break;
case FUNC_EVERY_50_MSECOND:
LightAnimate();
break;
From fbe29e485b4ea835b46320d85587e7b8f4285d0b Mon Sep 17 00:00:00 2001
From: Hadinger
Date: Sat, 21 Dec 2019 18:39:47 +0100
Subject: [PATCH 41/43] Zigbee aqara switch, support for double/triple clicks
---
tasmota/xdrv_23_zigbee_5_converters.ino | 1 +
1 file changed, 1 insertion(+)
diff --git a/tasmota/xdrv_23_zigbee_5_converters.ino b/tasmota/xdrv_23_zigbee_5_converters.ino
index 687ac2483..a4ab9e9fc 100644
--- a/tasmota/xdrv_23_zigbee_5_converters.ino
+++ b/tasmota/xdrv_23_zigbee_5_converters.ino
@@ -511,6 +511,7 @@ const Z_AttributeConverter Z_PostProcess[] PROGMEM = {
// On/off cluster
{ 0x0006, 0x0000, "Power", &Z_Copy },
+ { 0x0006, 0x8000, "Power", &Z_Copy }, // See 7280
// On/Off Switch Configuration cluster
{ 0x0007, 0x0000, "SwitchType", &Z_Copy },
From d13553baefa9a53af18c1eeb031449fa80708916 Mon Sep 17 00:00:00 2001
From: Theo Arends <11044339+arendst@users.noreply.github.com>
Date: Sat, 21 Dec 2019 18:59:00 +0100
Subject: [PATCH 42/43] Fix restore
Fix restore ShutterAccuracy, MqttLog, WifiConfig, WifiPower and SerialConfig (#7281)
---
tasmota/CHANGELOG.md | 3 +++
tasmota/settings.ino | 10 +++++-----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md
index e8b70c0cd..bd8801376 100644
--- a/tasmota/CHANGELOG.md
+++ b/tasmota/CHANGELOG.md
@@ -9,6 +9,9 @@
### 7.2.0 20191221
- Release
+- Fix Arduino IDE compile error (#7277)
+- Fix restore ShutterAccuracy, MqttLog, WifiConfig, WifiPower and SerialConfig (#7281)
+- Fix no AP on initial install (#7282)
### 7.1.2.6 20191214
diff --git a/tasmota/settings.ino b/tasmota/settings.ino
index 9a0ea44f1..2fd84bde0 100644
--- a/tasmota/settings.ino
+++ b/tasmota/settings.ino
@@ -1240,8 +1240,8 @@ void SettingsDelta(void)
memset((char*)&Settings +0x1D6, 0x00, 16);
}
if (Settings.version < 0x0606000F) {
- Settings.shutter_accuracy = 0;
- Settings.mqttlog_level = MQTT_LOG_LEVEL;
+ Settings.ex_shutter_accuracy = 0;
+ Settings.ex_mqttlog_level = MQTT_LOG_LEVEL;
}
if (Settings.version < 0x06060011) {
Settings.param[P_BACKLOG_DELAY] = MIN_BACKLOG_DELAY;
@@ -1281,7 +1281,7 @@ void SettingsDelta(void)
}
if (Settings.version < 0x06060015) {
if ((EX_WIFI_SMARTCONFIG == Settings.sta_config) || (EX_WIFI_WPSCONFIG == Settings.sta_config)) {
- Settings.sta_config = WIFI_MANAGER;
+ Settings.ex_sta_config = WIFI_MANAGER;
}
}
@@ -1294,10 +1294,10 @@ void SettingsDelta(void)
SettingsEnableAllI2cDrivers();
}
if (Settings.version < 0x07000004) {
- Settings.wifi_output_power = 170;
+ Settings.ex_wifi_output_power = 170;
}
if (Settings.version < 0x07010202) {
- Settings.serial_config = TS_SERIAL_8N1;
+ Settings.ex_serial_config = TS_SERIAL_8N1;
}
if (Settings.version < 0x07010204) {
if (Settings.flag3.ex_cors_enabled == 1) {
From 486894781f775eb7cde2b971aa904d7f3d059a4e Mon Sep 17 00:00:00 2001
From: Hadinger
Date: Sat, 21 Dec 2019 22:38:49 +0100
Subject: [PATCH 43/43] Fix AWS IoT
---
tasmota/settings.ino | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tasmota/settings.ino b/tasmota/settings.ino
index 2fd84bde0..8c378264b 100644
--- a/tasmota/settings.ino
+++ b/tasmota/settings.ino
@@ -1355,7 +1355,7 @@ void SettingsDelta(void)
} else {
char aws_mqtt_host[66];
snprintf_P(aws_mqtt_host, sizeof(aws_mqtt_host), PSTR("%s%s"), temp9, temp7);
- SettingsUpdateText(SET_MQTT_HOST, mqtt_host);
+ SettingsUpdateText(SET_MQTT_HOST, aws_mqtt_host);
SettingsUpdateText(SET_MQTT_USER, "");
}
#else