mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-22 02:06:31 +00:00
parent
d7ed311587
commit
b9a3fd4342
@ -689,11 +689,12 @@ typedef struct {
|
|||||||
power_t power; // 2AC
|
power_t power; // 2AC
|
||||||
EnergyUsage energy_usage; // 2B0
|
EnergyUsage energy_usage; // 2B0
|
||||||
unsigned long nextwakeup; // 2C8
|
unsigned long nextwakeup; // 2C8
|
||||||
uint8_t free_004[4]; // 2CC
|
uint32_t baudrate; // 2CC
|
||||||
uint32_t ultradeepsleep; // 2D0
|
uint32_t ultradeepsleep; // 2D0
|
||||||
uint16_t deepsleep_slip; // 2D4
|
uint16_t deepsleep_slip; // 2D4
|
||||||
|
|
||||||
uint8_t free_022[22]; // 2D6
|
uint8_t free_2d6[22]; // 2D6
|
||||||
|
|
||||||
// 2EC - 2FF free locations
|
// 2EC - 2FF free locations
|
||||||
} TRtcSettings;
|
} TRtcSettings;
|
||||||
TRtcSettings RtcSettings;
|
TRtcSettings RtcSettings;
|
||||||
|
@ -38,6 +38,7 @@ uint32_t GetRtcSettingsCrc(void)
|
|||||||
|
|
||||||
void RtcSettingsSave(void)
|
void RtcSettingsSave(void)
|
||||||
{
|
{
|
||||||
|
RtcSettings.baudrate = Settings.baudrate * 300;
|
||||||
if (GetRtcSettingsCrc() != rtc_settings_crc) {
|
if (GetRtcSettingsCrc() != rtc_settings_crc) {
|
||||||
RtcSettings.valid = RTC_MEM_VALID;
|
RtcSettings.valid = RTC_MEM_VALID;
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
@ -50,8 +51,8 @@ void RtcSettingsSave(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RtcSettingsLoad(void)
|
bool RtcSettingsLoad(void) {
|
||||||
{
|
bool was_read_valid = true;
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
ESP.rtcUserMemoryRead(100, (uint32_t*)&RtcSettings, sizeof(RtcSettings)); // 0x290
|
ESP.rtcUserMemoryRead(100, (uint32_t*)&RtcSettings, sizeof(RtcSettings)); // 0x290
|
||||||
#endif // ESP8266
|
#endif // ESP8266
|
||||||
@ -59,6 +60,7 @@ void RtcSettingsLoad(void)
|
|||||||
RtcSettings = RtcDataSettings;
|
RtcSettings = RtcDataSettings;
|
||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
if (RtcSettings.valid != RTC_MEM_VALID) {
|
if (RtcSettings.valid != RTC_MEM_VALID) {
|
||||||
|
was_read_valid = false;
|
||||||
memset(&RtcSettings, 0, sizeof(RtcSettings));
|
memset(&RtcSettings, 0, sizeof(RtcSettings));
|
||||||
RtcSettings.valid = RTC_MEM_VALID;
|
RtcSettings.valid = RTC_MEM_VALID;
|
||||||
RtcSettings.energy_kWhtoday = Settings.energy_kWhtoday;
|
RtcSettings.energy_kWhtoday = Settings.energy_kWhtoday;
|
||||||
@ -68,9 +70,12 @@ void RtcSettingsLoad(void)
|
|||||||
RtcSettings.pulse_counter[i] = Settings.pulse_counter[i];
|
RtcSettings.pulse_counter[i] = Settings.pulse_counter[i];
|
||||||
}
|
}
|
||||||
RtcSettings.power = Settings.power;
|
RtcSettings.power = Settings.power;
|
||||||
|
// RtcSettings.baudrate = Settings.baudrate * 300;
|
||||||
|
RtcSettings.baudrate = APP_BAUDRATE;
|
||||||
RtcSettingsSave();
|
RtcSettingsSave();
|
||||||
}
|
}
|
||||||
rtc_settings_crc = GetRtcSettingsCrc();
|
rtc_settings_crc = GetRtcSettingsCrc();
|
||||||
|
return was_read_valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RtcSettingsValid(void)
|
bool RtcSettingsValid(void)
|
||||||
|
@ -1495,13 +1495,6 @@ void GpioInit(void)
|
|||||||
}
|
}
|
||||||
SetModuleType();
|
SetModuleType();
|
||||||
|
|
||||||
TasmotaGlobal.module_changed = (Settings.module != Settings.last_module);
|
|
||||||
if (TasmotaGlobal.module_changed) {
|
|
||||||
Settings.baudrate = APP_BAUDRATE / 300;
|
|
||||||
Settings.serial_config = TS_SERIAL_8N1;
|
|
||||||
SetSerialBegin();
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: Used GPIOs %d"), GPIO_SENSOR_END);
|
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: Used GPIOs %d"), GPIO_SENSOR_END);
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
|
@ -215,22 +215,27 @@ void setup(void) {
|
|||||||
#endif
|
#endif
|
||||||
RtcRebootSave();
|
RtcRebootSave();
|
||||||
|
|
||||||
|
if (RtcSettingsLoad()) {
|
||||||
|
uint32_t baudrate = (RtcSettings.baudrate / 300) * 300; // Make it a valid baudrate
|
||||||
|
if (baudrate) { TasmotaGlobal.baudrate = baudrate; }
|
||||||
|
}
|
||||||
Serial.begin(TasmotaGlobal.baudrate);
|
Serial.begin(TasmotaGlobal.baudrate);
|
||||||
|
Serial.println();
|
||||||
// Serial.setRxBufferSize(INPUT_BUFFER_SIZE); // Default is 256 chars
|
// Serial.setRxBufferSize(INPUT_BUFFER_SIZE); // Default is 256 chars
|
||||||
TasmotaGlobal.seriallog_level = LOG_LEVEL_INFO; // Allow specific serial messages until config loaded
|
TasmotaGlobal.seriallog_level = LOG_LEVEL_INFO; // Allow specific serial messages until config loaded
|
||||||
|
|
||||||
snprintf_P(TasmotaGlobal.version, sizeof(TasmotaGlobal.version), PSTR("%d.%d.%d"), VERSION >> 24 & 0xff, VERSION >> 16 & 0xff, VERSION >> 8 & 0xff); // Release version 6.3.0
|
|
||||||
if (VERSION & 0xff) { // Development or patched version 6.3.0.10
|
|
||||||
snprintf_P(TasmotaGlobal.version, sizeof(TasmotaGlobal.version), PSTR("%s.%d"), TasmotaGlobal.version, VERSION & 0xff);
|
|
||||||
}
|
|
||||||
// Thehackbox inserts "release" or "commit number" before compiling using sed -i -e 's/PSTR("(%s)")/PSTR("(85cff52-%s)")/g' tasmota.ino
|
|
||||||
snprintf_P(TasmotaGlobal.image_name, sizeof(TasmotaGlobal.image_name), PSTR("(%s)"), CODE_IMAGE_STR); // Results in (85cff52-tasmota) or (release-tasmota)
|
|
||||||
|
|
||||||
SettingsLoad();
|
SettingsLoad();
|
||||||
SettingsDelta();
|
SettingsDelta();
|
||||||
|
|
||||||
OsWatchInit();
|
OsWatchInit();
|
||||||
|
|
||||||
|
TasmotaGlobal.module_changed = (Settings.module != Settings.last_module);
|
||||||
|
if (TasmotaGlobal.module_changed) {
|
||||||
|
Settings.baudrate = APP_BAUDRATE / 300;
|
||||||
|
Settings.serial_config = TS_SERIAL_8N1;
|
||||||
|
}
|
||||||
|
SetSerialBegin();
|
||||||
|
|
||||||
if (1 == RtcReboot.fast_reboot_count) { // Allow setting override only when all is well
|
if (1 == RtcReboot.fast_reboot_count) { // Allow setting override only when all is well
|
||||||
UpdateQuickPowerCycle(true);
|
UpdateQuickPowerCycle(true);
|
||||||
}
|
}
|
||||||
@ -281,6 +286,13 @@ void setup(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snprintf_P(TasmotaGlobal.version, sizeof(TasmotaGlobal.version), PSTR("%d.%d.%d"), VERSION >> 24 & 0xff, VERSION >> 16 & 0xff, VERSION >> 8 & 0xff); // Release version 6.3.0
|
||||||
|
if (VERSION & 0xff) { // Development or patched version 6.3.0.10
|
||||||
|
snprintf_P(TasmotaGlobal.version, sizeof(TasmotaGlobal.version), PSTR("%s.%d"), TasmotaGlobal.version, VERSION & 0xff);
|
||||||
|
}
|
||||||
|
// Thehackbox inserts "release" or "commit number" before compiling using sed -i -e 's/PSTR("(%s)")/PSTR("(85cff52-%s)")/g' tasmota.ino
|
||||||
|
snprintf_P(TasmotaGlobal.image_name, sizeof(TasmotaGlobal.image_name), PSTR("(%s)"), CODE_IMAGE_STR); // Results in (85cff52-tasmota) or (release-tasmota)
|
||||||
|
|
||||||
Format(TasmotaGlobal.mqtt_client, SettingsText(SET_MQTT_CLIENT), sizeof(TasmotaGlobal.mqtt_client));
|
Format(TasmotaGlobal.mqtt_client, SettingsText(SET_MQTT_CLIENT), sizeof(TasmotaGlobal.mqtt_client));
|
||||||
Format(TasmotaGlobal.mqtt_topic, SettingsText(SET_MQTT_TOPIC), sizeof(TasmotaGlobal.mqtt_topic));
|
Format(TasmotaGlobal.mqtt_topic, SettingsText(SET_MQTT_TOPIC), sizeof(TasmotaGlobal.mqtt_topic));
|
||||||
if (strchr(SettingsText(SET_HOSTNAME), '%') != nullptr) {
|
if (strchr(SettingsText(SET_HOSTNAME), '%') != nullptr) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user