LowPowerLab Forum

Hardware support => Moteino => Topic started by: Lensdigital on August 23, 2013, 11:36:53 AM

Title: Sending and recieving from same sketch
Post by: Lensdigital on August 23, 2013, 11:36:53 AM
This is probably a stupid question, but is it possible to send and receive from same sketch?  I have one device receiving data from Moteino sensor, but I also want it to send some data to another Moteino (for debugging, as I can't access serial port). From what I understand AVR activates receive function via Interrupt as soon as it sees signal incoming. But when I start sending wouldn't it trigger interrupt and switch chip to the receiver mode thus killing transmission? I'm confused :)
Title: Re: Sending and recieving from same sketch
Post by: Felix on August 23, 2013, 01:39:23 PM
You can always send/receive. Just not at the same time.
Think of ACKs, they are transmitted packets on receiver nodes.

The transceivers can switch seamlessly between sending and receiving.
To "listen" you have to enable RX by polling radio.receiveDone().
To send you simply call radio.send() to shoot and forget, or radio.sendWithRetry() if you want it to try hard sending a message - see the header file for all options on those functions.

Hope this answers your question.
Title: Re: Sending and recieving from same sketch
Post by: Lensdigital on August 23, 2013, 02:35:50 PM
Thanks Felix! This makes sense! :)