mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 11:46:31 +00:00
allow proper dynamic config change
This commit is contained in:
parent
a67898e8b3
commit
adbb691e67
@ -608,15 +608,23 @@ void TInfoInit(void)
|
|||||||
AddLog(LOG_LEVEL_INFO, PSTR("TIC: Enable with GPIO%d"), en_pin);
|
AddLog(LOG_LEVEL_INFO, PSTR("TIC: Enable with GPIO%d"), en_pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AddLog(0,PSTR("TIC:Init:TSerial=0x%08X"),TInfoSerial);
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
// Allow GPIO3 AND GPIO13 with hardware fallback to 2
|
// Allow GPIO3 AND GPIO13 with hardware fallback to 2
|
||||||
// Set buffer to nnn char to support 250ms loop at 9600 baud
|
// Set buffer to nnn char to support 250ms loop at 9600 baud
|
||||||
TInfoSerial = new TasmotaSerial(tic_rx_pin, -1, 2, 0, serial_buffer_size);
|
// In case of "on-the-fly" re-init, serial is already there, don't re-allocate
|
||||||
|
if (!TInfoSerial) {
|
||||||
|
TInfoSerial = new TasmotaSerial(tic_rx_pin, -1, 2, 0, serial_buffer_size);
|
||||||
|
}
|
||||||
//pinMode(rx_pin, INPUT_PULLUP);
|
//pinMode(rx_pin, INPUT_PULLUP);
|
||||||
#endif // ESP8266
|
#endif // ESP8266
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
// Set buffer to nnn char to support 250ms loop at 9600 baud
|
// Set buffer to nnn char to support 250ms loop at 9600 baud
|
||||||
TInfoSerial = new TasmotaSerial(tic_rx_pin, -1, 1, 0, serial_buffer_size);
|
// In case of "on-the-fly" re-init, serial is already there, don't re-allocate
|
||||||
|
if (!TInfoSerial) {
|
||||||
|
TInfoSerial = new TasmotaSerial(tic_rx_pin, -1, 1, 0, serial_buffer_size);
|
||||||
|
}
|
||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
|
|
||||||
if (TInfoSerial->begin(baudrate, SERIAL_7E1)) {
|
if (TInfoSerial->begin(baudrate, SERIAL_7E1)) {
|
||||||
@ -636,6 +644,9 @@ void TInfoInit(void)
|
|||||||
AddLog(LOG_LEVEL_INFO, PSTR("TIC: using software serial"));
|
AddLog(LOG_LEVEL_INFO, PSTR("TIC: using software serial"));
|
||||||
}
|
}
|
||||||
#endif // ESP8266
|
#endif // ESP8266
|
||||||
|
#ifdef ESP32
|
||||||
|
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: using hardserial %d"), TInfoSerial->getUart());
|
||||||
|
#endif
|
||||||
// Init teleinfo
|
// Init teleinfo
|
||||||
tinfo.init(tinfo_mode);
|
tinfo.init(tinfo_mode);
|
||||||
// Attach needed callbacks
|
// Attach needed callbacks
|
||||||
@ -651,6 +662,8 @@ void TInfoInit(void)
|
|||||||
AddLog(LOG_LEVEL_INFO, PSTR("TIC: Sending only one frame over %d "), raw_skip+1);
|
AddLog(LOG_LEVEL_INFO, PSTR("TIC: Sending only one frame over %d "), raw_skip+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
AddLog(LOG_LEVEL_INFO, PSTR("TIC: failed init serial"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -735,25 +748,13 @@ bool TInfoCmd(void) {
|
|||||||
// Only if current settings is different than previous
|
// Only if current settings is different than previous
|
||||||
if ( (tinfo_mode==TINFO_MODE_STANDARD && command_code==CMND_TELEINFO_HISTORIQUE) ||
|
if ( (tinfo_mode==TINFO_MODE_STANDARD && command_code==CMND_TELEINFO_HISTORIQUE) ||
|
||||||
(tinfo_mode==TINFO_MODE_HISTORIQUE && command_code==CMND_TELEINFO_STANDARD) ) {
|
(tinfo_mode==TINFO_MODE_HISTORIQUE && command_code==CMND_TELEINFO_STANDARD) ) {
|
||||||
|
|
||||||
// Cleanup Serial not sure it will works since
|
|
||||||
// there is no end() or close() on tasmotaserial class
|
|
||||||
if (TInfoSerial) {
|
|
||||||
TInfoSerial->flush();
|
|
||||||
//TInfoSerial->end();
|
|
||||||
free(TInfoSerial);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Change mode
|
// Change mode
|
||||||
Settings->teleinfo.mode_standard = command_code == CMND_TELEINFO_STANDARD ? 1 : 0;
|
Settings->teleinfo.mode_standard = command_code == CMND_TELEINFO_STANDARD ? 1 : 0;
|
||||||
|
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("TIC: '%s' mode"), mode_name);
|
AddLog(LOG_LEVEL_INFO, PSTR("TIC: '%s' mode"), mode_name);
|
||||||
|
|
||||||
// Re init teleinfo (LibTeleinfo always free linked list on init)
|
// Re init teleinfo (LibTeleinfo always free linked list on init)
|
||||||
TInfoInit();
|
TInfoInit();
|
||||||
|
|
||||||
serviced = true;
|
serviced = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("TIC: No change to '%s' mode"), mode_name);
|
AddLog(LOG_LEVEL_INFO, PSTR("TIC: No change to '%s' mode"), mode_name);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user