Hello everyone,
to replace an existing serial cable connection, I purchases two JeeNodes.
Before ordering, I studied the docs and examples and found the "rf12Serial.pde" demo sketch. "That's really easy", I thought, and I placed my order. But sometimes reality differs from what you wish. What I mean is, that this does not work for my purpose.
My application periodically sends strings to the clients. The strings are teminated by CR & LF (yes, Windows). That worked fine via cable since some years. But how to realize this by using two JeeNodes?
It took me a whole day (this is my first contact with Arduino), but I figured it out by combing several examples. Sender: Receives a string from UART and sends it to radio.
#include
byte Data [255]; int Counter = -1; byte EOT = 10;
void setup() { Serial.begin(9600); rf12initialize(1, RF12868MHZ, 99); }
void loop() { if (Serial.available()) { Data++Counter; if (DataCounter { rf12sendStart(0, Data, ++Counter); Counter = -1; } } }
Receiver: Receives a string from radio and sends it to UART:
#include
Port leds (1);
static void receiveLed (byte on) { leds.mode2(OUTPUT); leds.digiWrite2(!on); }
void setup() { Serial.begin(9600); Serial.println("\nReceiver"); rf12initialize(2, RF12868MHZ, 99); }
void loop() { if (rf12recvDone() && rf12crc == 0) { receiveLed(1); for (byte i = 0; i < rf12len; i++) { Serial.print(rf12datai; } receiveLed(0); } }
Now it's up to you to laugh about the stupid code, or help me to improve it. Is it really necessary to deal with every single byte?
In my opinion, it would be nice to have the same methods in "RF12" as in the "Serial" class. Not that easy, I know, but are there any plannings?
Have a nice day soldero
