My RFM69 Radio is Not Recievin Message from other RFM69 Radio!

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
animefruit
 
Posts: 332
Joined: Tue Feb 25, 2020 1:04 pm

My RFM69 Radio is Not Recievin Message from other RFM69 Radio!

Post by animefruit »

Hello Adafruit person.
I am Neal, a customer for Adafruit.
I have this code that is supposed to connect to "Clients" or other RFM69 Radios automatically.
One RFM69 Radio is the Server.
And any other RFM69 Radio are the Clients that Receive from the Server.
Right now the Server RFM69 Radio is Sending the "Hi IMC 4"
But I Want the Client RFM69 Radio to Receive "Hi IMC 4" back.
The Problem is that the Client RFM69 Radio is Not Receiving "Hi IMC 4" back.
Can you tell me how to fix this problem?

I Have my Code Separated in Tabs.

Here is the Main Code Tabs for the Server Code for this project:

First Important Code Tab for the Server:

Code: Select all

#include "Radio_TX_Setup.h"
#include "Radio_TX_Loop.h"
#include "Radio_RX_Setup.h"
#include "Radio_RX_Loop.h"
#include "Sensor_Monitor_Setup.h"
#include "Sensor_Monitor_Loop.h"

// The amount of time the game runs for:
int gameTime = 300000; // 5 min = 300000 milliseconds
const int MAX_CLIENTS = 10;
int clients[MAX_CLIENTS] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};

void setup() 
{
  Radio_RX_Setup();
  Radio_TX_Setup();   
}

void loop() 
{

  
  //Sensor_Monitor_Loop();
  
  Radio_RX_Loop();
  
  
//  if (millis=30000){
//    sendMessage("Game is Done");
  
}    

2nd Important Code Tab for Server:

Code: Select all

  extern const int MAX_CLIENTS;
extern int clients[];

void Radio_RX_Loop() 
{
 if (rf69.available()) 
 {
    // Should be a message for us now   
    uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);

    if (rf69.recv(buf, &len)) 
    {     
      if (!len) return;
      buf[len] = 0;
//      Serial.println(buf[0]);
//      Serial.println(buf[1]);
//      Serial.println(buf[2]);
//      Serial.print("Received [");
//      Serial.print(len);
//      Serial.print("]: ");
//      Serial.println((char*)buf );
//      Serial.print("RSSI: ");
//      Serial.println(rf69.lastRssi(), DEC);
//      Serial.println(buf[0]);
//      Serial.println(buf[1]);
//      Serial.println(buf[2]);

//        if(buf[0] == 73) // 'I' Initial
//          if(buf[1] == 77) // 'M' Message
//            if(buf[2] == 67) // 'C' Client
//            {
//              Serial.print("Received [");
//              Serial.print(len);
//              Serial.print("]: ");
//              Serial.println((char*)buf );
//              //Serial.print("RSSI: ");
//              //Serial.println(rf69.lastRssi(), DEC);
//
//              //Loop for buf comparasion
//
//              //if buf is the same, then don't include it 
//
////              if (clients[i-] == i+){//if added i equals same as past one 
////               i++; // skip over it
////              }
//
//              
//
//              // Add the client to the array of clients:
//              for(int i = 0; i < MAX_CLIENTS; i++)
//              {
//                //char results[3][1];
//                //results[0] = { "H", "i", " " }
//                char results[4] = { 'H', 'i', ' ', ' ' };
//                
//                // Check if the client is already in the list:
//                if (clients[i] == buf[4])
//                {
//                  //strcpy(results[0], "Hi ");
//                  //strcpy(results[1], buf[4]);
//                  char test;
//                  itoa(buf[4], test, 10);
//                  results[3] = test;
//                  sendMessage(results);
//                  break;
//                }
//                else
//                  if(clients[i] == -1)
//                  {
//                    clients[i] = buf[4];
//                    delay(200);
//                    sendMessage("Hi");
//                    break;
//                  }
//                }

if(buf[0] == 73) // 'I' Initial
          if(buf[1] == 77) // 'M' Message
            if(buf[2] == 67) // 'C' Client
            {
              Serial.print("Received [");
              Serial.print(len);
              Serial.print("]: ");
              Serial.println((char*)buf );

              // Add the client to the array of clients:
              for(int i = 0; i < MAX_CLIENTS; i++)
              {
                char results[4] = { 'H', 'i', ' ', ' ' };
                
                // Check if the client is already in the list:
                if (clients[i] == buf[4])
                { 
                  // Client is IN the list:
                  sendMessage("Client already registered...");
                  break;
                }
                else
                { 
                  // Client is NOT IN the list. So, get the first blank spot in the array:
                  if(clients[i] == -1)
                  {
                    clients[i] = buf[4];
                    //delay(200);
                    //strcpy(results[0], "Hi ");
                    //strcpy(results[1], buf[4]);
                    results[3] = buf[4];
                    //sendMessage("Hi");
                    sendMessage(results);
                    break;
                  }
                }
              }
             
              // Loop through the clients and print them out:
              for(int i = 0; i < MAX_CLIENTS; i++)
                Serial.print(clients[i]);
              Serial.println("\n");
             }
      // buf[4] will be the client ID
      
      //Serial.println(buf[4]);
      //Serial.println(clients[0]);
      
    } else {
      Serial.println("Receive failed");
    }
  }
}   
First Important Code Tab for Client:

Code: Select all

 #include "Radio_TX_Setup.h"
#include "Radio_TX_Loop.h"
#include "Radio_RX_Setup.h"
#include "Radio_RX_Loop.h"  
#include "Sensor_Monitor_Setup.h"
#include "Sensor_Monitor_Loop.h"

void setup() 
{
  Radio_RX_Setup();
  Radio_TX_Setup();
  //Sensor_Monitor_Setup();
  //sendMessage("IMC: Client Servo Connected");
  sendMessage("IMC:4");
  delay(10);
}

void loop() 
{
  //Sensor_Monitor_Loop();
  Radio_RX_Loop();
}  
The Rest of the Code is Not that important.
It is just Loop and the Setup of the norma TXRX Radio RFM69 Example Code.

But I have them attached to the Next Posts.

I will have the Server Code attached to the next post.

I will have the Client Code attached to the Next Code after that.
Last edited by animefruit on Sat Jun 03, 2023 8:02 pm, edited 1 time in total.

User avatar
animefruit
 
Posts: 332
Joined: Tue Feb 25, 2020 1:04 pm

Re: My RFM69 Radio is Not Recievin Message from other RFM69 Radio!

Post by animefruit »

Here is the rest of my Server Code:
Attachments
Radio_TX_Loop.h
(32 Bytes) Downloaded 3 times
Radio_RX_Setup.h
(1.19 KiB) Downloaded 4 times
Radio_RX_Loop.h
(4.16 KiB) Downloaded 3 times
Last edited by animefruit on Sat Jun 03, 2023 8:04 pm, edited 1 time in total.

User avatar
animefruit
 
Posts: 332
Joined: Tue Feb 25, 2020 1:04 pm

Re: My RFM69 Radio is Not Recievin Message from other RFM69 Radio!

Post by animefruit »

Here is the rest of my Client Code:
Attachments
Radio_TX_Loop.h
(32 Bytes) Downloaded 2 times
Radio_RX_Setup.h
(1.19 KiB) Downloaded 2 times
Radio_RX_Loop.h
(542 Bytes) Downloaded 2 times

User avatar
animefruit
 
Posts: 332
Joined: Tue Feb 25, 2020 1:04 pm

Re: My RFM69 Radio is Not Recievin Message from other RFM69 Radio!

Post by animefruit »

Here is the Serial Monitor for the Client RFM69 Radio:
Attachments
8F236791-B0E6-4685-AEB4-DC95949F09D3.jpeg
8F236791-B0E6-4685-AEB4-DC95949F09D3.jpeg (753.99 KiB) Viewed 133 times

User avatar
animefruit
 
Posts: 332
Joined: Tue Feb 25, 2020 1:04 pm

Re: My RFM69 Radio is Not Recievin Message from other RFM69 Radio!

Post by animefruit »

Here is the Serial Monitor for the Sever RFM69 Radio:
Attachments
B5CE94BA-1D03-4945-9C8F-E6644D406272.jpeg
B5CE94BA-1D03-4945-9C8F-E6644D406272.jpeg (389.53 KiB) Viewed 133 times

User avatar
animefruit
 
Posts: 332
Joined: Tue Feb 25, 2020 1:04 pm

Re: My RFM69 Radio is Not Recievin Message from other RFM69 Radio!

Post by animefruit »

Nevermind!
I figure it out!
Sounds great!

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”