Testing communication which sketch



  • What sketch are you guys using for testing communication between two radio nodes? In the library that is downloaded with version 1.3 I had been using the 'pingpair' sketch. But in the library that is downloaded with version 1.4, I cannot find the pingpair sketch.

    So, for those who like version 1.4 with the updated RF24L01 library, what sketch do you use to test the communication? How do I set it up? It seems that version 1.4 library needs to be modified so that these valuable sketches work, but I could be doing something wrong.

    I have tried using the 'GettingStarted' sketch under the RD24 lib, but that doesn't seem to work. Plus I like the simplicity of the 'pingpair' sketch better anyway. I'm assuming that the sketches need to be modified to work with the new RF24 lib, right?

    I am having no luck with this new version 1.4...


  • Mod

    @therik do the pingpair sketches use hardware ack's by default?
    I have to partly defunct radios that only work without hardware ack, so be sure to include that in the test.
    It might be useful to include a sketch in 1.4 that let's one node communicate directly to another and exchange some messages. That would have the same functionality as pingpair, but use the mysensors library. Can be a good starting point for anyone having troubles.


  • Admin

    Yes, that would be good to have around. Anyone wanting to contribute with something?
    Using the onboard LED to indicate working communication would also be good.



  • Okay, I actually got the pingpair sketch to work using the new library!

    The problem was that the new RF24 library does not return a bool for the read method like in the previous library, it's return is void. So, I changed the following code...

      if ( role == role_pong_back )
      {
        // if there is data ready
        if ( radio.available() )
       {
          // Dump the payloads until we've gotten everything
          unsigned long got_time;
          bool done = false;
          while (!done)
          {
            // Fetch the payload, and see if this was the last one.
            done = radio.read( &got_time, sizeof(unsigned long) );
          }
    

    to...

      if ( role == role_pong_back )
      {
        // if there is data ready
        if ( radio.available() )
       {
          // Dump the payloads until we've gotten everything
          unsigned long got_time;
          //bool done = false;
          //while (!done)
          //{
            // Fetch the payload, and see if this was the last one.
            radio.read( &got_time, sizeof(unsigned long) );
            //done = radio.read( &got_time, sizeof(unsigned long) );
            //the new library does not work like this any longer.
          //}
    

    And it compiled and I got successful ping-pong action. I don't know if this is entirely correct; or if I'm using the read method correctly. Anyone with more coding expertise care to comment?


  • Mod

    @therik I never really understood why the data was read this way in the pingpair sketch.
    Is keeps reading and overwriting data just read until there's nothing left to read.
    The pong sketch should just write 1 value for every value received, so there shouldn't be anything more to read anyway.
    Maybe on some boundary condition more data could come in, but I would prefer to read the value and flush the rest. Too bad flush Rx is not exported to public in current rf24 implementation...


Log in to reply
 

Suggested Topics

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts