Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: RadioHead / Airspayce issue

  1. #1

    RadioHead / Airspayce issue

    Hello All,

    I have two custom teensy's with an RFM69 connected to them.

    SERVER

    Code:
    #include <SPI.h>
    #include <RH_RF69.h>
    
    // Singleton instance of the radio driver
    RH_RF69 rf69(20, 2);
    
    int led = 33;
    
    void setup() 
    {
      Serial.begin(9600);
    
      if (!rf69.init())
        Serial.println("init failed");
      // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
      // No encryption
      
      if (!rf69.setFrequency(434.0))
        Serial.println("setFrequency failed");
    
      rf69.setModemConfig(RH_RF69::GFSK_Rb57_6Fd120);
    
      rf69.setPreambleLength(4);
    
      uint8_t syncwords[] = { 0x2d, 0xd4 };
      rf69.setSyncWords(syncwords, sizeof(syncwords));
    
      uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
                        0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
      
      rf69.setEncryptionKey(key);
    
      pinMode(led, OUTPUT);
    }
    
    void 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))
        {
    
          digitalWrite(led, HIGH);
          
          RH_RF69::printBuffer("request: ", buf, len);
          
          Serial.print("got request: ");
          Serial.println((char*)buf);
          Serial.print("RSSI: ");
          Serial.println(rf69.lastRssi(), DEC);
    
          // Send a reply
          uint8_t data[] = "And hello back to you";
          rf69.send(data, sizeof(data));
          rf69.waitPacketSent();
          Serial.println("Sent a reply");
        }
        else
        {
          Serial.println("recv failed");
        }
      }
    
      digitalWrite(led, LOW);
    }
    and CLIENT

    Code:
    #include <SPI.h>
    #include <RH_RF69.h>
    
    // Singleton instance of the radio driver
    RH_RF69 rf69(20, 2);
    
    int led = 33;
    
    void setup() 
    {
      Serial.begin(9600);
      if (!rf69.init())
        Serial.println("init failed");
    
      if (!rf69.setFrequency(434.0))
        Serial.println("setFrequency failed");
    
      rf69.setModemConfig(RH_RF69::GFSK_Rb57_6Fd120);
    
      rf69.setPreambleLength(4);
    
      uint8_t syncwords[] = { 0x2d, 0xd4 };
      rf69.setSyncWords(syncwords, sizeof(syncwords));
      
      uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
                        0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
      
      rf69.setEncryptionKey(key);
    
      pinMode(led, OUTPUT);
    }
    
    
    void loop()
    {
      digitalWrite(led, HIGH);
      
      Serial.println("Sending to rf69_server");
      
      // Send a message to rf69_server
      uint8_t data[] = "Hello World!";
      rf69.send(data, sizeof(data));  
      rf69.waitPacketSent();
      
      // Now wait for a reply
      uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
      uint8_t len = sizeof(buf);
    
      if (rf69.waitAvailableTimeout(500))
      { 
        // Should be a reply message for us now   
        if (rf69.recv(buf, &len))
        {
          Serial.print("got reply: ");
          Serial.println((char*)buf);
        }
        else
        {
          Serial.println("recv failed");
        }
      }
      else
      {
        Serial.println("No reply, is rf69_server running?");
      }
    
      digitalWrite(led, LOW);
    
      delay(1000);
    }
    Here is the output I get from the SERVER

    Code:
    request: 
    58 75 7C 7C 7F 30 57 7F 72 7C 74 31 10 
    got request: Xu||0Wr|t1��
    RSSI: -40
    Sent a reply
    Here is the output I get from the CLIENT
    Code:
    Sending to rf69_server
    got reply: Q~t0xu||0rqs{0t0yu
    Why are the messages getting corrupted?

    Thank in advance to anyone that helps me out!

    Cheers, Ben

  2. #2
    Senior Member
    Join Date
    Jun 2013
    Location
    So. Calif
    Posts
    2,828
    I've worked with the RFM69 quite a bit.
    this
    rf69.setModemConfig(RH_RF69::GFSK_Rb57_6Fd120);

    chooses a non-default modulation mode. I suggest starting with the default.
    I've never needed to setup synch words; their integral to the radio module firmware.

    Nor have I tried to use encryption.

    Does it work with all defaults in use and no encrytption?

  3. #3
    Senior Member Constantin's Avatar
    Join Date
    Nov 2012
    Location
    In the yard with a 17' Dia. Ferris Wheel
    Posts
    1,408
    Hey Steve, if you used radio head, what were the commercial licensing terms like?

  4. #4
    So basically removing the encryption fixes everything.

    I feel stupid, I should have tried that, but it's in their basic example so I assumed it would work.

    Thank you for your help Steve, I will reply on to the PM's shortly... we had an internal delay on decision making.

    Thanks, Ben

  5. #5
    Quote Originally Posted by Constantin View Post
    Hey Steve, if you used radio head, what were the commercial licensing terms like?
    I'd also be interested to know that.

  6. #6
    Senior Member
    Join Date
    Jun 2013
    Location
    So. Calif
    Posts
    2,828
    Negotiated.
    We agreed on a price for the first lot of systems that were not for resale (beta, friendly customers). IIRC, it was 50 or so units times 8 radios per device. Each device had many sensors and MCUs, and one radio per MCU. All battery powered. Fairly low cost but I shouldn't get detailed. Low cost mean it was fractionally prudent for the overall cost per device which was rather high.

    It was for a stage performance that is to grow to many venues.

    Personally, as well, I made a significant donation to Mike's account.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •