-
Notifications
You must be signed in to change notification settings - Fork 795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add JSON parsing and hardware serial support to RS232 gateway #1409
Conversation
This reverts commit a0ec9a1.
@DieKatzchen would it be possible to review this PR as you are the author of the first version ? |
Gave it a look over, only thing I would change is putting the SoftwareSerial #include inside the #ifndef, since we wouldn't be using it in that instance. The serial stuff all looks about right (actually, I learned a thing or two), and I can't comment on the JSON formatting. |
@mreijnde Thanks for the PR, could you take into account the comment please |
I moved the #include as requested. Furthermore:
|
Thanks! |
Description:
I added some features to the RS232 gateway I like to share. My use-case is logging JSON data to MQTT generated by an other microprocessor through a serial connection to OMG running on a ESP8266 or ESP32.
Improvements:
EXAMPLE:
retrieved data on serial link: "{temperature: {sens1: 22, sens2: 23}, humidity: {sens1: 80, sens2: 60}}"
output to MQTT ( RS232maxJSONlevel=1):
./RS232toMQTT/temperature ==> "{sens1: 22, sens2: 23}"
./RS232toMQTT/humidity ==> "{sens1: 80, sens2: 60}"
output to MQTT ( RS232maxJSONlevel=2 (or higher)):
./RS232toMQTT/temperature/sens1 ==> 22
./RS232toMQTT/temperature/sens2 ==> 23
./RS232toMQTT/humidity/sens1 ==> 80
./RS232toMQTT/humidity/sens2 ==> 60
As default the original behavior is enabled to send the full RS232 like as MQTT message. By setting the RS232toMQTTmode to 1, the new JSON parsing mode can be enabled.
I tested it on a ESP32 and a ESP8266. The original 'raw' mode compiles on a Arduino Uno, the JSON variant does not fit in flash. The Arduino Mega does not compile, like on the original branch. I removed reference to it in the update.
Please have a look , I am open to suggestions to improve.
Checklist: