-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
continued to work on serial interface0
- Loading branch information
marco
committed
Aug 21, 2016
1 parent
9331db1
commit a5d0bc0
Showing
8 changed files
with
137 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// rf69_reliable_datagram_server.pde | ||
// -*- mode: C++ -*- | ||
// Example sketch showing how to create a simple addressed, reliable messaging server | ||
// with the RHReliableDatagram class, using the RH_RF69 driver to control a RF69 radio. | ||
// It is designed to work with the other example rf69_reliable_datagram_client | ||
// Tested on Moteino with RFM69 http://lowpowerlab.com/moteino/ | ||
// Tested on miniWireless with RFM69 www.anarduino.com/miniwireless | ||
// Tested on Teensy 3.1 with RF69 on PJRC breakout board | ||
|
||
#include <RHReliableDatagram.h> | ||
#include <RH_RF69.h> | ||
#include <SPI.h> | ||
|
||
#define CLIENT_ADDRESS 1 | ||
#define SERVER_ADDRESS 2 | ||
|
||
// Singleton instance of the radio driver | ||
RH_RF69 driver; | ||
//RH_RF69 driver(15, 16); // For RF69 on PJRC breakout board with Teensy 3.1 | ||
//RH_RF69 rf69(4, 2); // For MoteinoMEGA https://lowpowerlab.com/shop/moteinomega | ||
|
||
// Class to manage message delivery and receipt, using the driver declared above | ||
RHReliableDatagram manager(driver, SERVER_ADDRESS); | ||
|
||
void setup() | ||
{ | ||
Serial.begin(9600); | ||
if (!manager.init()) | ||
Serial.println("init failed"); | ||
|
||
uint8_t key[] = { 0x05, 0x02, 0x03, 0x07, 0x05, 0x06, 0x07, 0x08, | ||
0x01, 0x02, 0x03, 0x05, 0x05, 0x06, 0x07, 0x08}; | ||
driver.setEncryptionKey(key); | ||
// Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM | ||
|
||
// If you are using a high power RF69, you *must* set a Tx power in the | ||
// range 14 to 20 like this: | ||
// driver.setTxPower(14); | ||
} | ||
|
||
uint8_t data[] = "And hello back to you"; | ||
// Dont put this on the stack: | ||
uint8_t buf[RH_RF69_MAX_MESSAGE_LEN]; | ||
|
||
void loop() | ||
{ | ||
if (manager.available()) | ||
{ | ||
// Wait for a message addressed to us from the client | ||
uint8_t len = sizeof(buf); | ||
uint8_t from; | ||
if (manager.recvfromAck(buf, &len, &from)) | ||
{ | ||
Serial.print("got request from : 0x"); | ||
Serial.print(from, HEX); | ||
Serial.print(": "); | ||
Serial.println((char*)buf); | ||
|
||
// Send a reply back to the originator client | ||
if (!manager.sendtoWait(data, sizeof(data), from)) | ||
Serial.println("sendtoWait failed"); | ||
} | ||
} | ||
} | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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