RF24G 0.9
Simple Abstraction Layer for the nRF24L01
Loading...
Searching...
No Matches
rf24g.h
Go to the documentation of this file.
1
16#ifndef __RF24G_H__
17#define __RF24G_H__
18
19#if defined(ARDUINO_ARCH_NRF52) || defined(ARDUINO_ARCH_NRF52840)
20#include <nrf_to_nrf.h>
21#else
22#include "RF24.h"
23#endif
24
25#define PACKET_CNTER 32
26
27#define MAX_NODES 7
28
29#define MAX_PAYLOAD_SIZE 32
30
31#define BASE_ADDRESS 0xDEADBEEF00LL
32
33
34#define TIMEOUT 5
35
36class packet {
37 public:
38 packet();
45private:
46 uint8_t address;
47 uint8_t cnt;
48 byte buffer[MAX_PAYLOAD_SIZE-2];
49public:
64 void setAddress(uint8_t _address);
65
73 uint8_t getAddress() const;
74
84 uint8_t getCnt() const;
85
94 void setCnt(uint8_t _cnt);
95
116 bool addPayload(const void * data, const uint8_t size);
117
141 bool readPayload(void * data, const uint8_t size);
142};
143
144
145
146
147class RF24_G {
153private:
154 uint8_t myAddress;
155 uint8_t TXpacketCounters[MAX_NODES];
156 uint8_t RXpacketCounters[MAX_NODES];
157 #if defined NRF52_RADIO_LIBRARY
158
159 #else
160 RF24 radio{8,9};
161 #endif
162public:
176 RF24_G();
177
185 RF24_G(uint8_t address);
186
198 RF24_G(uint8_t address, uint8_t _cepin, uint8_t _cspin);
199
207 bool available();
208
228 bool write(packet* _packet);
245 bool read(packet* _packet);
253 bool setChannel(uint8_t channel);
254
255private:
259 void setup(uint8_t address, uint8_t _cepin, uint8_t _cspin);
260
264 packet receive;
265
266};
267
311 #endif
Definition rf24g.h:147
bool read(packet *_packet)
Definition rf24g.cpp:150
bool write(packet *_packet)
Definition rf24g.cpp:122
RF24_G()
Definition rf24g.cpp:60
bool available()
Definition rf24g.cpp:117
bool setChannel(uint8_t channel)
Definition rf24g.cpp:165
Definition rf24g.h:36
uint8_t getAddress() const
Definition rf24g.cpp:24
void setCnt(uint8_t _cnt)
Definition rf24g.cpp:32
uint8_t getCnt() const
Definition rf24g.cpp:28
bool readPayload(void *data, const uint8_t size)
Definition rf24g.cpp:48
void setAddress(uint8_t _address)
Definition rf24g.cpp:20
bool addPayload(const void *data, const uint8_t size)
Definition rf24g.cpp:36