Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. How to determine from which Node a message is comming from

How to determine from which Node a message is comming from

Scheduled Pinned Locked Moved Troubleshooting
3 Posts 2 Posters 1.1k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • TheoLT Offline
    TheoLT Offline
    TheoL
    Contest Winner
    wrote on last edited by
    #1

    First of all, not sure whether this is the right topic for my question, so if not I apologize.

    I've been experimenting with node to node communication inspired by @GertSanders his presentation during the Dutch MySensors meetup. I haven't discovered this feature of MySensors before, but it's brilliant.

    I can communicate from one sensor to another without the interference of any controller. Love it! It opens new possibilities, and probably keep me awake for a couple of nights ;-)

    So I'd like to know, if there's a way to determine the sender of a message in the incomming message handler. I do see a setDestination() method but - at least in 1.5 - there's no getter and it seems like MySensors ignores that. For my use case it would be great if I can determine what the id is of the node of which the message is originating from.

    I also tried to create a message with the default constructor like this:

      MyMessage myMsg(); 
      myMsg.setDestination( aNodeId );
    

    but that results into the following compile error:

    error: request for member 'setDestination' in 'myMsg', which is of non-class type 'MyMessage()'
       myMsg.setDestination( aNodeId );
             ^
    

    I can get around that easily, so I think I misunderstood the API documentation for that.

    void sendMessage( uint8_t aNodeId, char *aMsg ) {
      MyMessage myMsg( 255, V_VAR1 );
      myMsg.setDestination( aNodeId );
      myMsg.set( aMsg );
      gw.send( myMsg, true );
    }
    
    
    mfalkviddM 1 Reply Last reply
    0
    • TheoLT TheoL

      First of all, not sure whether this is the right topic for my question, so if not I apologize.

      I've been experimenting with node to node communication inspired by @GertSanders his presentation during the Dutch MySensors meetup. I haven't discovered this feature of MySensors before, but it's brilliant.

      I can communicate from one sensor to another without the interference of any controller. Love it! It opens new possibilities, and probably keep me awake for a couple of nights ;-)

      So I'd like to know, if there's a way to determine the sender of a message in the incomming message handler. I do see a setDestination() method but - at least in 1.5 - there's no getter and it seems like MySensors ignores that. For my use case it would be great if I can determine what the id is of the node of which the message is originating from.

      I also tried to create a message with the default constructor like this:

        MyMessage myMsg(); 
        myMsg.setDestination( aNodeId );
      

      but that results into the following compile error:

      error: request for member 'setDestination' in 'myMsg', which is of non-class type 'MyMessage()'
         myMsg.setDestination( aNodeId );
               ^
      

      I can get around that easily, so I think I misunderstood the API documentation for that.

      void sendMessage( uint8_t aNodeId, char *aMsg ) {
        MyMessage myMsg( 255, V_VAR1 );
        myMsg.setDestination( aNodeId );
        myMsg.set( aMsg );
        gw.send( myMsg, true );
      }
      
      
      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by
      #2

      @TheoL this code:

      void receive(const MyMessage &message) {
        
        LOG(F("Received %s from %s\n"), msgTypeAsCharRepresentation((mysensor_data)message.type), nodeTypeAsCharRepresentation(message.sender));
      
        delay(250);
        sendPingOrPongResponse( message );  
      }
      

      from the PingPong example suggests that the sender is available.

      Is that a solution to your problem or did I not quite understand your question?

      TheoLT 1 Reply Last reply
      0
      • mfalkviddM mfalkvidd

        @TheoL this code:

        void receive(const MyMessage &message) {
          
          LOG(F("Received %s from %s\n"), msgTypeAsCharRepresentation((mysensor_data)message.type), nodeTypeAsCharRepresentation(message.sender));
        
          delay(250);
          sendPingOrPongResponse( message );  
        }
        

        from the PingPong example suggests that the sender is available.

        Is that a solution to your problem or did I not quite understand your question?

        TheoLT Offline
        TheoLT Offline
        TheoL
        Contest Winner
        wrote on last edited by
        #3

        @mfalkvidd Thanx for the quick reply and the example. It's exactly what I was I was looking for. I just overlooked the union definition in Message.h.

        I'm currently sending the message to the Node itself as a test. But event that that works.

        1 Reply Last reply
        1
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        12

        Online

        11.7k

        Users

        11.2k

        Topics

        113.1k

        Posts


        Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • MySensors
        • OpenHardware.io
        • Categories
        • Recent
        • Tags
        • Popular