[RF69] Fixed typos in examples
This commit is contained in:
parent
3ad3e0cd61
commit
6e31c7b9be
6 changed files with 18 additions and 19 deletions
|
@ -35,7 +35,7 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// set node address
|
// set node address
|
||||||
// NOTE: calling this method will autmatically enable
|
// NOTE: calling this method will automatically enable
|
||||||
// address filtering (node address only)
|
// address filtering (node address only)
|
||||||
Serial.print(F("[RF69] Setting node address ... "));
|
Serial.print(F("[RF69] Setting node address ... "));
|
||||||
state = rf.setNodeAddress(0x02);
|
state = rf.setNodeAddress(0x02);
|
||||||
|
|
|
@ -14,7 +14,7 @@ RF69 rf = RadioShield.ModuleA;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
// initialize RF69 with default settings
|
// initialize RF69 with default settings
|
||||||
Serial.print(F("[RF69] Initializing ... "));
|
Serial.print(F("[RF69] Initializing ... "));
|
||||||
// carrier frequency: 434.0 MHz
|
// carrier frequency: 434.0 MHz
|
||||||
|
@ -32,10 +32,10 @@ void setup() {
|
||||||
while (true);
|
while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the function that will be called
|
// set the function that will be called
|
||||||
// when new packet is received
|
// when new packet is received
|
||||||
rf.setDio0Action(setFlag);
|
rf.setDio0Action(setFlag);
|
||||||
|
|
||||||
// start listening for packets
|
// start listening for packets
|
||||||
Serial.print(F("[RF69] Starting to listen ... "));
|
Serial.print(F("[RF69] Starting to listen ... "));
|
||||||
state = rf.startReceive();
|
state = rf.startReceive();
|
||||||
|
@ -54,7 +54,6 @@ void setup() {
|
||||||
// rf.sleep()
|
// rf.sleep()
|
||||||
// rf.transmit();
|
// rf.transmit();
|
||||||
// rf.receive();
|
// rf.receive();
|
||||||
// rf.scanChannel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// flag to indicate that a packet was received
|
// flag to indicate that a packet was received
|
||||||
|
@ -86,23 +85,23 @@ void loop() {
|
||||||
|
|
||||||
// reset flag
|
// reset flag
|
||||||
receivedFlag = false;
|
receivedFlag = false;
|
||||||
|
|
||||||
// you can read received data as an Arduino String
|
// you can read received data as an Arduino String
|
||||||
String str;
|
String str;
|
||||||
int state = rf.readData(str);
|
int state = rf.readData(str);
|
||||||
|
|
||||||
// you can also read received data as byte array
|
// you can also read received data as byte array
|
||||||
/*
|
/*
|
||||||
byte byteArr[8];
|
byte byteArr[8];
|
||||||
int state = lora.receive(byteArr, 8);
|
int state = lora.receive(byteArr, 8);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
// packet was successfully received
|
// packet was successfully received
|
||||||
Serial.println("[RF69] Received packet!");
|
Serial.println(F("[RF69] Received packet!"));
|
||||||
|
|
||||||
// print data of the packet
|
// print data of the packet
|
||||||
Serial.print("[RF69] Data:\t\t\t");
|
Serial.print(F("[RF69] Data:\t\t\t"));
|
||||||
Serial.println(str);
|
Serial.println(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// up to 8 bytes can be set as sync word
|
// up to 8 bytes can be set as sync word
|
||||||
// NOTE: sync word must not conatin any zero bytes
|
// NOTE: sync word must not contain any zero bytes
|
||||||
// set sync word to 0x0123456789ABCDEF
|
// set sync word to 0x0123456789ABCDEF
|
||||||
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
|
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
|
||||||
if (rf1.setSyncWord(syncWord, 8) == ERR_INVALID_SYNC_WORD) {
|
if (rf1.setSyncWord(syncWord, 8) == ERR_INVALID_SYNC_WORD) {
|
||||||
|
|
|
@ -45,11 +45,11 @@ void loop() {
|
||||||
|
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
// the packet was successfully transmitted
|
// the packet was successfully transmitted
|
||||||
Serial.println(" success!");
|
Serial.println(F(" success!"));
|
||||||
|
|
||||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||||
// the supplied packet was longer than 64 bytes
|
// the supplied packet was longer than 64 bytes
|
||||||
Serial.println(" too long!");
|
Serial.println(F(" too long!"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,11 +62,11 @@ void loop() {
|
||||||
|
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
// the packet was successfully transmitted
|
// the packet was successfully transmitted
|
||||||
Serial.println(" success!");
|
Serial.println(F(" success!"));
|
||||||
|
|
||||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||||
// the supplied packet was longer than 256 bytes
|
// the supplied packet was longer than 256 bytes
|
||||||
Serial.println(" too long!");
|
Serial.println(F(" too long!"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// set broadcast address
|
// set broadcast address
|
||||||
// NOTE: calling this method will autmatically enable
|
// NOTE: calling this method will automatically enable
|
||||||
// address filtering (node or broadcast address)
|
// address filtering (node or broadcast address)
|
||||||
Serial.print(F("[RF69] Setting broadcast address ... "));
|
Serial.print(F("[RF69] Setting broadcast address ... "));
|
||||||
state = rf.setBroadcastAddress(0xFF);
|
state = rf.setBroadcastAddress(0xFF);
|
||||||
|
@ -101,11 +101,11 @@ void loop() {
|
||||||
|
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
// the packet was successfully transmitted
|
// the packet was successfully transmitted
|
||||||
Serial.println(" success!");
|
Serial.println(F(" success!"));
|
||||||
|
|
||||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||||
// the supplied packet was longer than 256 bytes
|
// the supplied packet was longer than 256 bytes
|
||||||
Serial.println(" too long!");
|
Serial.println(F(" too long!"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue