Fix some serial interface initializations

Fix Sonoff Bridge, Sc, L1, iFan03 and CSE7766 serial interface to forced speed, config and disable logging
This commit is contained in:
Theo Arends 2019-12-27 15:13:40 +01:00
parent 24aff9b415
commit 5682675ac9
10 changed files with 21 additions and 29 deletions

View File

@ -54,6 +54,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
### Version 8.1.0.1
- Fix Sonoff Bridge, Sc, L1, iFan03 and CSE7766 serial interface to forced speed, config and disable logging
- Fix commands ``Display`` and ``Counter`` from overruling command processing (#7322)
- Add SerialConfig to ``Status 1``
- Add WifiPower to ``Status 5``

View File

@ -2,6 +2,7 @@
### 8.1.0.1 20191225
- Fix Sonoff Bridge, Sc, L1, iFan03 and CSE7766 serial interface to forced speed, config and disable logging
- Fix commands ``Display`` and ``Counter`` from overruling command processing (#7322)
- Add SerialConfig to ``Status 1``
- Add WifiPower to ``Status 5``

View File

@ -790,14 +790,9 @@ String GetSerialConfig(void)
void SetSerialBegin(uint32_t baudrate)
{
if (seriallog_level) {
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "Set Serial to %s %d bit/s"), GetSerialConfig().c_str(), baudrate);
delay(100);
}
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "Set Serial to %s %d bit/s"), GetSerialConfig().c_str(), baudrate);
Serial.flush();
Serial.begin(baudrate, (SerialConfig)pgm_read_byte(kTasmotaSerialConfig + Settings.serial_config));
delay(10);
Serial.println();
}
void SetSerialConfig(uint32_t serial_config)
@ -812,11 +807,17 @@ void SetSerialConfig(uint32_t serial_config)
void SetSerialBaudrate(int baudrate)
{
Settings.baudrate = baudrate / 300;
if (Serial.baudRate() == baudrate) { return; }
SetSerialBegin(baudrate);
}
void PrepSerial(int prep_baudrate, uint32_t serial_config)
{
Settings.flag.mqtt_serial = 0; // CMND_SERIALSEND and CMND_SERIALLOG
Settings.serial_config = serial_config;
baudrate = prep_baudrate;
SetSeriallog(LOG_LEVEL_NONE);
}
void ClaimSerial(void)
{
serial_local = true;

View File

@ -1296,20 +1296,16 @@ void GpioInit(void)
// devices_present = 1;
}
else if (SONOFF_DUAL == my_module_type) {
Settings.flag.mqtt_serial = 0; // CMND_SERIALSEND and CMND_SERIALLOG
devices_present = 2;
baudrate = 19200;
PrepSerial(19200, TS_SERIAL_8N1);
}
else if (CH4 == my_module_type) {
Settings.flag.mqtt_serial = 0; // CMND_SERIALSEND and CMND_SERIALLOG
devices_present = 4;
baudrate = 19200;
PrepSerial(19200, TS_SERIAL_8N1);
}
#ifdef USE_SONOFF_SC
else if (SONOFF_SC == my_module_type) {
Settings.flag.mqtt_serial = 0; // CMND_SERIALSEND and CMND_SERIALLOG
devices_present = 0;
baudrate = 19200;
PrepSerial(19200, TS_SERIAL_8N1);
}
#endif // USE_SONOFF_SC

View File

@ -194,8 +194,6 @@ void setup(void)
RtcRebootSave();
Serial.begin(baudrate);
delay(10);
Serial.println();
seriallog_level = LOG_LEVEL_INFO; // Allow specific serial messages until config loaded
snprintf_P(my_version, sizeof(my_version), PSTR("%d.%d.%d"), VERSION >> 24 & 0xff, VERSION >> 16 & 0xff, VERSION >> 8 & 0xff); // Release version 6.3.0

View File

@ -578,8 +578,7 @@ bool Xdrv06(uint8_t function)
SonoffBridgeSendCommand(0xA7); // Stop reading RF signals enabling iTead default RF handling
break;
case FUNC_PRE_INIT:
Settings.flag.mqtt_serial = 0; // CMND_SERIALSEND and CMND_SERIALLOG
baudrate = 19200;
PrepSerial(19200, TS_SERIAL_8N1);
break;
}
}

View File

@ -217,9 +217,7 @@ void CmndFanspeed(void)
bool SonoffIfanInit(void)
{
if (SONOFF_IFAN03 == my_module_type) {
Settings.flag.mqtt_serial = 0; // CMND_SERIALSEND and CMND_SERIALLOG
baudrate = 9600;
SetSeriallog(LOG_LEVEL_NONE);
PrepSerial(9600, TS_SERIAL_8N1);
}
return false; // Continue init chain
}

View File

@ -222,8 +222,7 @@ void SnfL1ModuleSelected(void)
{
if (SONOFF_L1 == my_module_type) {
if ((pin[GPIO_RXD] < 99) && (pin[GPIO_TXD] < 99)) {
Settings.flag.mqtt_serial = 0; // CMND_SERIALSEND and CMND_SERIALLOG
baudrate = 19200;
PrepSerial(19200, TS_SERIAL_8N1);
light_type = LT_RGB;
light_flg = XLGT_05;

View File

@ -210,8 +210,7 @@ void CseEverySecond(void)
void CseDrvInit(void)
{
if ((3 == pin[GPIO_CSE7766_RX]) && (1 == pin[GPIO_CSE7766_TX])) { // As it uses 8E1 currently only hardware serial is supported
baudrate = 4800;
Settings.serial_config = TS_SERIAL_8E1;
PrepSerial(4800, TS_SERIAL_8E1);
if (0 == Settings.param[P_CSE7766_INVALID_POWER]) {
Settings.param[P_CSE7766_INVALID_POWER] = CSE_MAX_INVALID_POWER; // SetOption39 1..255
}

View File

@ -159,9 +159,6 @@ bool Xsns04(uint8_t function)
if (SONOFF_SC == my_module_type) {
switch (function) {
case FUNC_INIT:
SonoffScInit();
break;
case FUNC_JSON_APPEND:
SonoffScShow(1);
break;
@ -170,6 +167,9 @@ bool Xsns04(uint8_t function)
SonoffScShow(0);
break;
#endif // USE_WEBSERVER
case FUNC_INIT:
SonoffScInit();
break;
}
}
return result;