mirror of https://github.com/arendst/Tasmota.git
Merge pull request #8517 from abmaonline/send-on-full-buffer
Send all chars from serial to mqtt
This commit is contained in:
commit
a5130fa2e4
|
@ -1291,16 +1291,23 @@ void SerialInput(void)
|
|||
}
|
||||
} else {
|
||||
if (serial_in_byte || Settings.flag.mqtt_serial_raw) { // Any char between 1 and 127 or any char (0 - 255) - CMND_SERIALSEND3
|
||||
bool in_byte_is_delimiter = // Char is delimiter when...
|
||||
(((Settings.serial_delimiter < 128) && (serial_in_byte == Settings.serial_delimiter)) || // Any char between 1 and 127 and being delimiter
|
||||
((Settings.serial_delimiter == 128) && !isprint(serial_in_byte))) && // Any char not between 32 and 127
|
||||
!Settings.flag.mqtt_serial_raw; // In raw mode (CMND_SERIALSEND3) there is never a delimiter
|
||||
|
||||
if ((serial_in_byte_counter < INPUT_BUFFER_SIZE -1) && // Add char to string if it still fits and ...
|
||||
((isprint(serial_in_byte) && (128 == Settings.serial_delimiter)) || // Any char between 32 and 127
|
||||
((serial_in_byte != Settings.serial_delimiter) && (128 != Settings.serial_delimiter)) || // Any char between 1 and 127 and not being delimiter
|
||||
Settings.flag.mqtt_serial_raw)) { // Any char between 0 and 255 - CMND_SERIALSEND3
|
||||
!in_byte_is_delimiter) { // Char is not a delimiter
|
||||
serial_in_buffer[serial_in_byte_counter++] = serial_in_byte;
|
||||
serial_polling_window = millis();
|
||||
} else {
|
||||
}
|
||||
|
||||
if ((serial_in_byte_counter >= INPUT_BUFFER_SIZE -1) || // Send message when buffer is full or ...
|
||||
in_byte_is_delimiter) { // Char is delimiter
|
||||
serial_polling_window = 0; // Reception done - send mqtt
|
||||
break;
|
||||
}
|
||||
|
||||
serial_polling_window = millis(); // Wait for next char
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,17 +54,23 @@ void SerialBridgeInput(void)
|
|||
return;
|
||||
}
|
||||
if (serial_in_byte || serial_bridge_raw) { // Any char between 1 and 127 or any char (0 - 255)
|
||||
bool in_byte_is_delimiter = // Char is delimiter when...
|
||||
(((Settings.serial_delimiter < 128) && (serial_in_byte == Settings.serial_delimiter)) || // Any char between 1 and 127 and being delimiter
|
||||
((Settings.serial_delimiter == 128) && !isprint(serial_in_byte))) && // Any char not between 32 and 127
|
||||
!serial_bridge_raw; // In raw mode (CMND_SERIALSEND3) there is never a delimiter
|
||||
|
||||
if ((serial_bridge_in_byte_counter < SERIAL_BRIDGE_BUFFER_SIZE -1) && // Add char to string if it still fits and ...
|
||||
((isprint(serial_in_byte) && (128 == Settings.serial_delimiter)) || // Any char between 32 and 127
|
||||
((serial_in_byte != Settings.serial_delimiter) && (128 != Settings.serial_delimiter)) || // Any char between 1 and 127 and not being delimiter
|
||||
serial_bridge_raw)) { // Any char between 0 and 255
|
||||
!in_byte_is_delimiter) { // Char is not a delimiter
|
||||
serial_bridge_buffer[serial_bridge_in_byte_counter++] = serial_in_byte;
|
||||
serial_bridge_polling_window = millis(); // Wait for more data
|
||||
} else {
|
||||
}
|
||||
|
||||
if ((serial_bridge_in_byte_counter >= SERIAL_BRIDGE_BUFFER_SIZE -1) || // Send message when buffer is full or ...
|
||||
in_byte_is_delimiter) { // Char is delimiter
|
||||
serial_bridge_polling_window = 0; // Publish now
|
||||
break;
|
||||
}
|
||||
|
||||
serial_bridge_polling_window = millis(); // Wait for more data
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue