forked from mannkind/rf24node_msgproto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RF24NetworkWrapper.cpp
33 lines (26 loc) · 1.12 KB
/
RF24NetworkWrapper.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "RF24NetworkWrapper.h"
RF24NetworkWrapper::RF24NetworkWrapper(uint8_t _channel, uint16_t _node_address, rf24_pa_dbm_e _palevel, rf24_datarate_e _datarate) :
channel(_channel), node_address(_node_address), palevel(_palevel), datarate(_datarate),
radio(RPI_V2_GPIO_P1_22, BCM2835_SPI_CS0, BCM2835_SPI_SPEED_8MHZ), network(this->radio) { }
void RF24NetworkWrapper::begin(void) {
this->radio.begin();
this->network.begin(this->channel, this->node_address);
this->radio.setDataRate(this->datarate);
this->radio.setPALevel(this->palevel);
this->radio.printDetails();
}
void RF24NetworkWrapper::update(void) {
this->network.update();
}
bool RF24NetworkWrapper::available(void) {
return this->network.available();
}
void RF24NetworkWrapper::peek(RF24NetworkHeader& header) {
this->network.peek(header);
}
size_t RF24NetworkWrapper::read(RF24NetworkHeader& header, void* message, size_t maxlen) {
return this->network.read(header, message, maxlen);
}
bool RF24NetworkWrapper::write(RF24NetworkHeader& header,const void* message, size_t len) {
return this->network.write(header, message, len);
}