1

Now, I'm working on RH-RF22 library which i need to change frequency and modulation

#include <RHReliableDatagram.h>
#include <RH_RF22.h>
#include <SPI.h>
#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2
// Singleton instance of the radio driver

RH_RF22 driver;

// Class to manage message delivery and receipt, using the driver declared above
RHReliableDatagram manager(driver, CLIENT_ADDRESS);
void setup() 
{
  driver.setFrequency(433,0.5);
  driver.setModemConfig(ModemConfigChoice GFSK_Rb9_6Fd45);
  Serial.begin(9600);
  if (!manager.init())
    Serial.println("init failed");
  // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
}
uint8_t data[] = "Hello World!";
// Dont put this on the stack:
uint8_t buf[RH_RF22_MAX_MESSAGE_LEN];
void loop()
{
  Serial.println("Sending to rf22_reliable_datagram_server");

  // Send a message to manager_server
  if (manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
  {
    // Now wait for a reply from the server
    uint8_t len = sizeof(buf);
    uint8_t from;   
    if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
    {
      Serial.print("got reply from : 0x");
      Serial.print(from, HEX);
      Serial.print(": ");
      Serial.println((char*)buf);
    }
    else
    {
      Serial.println("No reply, is rf22_reliable_datagram_server running?");
    }
  }
  else
    Serial.println("sendtoWait failed");
  delay(500);
}

There is an error about enum on the this line

driver.setModemConfig(ModemConfigChoice GFSK_Rb9_6Fd45);

but

driver.setFrequency(433,0.5);

is ok. Here is the library link

RH_RF22.cpp

RH_RF22.h

as you could see on the link RH_RF22.hcontains typedef enum ModemConfigChoice which I want to use it to assign to

setModemConfig() 

function. You can see the

setModemConfig() 

function in RH_RF22.cpp

Note: The error from arduino ide look like this

rfm23bp.ino: In function 'void setup()':
rfm23bp:15: error: 'ModemConfigChoice' was not declared in this scope
6
  • are you just missing the :: between ModemConfigChoice::GFSK_Rb9_6Fd45? Commented Oct 26, 2015 at 9:37
  • Thank you. but there is a new error when edit as your advice. rfm23bp.ino: In function 'void setup()': rfm23bp:15: error: 'ModemConfigChoice' has not been declared @m.s. Commented Oct 26, 2015 at 9:38
  • it should be RH_RF22::ModemConfigChoice::GFSK_Rb9_6Fd45 because that enum is defined inside a class`. Commented Oct 26, 2015 at 9:39
  • As you can see I already initialize RH_RF22 driver; and still have an error from your second advice. rfm23bp.ino: In function 'void setup()': rfm23bp:15: error: 'RH_RF22::ModemConfigChoice' is not a class or namespace @m.s. Commented Oct 26, 2015 at 9:41
  • You are probably then not compiling in C++11 (or up), so you need RH_RF22::GFSK_Rb9_6Fd45. Commented Oct 26, 2015 at 9:47

1 Answer 1

1

You need to change your code to the following to get it working:

driver.setModemConfig(RH_RF22::GFSK_Rb9_6Fd45);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.