root / Ports / PortsRF12.cpp
History | View | Annotate | Download (703 Bytes)
| 1 | //>>> The latest version of this code can be found at https://github.com/jcw/ !!
|
|---|---|
| 2 | |
| 3 | // Ports library remote interface to the RF12 wireless radio
|
| 4 | // 2009-02-14 <jcw@equi4.com> http://opensource.org/licenses/mit-license.php
|
| 5 | // $Id: PortsRF12.cpp 7763 2011-12-11 01:28:16Z jcw $
|
| 6 | |
| 7 | #include <Ports.h> |
| 8 | #include "RF12.h" |
| 9 | |
| 10 | void RemoteHandler::setup(uint8_t id, uint8_t band, uint8_t group) {
|
| 11 | rf12_config(); |
| 12 | } |
| 13 | |
| 14 | uint8_t RemoteHandler::poll(RemoteNode& node, uint8_t send) {
|
| 15 | if (rf12_recvDone() && rf12_crc == 0 && rf12_len == sizeof node.data) |
| 16 | memcpy(&node.data, (void*) rf12_data, sizeof node.data); |
| 17 | |
| 18 | if (send && rf12_canSend()) {
|
| 19 | rf12_sendStart(RF12_HDR_ACK, &node.data, sizeof node.data);
|
| 20 | return 1; |
| 21 | } |
| 22 | |
| 23 | return 0; |
| 24 | } |