Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
json payload #49
referenced this issue
Jul 28, 2017
I just got my IR detection working, and saw that I get 4 MQTT messages back for each time I press the button. I would definitely prefer to get the data back as one JSON message with fields for each of the parameters. My main concerns is that I want to have multiple IR gateways, and if 2 devices report at the same time it's harder to determine which go together.
added a commit
Mar 8, 2018
It seems like we could have 2 .cpp files, one that would create an MQTT message for each return parameter, and another that would accumulate a JSON message for each of those parameters.
ReporterJSON report // Uncomment only one to enable that reporting method
For example if we added a device for light sensing that returned RGB values, it could call:
if we include the MQTT reporter library it would send back:
If we included the JSON reporter library it would instead return
This might help reduce a lot of redundant code across the project, and allow people to add new sensors/features to the software more readily (They just hook into the same reporting method to send back data)
I agree that we should reduce redundant code, for sensors @broekema proposed an implementation #168
Regarding the division in two cpp files depending on the publishing methods I don't know what are the cons and pros
I was thinking about begining by json implementation with the current code, publish a new release and refactor it for the next version. But if there is people for helping me refactoring it in the same time we can do both for the next version.