BayEOS-Arduino  1.8.0_0.0.4
BayRF24.cpp
1 #include "BayRF24.h"
2 
3 BayRF24::BayRF24(uint8_t _cepin, uint8_t _cspin, uint8_t powerdown = 1) :
4  RF24(_cepin, _cspin) {
5  _powerdown = powerdown;
6 }
7 
8 
9 uint8_t BayRF24::sendPayload(void) {
10  if (_powerdown)
11  powerUp();
12  else
13  stopListening();
14  openWritingPipe (_pipe);
15  uint8_t res;
16 
18  uint8_t curr_pa = 0;
19  while (!res && curr_pa < 4) {
20  setPALevel((rf24_pa_dbm_e) curr_pa);
22  curr_pa++;
23  }
24 
25  if (_powerdown)
26  powerDown();
27  else {
28  txStandBy();
29  startListening();
30  }
31 
32  return !res;
33 }
34 
35 void BayRF24::init(uint64_t address, uint8_t c = 0x71, rf24_pa_dbm_e pa_level =
36  RF24_PA_HIGH, rf24_datarate_e rate = RF24_250KBPS) {
37  _pipe = address;
38  RF24::begin();
39  setChannel(c);
40  setPayloadSize(32);
41  enableDynamicPayloads();
42  setCRCLength (RF24_CRC_16);
43  setDataRate(rate);
44  setPALevel(pa_level);
45  _pa_level = pa_level;
46  setRetries(15, 15);
47  setAutoAck(true);
48  if (_powerdown)
49  powerDown();
50 }
51 
52 bool BayRF24::i_available(uint8_t* pipe_nr) {
53  return RF24::available(pipe_nr);
54 }
bool available(void)
Definition: RF24.cpp:1053
const uint8_t * getPayload(void) const
Definition: BayEOS.cpp:399
bool write(const void *buf, uint8_t len)
Definition: RF24.cpp:824
uint8_t getPacketLength(void) const
Definition: BayEOS.cpp:395
rf24_datarate_e
Definition: iBoardRF24.h:33
Definition: RF24.h:53
uint8_t sendPayload(void)
Definition: BayRF24.cpp:9
rf24_pa_dbm_e
Definition: iBoardRF24.h:26
bool begin(void)
Definition: RF24.cpp:569