Created
March 16, 2019 15:57
-
-
Save connected/815e20cf0eff15efd16192166251b191 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <RF22ReliableDatagram.h> | |
#include <RF22.h> | |
#include <SPI.h> | |
#define CLIENT_ADDRESS 1 | |
#define SERVER_ADDRESS 2 | |
RF22ReliableDatagram rf22(CLIENT_ADDRESS); | |
void setup() { | |
Serial.begin(9600); | |
if (!rf22.init()) { | |
Serial.println("RF22 init failed"); | |
} | |
} | |
// uint8_t data[] = "Hello World!"; | |
uint8_t buf[RF22_MAX_MESSAGE_LEN]; | |
uint8_t data[] = { | |
255, 0, 0, | |
255, 0, 0, | |
255, 0, 0, | |
0, 255, 0, | |
0, 255, 0, | |
0, 255, 0, | |
0, 0, 255, | |
0, 0, 255, | |
0, 0, 255, | |
255, 0, 0, | |
255, 0, 0, | |
255, 0, 0, | |
0, 255, 0, | |
0, 255, 0, | |
0, 255, 0, | |
255, 255, 255 | |
}; | |
void loop() { | |
Serial.println("Sending to rf22_datagram_server"); | |
if (!rf22.sendtoWait(data, sizeof(data), SERVER_ADDRESS)) { | |
Serial.println("sendtoWait failed"); | |
} else { | |
// uint8_t len = sizeof(buf); | |
// uint8_t from; | |
// if (rf22.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_datagram_server running?"); | |
// } | |
} | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment