Statistics
| Revision:

root / Ports / PortsRF12.cpp

History | View | Annotate | Download (703 Bytes)

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