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


  • Admin

    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.


  • Admin

    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.


  • Contest Winner

    @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!


Log in to reply
 

Suggested Topics

  • 4
  • 1
  • 5
  • 3
  • 274
  • 9

2
Online

11.2k
Users

11.1k
Topics

112.5k
Posts