6 #ifndef RHGenericDriver_h
7 #define RHGenericDriver_h
13 #define RH_FLAGS_RESERVED 0xf0
14 #define RH_FLAGS_APPLICATION_SPECIFIC 0x0f
15 #define RH_FLAGS_NONE 0
18 #define RH_CAD_DEFAULT_TIMEOUT 10000
84 virtual bool recv(uint8_t* buf, uint8_t* len) = 0;
97 virtual bool send(
const uint8_t* data, uint8_t len) = 0;
182 virtual void setHeaderFlags(uint8_t set, uint8_t clear = RH_FLAGS_APPLICATION_SPECIFIC);
224 virtual bool sleep();
231 static void printBuffer(
const char* prompt,
const uint8_t* buf, uint8_t len);
238 virtual uint16_t
rxBad();
243 virtual uint16_t
rxGood();
248 virtual uint16_t
txGood();
volatile uint16_t _rxGood
Count of the number of successfully transmitted messaged.
Definition: RHGenericDriver.h:292
void setCADTimeout(unsigned long cad_timeout)
Definition: RHGenericDriver.cpp:209
virtual uint8_t maxMessageLength()=0
@ RHModeCad
Transport is in the process of detecting channel activity (if supported)
Definition: RHGenericDriver.h:55
virtual bool available()=0
volatile uint8_t _rxHeaderFrom
FROM header in the last received mesasge.
Definition: RHGenericDriver.h:265
virtual bool waitAvailableTimeout(uint16_t timeout)
Definition: RHGenericDriver.cpp:38
virtual uint16_t txGood()
Definition: RHGenericDriver.cpp:204
volatile int16_t _lastRssi
The value of the last received RSSI value, in some transport specific units.
Definition: RHGenericDriver.h:286
volatile uint16_t _rxBad
Count of the number of bad messages (eg bad checksum etc) received.
Definition: RHGenericDriver.h:289
virtual uint8_t headerFlags()
Definition: RHGenericDriver.cpp:149
virtual bool isChannelActive()
Definition: RHGenericDriver.cpp:98
volatile uint8_t _rxHeaderTo
TO header in the last received mesasge.
Definition: RHGenericDriver.h:262
uint8_t _txHeaderFrom
FROM header to send in all messages.
Definition: RHGenericDriver.h:277
Abstract base class for a RadioHead driver.
Definition: RHGenericDriver.h:41
virtual uint8_t headerId()
Definition: RHGenericDriver.cpp:144
RHMode
Defines different operating modes for the transport hardware.
Definition: RHGenericDriver.h:48
uint8_t _thisAddress
This node id.
Definition: RHGenericDriver.h:256
volatile uint16_t _txGood
Count of the number of bad messages (correct checksum etc) received.
Definition: RHGenericDriver.h:295
virtual void setPromiscuous(bool promiscuous)
Definition: RHGenericDriver.cpp:103
virtual uint8_t headerFrom()
Definition: RHGenericDriver.cpp:139
bool _promiscuous
Whether the transport is in promiscuous mode.
Definition: RHGenericDriver.h:259
virtual void setThisAddress(uint8_t thisAddress)
Definition: RHGenericDriver.cpp:108
virtual void setHeaderId(uint8_t id)
Definition: RHGenericDriver.cpp:123
volatile uint8_t _rxHeaderFlags
FLAGS header in the last received mesasge.
Definition: RHGenericDriver.h:271
virtual int16_t lastRssi()
Definition: RHGenericDriver.cpp:154
virtual bool sleep()
Definition: RHGenericDriver.cpp:169
virtual uint16_t rxGood()
Definition: RHGenericDriver.cpp:199
virtual bool recv(uint8_t *buf, uint8_t *len)=0
virtual bool send(const uint8_t *data, uint8_t len)=0
@ RHModeSleep
Transport hardware is in low power sleep mode (if supported)
Definition: RHGenericDriver.h:51
virtual uint16_t rxBad()
Definition: RHGenericDriver.cpp:194
volatile bool _cad
Channel activity detected.
Definition: RHGenericDriver.h:298
RHGenericDriver()
Constructor.
Definition: RHGenericDriver.cpp:8
virtual void setHeaderTo(uint8_t to)
Definition: RHGenericDriver.cpp:113
uint8_t _txHeaderId
ID header to send in all messages.
Definition: RHGenericDriver.h:280
uint8_t _txHeaderTo
TO header to send in all messages.
Definition: RHGenericDriver.h:274
virtual void setHeaderFrom(uint8_t from)
Definition: RHGenericDriver.cpp:118
virtual bool init()
Definition: RHGenericDriver.cpp:23
uint8_t _txHeaderFlags
FLAGS header to send in all messages.
Definition: RHGenericDriver.h:283
virtual uint8_t headerTo()
Definition: RHGenericDriver.cpp:134
static void printBuffer(const char *prompt, const uint8_t *buf, uint8_t len)
Definition: RHGenericDriver.cpp:175
volatile uint8_t _rxHeaderId
ID header in the last received mesasge.
Definition: RHGenericDriver.h:268
virtual void setHeaderFlags(uint8_t set, uint8_t clear=RH_FLAGS_APPLICATION_SPECIFIC)
Definition: RHGenericDriver.cpp:128
@ RHModeIdle
Transport is idle.
Definition: RHGenericDriver.h:52
unsigned int _cad_timeout
Channel activity timeout in ms.
Definition: RHGenericDriver.h:301
virtual bool waitPacketSent()
Definition: RHGenericDriver.cpp:52
volatile RHMode _mode
The current transport operating mode.
Definition: RHGenericDriver.h:253
@ RHModeTx
Transport is in the process of transmitting a message.
Definition: RHGenericDriver.h:53
@ RHModeInitialising
Transport is initialising. Initial default value until init() is called..
Definition: RHGenericDriver.h:50
virtual RHMode mode()
Definition: RHGenericDriver.cpp:159
@ RHModeRx
Transport is in the process of receiving a message.
Definition: RHGenericDriver.h:54
virtual void setMode(RHMode mode)
Sets the operating mode of the transport.
Definition: RHGenericDriver.cpp:164
virtual void waitAvailable()
Definition: RHGenericDriver.cpp:29
virtual bool waitCAD()
Definition: RHGenericDriver.cpp:72