Merge pull request #8819 from effelle/development

TuyaMCU: SetOption97 to set higher baud rate
This commit is contained in:
Theo Arends 2020-06-29 16:23:12 +02:00 committed by GitHub
commit a6a372c2e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -116,7 +116,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t max6675 : 1; // bit 12 (v8.3.1.2) - SetOption94 - Implement simpler MAX6675 protocol instead of MAX31855
uint32_t network_wifi : 1; // bit 13 (v8.3.1.3) - CMND_WIFI
uint32_t network_ethernet : 1; // bit 14 (v8.3.1.3) = CMND_ETHERNET
uint32_t spare15 : 1;
uint32_t tuyamcu_baudrate : 1; // bit 15 (v8.3.1.6) - SetOption97 - Set Baud rate for TuyaMCU serial communication (0 = 9600 or 1 = 115200)
uint32_t spare16 : 1;
uint32_t spare17 : 1;
uint32_t spare18 : 1;

View File

@ -899,6 +899,7 @@ void CmndSetoption(void)
switch (pindex) {
case 3: // SetOption85 - Enable Device Groups
case 6: // SetOption88 - PWM Dimmer Buttons control remote devices
case 15: // SetOption97 - Set Baud rate for TuyaMCU serial communication (0 = 9600 or 1 = 115200)
restart_flag = 2;
break;
}

View File

@ -641,13 +641,16 @@ bool TuyaModuleSelected(void)
void TuyaInit(void)
{
int baudrate = 9600;
if (Settings.flag4.tuyamcu_baudrate) { baudrate = 115200; } // SetOption97 - Set Baud rate for TuyaMCU serial communication (0 = 9600 or 1 = 115200)
Tuya.buffer = (char*)(malloc(TUYA_BUFFER_SIZE));
if (Tuya.buffer != nullptr) {
TuyaSerial = new TasmotaSerial(Pin(GPIO_TUYA_RX), Pin(GPIO_TUYA_TX), 2);
if (TuyaSerial->begin(9600)) {
if (TuyaSerial->begin(baudrate)) {
if (TuyaSerial->hardwareSerial()) { ClaimSerial(); }
// Get MCU Configuration
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Request MCU configuration"));
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Request MCU configuration at %d baud rate"));
TuyaSendCmd(TUYA_CMD_QUERY_PRODUCT);
}