2017-02-19 16:49:17 +00:00
|
|
|
/*
|
2017-05-13 12:02:10 +01:00
|
|
|
settings.ino - user settings for Sonoff-Tasmota
|
|
|
|
|
2017-12-22 13:55:24 +00:00
|
|
|
Copyright (C) 2018 Theo Arends
|
2017-05-13 12:02:10 +01:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2017-02-19 16:49:17 +00:00
|
|
|
*/
|
|
|
|
|
2017-09-30 12:32:53 +01:00
|
|
|
#ifndef DOMOTICZ_UPDATE_TIMER
|
2017-12-28 12:43:51 +00:00
|
|
|
#define DOMOTICZ_UPDATE_TIMER 0 // [DomoticzUpdateTimer] Send relay status (0 = disable, 1 - 3600 seconds) (Optional)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef EMULATION
|
|
|
|
#define EMULATION EMUL_NONE // [Emulation] Select Belkin WeMo (single relay/light) or Hue Bridge emulation (multi relay/light) (EMUL_NONE, EMUL_WEMO or EMUL_HUE)
|
2017-09-30 12:32:53 +01:00
|
|
|
#endif
|
|
|
|
|
2018-01-07 14:15:01 +00:00
|
|
|
#ifndef MTX_ADDRESS1 // Add Display Support for up to eigth Matrices
|
2018-01-07 13:56:23 +00:00
|
|
|
#define MTX_ADDRESS1 0
|
2018-01-07 14:15:01 +00:00
|
|
|
#endif
|
|
|
|
#ifndef MTX_ADDRESS2
|
2018-01-07 13:56:23 +00:00
|
|
|
#define MTX_ADDRESS2 0
|
2018-01-07 14:15:01 +00:00
|
|
|
#endif
|
|
|
|
#ifndef MTX_ADDRESS3
|
2018-01-07 13:56:23 +00:00
|
|
|
#define MTX_ADDRESS3 0
|
2018-01-07 14:15:01 +00:00
|
|
|
#endif
|
|
|
|
#ifndef MTX_ADDRESS4
|
2018-01-07 13:56:23 +00:00
|
|
|
#define MTX_ADDRESS4 0
|
2018-01-07 14:15:01 +00:00
|
|
|
#endif
|
|
|
|
#ifndef MTX_ADDRESS5
|
2018-01-07 13:56:23 +00:00
|
|
|
#define MTX_ADDRESS5 0
|
2018-01-07 14:15:01 +00:00
|
|
|
#endif
|
|
|
|
#ifndef MTX_ADDRESS6
|
2018-01-07 13:56:23 +00:00
|
|
|
#define MTX_ADDRESS6 0
|
2018-01-07 14:15:01 +00:00
|
|
|
#endif
|
|
|
|
#ifndef MTX_ADDRESS7
|
2018-01-07 13:56:23 +00:00
|
|
|
#define MTX_ADDRESS7 0
|
2018-01-07 14:15:01 +00:00
|
|
|
#endif
|
|
|
|
#ifndef MTX_ADDRESS8
|
2018-01-07 13:56:23 +00:00
|
|
|
#define MTX_ADDRESS8 0
|
|
|
|
#endif
|
|
|
|
|
2018-02-17 13:09:39 +00:00
|
|
|
#ifndef HOME_ASSISTANT_DISCOVERY_ENABLE
|
|
|
|
#define HOME_ASSISTANT_DISCOVERY_ENABLE 0
|
|
|
|
#endif
|
|
|
|
|
2017-02-28 15:01:48 +00:00
|
|
|
/*********************************************************************************************\
|
|
|
|
* RTC memory
|
|
|
|
\*********************************************************************************************/
|
|
|
|
|
|
|
|
#define RTC_MEM_VALID 0xA55A
|
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
uint32_t rtc_settings_hash = 0;
|
2017-02-28 15:01:48 +00:00
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
uint32_t GetRtcSettingsHash()
|
2017-02-28 15:01:48 +00:00
|
|
|
{
|
|
|
|
uint32_t hash = 0;
|
2017-10-18 17:22:34 +01:00
|
|
|
uint8_t *bytes = (uint8_t*)&RtcSettings;
|
2017-02-28 15:01:48 +00:00
|
|
|
|
2017-04-25 17:24:42 +01:00
|
|
|
for (uint16_t i = 0; i < sizeof(RTCMEM); i++) {
|
|
|
|
hash += bytes[i]*(i+1);
|
|
|
|
}
|
2017-02-28 15:01:48 +00:00
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
void RtcSettingsSave()
|
2017-02-28 15:01:48 +00:00
|
|
|
{
|
2017-10-18 17:22:34 +01:00
|
|
|
if (GetRtcSettingsHash() != rtc_settings_hash) {
|
|
|
|
RtcSettings.valid = RTC_MEM_VALID;
|
|
|
|
ESP.rtcUserMemoryWrite(100, (uint32_t*)&RtcSettings, sizeof(RTCMEM));
|
|
|
|
rtc_settings_hash = GetRtcSettingsHash();
|
2017-02-28 15:01:48 +00:00
|
|
|
#ifdef DEBUG_THEO
|
2017-10-18 17:22:34 +01:00
|
|
|
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Dump: Save"));
|
|
|
|
RtcSettingsDump();
|
2017-02-28 15:01:48 +00:00
|
|
|
#endif // DEBUG_THEO
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
void RtcSettingsLoad()
|
2017-02-28 15:01:48 +00:00
|
|
|
{
|
2017-10-18 17:22:34 +01:00
|
|
|
ESP.rtcUserMemoryRead(100, (uint32_t*)&RtcSettings, sizeof(RTCMEM));
|
2017-02-28 15:01:48 +00:00
|
|
|
#ifdef DEBUG_THEO
|
2017-10-18 17:22:34 +01:00
|
|
|
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Dump: Load"));
|
|
|
|
RtcSettingsDump();
|
2017-02-28 15:01:48 +00:00
|
|
|
#endif // DEBUG_THEO
|
2017-10-18 17:22:34 +01:00
|
|
|
if (RtcSettings.valid != RTC_MEM_VALID) {
|
|
|
|
memset(&RtcSettings, 0, sizeof(RTCMEM));
|
|
|
|
RtcSettings.valid = RTC_MEM_VALID;
|
2017-12-16 14:51:45 +00:00
|
|
|
RtcSettings.energy_kWhtoday = Settings.energy_kWhtoday;
|
|
|
|
RtcSettings.energy_kWhtotal = Settings.energy_kWhtotal;
|
2017-10-10 14:40:02 +01:00
|
|
|
for (byte i = 0; i < MAX_COUNTERS; i++) {
|
2017-10-18 17:22:34 +01:00
|
|
|
RtcSettings.pulse_counter[i] = Settings.pulse_counter[i];
|
2017-05-17 21:49:22 +01:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
RtcSettings.power = Settings.power;
|
|
|
|
RtcSettingsSave();
|
2017-02-28 15:01:48 +00:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
rtc_settings_hash = GetRtcSettingsHash();
|
2017-02-28 15:01:48 +00:00
|
|
|
}
|
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
boolean RtcSettingsValid()
|
2017-02-28 15:01:48 +00:00
|
|
|
{
|
2017-10-18 17:22:34 +01:00
|
|
|
return (RTC_MEM_VALID == RtcSettings.valid);
|
2017-02-28 15:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG_THEO
|
2017-10-18 17:22:34 +01:00
|
|
|
void RtcSettingsDump()
|
2017-02-28 15:01:48 +00:00
|
|
|
{
|
|
|
|
#define CFG_COLS 16
|
2017-09-02 13:37:02 +01:00
|
|
|
|
2017-04-25 17:24:42 +01:00
|
|
|
uint16_t idx;
|
|
|
|
uint16_t maxrow;
|
|
|
|
uint16_t row;
|
|
|
|
uint16_t col;
|
2017-02-28 15:01:48 +00:00
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
uint8_t *buffer = (uint8_t *) &RtcSettings;
|
2017-02-28 15:01:48 +00:00
|
|
|
maxrow = ((sizeof(RTCMEM)+CFG_COLS)/CFG_COLS);
|
|
|
|
|
|
|
|
for (row = 0; row < maxrow; row++) {
|
|
|
|
idx = row * CFG_COLS;
|
2018-02-06 12:50:05 +00:00
|
|
|
snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), idx);
|
2017-02-28 15:01:48 +00:00
|
|
|
for (col = 0; col < CFG_COLS; col++) {
|
2017-04-25 17:24:42 +01:00
|
|
|
if (!(col%4)) {
|
2017-09-13 13:19:34 +01:00
|
|
|
snprintf_P(log_data, sizeof(log_data), PSTR("%s "), log_data);
|
2017-04-25 17:24:42 +01:00
|
|
|
}
|
2017-09-13 13:19:34 +01:00
|
|
|
snprintf_P(log_data, sizeof(log_data), PSTR("%s %02X"), log_data, buffer[idx + col]);
|
2017-02-28 15:01:48 +00:00
|
|
|
}
|
2017-09-13 13:19:34 +01:00
|
|
|
snprintf_P(log_data, sizeof(log_data), PSTR("%s |"), log_data);
|
2017-02-28 15:01:48 +00:00
|
|
|
for (col = 0; col < CFG_COLS; col++) {
|
2017-04-25 17:24:42 +01:00
|
|
|
// if (!(col%4)) {
|
2017-09-13 13:19:34 +01:00
|
|
|
// snprintf_P(log_data, sizeof(log_data), PSTR("%s "), log_data);
|
2017-04-25 17:24:42 +01:00
|
|
|
// }
|
2017-09-13 13:19:34 +01:00
|
|
|
snprintf_P(log_data, sizeof(log_data), PSTR("%s%c"), log_data, ((buffer[idx + col] > 0x20) && (buffer[idx + col] < 0x7F)) ? (char)buffer[idx + col] : ' ');
|
2017-02-28 15:01:48 +00:00
|
|
|
}
|
2017-09-13 13:19:34 +01:00
|
|
|
snprintf_P(log_data, sizeof(log_data), PSTR("%s|"), log_data);
|
2017-10-18 17:22:34 +01:00
|
|
|
AddLog(LOG_LEVEL_INFO);
|
2017-02-28 15:01:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // DEBUG_THEO
|
|
|
|
|
2017-02-19 16:49:17 +00:00
|
|
|
/*********************************************************************************************\
|
2017-04-24 17:25:53 +01:00
|
|
|
* Config - Flash
|
2017-02-19 16:49:17 +00:00
|
|
|
\*********************************************************************************************/
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include "spi_flash.h"
|
|
|
|
}
|
|
|
|
#include "eboot_command.h"
|
|
|
|
|
2017-04-24 17:25:53 +01:00
|
|
|
extern "C" uint32_t _SPIFFS_end;
|
|
|
|
|
2018-02-15 11:29:07 +00:00
|
|
|
// From libraries/EEPROM/EEPROM.cpp EEPROMClass
|
2017-02-19 16:49:17 +00:00
|
|
|
#define SPIFFS_END ((uint32_t)&_SPIFFS_end - 0x40200000) / SPI_FLASH_SEC_SIZE
|
|
|
|
|
2017-06-22 21:00:09 +01:00
|
|
|
// Version 3.x config
|
2017-10-18 17:22:34 +01:00
|
|
|
#define SETTINGS_LOCATION_3 SPIFFS_END - 4
|
2017-06-22 21:00:09 +01:00
|
|
|
|
2017-04-24 17:25:53 +01:00
|
|
|
// Version 4.2 config = eeprom area
|
2017-10-18 17:22:34 +01:00
|
|
|
#define SETTINGS_LOCATION SPIFFS_END // No need for SPIFFS as it uses EEPROM area
|
2017-06-19 21:54:49 +01:00
|
|
|
// Version 5.2 allow for more flash space
|
2017-07-15 14:07:30 +01:00
|
|
|
#define CFG_ROTATES 8 // Number of flash sectors used (handles uploads)
|
2017-02-19 16:49:17 +00:00
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
uint32_t settings_hash = 0;
|
|
|
|
uint32_t settings_location = SETTINGS_LOCATION;
|
2017-02-19 16:49:17 +00:00
|
|
|
|
|
|
|
/********************************************************************************************/
|
|
|
|
/*
|
|
|
|
* Based on cores/esp8266/Updater.cpp
|
|
|
|
*/
|
2017-10-18 17:22:34 +01:00
|
|
|
void SetFlashModeDout()
|
2017-02-19 16:49:17 +00:00
|
|
|
{
|
|
|
|
uint8_t *_buffer;
|
|
|
|
uint32_t address;
|
|
|
|
|
2017-08-08 15:31:43 +01:00
|
|
|
eboot_command ebcmd;
|
|
|
|
eboot_command_read(&ebcmd);
|
|
|
|
address = ebcmd.args[0];
|
2017-02-19 16:49:17 +00:00
|
|
|
_buffer = new uint8_t[FLASH_SECTOR_SIZE];
|
2018-02-24 15:37:33 +00:00
|
|
|
|
|
|
|
if (ESP.flashRead(address, (uint32_t*)_buffer, FLASH_SECTOR_SIZE)) {
|
2017-08-08 15:31:43 +01:00
|
|
|
if (_buffer[2] != 3) { // DOUT
|
|
|
|
_buffer[2] = 3;
|
2018-02-24 15:37:33 +00:00
|
|
|
if (ESP.flashEraseSector(address / FLASH_SECTOR_SIZE)) ESP.flashWrite(address, (uint32_t*)_buffer, FLASH_SECTOR_SIZE);
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
delete[] _buffer;
|
|
|
|
}
|
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
uint32_t GetSettingsHash()
|
2017-02-19 16:49:17 +00:00
|
|
|
{
|
|
|
|
uint32_t hash = 0;
|
2017-10-18 17:22:34 +01:00
|
|
|
uint8_t *bytes = (uint8_t*)&Settings;
|
2017-02-19 16:49:17 +00:00
|
|
|
|
2017-04-25 17:24:42 +01:00
|
|
|
for (uint16_t i = 0; i < sizeof(SYSCFG); i++) {
|
|
|
|
hash += bytes[i]*(i+1);
|
|
|
|
}
|
2017-02-19 16:49:17 +00:00
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
|
2017-11-21 15:06:51 +00:00
|
|
|
void SettingsSaveAll()
|
|
|
|
{
|
|
|
|
if (Settings.flag.save_state) {
|
|
|
|
Settings.power = power;
|
|
|
|
} else {
|
|
|
|
Settings.power = 0;
|
|
|
|
}
|
2017-12-25 16:41:12 +00:00
|
|
|
XsnsCall(FUNC_SAVE_BEFORE_RESTART);
|
2017-11-21 15:06:51 +00:00
|
|
|
SettingsSave(0);
|
|
|
|
}
|
|
|
|
|
2017-02-19 16:49:17 +00:00
|
|
|
/*********************************************************************************************\
|
2017-04-24 17:25:53 +01:00
|
|
|
* Config Save - Save parameters to Flash ONLY if any parameter has changed
|
2017-02-19 16:49:17 +00:00
|
|
|
\*********************************************************************************************/
|
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
uint32_t GetSettingsAddress()
|
2017-06-25 22:01:41 +01:00
|
|
|
{
|
2017-10-18 17:22:34 +01:00
|
|
|
return settings_location * SPI_FLASH_SEC_SIZE;
|
2017-06-25 22:01:41 +01:00
|
|
|
}
|
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
void SettingsSave(byte rotate)
|
2017-02-19 16:49:17 +00:00
|
|
|
{
|
2017-06-30 16:54:19 +01:00
|
|
|
/* Save configuration in eeprom or one of 7 slots below
|
2017-09-02 13:37:02 +01:00
|
|
|
*
|
2017-06-30 16:54:19 +01:00
|
|
|
* rotate 0 = Save in next flash slot
|
|
|
|
* rotate 1 = Save only in eeprom flash slot until SetOption12 0 or restart
|
2017-07-25 17:05:47 +01:00
|
|
|
* rotate 2 = Save in eeprom flash slot, erase next flash slots and continue depending on stop_flash_rotate
|
2017-06-30 16:54:19 +01:00
|
|
|
* stop_flash_rotate 0 = Allow flash slot rotation (SetOption12 0)
|
|
|
|
* stop_flash_rotate 1 = Allow only eeprom flash slot use (SetOption12 1)
|
|
|
|
*/
|
2017-03-29 17:42:05 +01:00
|
|
|
#ifndef BE_MINIMAL
|
2017-10-18 17:22:34 +01:00
|
|
|
if ((GetSettingsHash() != settings_hash) || rotate) {
|
2017-07-25 17:05:47 +01:00
|
|
|
if (1 == rotate) { // Use eeprom flash slot only and disable flash rotate from now on (upgrade)
|
|
|
|
stop_flash_rotate = 1;
|
2017-06-25 22:01:41 +01:00
|
|
|
}
|
2017-07-25 17:05:47 +01:00
|
|
|
if (2 == rotate) { // Use eeprom flash slot and erase next flash slots if stop_flash_rotate is off (default)
|
2017-10-18 17:22:34 +01:00
|
|
|
settings_location = SETTINGS_LOCATION +1;
|
2017-06-30 16:54:19 +01:00
|
|
|
}
|
2017-06-25 22:01:41 +01:00
|
|
|
if (stop_flash_rotate) {
|
2017-10-18 17:22:34 +01:00
|
|
|
settings_location = SETTINGS_LOCATION;
|
2017-06-19 21:54:49 +01:00
|
|
|
} else {
|
2017-10-18 17:22:34 +01:00
|
|
|
settings_location--;
|
|
|
|
if (settings_location <= (SETTINGS_LOCATION - CFG_ROTATES)) {
|
|
|
|
settings_location = SETTINGS_LOCATION;
|
2017-06-19 21:54:49 +01:00
|
|
|
}
|
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.save_flag++;
|
2018-02-24 15:37:33 +00:00
|
|
|
ESP.flashEraseSector(settings_location);
|
|
|
|
ESP.flashWrite(settings_location * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(SYSCFG));
|
2017-06-30 16:54:19 +01:00
|
|
|
if (!stop_flash_rotate && rotate) {
|
2017-06-19 21:54:49 +01:00
|
|
|
for (byte i = 1; i < CFG_ROTATES; i++) {
|
2018-02-24 15:37:33 +00:00
|
|
|
ESP.flashEraseSector(settings_location -i); // Delete previous configurations by resetting to 0xFF
|
2017-06-19 21:54:49 +01:00
|
|
|
delay(1);
|
|
|
|
}
|
|
|
|
}
|
2017-09-13 13:19:34 +01:00
|
|
|
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_CONFIG D_SAVED_TO_FLASH_AT " %X, " D_COUNT " %d, " D_BYTES " %d"),
|
2017-10-18 17:22:34 +01:00
|
|
|
settings_location, Settings.save_flag, sizeof(SYSCFG));
|
|
|
|
AddLog(LOG_LEVEL_DEBUG);
|
|
|
|
settings_hash = GetSettingsHash();
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
2017-03-29 17:42:05 +01:00
|
|
|
#endif // BE_MINIMAL
|
2017-10-18 17:22:34 +01:00
|
|
|
RtcSettingsSave();
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
void SettingsLoad()
|
2017-02-19 16:49:17 +00:00
|
|
|
{
|
2017-06-30 16:54:19 +01:00
|
|
|
/* Load configuration from eeprom or one of 7 slots below if first load does not stop_flash_rotate
|
|
|
|
*/
|
2017-04-24 17:25:53 +01:00
|
|
|
struct SYSCFGH {
|
|
|
|
unsigned long cfg_holder;
|
2017-10-18 17:22:34 +01:00
|
|
|
unsigned long save_flag;
|
|
|
|
} _SettingsH;
|
2017-02-19 16:49:17 +00:00
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
settings_location = SETTINGS_LOCATION +1;
|
2017-06-19 21:54:49 +01:00
|
|
|
for (byte i = 0; i < CFG_ROTATES; i++) {
|
2017-10-18 17:22:34 +01:00
|
|
|
settings_location--;
|
2018-02-24 15:37:33 +00:00
|
|
|
ESP.flashRead(settings_location * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(SYSCFG));
|
|
|
|
ESP.flashRead((settings_location -1) * SPI_FLASH_SEC_SIZE, (uint32*)&_SettingsH, sizeof(SYSCFGH));
|
2017-04-24 17:25:53 +01:00
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
// snprintf_P(log_data, sizeof(log_data), PSTR("Cnfg: Check at %X with count %d and holder %X"), settings_location -1, _SettingsH.save_flag, _SettingsH.cfg_holder);
|
|
|
|
// AddLog(LOG_LEVEL_DEBUG);
|
2017-06-19 21:54:49 +01:00
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
if (((Settings.version > 0x05000200) && Settings.flag.stop_flash_rotate) || (Settings.cfg_holder != _SettingsH.cfg_holder) || (Settings.save_flag > _SettingsH.save_flag)) {
|
2017-06-19 21:54:49 +01:00
|
|
|
break;
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
2017-06-19 21:54:49 +01:00
|
|
|
delay(1);
|
|
|
|
}
|
2017-09-13 13:19:34 +01:00
|
|
|
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_CONFIG D_LOADED_FROM_FLASH_AT " %X, " D_COUNT " %d"),
|
2017-10-18 17:22:34 +01:00
|
|
|
settings_location, Settings.save_flag);
|
|
|
|
AddLog(LOG_LEVEL_DEBUG);
|
|
|
|
if (Settings.cfg_holder != CFG_HOLDER) {
|
2017-06-30 16:54:19 +01:00
|
|
|
// Auto upgrade
|
2018-02-24 15:37:33 +00:00
|
|
|
ESP.flashRead((SETTINGS_LOCATION_3) * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(SYSCFG));
|
|
|
|
ESP.flashRead((SETTINGS_LOCATION_3 + 1) * SPI_FLASH_SEC_SIZE, (uint32*)&_SettingsH, sizeof(SYSCFGH));
|
|
|
|
if (Settings.save_flag < _SettingsH.save_flag) ESP.flashRead((SETTINGS_LOCATION_3 + 1) * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(SYSCFG));
|
|
|
|
if ((Settings.cfg_holder != CFG_HOLDER) || (Settings.version >= 0x04020000)) SettingsDefault();
|
2017-06-22 21:00:09 +01:00
|
|
|
}
|
2017-09-02 13:37:02 +01:00
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
settings_hash = GetSettingsHash();
|
2017-02-28 15:01:48 +00:00
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
RtcSettingsLoad();
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
|
|
|
|
2018-02-24 15:37:33 +00:00
|
|
|
void SettingsErase(uint8_t type)
|
2017-02-19 16:49:17 +00:00
|
|
|
{
|
2018-02-24 15:37:33 +00:00
|
|
|
/*
|
|
|
|
0 = Erase from program end until end of physical flash
|
|
|
|
1 = Erase SDK parameter area at end of linker memory model (0x0FDxxx - 0x0FFFFF) solving possible wifi errors
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool result;
|
2017-02-19 16:49:17 +00:00
|
|
|
|
|
|
|
uint32_t _sectorStart = (ESP.getSketchSize() / SPI_FLASH_SEC_SIZE) + 1;
|
|
|
|
uint32_t _sectorEnd = ESP.getFlashChipRealSize() / SPI_FLASH_SEC_SIZE;
|
2018-02-24 15:37:33 +00:00
|
|
|
if (1 == type) {
|
|
|
|
_sectorStart = SETTINGS_LOCATION +2; // SDK parameter area above EEPROM area (0x0FDxxx - 0x0FFFFF)
|
|
|
|
_sectorEnd = SETTINGS_LOCATION +5;
|
|
|
|
}
|
|
|
|
|
2017-02-19 16:49:17 +00:00
|
|
|
boolean _serialoutput = (LOG_LEVEL_DEBUG_MORE <= seriallog_level);
|
|
|
|
|
2017-09-13 13:19:34 +01:00
|
|
|
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_ERASE " %d " D_UNIT_SECTORS), _sectorEnd - _sectorStart);
|
2017-10-18 17:22:34 +01:00
|
|
|
AddLog(LOG_LEVEL_DEBUG);
|
2017-02-19 16:49:17 +00:00
|
|
|
|
|
|
|
for (uint32_t _sector = _sectorStart; _sector < _sectorEnd; _sector++) {
|
2018-02-24 15:37:33 +00:00
|
|
|
result = ESP.flashEraseSector(_sector);
|
2017-02-19 16:49:17 +00:00
|
|
|
if (_serialoutput) {
|
2017-09-02 13:37:02 +01:00
|
|
|
Serial.print(F(D_LOG_APPLICATION D_ERASED_SECTOR " "));
|
2017-02-19 16:49:17 +00:00
|
|
|
Serial.print(_sector);
|
2018-02-24 15:37:33 +00:00
|
|
|
if (result) {
|
2017-09-02 13:37:02 +01:00
|
|
|
Serial.println(F(" " D_OK));
|
2017-02-19 16:49:17 +00:00
|
|
|
} else {
|
2017-09-02 13:37:02 +01:00
|
|
|
Serial.println(F(" " D_ERROR));
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
|
|
|
delay(10);
|
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
OsWatchLoop();
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-24 15:37:33 +00:00
|
|
|
// Copied from 2.4.0 as 2.3.0 is incomplete
|
|
|
|
bool SettingsEraseConfig(void) {
|
|
|
|
const size_t cfgSize = 0x4000;
|
|
|
|
size_t cfgAddr = ESP.getFlashChipSize() - cfgSize;
|
|
|
|
|
|
|
|
for (size_t offset = 0; offset < cfgSize; offset += SPI_FLASH_SEC_SIZE) {
|
|
|
|
if (!ESP.flashEraseSector((cfgAddr + offset) / SPI_FLASH_SEC_SIZE)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsSdkErase()
|
|
|
|
{
|
|
|
|
WiFi.disconnect(true); // Delete SDK wifi config
|
|
|
|
SettingsErase(1);
|
|
|
|
SettingsEraseConfig();
|
|
|
|
delay(1000);
|
|
|
|
}
|
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
void SettingsDump(char* parms)
|
2017-02-19 16:49:17 +00:00
|
|
|
{
|
|
|
|
#define CFG_COLS 16
|
2017-09-02 13:37:02 +01:00
|
|
|
|
2017-04-25 17:24:42 +01:00
|
|
|
uint16_t idx;
|
|
|
|
uint16_t maxrow;
|
|
|
|
uint16_t row;
|
|
|
|
uint16_t col;
|
2017-07-30 16:55:37 +01:00
|
|
|
char *p;
|
2017-02-19 16:49:17 +00:00
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
uint8_t *buffer = (uint8_t *) &Settings;
|
2017-02-19 16:49:17 +00:00
|
|
|
maxrow = ((sizeof(SYSCFG)+CFG_COLS)/CFG_COLS);
|
2017-07-30 16:55:37 +01:00
|
|
|
|
|
|
|
uint16_t srow = strtol(parms, &p, 16) / CFG_COLS;
|
|
|
|
uint16_t mrow = strtol(p, &p, 10);
|
|
|
|
|
2017-09-13 13:19:34 +01:00
|
|
|
// snprintf_P(log_data, sizeof(log_data), PSTR("Cnfg: Parms %s, Start row %d, rows %d"), parms, srow, mrow);
|
2017-10-18 17:22:34 +01:00
|
|
|
// AddLog(LOG_LEVEL_DEBUG);
|
2017-07-30 16:55:37 +01:00
|
|
|
|
|
|
|
if (0 == mrow) { // Default only 8 lines
|
|
|
|
mrow = 8;
|
2017-05-03 17:19:13 +01:00
|
|
|
}
|
2017-07-30 16:55:37 +01:00
|
|
|
if (srow > maxrow) {
|
|
|
|
srow = maxrow - mrow;
|
2017-05-03 17:19:13 +01:00
|
|
|
}
|
2017-07-30 16:55:37 +01:00
|
|
|
if (mrow < (maxrow - srow)) {
|
|
|
|
maxrow = srow + mrow;
|
2017-05-03 17:19:13 +01:00
|
|
|
}
|
2017-02-19 16:49:17 +00:00
|
|
|
|
2017-05-03 17:19:13 +01:00
|
|
|
for (row = srow; row < maxrow; row++) {
|
2017-02-19 16:49:17 +00:00
|
|
|
idx = row * CFG_COLS;
|
2018-02-06 12:50:05 +00:00
|
|
|
snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), idx);
|
2017-02-19 16:49:17 +00:00
|
|
|
for (col = 0; col < CFG_COLS; col++) {
|
2017-04-25 17:24:42 +01:00
|
|
|
if (!(col%4)) {
|
2017-09-13 13:19:34 +01:00
|
|
|
snprintf_P(log_data, sizeof(log_data), PSTR("%s "), log_data);
|
2017-04-25 17:24:42 +01:00
|
|
|
}
|
2017-09-13 13:19:34 +01:00
|
|
|
snprintf_P(log_data, sizeof(log_data), PSTR("%s %02X"), log_data, buffer[idx + col]);
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
2017-09-13 13:19:34 +01:00
|
|
|
snprintf_P(log_data, sizeof(log_data), PSTR("%s |"), log_data);
|
2017-02-19 16:49:17 +00:00
|
|
|
for (col = 0; col < CFG_COLS; col++) {
|
2017-04-25 17:24:42 +01:00
|
|
|
// if (!(col%4)) {
|
2017-09-13 13:19:34 +01:00
|
|
|
// snprintf_P(log_data, sizeof(log_data), PSTR("%s "), log_data);
|
2017-04-25 17:24:42 +01:00
|
|
|
// }
|
2017-09-13 13:19:34 +01:00
|
|
|
snprintf_P(log_data, sizeof(log_data), PSTR("%s%c"), log_data, ((buffer[idx + col] > 0x20) && (buffer[idx + col] < 0x7F)) ? (char)buffer[idx + col] : ' ');
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
2017-09-13 13:19:34 +01:00
|
|
|
snprintf_P(log_data, sizeof(log_data), PSTR("%s|"), log_data);
|
2017-10-18 17:22:34 +01:00
|
|
|
AddLog(LOG_LEVEL_INFO);
|
2017-08-05 14:11:50 +01:00
|
|
|
delay(1);
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************************/
|
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
void SettingsDefault()
|
2017-05-03 17:19:13 +01:00
|
|
|
{
|
2017-10-18 17:22:34 +01:00
|
|
|
AddLog_P(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG D_USE_DEFAULTS));
|
|
|
|
SettingsDefaultSet1();
|
|
|
|
SettingsDefaultSet2();
|
|
|
|
SettingsSave(2);
|
2017-05-03 17:19:13 +01:00
|
|
|
}
|
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
void SettingsDefaultSet1()
|
2017-02-19 16:49:17 +00:00
|
|
|
{
|
2017-10-18 17:22:34 +01:00
|
|
|
memset(&Settings, 0x00, sizeof(SYSCFG));
|
2017-02-19 16:49:17 +00:00
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.cfg_holder = CFG_HOLDER;
|
|
|
|
// Settings.save_flag = 0;
|
|
|
|
Settings.version = VERSION;
|
|
|
|
// Settings.bootcount = 0;
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
2017-09-02 13:37:02 +01:00
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
void SettingsDefaultSet2()
|
2017-02-19 16:49:17 +00:00
|
|
|
{
|
2017-10-18 17:22:34 +01:00
|
|
|
memset((char*)&Settings +16, 0x00, sizeof(SYSCFG) -16);
|
|
|
|
|
|
|
|
Settings.flag.save_state = SAVE_STATE;
|
|
|
|
//Settings.flag.button_restrict = 0;
|
|
|
|
//Settings.flag.value_units = 0;
|
|
|
|
Settings.flag.mqtt_enabled = MQTT_USE;
|
|
|
|
//Settings.flag.mqtt_response = 0;
|
|
|
|
Settings.flag.mqtt_power_retain = MQTT_POWER_RETAIN;
|
|
|
|
Settings.flag.mqtt_button_retain = MQTT_BUTTON_RETAIN;
|
|
|
|
Settings.flag.mqtt_switch_retain = MQTT_SWITCH_RETAIN;
|
2018-01-27 16:52:48 +00:00
|
|
|
Settings.flag.hass_discovery = HOME_ASSISTANT_DISCOVERY_ENABLE;
|
2017-10-18 17:22:34 +01:00
|
|
|
|
2017-11-11 11:33:30 +00:00
|
|
|
Settings.flag2.emulation = EMULATION;
|
2017-10-18 17:22:34 +01:00
|
|
|
|
|
|
|
Settings.save_data = SAVE_DATA;
|
|
|
|
Settings.timezone = APP_TIMEZONE;
|
|
|
|
strlcpy(Settings.ota_url, OTA_URL, sizeof(Settings.ota_url));
|
|
|
|
|
|
|
|
Settings.seriallog_level = SERIAL_LOG_LEVEL;
|
|
|
|
// Settings.sta_active = 0;
|
|
|
|
strlcpy(Settings.sta_ssid[0], STA_SSID1, sizeof(Settings.sta_ssid[0]));
|
|
|
|
strlcpy(Settings.sta_pwd[0], STA_PASS1, sizeof(Settings.sta_pwd[0]));
|
|
|
|
strlcpy(Settings.sta_ssid[1], STA_SSID2, sizeof(Settings.sta_ssid[1]));
|
|
|
|
strlcpy(Settings.sta_pwd[1], STA_PASS2, sizeof(Settings.sta_pwd[1]));
|
|
|
|
strlcpy(Settings.hostname, WIFI_HOSTNAME, sizeof(Settings.hostname));
|
|
|
|
Settings.sta_config = WIFI_CONFIG_TOOL;
|
|
|
|
strlcpy(Settings.syslog_host, SYS_LOG_HOST, sizeof(Settings.syslog_host));
|
|
|
|
Settings.syslog_port = SYS_LOG_PORT;
|
|
|
|
Settings.syslog_level = SYS_LOG_LEVEL;
|
|
|
|
Settings.webserver = WEB_SERVER;
|
|
|
|
Settings.weblog_level = WEB_LOG_LEVEL;
|
|
|
|
|
2018-03-09 17:08:17 +00:00
|
|
|
char fingerprint[60];
|
|
|
|
strlcpy(fingerprint, MQTT_FINGERPRINT1, sizeof(fingerprint));
|
|
|
|
char *p = fingerprint;
|
|
|
|
for (byte i = 0; i < 20; i++) {
|
|
|
|
Settings.mqtt_fingerprint[0][i] = strtol(p, &p, 16);
|
|
|
|
}
|
|
|
|
strlcpy(fingerprint, MQTT_FINGERPRINT2, sizeof(fingerprint));
|
|
|
|
p = fingerprint;
|
|
|
|
for (byte i = 0; i < 20; i++) {
|
|
|
|
Settings.mqtt_fingerprint[1][i] = strtol(p, &p, 16);
|
|
|
|
}
|
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
strlcpy(Settings.mqtt_host, MQTT_HOST, sizeof(Settings.mqtt_host));
|
|
|
|
Settings.mqtt_port = MQTT_PORT;
|
|
|
|
strlcpy(Settings.mqtt_client, MQTT_CLIENT_ID, sizeof(Settings.mqtt_client));
|
|
|
|
strlcpy(Settings.mqtt_user, MQTT_USER, sizeof(Settings.mqtt_user));
|
|
|
|
strlcpy(Settings.mqtt_pwd, MQTT_PASS, sizeof(Settings.mqtt_pwd));
|
|
|
|
strlcpy(Settings.mqtt_topic, MQTT_TOPIC, sizeof(Settings.mqtt_topic));
|
|
|
|
strlcpy(Settings.button_topic, "0", sizeof(Settings.button_topic));
|
|
|
|
strlcpy(Settings.mqtt_grptopic, MQTT_GRPTOPIC, sizeof(Settings.mqtt_grptopic));
|
|
|
|
Settings.tele_period = TELE_PERIOD;
|
|
|
|
|
|
|
|
Settings.power = APP_POWER;
|
|
|
|
Settings.poweronstate = APP_POWERON_STATE;
|
|
|
|
Settings.ledstate = APP_LEDSTATE;
|
|
|
|
Settings.blinktime = APP_BLINKTIME;
|
|
|
|
Settings.blinkcount = APP_BLINKCOUNT;
|
|
|
|
Settings.sleep = APP_SLEEP;
|
|
|
|
|
|
|
|
Settings.domoticz_update_timer = DOMOTICZ_UPDATE_TIMER;
|
2017-10-12 13:09:19 +01:00
|
|
|
for (byte i = 0; i < MAX_SWITCHES; i++) {
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.switchmode[i] = SWITCH_MODE;
|
|
|
|
// Settings.domoticz_relay_idx[i] = 0;
|
|
|
|
// Settings.domoticz_key_idx[i] = 0;
|
|
|
|
// Settings.domoticz_switch_idx[i] = 0;
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
|
|
|
|
2018-03-14 13:32:51 +00:00
|
|
|
Settings.energy_power_delta = 80;
|
2018-02-03 22:25:05 +00:00
|
|
|
Settings.energy_power_calibration = HLW_PREF_PULSE;
|
|
|
|
Settings.energy_voltage_calibration = HLW_UREF_PULSE;
|
|
|
|
Settings.energy_current_calibration = HLW_IREF_PULSE;
|
2017-12-16 14:51:45 +00:00
|
|
|
// Settings.energy_kWhtoday = 0;
|
|
|
|
// Settings.energy_kWhyesterday = 0;
|
|
|
|
// Settings.energy_kWhdoy = 0;
|
|
|
|
// Settings.energy_min_power = 0;
|
|
|
|
// Settings.energy_max_power = 0;
|
|
|
|
// Settings.energy_min_voltage = 0;
|
|
|
|
// Settings.energy_max_voltage = 0;
|
|
|
|
// Settings.energy_min_current = 0;
|
|
|
|
// Settings.energy_max_current = 0;
|
|
|
|
// Settings.energy_max_power_limit = 0; // MaxPowerLimit
|
|
|
|
Settings.energy_max_power_limit_hold = MAX_POWER_HOLD;
|
|
|
|
Settings.energy_max_power_limit_window = MAX_POWER_WINDOW;
|
|
|
|
// Settings.energy_max_power_safe_limit = 0; // MaxSafePowerLimit
|
|
|
|
Settings.energy_max_power_safe_limit_hold = SAFE_POWER_HOLD;
|
|
|
|
Settings.energy_max_power_safe_limit_window = SAFE_POWER_WINDOW;
|
|
|
|
// Settings.energy_max_energy = 0; // MaxEnergy
|
|
|
|
// Settings.energy_max_energy_start = 0; // MaxEnergyStart
|
2017-10-18 17:22:34 +01:00
|
|
|
|
|
|
|
SettingsDefaultSet_3_2_4();
|
|
|
|
|
|
|
|
strlcpy(Settings.friendlyname[0], FRIENDLY_NAME, sizeof(Settings.friendlyname[0]));
|
|
|
|
strlcpy(Settings.friendlyname[1], FRIENDLY_NAME"2", sizeof(Settings.friendlyname[1]));
|
|
|
|
strlcpy(Settings.friendlyname[2], FRIENDLY_NAME"3", sizeof(Settings.friendlyname[2]));
|
|
|
|
strlcpy(Settings.friendlyname[3], FRIENDLY_NAME"4", sizeof(Settings.friendlyname[3]));
|
|
|
|
|
|
|
|
SettingsDefaultSet_3_9_3();
|
|
|
|
|
|
|
|
strlcpy(Settings.switch_topic, "0", sizeof(Settings.switch_topic));
|
|
|
|
|
|
|
|
strlcpy(Settings.web_password, WEB_PASSWORD, sizeof(Settings.web_password));
|
|
|
|
|
|
|
|
SettingsDefaultSet_4_0_4();
|
|
|
|
Settings.pulse_timer[0] = APP_PULSETIME;
|
2017-03-19 17:19:08 +00:00
|
|
|
|
2017-03-25 16:24:11 +00:00
|
|
|
// 4.0.7
|
2017-10-18 17:22:34 +01:00
|
|
|
// for (byte i = 0; i < MAX_PWMS; i++) Settings.pwm_value[i] = 0;
|
2017-03-25 16:24:11 +00:00
|
|
|
|
|
|
|
// 4.0.9
|
2017-10-18 17:22:34 +01:00
|
|
|
SettingsDefaultSet_4_0_9();
|
2017-03-29 17:42:05 +01:00
|
|
|
|
2017-06-06 22:23:23 +01:00
|
|
|
// 4.1.1 + 5.1.6
|
2017-10-18 17:22:34 +01:00
|
|
|
SettingsDefaultSet_4_1_1();
|
2017-03-29 17:42:05 +01:00
|
|
|
|
2017-05-03 17:19:13 +01:00
|
|
|
// 5.0.2
|
2017-10-18 17:22:34 +01:00
|
|
|
SettingsDefaultSet_5_0_2();
|
2017-05-05 16:57:05 +01:00
|
|
|
|
|
|
|
// 5.0.4
|
2017-12-16 14:51:45 +00:00
|
|
|
// Settings.energy_kWhtotal = 0;
|
|
|
|
RtcSettings.energy_kWhtotal = 0;
|
2017-05-08 12:21:45 +01:00
|
|
|
|
2017-05-10 13:19:36 +01:00
|
|
|
// 5.0.5
|
2017-10-18 17:22:34 +01:00
|
|
|
strlcpy(Settings.mqtt_fulltopic, MQTT_FULLTOPIC, sizeof(Settings.mqtt_fulltopic));
|
2017-05-08 12:21:45 +01:00
|
|
|
|
2017-05-10 13:19:36 +01:00
|
|
|
// 5.0.6
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.mqtt_retry = MQTT_RETRY_SECS;
|
2017-06-16 13:33:49 +01:00
|
|
|
|
|
|
|
// 5.1.7
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.param[P_HOLD_TIME] = KEY_HOLD_TIME; // Default 4 seconds hold time
|
2017-06-16 13:33:49 +01:00
|
|
|
|
2017-06-19 21:54:49 +01:00
|
|
|
// 5.2.0
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.param[P_MAX_POWER_RETRY] = MAX_POWER_RETRY;
|
2017-06-19 21:54:49 +01:00
|
|
|
|
2017-07-30 16:55:37 +01:00
|
|
|
// 5.4.1
|
2017-10-18 17:22:34 +01:00
|
|
|
memcpy_P(Settings.rf_code[0], kDefaultRfCode, 9);
|
2017-09-02 13:37:02 +01:00
|
|
|
|
2017-09-23 10:12:16 +01:00
|
|
|
// 5.8.0
|
2017-10-26 15:33:33 +01:00
|
|
|
Settings.light_pixels = WS2812_LEDS;
|
2018-03-10 16:58:54 +00:00
|
|
|
// Settings.light_rotation = 0;
|
2017-10-23 11:18:15 +01:00
|
|
|
|
|
|
|
// 5.8.1
|
2017-10-26 15:33:33 +01:00
|
|
|
// Settings.altitude = 0;
|
|
|
|
Settings.pwm_frequency = PWM_FREQ;
|
|
|
|
Settings.pwm_range = PWM_RANGE;
|
2017-10-23 11:18:15 +01:00
|
|
|
SettingsDefaultSet_5_8_1();
|
2017-11-11 11:33:30 +00:00
|
|
|
|
|
|
|
// 5.9.2
|
|
|
|
Settings.flag2.current_resolution = 3;
|
2018-01-05 11:26:19 +00:00
|
|
|
|
|
|
|
// 5.10.1
|
|
|
|
SettingsDefaultSet_5_10_1();
|
2017-03-12 17:36:33 +00:00
|
|
|
}
|
|
|
|
|
2017-05-03 17:19:13 +01:00
|
|
|
/********************************************************************************************/
|
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
void SettingsDefaultSet_3_2_4()
|
2017-03-12 17:36:33 +00:00
|
|
|
{
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.ws_red = 255;
|
|
|
|
Settings.ws_green = 0;
|
|
|
|
Settings.ws_blue = 0;
|
|
|
|
Settings.ws_ledtable = 0;
|
|
|
|
Settings.ws_dimmer = 8;
|
|
|
|
Settings.ws_fade = 0;
|
|
|
|
Settings.ws_speed = 1;
|
|
|
|
Settings.ws_scheme = 0;
|
2017-10-23 11:18:15 +01:00
|
|
|
Settings.ex_ws_width = 1;
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.ws_wakeup = 0;
|
2017-03-12 17:36:33 +00:00
|
|
|
}
|
2017-02-19 16:49:17 +00:00
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
void SettingsDefaultSet_3_9_3()
|
2017-03-12 17:36:33 +00:00
|
|
|
{
|
2017-10-12 13:09:19 +01:00
|
|
|
for (byte i = 0; i < MAX_DOMOTICZ_IDX; i++) {
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.domoticz_switch_idx[i] = 0;
|
2017-04-25 17:24:42 +01:00
|
|
|
}
|
|
|
|
for (byte i = 0; i < 12; i++) {
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.domoticz_sensor_idx[i] = 0;
|
2017-04-25 17:24:42 +01:00
|
|
|
}
|
2017-02-19 16:49:17 +00:00
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.module = MODULE;
|
2017-04-25 17:24:42 +01:00
|
|
|
for (byte i = 0; i < MAX_GPIO_PIN; i++){
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.my_gp.io[i] = 0;
|
2017-04-25 17:24:42 +01:00
|
|
|
}
|
2017-03-12 17:36:33 +00:00
|
|
|
|
2017-10-26 15:33:33 +01:00
|
|
|
Settings.light_pixels = WS2812_LEDS;
|
2018-03-10 16:58:54 +00:00
|
|
|
Settings.light_rotation = 0;
|
2017-10-12 13:09:19 +01:00
|
|
|
for (byte i = 0; i < MAX_PWMS; i++) {
|
2017-10-26 15:33:33 +01:00
|
|
|
Settings.light_color[i] = 255;
|
2017-04-25 17:24:42 +01:00
|
|
|
}
|
2017-10-26 15:33:33 +01:00
|
|
|
Settings.light_correction = 0;
|
|
|
|
Settings.light_dimmer = 10;
|
|
|
|
Settings.light_fade = 0;
|
|
|
|
Settings.light_speed = 1;
|
|
|
|
Settings.light_scheme = 0;
|
|
|
|
Settings.light_width = 1;
|
|
|
|
Settings.light_wakeup = 0;
|
2017-03-12 17:36:33 +00:00
|
|
|
}
|
2017-02-21 17:14:33 +00:00
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
void SettingsDefaultSet_4_0_4()
|
2017-03-12 17:36:33 +00:00
|
|
|
{
|
2017-10-18 17:22:34 +01:00
|
|
|
strlcpy(Settings.ntp_server[0], NTP_SERVER1, sizeof(Settings.ntp_server[0]));
|
|
|
|
strlcpy(Settings.ntp_server[1], NTP_SERVER2, sizeof(Settings.ntp_server[1]));
|
|
|
|
strlcpy(Settings.ntp_server[2], NTP_SERVER3, sizeof(Settings.ntp_server[2]));
|
2017-10-12 13:09:19 +01:00
|
|
|
for (byte j = 0; j < 3; j++) {
|
2017-10-18 17:22:34 +01:00
|
|
|
for (byte i = 0; i < strlen(Settings.ntp_server[j]); i++) {
|
|
|
|
if (Settings.ntp_server[j][i] == ',') {
|
|
|
|
Settings.ntp_server[j][i] = '.';
|
2017-04-25 17:24:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.pulse_timer[0] = APP_PULSETIME;
|
2017-04-25 17:24:42 +01:00
|
|
|
for (byte i = 1; i < MAX_PULSETIMERS; i++) {
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.pulse_timer[i] = 0;
|
2017-04-25 17:24:42 +01:00
|
|
|
}
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
void SettingsDefaultSet_4_0_9()
|
2017-03-25 16:24:11 +00:00
|
|
|
{
|
2017-10-18 17:22:34 +01:00
|
|
|
strlcpy(Settings.mqtt_prefix[0], SUB_PREFIX, sizeof(Settings.mqtt_prefix[0]));
|
|
|
|
strlcpy(Settings.mqtt_prefix[1], PUB_PREFIX, sizeof(Settings.mqtt_prefix[1]));
|
|
|
|
strlcpy(Settings.mqtt_prefix[2], PUB_PREFIX2, sizeof(Settings.mqtt_prefix[2]));
|
|
|
|
ParseIp(&Settings.ip_address[0], WIFI_IP_ADDRESS);
|
|
|
|
ParseIp(&Settings.ip_address[1], WIFI_GATEWAY);
|
|
|
|
ParseIp(&Settings.ip_address[2], WIFI_SUBNETMASK);
|
|
|
|
ParseIp(&Settings.ip_address[3], WIFI_DNS);
|
2017-03-25 16:24:11 +00:00
|
|
|
}
|
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
void SettingsDefaultSet_4_1_1()
|
2017-02-19 16:49:17 +00:00
|
|
|
{
|
2017-10-18 17:22:34 +01:00
|
|
|
strlcpy(Settings.state_text[0], MQTT_STATUS_OFF, sizeof(Settings.state_text[0]));
|
|
|
|
strlcpy(Settings.state_text[1], MQTT_STATUS_ON, sizeof(Settings.state_text[1]));
|
|
|
|
strlcpy(Settings.state_text[2], MQTT_CMND_TOGGLE, sizeof(Settings.state_text[2]));
|
|
|
|
strlcpy(Settings.state_text[3], MQTT_CMND_HOLD, sizeof(Settings.state_text[3])); // v5.1.6
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
void SettingsDefaultSet_5_0_2()
|
2017-02-19 16:49:17 +00:00
|
|
|
{
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.flag.temperature_conversion = TEMP_CONVERSION;
|
2017-11-11 11:33:30 +00:00
|
|
|
Settings.flag2.temperature_resolution = TEMP_RESOLUTION;
|
|
|
|
Settings.flag2.humidity_resolution = HUMIDITY_RESOLUTION;
|
|
|
|
Settings.flag2.pressure_resolution = PRESSURE_RESOLUTION;
|
|
|
|
Settings.flag2.energy_resolution = ENERGY_RESOLUTION;
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
|
|
|
|
2017-10-23 11:18:15 +01:00
|
|
|
void SettingsDefaultSet_5_8_1()
|
|
|
|
{
|
|
|
|
// Settings.flag.ws_clock_reverse = 0;
|
|
|
|
Settings.ws_width[WS_SECOND] = 1;
|
|
|
|
Settings.ws_color[WS_SECOND][WS_RED] = 255;
|
|
|
|
Settings.ws_color[WS_SECOND][WS_GREEN] = 0;
|
|
|
|
Settings.ws_color[WS_SECOND][WS_BLUE] = 255;
|
|
|
|
Settings.ws_width[WS_MINUTE] = 3;
|
|
|
|
Settings.ws_color[WS_MINUTE][WS_RED] = 0;
|
|
|
|
Settings.ws_color[WS_MINUTE][WS_GREEN] = 255;
|
|
|
|
Settings.ws_color[WS_MINUTE][WS_BLUE] = 0;
|
|
|
|
Settings.ws_width[WS_HOUR] = 5;
|
|
|
|
Settings.ws_color[WS_HOUR][WS_RED] = 255;
|
|
|
|
Settings.ws_color[WS_HOUR][WS_GREEN] = 0;
|
|
|
|
Settings.ws_color[WS_HOUR][WS_BLUE] = 0;
|
|
|
|
}
|
|
|
|
|
2018-01-05 11:26:19 +00:00
|
|
|
void SettingsDefaultSet_5_10_1()
|
|
|
|
{
|
|
|
|
Settings.display_model = 0;
|
|
|
|
Settings.display_mode = 1;
|
|
|
|
Settings.display_refresh = 2;
|
|
|
|
Settings.display_rows = 2;
|
|
|
|
Settings.display_cols[0] = 16;
|
|
|
|
Settings.display_cols[1] = 8;
|
|
|
|
//#if defined(USE_I2C) && defined(USE_DISPLAY)
|
|
|
|
Settings.display_address[0] = MTX_ADDRESS1;
|
|
|
|
Settings.display_address[1] = MTX_ADDRESS2;
|
|
|
|
Settings.display_address[2] = MTX_ADDRESS3;
|
|
|
|
Settings.display_address[3] = MTX_ADDRESS4;
|
|
|
|
Settings.display_address[4] = MTX_ADDRESS5;
|
|
|
|
Settings.display_address[5] = MTX_ADDRESS6;
|
|
|
|
Settings.display_address[6] = MTX_ADDRESS7;
|
|
|
|
Settings.display_address[7] = MTX_ADDRESS8;
|
|
|
|
//#endif // USE_DISPLAY
|
|
|
|
Settings.display_dimmer = 1;
|
|
|
|
Settings.display_size = 1;
|
|
|
|
}
|
|
|
|
|
2017-02-19 16:49:17 +00:00
|
|
|
/********************************************************************************************/
|
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
void SettingsDelta()
|
2017-02-19 16:49:17 +00:00
|
|
|
{
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version != VERSION) { // Fix version dependent changes
|
|
|
|
if (Settings.version < 0x03010200) { // 3.1.2 - Add parameter
|
|
|
|
Settings.poweronstate = APP_POWERON_STATE;
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x03010600) { // 3.1.6 - Add parameter
|
|
|
|
Settings.blinktime = APP_BLINKTIME;
|
|
|
|
Settings.blinkcount = APP_BLINKCOUNT;
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x03020400) { // 3.2.4 - Add parameter
|
|
|
|
SettingsDefaultSet_3_2_4();
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x03020500) { // 3.2.5 - Add parameter
|
|
|
|
GetMqttClient(Settings.friendlyname[0], Settings.mqtt_client, sizeof(Settings.friendlyname[0]));
|
|
|
|
strlcpy(Settings.friendlyname[1], FRIENDLY_NAME"2", sizeof(Settings.friendlyname[1]));
|
|
|
|
strlcpy(Settings.friendlyname[2], FRIENDLY_NAME"3", sizeof(Settings.friendlyname[2]));
|
|
|
|
strlcpy(Settings.friendlyname[3], FRIENDLY_NAME"4", sizeof(Settings.friendlyname[3]));
|
2017-09-02 13:37:02 +01:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x03020800) { // 3.2.8 - Add parameter
|
|
|
|
strlcpy(Settings.switch_topic, Settings.button_topic, sizeof(Settings.switch_topic));
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x03020C00) { // 3.2.12 - Add parameter
|
|
|
|
Settings.sleep = APP_SLEEP;
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x03090300) { // 3.9.2d - Add parameter
|
|
|
|
SettingsDefaultSet_3_9_3();
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x03091400) {
|
|
|
|
strlcpy(Settings.web_password, WEB_PASSWORD, sizeof(Settings.web_password));
|
2017-02-21 17:14:33 +00:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x03091500) {
|
2017-10-12 13:09:19 +01:00
|
|
|
for (byte i = 0; i < MAX_SWITCHES; i++) {
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.switchmode[i] = SWITCH_MODE;
|
2017-10-12 13:09:19 +01:00
|
|
|
}
|
2017-02-24 17:17:48 +00:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x04000400) {
|
|
|
|
SettingsDefaultSet_4_0_4();
|
2017-03-12 17:36:33 +00:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x04000500) {
|
|
|
|
memmove(Settings.my_gp.io, Settings.my_gp.io +1, MAX_GPIO_PIN -1); // move myio 1 byte to front
|
|
|
|
Settings.my_gp.io[MAX_GPIO_PIN -1] = 0; // Clear ADC0
|
2017-03-14 17:03:25 +00:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x04000700) {
|
2017-10-12 13:09:19 +01:00
|
|
|
for (byte i = 0; i < MAX_PWMS; i++) {
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.pwm_value[i] = 0;
|
2017-04-25 17:24:42 +01:00
|
|
|
}
|
2017-03-19 17:19:08 +00:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x04000804) {
|
|
|
|
SettingsDefaultSet_4_0_9();
|
2017-03-25 16:24:11 +00:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x04010100) {
|
|
|
|
SettingsDefaultSet_4_1_1();
|
2017-03-29 17:42:05 +01:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x05000105) {
|
|
|
|
Settings.flag = { 0 };
|
|
|
|
Settings.flag.save_state = SAVE_STATE;
|
|
|
|
// Settings.flag.button_restrict = 0;
|
|
|
|
// Settings.flag.value_units = 0;
|
|
|
|
Settings.flag.mqtt_enabled = MQTT_USE;
|
|
|
|
// Settings.flag.mqtt_response = 0;
|
|
|
|
// Settings.flag.mqtt_power_retain = 0;
|
|
|
|
// Settings.flag.mqtt_button_retain = 0;
|
|
|
|
Settings.flag.mqtt_switch_retain = MQTT_SWITCH_RETAIN;
|
2017-11-11 11:33:30 +00:00
|
|
|
Settings.flag2.emulation = EMULATION;
|
2017-05-03 17:19:13 +01:00
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
SettingsDefaultSet_5_0_2();
|
2017-05-03 17:19:13 +01:00
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.save_data = SAVE_DATA;
|
2017-05-03 17:19:13 +01:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x05000400) {
|
2017-12-16 14:51:45 +00:00
|
|
|
Settings.energy_kWhtotal = 0;
|
|
|
|
RtcSettings.energy_kWhtotal = 0;
|
2017-05-05 16:57:05 +01:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x05000500) {
|
|
|
|
strlcpy(Settings.mqtt_fulltopic, MQTT_FULLTOPIC, sizeof(Settings.mqtt_fulltopic));
|
2017-05-08 12:21:45 +01:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x05000600) {
|
|
|
|
Settings.mqtt_retry = MQTT_RETRY_SECS;
|
2017-05-10 13:19:36 +01:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x05010100) {
|
|
|
|
Settings.pulse_counter_type = 0;
|
|
|
|
Settings.pulse_counter_debounce = 0;
|
2017-05-20 13:03:34 +01:00
|
|
|
for (byte i = 0; i < MAX_COUNTERS; i++) {
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.pulse_counter[i] = 0;
|
|
|
|
RtcSettings.pulse_counter[i] = 0;
|
2017-05-17 21:49:22 +01:00
|
|
|
}
|
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x05010600) {
|
|
|
|
SettingsDefaultSet_4_1_1();
|
2017-06-06 22:23:23 +01:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x05010700) {
|
|
|
|
Settings.param[P_HOLD_TIME] = KEY_HOLD_TIME; // Default 4 seconds hold time
|
2017-06-16 13:33:49 +01:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x05020000) {
|
|
|
|
Settings.param[P_MAX_POWER_RETRY] = MAX_POWER_RETRY;
|
2017-06-19 21:54:49 +01:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x05050000) {
|
2017-07-30 16:55:37 +01:00
|
|
|
for (byte i = 0; i < 17; i++) {
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.rf_code[i][0] = 0;
|
2017-07-30 16:55:37 +01:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
memcpy_P(Settings.rf_code[0], kDefaultRfCode, 9);
|
2017-07-30 16:55:37 +01:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x05080000) {
|
2017-09-16 16:34:03 +01:00
|
|
|
uint8_t cfg_wsflg = 0;
|
|
|
|
for (byte i = 0; i < MAX_GPIO_PIN; i++) {
|
2017-10-18 17:22:34 +01:00
|
|
|
if (GPIO_WS2812 == Settings.my_gp.io[i]) {
|
2017-09-16 16:34:03 +01:00
|
|
|
cfg_wsflg = 1;
|
|
|
|
}
|
|
|
|
}
|
2017-10-26 15:33:33 +01:00
|
|
|
if (!Settings.light_pixels && cfg_wsflg) {
|
2018-03-10 16:58:54 +00:00
|
|
|
Settings.light_pixels = WS2812_LEDS;
|
2017-10-26 15:33:33 +01:00
|
|
|
Settings.light_color[0] = Settings.ws_red;
|
|
|
|
Settings.light_color[1] = Settings.ws_green;
|
|
|
|
Settings.light_color[2] = Settings.ws_blue;
|
|
|
|
Settings.light_dimmer = Settings.ws_dimmer;
|
|
|
|
Settings.light_correction = Settings.ws_ledtable;
|
|
|
|
Settings.light_fade = Settings.ws_fade;
|
|
|
|
Settings.light_speed = Settings.ws_speed;
|
|
|
|
Settings.light_scheme = Settings.ws_scheme;
|
|
|
|
Settings.light_width = Settings.ex_ws_width;
|
|
|
|
Settings.light_wakeup = Settings.ws_wakeup;
|
2017-09-16 16:34:03 +01:00
|
|
|
} else {
|
2017-10-26 15:33:33 +01:00
|
|
|
Settings.light_pixels = WS2812_LEDS;
|
|
|
|
Settings.light_width = 1;
|
2017-09-16 16:34:03 +01:00
|
|
|
}
|
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x0508000A) {
|
|
|
|
Settings.power = Settings.ex_power;
|
|
|
|
Settings.altitude = 0;
|
2017-10-10 14:40:02 +01:00
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x0508000B) {
|
2017-10-12 10:29:40 +01:00
|
|
|
for (byte i = 0; i < MAX_GPIO_PIN; i++) { // Move GPIO_LEDs
|
2017-10-18 17:22:34 +01:00
|
|
|
if ((Settings.my_gp.io[i] >= 25) && (Settings.my_gp.io[i] <= 32)) { // Was GPIO_LED1
|
|
|
|
Settings.my_gp.io[i] += 23; // Move GPIO_LED1
|
2017-10-12 10:29:40 +01:00
|
|
|
}
|
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
for (byte i = 0; i < MAX_PWMS; i++) { // Move pwm_value and reset additional pulse_timerrs
|
|
|
|
Settings.pwm_value[i] = Settings.pulse_timer[4 +i];
|
|
|
|
Settings.pulse_timer[4 +i] = 0;
|
2017-10-12 10:29:40 +01:00
|
|
|
}
|
|
|
|
}
|
2017-10-18 17:22:34 +01:00
|
|
|
if (Settings.version < 0x0508000D) {
|
|
|
|
Settings.pwm_frequency = PWM_FREQ;
|
|
|
|
Settings.pwm_range = PWM_RANGE;
|
|
|
|
}
|
2017-10-23 11:18:15 +01:00
|
|
|
if (Settings.version < 0x0508000E) {
|
|
|
|
SettingsDefaultSet_5_8_1();
|
|
|
|
}
|
2017-11-11 11:33:30 +00:00
|
|
|
if (Settings.version < 0x05090102) {
|
|
|
|
Settings.flag2.data = Settings.flag.data;
|
|
|
|
Settings.flag2.data &= 0xFFE80000;
|
2018-01-27 16:52:48 +00:00
|
|
|
Settings.flag2.voltage_resolution = Settings.flag.not_power_linked;
|
2017-11-11 11:33:30 +00:00
|
|
|
Settings.flag2.current_resolution = 3;
|
|
|
|
Settings.ina219_mode = 0;
|
|
|
|
}
|
2018-01-05 11:26:19 +00:00
|
|
|
if (Settings.version < 0x050A0009) {
|
|
|
|
SettingsDefaultSet_5_10_1();
|
|
|
|
}
|
2018-01-27 16:52:48 +00:00
|
|
|
if (Settings.version < 0x050B0107) {
|
|
|
|
Settings.flag.not_power_linked = 0;
|
|
|
|
}
|
2018-03-09 17:08:17 +00:00
|
|
|
if (Settings.version < 0x050C0005) {
|
2018-03-10 16:58:54 +00:00
|
|
|
Settings.light_rotation = 0;
|
2018-03-14 13:32:51 +00:00
|
|
|
Settings.energy_power_delta = 80;
|
2018-03-09 17:08:17 +00:00
|
|
|
char fingerprint[60];
|
|
|
|
memcpy(fingerprint, Settings.mqtt_fingerprint, sizeof(fingerprint));
|
|
|
|
char *p = fingerprint;
|
|
|
|
for (byte i = 0; i < 20; i++) {
|
|
|
|
Settings.mqtt_fingerprint[0][i] = strtol(p, &p, 16);
|
|
|
|
Settings.mqtt_fingerprint[1][i] = Settings.mqtt_fingerprint[0][i];
|
|
|
|
}
|
|
|
|
}
|
2017-09-02 13:37:02 +01:00
|
|
|
|
2017-10-18 17:22:34 +01:00
|
|
|
Settings.version = VERSION;
|
|
|
|
SettingsSave(1);
|
2017-02-19 16:49:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-08 15:08:08 +01:00
|
|
|
|