Possibility of Intercepting Serial Messages in Gateway for own Message Handling?
-
Hello guys,
I built myself a gateway on 1.5.4 which also did a lot of other functions. E.g. controlling locally connected lights and a ventilation controller.
To achieve this I intercepted the serial messages from the controller in my gateway Arduino and handled them by myself. To have a logic order I gave every different attached "device" an own Node ID. This means that I have basically three additional devices which show up in my controller as if they were independent Arduinos connected to the MySensors network via radio link, but actually those were just functions locally wired to my gateway. I like it this way because everything is logically separated and not cluttered in my controller.
Now my Problem: I want to migrate my gateway to the 2.0 MySensors version but the programming is vastly different. For the serial handling I previously directly used the "void SerialEvent()" function and checked if the Node ID of a received serial command matches my "locally attached" Node IDs and handled them myself in this case. MySensors 2.0 doesn't have this function anymore.
Do I have some different way of directly intercepting the Serial messages sent from my Controller to my Gateway?
Thanks a lot in advance for your help!
Martin
-
Messages sent to the gateway will end up in the
receive()
-function (if you add it to the gateway sketch). Just like any other node.
-
So if I understand this correctly, I can just check for "if (message.destination == my custom node id)" in the receive() - function of my gateway?
This would be really awesome.
-
Messages for other nodes will not be directed to receive() in he gateway. You have to send the to nodeId=0 from the controller. To distinguish them use childId instead.
-
Hm that's a pity. This functionality is specifically what I'm looking for because I want my gateway to function as three different devices with own Node IDs so that those different functionalities show up in my controller as separate devices.
-
@Mathea90 I don't advice to put logic like this in the gateway. If you're controller is running on linux it's easy to write a proxy application between the gateway and your controller and let do the transformation of child id's to unique node id's.
That would save you a lot of trouble whenever a new MySensor's version will be released.
But in my opinion logic like this should be handled in the controller not on the gateway side.
-
@TheoL Hm yeah I guess that makes sense. The point with the future updates is a good one and I think I will now try to alter the structure in my controller to fit my needs.
Thanks for the input!
Suggested Topics
-
Update RF24 library to latest version
Bug Reports • 23 Mar 2014, 23:37 • andriej 24 Mar 2014, 22:52 -
is this project dead?
General Discussion • 8 days ago • perfectom 8 days ago -
Email notifications received twice
General Discussion • 6 Feb 2023, 16:15 • Jodaille 22 days ago -
ESP32 with LoRa
General Discussion • 31 Jan 2023, 11:06 • dhanushmh 16 days ago -
Meet in Malmö, Summer 2016?
General Discussion • 1 Feb 2016, 15:34 • bjacobse 4 Mar 2025, 00:29 -
Is it possible to extract child ID from a just sent message?
General Discussion • 8 Nov 2021, 09:21 • Nigel31 19 days ago