Node to Node Communication via Gatreway


  • Plugin Developer

    My topology is as follows,
    Node-1 <--> Gateway <--> Node-2.

    When I send message from Node-1 to Node-2 (or) Node-2 to Node-1 is not working,
    Node-1 and Node-2 are repeater nodes.

    Gateway does not route packets to another node in the network?


  • Admin

    That's strange. You probably have to look at the serial output from the nodes and gateway to find the cause.


  • Plugin Developer

    @hek Thank you I did serial debug, I'm not clear about route (to) address
    https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/MySensor.cpp#L401

    Node-1:
    send: 1-1-0-0 s=255,c=0,t=18,pt=0,l=6,sg=0,st=ok:1.5 b1
    send: 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
    repeater started, id=1, parent=0, distance=1
    send: 1-1-0-0 s=255,c=3,t=11,pt=0,l=16,sg=0,st=ok:LevelSensor
    send: 1-1-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
    send: 1-1-0-0 s=1,c=0,t=15,pt=0,l=6,sg=0,st=ok:1.5 b1
    send: 1-1-0-0 s=1,c=1,t=13,pt=2,l=2,sg=0,st=ok:0
    send: 1-1-3-3 s=1,c=1,t=13,pt=2,l=2,sg=0,st=fail:0

    above '3' is 'to' (route) address, I do not understand what is '3' and how it was calculated, I hope here 'to' should be a parent address, which is 0

    Gateway:
    0;0;3;0;9;gateway started, id=0, parent=0, distance=0
    0;0;3;0;14;Gateway startup complete.
    0;0;3;0;9;read: 1-1-0 s=255,c=0,t=18,pt=0,l=6,sg=0:1.5 b1
    1;255;0;0;18;1.5 b1
    0;0;3;0;9;read: 1-1-0 s=255,c=3,t=6,pt=1,l=1,sg=0:0
    1;255;3;0;6;0
    0;0;3;0;9;read: 1-1-0 s=255,c=3,t=11,pt=0,l=16,sg=0:LevelSensor

    1;255;3;0;11;LevelSensor
    0;0;3;0;9;read: 1-1-0 s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
    1;255;3;0;12;1.0
    0;0;3;0;9;read: 1-1-0 s=1,c=0,t=15,pt=0,l=6,sg=0:1.5 b1
    1;1;0;0;15;1.5 b1
    0;0;3;0;9;read: 1-1-0 s=1,c=1,t=13,pt=2,l=2,sg=0:0
    1;1;1;0;13;0

    0;0;3;0;9;read: 3-3-0 s=255,c=0,t=18,pt=0,l=6,sg=0:1.5 b1
    3;255;0;0;18;1.5 b1
    0;0;3;0;9;read: 3-3-0 s=255,c=3,t=6,pt=1,l=1,sg=0:0
    3;255;3;0;6;0
    0;0;3;0;9;read: 3-3-0 s=255,c=3,t=11,pt=0,l=19,sg=0:LevelIndicator
    3;255;3;0;11;LevelIndicator
    0;0;3;0;9;read: 3-3-0 s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
    3;255;3;0;12;1.0
    0;0;3;0;9;read: 3-3-0 s=1,c=0,t=15,pt=0,l=6,sg=0:1.5 b1
    3;1;0;0;15;1.5 b1

    Node-2:
    send: 3-3-0-0 s=255,c=0,t=18,pt=0,l=6,sg=0,st=ok:1.5 b1
    send: 3-3-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
    repeater started, id=3, parent=0, distance=1
    send: 3-3-0-0 s=255,c=3,t=11,pt=0,l=19,sg=0,st=ok:LevelIndicator
    send: 3-3-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
    send: 3-3-0-0 s=1,c=0,t=15,pt=0,l=6,sg=0,st=ok:1.5 b1
    send: 3-3-1-1 s=1,c=1,t=13,pt=2,l=2,sg=0,st=fail:0


  • Admin

    What does your code look like on the sending node (1)?


  • Plugin Developer

    #define NODE_ID (int8_t) 1
    #define N_LEVEL_DISPLAY_ID (int8_t) 3
    #define S_LEVEL_DISPLAY_ID (int8_t) 1
    
    MySensor gw;
     gw.begin(incomingMessage, NODE_ID, true);
    MyMessage levelDisplayBoard(S_LEVEL_DISPLAY_ID, V_DISTANCE);
    levelDisplayBoard.setDestination(N_LEVEL_DISPLAY_ID);
    int dist = getDistance();
    gw.send(levelDisplayBoard.set(dist));
    

  • Admin

    I think node 1 has a corrupt routing table (it thinks node 3 is a child).

    Try clearing eeprom and re-upload your sketch. Or disable repeater-mode on it.


  • Plugin Developer

    How to print routing table in serial console?


  • Admin

    You have to read it from eeprom.
    It starts at position: EEPROM_ROUTES_ADDRESS (defined in MySensors.h)

    http://www.arduino.cc/en/Tutorial/EEPROMRead


  • Plugin Developer

    @hek you are right! There was an entry for Node-2 in Node-1 routing table, As it has direct access to Node-2, was trying to send directly. I removed the entry and now it's going throw gateway. All node works well. Perfect!

    I thing we have to add code to remove routing table entry dynamically if it face some N number of failures. It will make life easier for those who is shifting node from one location to another location often.


 

211
Online

8.4k
Users

9.3k
Topics

97.9k
Posts