2020#ifdef USE_SERIAL_BRIDGE
2121/* ********************************************************************************************\
2222 * Serial Bridge using Software Serial library (TasmotaSerial)
23+ *
24+ * SBaudrate <baudrate> - Set baudrate
25+ * SBaudrate 9600
26+ * SSerialConfig <config> - Set serial config
27+ * SSerialConfig 8N1
28+ * SSerialBuffer <size> - Set serial receive buffer
29+ * SSerialSend "Hello Tiger" - Send "Hello Tiger\n"
30+ * SSerialSend - Set to text decoding
31+ * SSerialSend1 "Hello Tiger" - Send "Hello Tiger\n"
32+ * SSerialSend2 "Hello Tiger" - Send "Hello Tiger"
33+ * SSerialSend3 "Hello Tiger" - Send "Hello Tiger\f"
34+ * SSerialSend4 - Set to binary decoding
35+ * SSerialSend4 "Hello Tiger" - Send "Hello Tiger" and set to binary decoding
36+ * SSerialSend5 "AA004566" - Send "AA004566" as hex values
37+ * SSerialSend6 "72,101,108,108" - Send decimals as hex values
38+ * SerialDelimiter 255 - Receive data between 32 and 127 only
39+ * SerialDelimiter 254 - Receive hexadecimal data
40+ * SerialDelimiter 128 - Receive no data between 32 and 127
2341\*********************************************************************************************/
2442
2543#define XDRV_08 8
@@ -91,7 +109,7 @@ void SerialBridgeInput(void) {
91109 uint8_t serial_in_byte = SerialBridgeSerial->read ();
92110
93111#ifdef USE_SERIAL_BRIDGE_TEE
94- if (Settings->sbflag1 .serbridge_console ) {
112+ if (Settings->sbflag1 .serbridge_console ) { // CMND_SSERIALSEND9 - Enable logging tee to serialbridge
95113 static bool serial_bridge_overrun = false ;
96114
97115 if (isprint (serial_in_byte)) { // Any char between 32 and 127
@@ -117,7 +135,7 @@ void SerialBridgeInput(void) {
117135 }
118136 } else {
119137#endif // USE_SERIAL_BRIDGE_TEE
120- serial_bridge_raw = (254 == Settings->serial_delimiter );
138+ serial_bridge_raw = (254 == Settings->serial_delimiter ); // SerialDelimiter
121139 if ((serial_in_byte > 127 ) && !serial_bridge_raw) { // Discard binary data above 127 if no raw reception allowed
122140 serial_bridge_in_byte_counter = 0 ;
123141 SerialBridgeSerial->flush ();
@@ -147,17 +165,17 @@ void SerialBridgeInput(void) {
147165 }
148166
149167#ifdef USE_SERIAL_BRIDGE_TEE
150- if (Settings->sbflag1 .serbridge_console ) {
168+ if (Settings->sbflag1 .serbridge_console ) { // CMND_SSERIALSEND9 - Enable logging tee to serialbridge
151169 return ;
152170 }
153171#endif // USE_SERIAL_BRIDGE_TEE
154172
155173 if (serial_bridge_in_byte_counter && (millis () > (serial_bridge_polling_window + SERIAL_POLLING))) {
156- serial_bridge_buffer[serial_bridge_in_byte_counter] = 0 ; // Serial data completed
174+ serial_bridge_buffer[serial_bridge_in_byte_counter] = 0 ; // Serial data completed
157175 bool assume_json = (!serial_bridge_raw && (serial_bridge_buffer[0 ] == ' {' ));
158176
159- TasmotaGlobal.serial_skip ++; // SetOption35 Skip number of serial messages received (default 0)
160- if (TasmotaGlobal.serial_skip > Settings->param [P_SERIAL_SKIP]) { // Handle intermediate changes to SetOption35
177+ TasmotaGlobal.serial_skip ++; // SetOption35 Skip number of serial messages received (default 0)
178+ if (TasmotaGlobal.serial_skip > Settings->param [P_SERIAL_SKIP]) { // Handle intermediate changes to SetOption35
161179 TasmotaGlobal.serial_skip = 0 ;
162180
163181 Response_P (PSTR (" {\" " D_JSON_SSERIALRECEIVED " \" :" ));
@@ -188,7 +206,7 @@ void SerialBridgeInput(void) {
188206/* *******************************************************************************************/
189207
190208void SerialBridgeInit (void ) {
191- if (PinUsed (GPIO_SBR_RX) && PinUsed (GPIO_SBR_TX)) {
209+ if (PinUsed (GPIO_SBR_RX) || PinUsed (GPIO_SBR_TX)) {
192210// SerialBridgeSerial = new TasmotaSerial(Pin(GPIO_SBR_RX), Pin(GPIO_SBR_TX), HARDWARE_FALLBACK); // Default TM_SERIAL_BUFFER_SIZE (=64) size
193211 SerialBridgeSerial = new TasmotaSerial (Pin (GPIO_SBR_RX), Pin (GPIO_SBR_TX), HARDWARE_FALLBACK, 0 , MIN_INPUT_BUFFER_SIZE); // 256
194212 if (SetSSerialBegin ()) {
0 commit comments