Reputation: 13
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
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
Upvotes: 1
Views: 1641
Reputation: 16324
You need to change your code to the following to get it working:
driver.setModemConfig(RH_RF22::GFSK_Rb9_6Fd45);
Upvotes: 1