mirror of
https://github.com/arendst/Tasmota.git
synced 2025-08-06 17:37:44 +00:00
Add command SerialDelimiter 128
Add command SerialDelimiter 128 to filter reception of only characters between ASCII 32 and 127 (#5131)
This commit is contained in:
parent
10802d11dc
commit
ab11096f3a
@ -1,6 +1,7 @@
|
|||||||
/* 6.4.1.15 20190208
|
/* 6.4.1.15 20190208
|
||||||
* Change image name BE_MINIMAL to FIRMWARE_MINIMAL (#5106)
|
* Change image name BE_MINIMAL to FIRMWARE_MINIMAL (#5106)
|
||||||
* Change image names USE_xyz to FIRMWARE_xyz (#5106)
|
* Change image names USE_xyz to FIRMWARE_xyz (#5106)
|
||||||
|
* Add command SerialDelimiter 128 to filter reception of only characters between ASCII 32 and 127 (#5131)
|
||||||
*
|
*
|
||||||
* 6.4.1.14 20190203
|
* 6.4.1.14 20190203
|
||||||
* Add SetOption32 until SetOption49 diagnostic information to Status 3 report as replacement for second property value in SetOption property name
|
* Add SetOption32 until SetOption49 diagnostic information to Status 3 report as replacement for second property value in SetOption property name
|
||||||
|
@ -2171,27 +2171,29 @@ void SerialInput(void)
|
|||||||
|
|
||||||
/*-------------------------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
if (serial_in_byte > 127 && !Settings.flag.mqtt_serial_raw) { // binary data...
|
if (serial_in_byte > 127 && !Settings.flag.mqtt_serial_raw) { // Discard binary data above 127 if no raw reception allowed
|
||||||
serial_in_byte_counter = 0;
|
serial_in_byte_counter = 0;
|
||||||
Serial.flush();
|
Serial.flush();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Settings.flag.mqtt_serial) {
|
if (!Settings.flag.mqtt_serial) { // SerialSend active
|
||||||
if (isprint(serial_in_byte)) {
|
if (isprint(serial_in_byte)) { // Any char between 32 and 127
|
||||||
if (serial_in_byte_counter < INPUT_BUFFER_SIZE -1) { // add char to string if it still fits
|
if (serial_in_byte_counter < INPUT_BUFFER_SIZE -1) { // Add char to string if it still fits
|
||||||
serial_in_buffer[serial_in_byte_counter++] = serial_in_byte;
|
serial_in_buffer[serial_in_byte_counter++] = serial_in_byte;
|
||||||
} else {
|
} else {
|
||||||
serial_in_byte_counter = 0;
|
serial_in_byte_counter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (serial_in_byte || Settings.flag.mqtt_serial_raw) {
|
if (serial_in_byte || Settings.flag.mqtt_serial_raw) { // Any char between 1 and 127 or any char (0 - 255)
|
||||||
if ((serial_in_byte_counter < INPUT_BUFFER_SIZE -1) &&
|
if ((serial_in_byte_counter < INPUT_BUFFER_SIZE -1) && // Add char to string if it still fits and ...
|
||||||
((serial_in_byte != Settings.serial_delimiter) || Settings.flag.mqtt_serial_raw)) { // add char to string if it still fits
|
((isprint(serial_in_byte) && (128 == Settings.serial_delimiter)) || // Any char between 32 and 127
|
||||||
|
(serial_in_byte != Settings.serial_delimiter) || // Any char between 1 and 127 and not being delimiter
|
||||||
|
Settings.flag.mqtt_serial_raw)) { // Any char between 0 and 255
|
||||||
serial_in_buffer[serial_in_byte_counter++] = serial_in_byte;
|
serial_in_buffer[serial_in_byte_counter++] = serial_in_byte;
|
||||||
serial_polling_window = millis();
|
serial_polling_window = millis();
|
||||||
} else {
|
} else {
|
||||||
serial_polling_window = 0;
|
serial_polling_window = 0; // Reception done - send mqtt
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2202,7 +2204,7 @@ void SerialInput(void)
|
|||||||
\*-------------------------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------------------------*/
|
||||||
if (SONOFF_SC == Settings.module) {
|
if (SONOFF_SC == Settings.module) {
|
||||||
if (serial_in_byte == '\x1B') { // Sonoff SC status from ATMEGA328P
|
if (serial_in_byte == '\x1B') { // Sonoff SC status from ATMEGA328P
|
||||||
serial_in_buffer[serial_in_byte_counter] = 0; // serial data completed
|
serial_in_buffer[serial_in_byte_counter] = 0; // Serial data completed
|
||||||
SonoffScSerialInput(serial_in_buffer);
|
SonoffScSerialInput(serial_in_buffer);
|
||||||
serial_in_byte_counter = 0;
|
serial_in_byte_counter = 0;
|
||||||
Serial.flush();
|
Serial.flush();
|
||||||
@ -2213,7 +2215,7 @@ void SerialInput(void)
|
|||||||
/*-------------------------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
else if (!Settings.flag.mqtt_serial && (serial_in_byte == '\n')) {
|
else if (!Settings.flag.mqtt_serial && (serial_in_byte == '\n')) {
|
||||||
serial_in_buffer[serial_in_byte_counter] = 0; // serial data completed
|
serial_in_buffer[serial_in_byte_counter] = 0; // Serial data completed
|
||||||
seriallog_level = (Settings.seriallog_level < LOG_LEVEL_INFO) ? (uint8_t)LOG_LEVEL_INFO : Settings.seriallog_level;
|
seriallog_level = (Settings.seriallog_level < LOG_LEVEL_INFO) ? (uint8_t)LOG_LEVEL_INFO : Settings.seriallog_level;
|
||||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_COMMAND "%s"), serial_in_buffer);
|
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_COMMAND "%s"), serial_in_buffer);
|
||||||
AddLog(LOG_LEVEL_INFO);
|
AddLog(LOG_LEVEL_INFO);
|
||||||
@ -2226,7 +2228,7 @@ void SerialInput(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.flag.mqtt_serial && serial_in_byte_counter && (millis() > (serial_polling_window + SERIAL_POLLING))) {
|
if (Settings.flag.mqtt_serial && serial_in_byte_counter && (millis() > (serial_polling_window + SERIAL_POLLING))) {
|
||||||
serial_in_buffer[serial_in_byte_counter] = 0; // serial data completed
|
serial_in_buffer[serial_in_byte_counter] = 0; // Serial data completed
|
||||||
if (!Settings.flag.mqtt_serial_raw) {
|
if (!Settings.flag.mqtt_serial_raw) {
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_SERIALRECEIVED "\":\"%s\"}"), serial_in_buffer);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_SERIALRECEIVED "\":\"%s\"}"), serial_in_buffer);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user