Fix exception caused by wrong baudrate selection

Fix exception caused by wrong baudrate selection (#5441)
This commit is contained in:
Theo Arends 2019-03-12 10:23:20 +01:00
parent 2aaca4bc2b
commit 73be43b60f
2 changed files with 2 additions and 2 deletions

View File

@ -1068,7 +1068,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE, command, Settings.switch_debounce);
}
else if (CMND_BAUDRATE == command_code) {
if (payload32 > 0) {
if (payload32 > 1200) {
payload32 /= 1200; // Make it a valid baudrate
baudrate = (1 == payload) ? APP_BAUDRATE : payload32 * 1200;
SetSerialBaudrate(baudrate);

View File

@ -150,7 +150,7 @@ bool SerialBridgeCommand(void)
else if (CMND_SBAUDRATE == command_code) {
char *p;
int baud = strtol(XdrvMailbox.data, &p, 10);
if (baud > 0) {
if (baud >= 1200) {
baud /= 1200; // Make it a valid baudrate
Settings.sbaudrate = (1 == XdrvMailbox.payload) ? SOFT_BAUDRATE / 1200 : baud;
SerialBridgeSerial->begin(Settings.sbaudrate * 1200); // Reinitialize serial port with new baud rate