PingPong without gateway or controller?



  • I am trying to test RFM95 radios. So far I can not get any communication between them. I would like to be able to test without having to worry about a gateway or controller. I just want to get communication of some kind between the two nodes. I have tried the Example sketch PingPongSensor, but it is going through the process of trying to communicate upstream:

     __  __       ____
    |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
    | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
    | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
    |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
            |___/                      2.2.0-rc.1
    
    18 MCO:BGN:INIT NODE,CP=RLNNA---,VER=2.2.0-rc.1
    28 TSM:INIT
    28 TSF:WUR:MS=0
    47 TSM:INIT:TSP OK
    49 TSM:FPAR
    2050 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    4059 !TSM:FPAR:NO REPLY
    4061 TSM:FPAR
    6064 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    8073 !TSM:FPAR:NO REPLY
    8075 TSM:FPAR
    10078 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    12087 !TSM:FPAR:NO REPLY
    12089 TSM:FPAR
    14092 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    16101 !TSM:FPAR:FAIL
    16103 TSM:FAIL:CNT=1
    16105 TSM:FAIL:DIS
    16107 TSF:TDI:TSL
    26112 TSM:FAIL:RE-INIT
    26114 TSM:INIT
    26130 TSM:INIT:TSP OK
    26132 TSM:FPAR
    28135 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    30144 !TSM:FPAR:NO REPLY
    30146 TSM:FPAR
    32149 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    34158 !TSM:FPAR:NO REPLY
    34160 TSM:FPAR
    36163 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    38172 !TSM:FPAR:NO REPLY
    38174 TSM:FPAR
    40177 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    42186 !TSM:FPAR:FAIL
    

    and so on, endlessly looking for a parent. It never gets to presentation() or loop().

    Is there some easy way to let the test go forward with needing a gateway controller? Since the sketch later sets the nodeId to with 200 or 201 and there is no need to communicate upstream for the simple purpose of a ping, I don't see a need for a gateway or controller to be present for this test.


  • Mod

    According to the log your node does not have an ID, try assigning one manually and see if you see any change



  • @gohan confirmed one of my guesses. I made some further guesses as well. I hard coded a node ID, disabled the uplink check, hard coded a parent ID and defined it as static. All of this seems to have gotten the node to be independent.

    One of the consequences of my modifications is that entering "0" or "1" in the terminal no longer has any real effect. Below is the output, including the results of me entering "T" from the serial monitor at the end.

     __  __       ____
    |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
    | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
    | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
    |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
            |___/                      2.2.0-rc.1
    
    18 MCO:BGN:INIT NODE,CP=RLNNA---,VER=2.2.0-rc.1
    28 TSM:INIT
    28 TSF:WUR:MS=0
    47 TSM:INIT:TSP OK
    49 TSM:INIT:STATID=201
    51 TSF:SID:OK,ID=201
    53 TSM:FPAR
    53 TSM:FPAR:STATP=1
    55 TSM:ID
    57 TSM:ID:OK
    59 TSM:UPL:DISABLED
    61 TSM:READY:ID=201,PAR=1,DIS=1
    15376 !TSF:MSG:SEND,201-201-1-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=NACK:0100
    32694 !TSF:MSG:SEND,201-201-1-0,s=255,c=0,t=17,pt=0,l=10,sg=0,ft=1,st=NACK:2.2.0-rc.1
    48015 !TSF:MSG:SEND,201-201-1-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=2,st=NACK:1
    65335 !TSF:MSG:SEND,201-201-1-0,s=1,c=0,t=23,pt=0,l=0,sg=0,ft=3,st=NACK:
    80656 !TSF:MSG:SEND,201-201-1-0,s=255,c=3,t=11,pt=0,l=9,sg=0,ft=4,st=NACK:Yang Node
    96006 !TSF:MSG:SEND,201-201-1-0,s=255,c=3,t=12,pt=0,l=4,sg=0,ft=5,st=NACK:v1.0
    
    Yang NodeReady.
    96014 MCO:REG:REQ
    111357 !TSF:MSG:SEND,201-201-1-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=6,st=NACK:2
    111366 !TSM:READY:UPL FAIL,STATP
    128645 !TSF:MSG:SEND,201-201-1-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=NACK:2
    145936 !TSF:MSG:SEND,201-201-1-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=1,st=NACK:2
    163254 !TSF:MSG:SEND,201-201-1-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=2,st=NACK:2
    165263 MCO:BGN:STP
    Setting node id to: 201.
    ***Please restart the node for changes to take effect.
    165267 MCO:BGN:INIT OK,TSP=1
    T received - starting test...
    Sending Ping to Ying Node
    289431 !TSF:MSG:SEND,201-201-1-200,s=1,c=1,t=24,pt=5,l=4,sg=0,ft=3,st=NACK:274122
    

    Here's is my hacked, diced and sliced version of the sketch. As noted, nothing is changed below void presentation()

    /***
     *  This is a simple sketch used to demenstrate and test node-to-node MySensor's communication.
     *  To use this sketch, assemble MySensors nodes - they need nothing more than a radio
     *  1.  Flash each node with the same sketch, open the console and type either 0 or 1 to the respective nodes to set thei ID
     *  2.  You only need to set the node id once, and restart the nodes
     *  3.  To being a ping-pong test, simply type T in the console for one of the nodes.
     *
     *  2015-05-25 Bruce Lacey v1.0
     */
    
    //The Node ID's are hard coded in this sketch, so the option described in #1 above
    //of specifying 0 or 1 no longer works.  Each node will need to be flahed with the
    //correct #define for eith NODE_YING or NODE_YANG
    
    //Which node is this?
    //#define NODE_YING
    #define NODE_YANG
    
    // Define two generic nodes with a single child
    #define YING 200
    #define YANG 201
    #define CHILD 1
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    //#define   MY_SPECIAL_DEBUG
    #define   MY_TRANSPORT_UPLINK_CHECK_DISABLED  //Don't check for uplink
    #define   MY_NODE_ID 199  //Fallback NodeId
    
    //We don't care about a parent, but this satisfies various demands
    //We hard code a parent ID of 1 and say that it's static
    //so that the system won't check for one
    #define   MY_PARENT_NODE_ID  1
    #define   MY_PARENT_NODE_IS_STATIC
    
    //Override the fallback NodeId
    #ifdef NODE_YING
    #define MY_NODE_ID YING
    #endif
    #ifdef NODE_YANG
    #define MY_NODE_ID YANG
    #endif
    
    // Enable and select radio type attached
    //#define MY_RADIO_NRF24
    //#define MY_RADIO_NRF5_ESB
    //#define MY_RADIO_RFM69
    //#define MY_RADIO_RFM95
    
    //RFM95 with various trial settings
    #define   MY_RFM95_FREQUENCY RFM95_915MHZ
    #define   MY_RFM95_MODEM_CONFIGRUATION RFM95_BW125CR45SF128 
    #define   MY_RFM95_ATC_MODE_DISABLED
    #define   MY_RFM95_MAX_POWER_LEVEL_DBM 20
    
    //My nodes are different hardware with different pinouts
    #ifdef NODE_YING
    #define   RFM95_IRQ_PIN     5  // library 2.1.1 = GPIO Pin 9
    #define   RFM95_RST_PIN     5  // library 2.1.1
    #define   RFM95_SPI_CS      6  // library 2.1.1
    #define   MY_RFM95_IRQ_PIN  5  // library 2.2 beta = GPIO
    #define   MY_RFM95_RST_PIN  5  // library 2.2 beta
    #define   MY_RFM95_CS_PIN   6  // library 2.2 beta
    #endif
    #ifdef NODE_YANG
    #define   RFM95_IRQ_PIN     6  // library 2.1.1
    #define   RFM95_RST_PIN     9  // library 2.1.1
    #define   RFM95_SPI_CS     10  // library 2.1.1
    #define   MY_RFM95_IRQ_PIN  6  // library 2.2 beta = GPIO Pin 6
    #define   MY_RFM95_RST_PIN  9  // library 2.2 beta
    #define   MY_RFM95_CS_PIN  10  // library 2.2 beta
    #endif
    
    #define   MY_RADIO_RFM95
    //#define   MY_DEBUG_VERBOSE_RFM95
    
    #include <MySensors.h>
    #include "MYSLog.h"
    
    #define VSN "v1.0"
    
    MyMessage mPing(CHILD, V_VAR1);   //Ping message
    MyMessage mPong(CHILD, V_VAR2);   //Pong message
    
    void setup()
    {
    #ifdef NODE_YING
      setNodeId(YING);
    #endif
    #ifdef NODE_YANG
      setNodeId(YANG);
    #endif
    }
    
    //////////////////////////////////////////////
    //No changes have been made below this point
    //////////////////////////////////////////////
    
    void presentation()
    {
    	present(CHILD, S_CUSTOM);  //
    
    	sendSketchInfo( nodeTypeAsCharRepresentation( getNodeId() ), VSN );
    	LOG(F("\n%sReady.\n"), nodeTypeAsCharRepresentation(getNodeId()));
    }
    
    void loop()
    {
    
    	// Interactive command and control
    	// Entering a number from 0 or 1 will write the node 200 (YING) or 201 (YANG) to EEPROM
    	// Entering T on either node will initiatve a ping-pong test.
    	if (Serial.available()) {
    		byte inChar = Serial.read();
    		uint8_t node = getNodeId();
    
    		// Manual Test Mode
    		if (inChar == 'T' || inChar == 't') {
    			LOG(F("T received - starting test...\n"));
    			MyMessage msg = mPong;
    			msg.sender = (node == YING ? YANG : YING);
    			sendPingOrPongResponse( msg );
    		} else if (inChar == '0' or inChar == '1') {
    			byte nodeID = 200 + (inChar - '0');
    			setNodeId(nodeID);
    		} else {
    			LOG("Invalid input\n");
    		}
    	}
    }
    
    void receive(const MyMessage &message)
    {
    
    	LOG(F("Received %s from %s\n"), msgTypeAsCharRepresentation((mysensor_data)message.type),
    	    nodeTypeAsCharRepresentation(message.sender));
    
    	delay(250);
    	sendPingOrPongResponse( message );
    }
    
    void sendPingOrPongResponse( MyMessage msg )
    {
    
    	MyMessage response = (msg.type == V_VAR1 ? mPong : mPing);
    
    	LOG(F("Sending %s to %s\n"), msgTypeAsCharRepresentation( (mysensor_data)response.type ),
    	    nodeTypeAsCharRepresentation(msg.sender));
    
    	// Set payload to current time in millis to ensure each message is unique
    	response.set( (uint32_t)millis() );
    	response.setDestination(msg.sender);
    	send(response);
    }
    
    void setNodeId(byte nodeID)
    {
    	LOG(F("Setting node id to: %i.\n***Please restart the node for changes to take effect.\n"), nodeID);
    	hwWriteConfig(EEPROM_NODE_ID_ADDRESS, (byte)nodeID);
    }
    
    const char * msgTypeAsCharRepresentation( mysensor_data mType )
    {
    	return mType == V_VAR1 ? "Ping" : "Pong";
    }
    
    const char * nodeTypeAsCharRepresentation( uint8_t node )
    {
    	return node == YING ? "Ying Node" : "Yang Node";
    }
    

  • Mod

    I remember there were some posts last month from a user using node to node direct communication without gateway.



  • Based on what @gohan posted, I searched for 'without gateway' and found several useful posts. Sometimes all it takes is knowing how to ask the question.


  • Mod

    I'm glad you found something useful, let us know if you have succeeded



  • The sketch works using a direct, wired connection (RS485).

    T received - starting test...
    Sending Ping to Ying Node
    2226167 TSF:MSG:SEND,201-201-1-200,s=1,c=1,t=24,pt=5,l=4,sg=0,ft=0,st=OK:2226165
    

    But it does not work with my RFM95's, but that is a completely different topic.


 

360
Online

7.8k
Users

8.7k
Topics

93.0k
Posts