[SERIAL][BREAKING] RS232 change to SERIAL GATEWAY (#2008)

Make the RS232 more generic by converting it to a Serial Gateway
Add the capability to decode BLE data coming through Serial
This commit is contained in:
Florian authored and GitHub committed 2024-08-16 11:23:39 -05:00
1 parent 25c3da7ee9
commit 8a28bb2cf8
12 files changed
+419 -379

No files matched your search

+2 -2
View File
@@ -35,7 +35,7 @@ module.exports = {
'setitup/ir',
'setitup/lora',
'setitup/gsm',
'setitup/rs232',
'setitup/serial',
'setitup/sensors',
'setitup/actuators'
]
@@ -62,7 +62,7 @@ module.exports = {
'use/ir',
'use/lora',
'use/gsm',
'use/rs232',
'use/serial',
'use/rfm69',
'use/sensors',
'use/actuators',
@@ -1,4 +1,4 @@
# RS232 gateway
# Serial/RS232 gateway
## Compatible parts
|Module|Purpose|Where to Buy|
|-|-|-|
+15 -15
View File
@@ -1,32 +1,32 @@
# RS232 gateway
# RS232/Serial gateway
The RS232 gateway can be used to send and receive data from the serial connection to and from MQTT. Both softwareSerial as hardwareSerial are supported. HardwareSerial can be used for higher baud rates, but is limited to specific pins on most platforms.
The SERIAL gateway can be used to send and receive data from the serial connection to and from MQTT. Both softwareSerial as hardwareSerial are supported. HardwareSerial can be used for higher baud rates, but is limited to specific pins on most platforms.
## Sending an RS232 message
## Sending an SERIAL message
Simply publish the message you wish to transmit, minus the prefix and postfix. For example, to send the "Turn On" signal for a Mitsubishi XD221U projector, the code is simply '!' so you would use the command
`mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoRS232 -m '{"value": "!"}'`
`mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoSERIAL -m '{"value": "!"}'`
It will automatically add the prefix and postfix you set in [config_RS232.h](https://github.com/1technophile/OpenMQTTGateway/blob/master/main/config_RS232.h).
It will automatically add the prefix and postfix you set in [config_SERIAL.h](https://github.com/1technophile/OpenMQTTGateway/blob/master/main/config_SERIAL.h).
## Receiving an RS232 message
## Receiving an SERIAL message
Two modes are available for receiving RS232 messages.
Two modes are available for receiving SERIAL messages.
### Single MQTT message mode (default)
To receive a message, subscribe to all with `mosquitto_sub -t +/# -v`
and perform an action that should get a response from the device. For example, If I were to send the "Turn On" signal from earlier, I would receive back
```json
home/OpenMQTTGateway/RS232toMQTT {"value":"1"}
home/OpenMQTTGateway/SERIALtoMQTT {"value":"1"}
```
Because this projector echoes back a received command to acknowledge. Some devices will send a NACK, or Negative Acknowledge, to confirm that they received your message but could not comply. That would look like
```json
home/OpenMQTTGateway/RStoMQTT {"value":"!:N"}
home/OpenMQTTGateway/SERIALtoMQTT {"value":"!:N"}
```
### JSON mode
@@ -42,15 +42,15 @@ input received at serial link:
output in case of max nesting level 1:
```json
home/OpenMQTTGateway/RS232toMQTT/temperature "{sens1: 22, sens2: 23}"
home/OpenMQTTGateway/RS232toMQTT/humidity "{sens1: 80, sens2: 60}"
home/OpenMQTTGateway/SERIALtoMQTT/temperature "{sens1: 22, sens2: 23}"
home/OpenMQTTGateway/SERIALtoMQTT/humidity "{sens1: 80, sens2: 60}"
```
output in case of max nesting level 2 (or higher):
```json
home/OpenMQTTGateway/RS232toMQTT/temperature/sens1 22
home/OpenMQTTGateway/RS232toMQTT/temperature/sens2 23
home/OpenMQTTGateway/RS232toMQTT/humidity/sens1 80
home/OpenMQTTGateway/RS232toMQTT/humidity/sens2 60
home/OpenMQTTGateway/SERIALtoMQTT/temperature/sens1 22
home/OpenMQTTGateway/SERIALtoMQTT/temperature/sens2 23
home/OpenMQTTGateway/SERIALtoMQTT/humidity/sens1 80
home/OpenMQTTGateway/SERIALtoMQTT/humidity/sens2 60
```