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
87 virtual bool recv(uint8_t* buf, uint8_t* len) = 0;
100 virtual bool send(
const uint8_t* data, uint8_t len) = 0;
193 virtual void setHeaderFlags(uint8_t set, uint8_t clear = RH_FLAGS_APPLICATION_SPECIFIC);
235 virtual bool sleep();
242 static void printBuffer(
const char* prompt,
const uint8_t* buf, uint8_t len);
249 virtual uint16_t
rxBad();
254 virtual uint16_t
rxGood();
259 virtual uint16_t
txGood();
Abstract base class for a RadioHead driver.
Definition RHGenericDriver.h:42
virtual uint16_t rxBad()
Definition RHGenericDriver.cpp:200
volatile bool _cad
Channel activity detected.
Definition RHGenericDriver.h:309
virtual uint8_t headerFlags()
Definition RHGenericDriver.cpp:155
virtual void setHeaderTo(uint8_t to)
Definition RHGenericDriver.cpp:119
virtual uint8_t maxMessageLength()=0
virtual void setPromiscuous(bool promiscuous)
Definition RHGenericDriver.cpp:109
uint8_t _txHeaderFrom
FROM header to send in all messages.
Definition RHGenericDriver.h:288
bool _promiscuous
Whether the transport is in promiscuous mode.
Definition RHGenericDriver.h:270
virtual bool available()=0
volatile uint8_t _rxHeaderId
ID header in the last received mesasge.
Definition RHGenericDriver.h:279
volatile RHMode _mode
The current transport operating mode.
Definition RHGenericDriver.h:264
volatile uint16_t _rxBad
Count of the number of bad messages (eg bad checksum etc) received.
Definition RHGenericDriver.h:300
virtual bool init()
Definition RHGenericDriver.cpp:23
unsigned int _cad_timeout
Channel activity timeout in ms.
Definition RHGenericDriver.h:312
void setCADTimeout(unsigned long cad_timeout)
Definition RHGenericDriver.cpp:215
virtual void setHeaderFrom(uint8_t from)
Definition RHGenericDriver.cpp:124
virtual void setHeaderId(uint8_t id)
Definition RHGenericDriver.cpp:129
virtual bool send(const uint8_t *data, uint8_t len)=0
virtual bool recv(uint8_t *buf, uint8_t *len)=0
virtual void setThisAddress(uint8_t thisAddress)
Definition RHGenericDriver.cpp:114
volatile uint16_t _txGood
Count of the number of bad messages (correct checksum etc) received.
Definition RHGenericDriver.h:306
virtual uint16_t rxGood()
Definition RHGenericDriver.cpp:205
volatile uint8_t _rxHeaderFlags
FLAGS header in the last received mesasge.
Definition RHGenericDriver.h:282
static void printBuffer(const char *prompt, const uint8_t *buf, uint8_t len)
Definition RHGenericDriver.cpp:181
virtual uint16_t txGood()
Definition RHGenericDriver.cpp:210
uint8_t _thisAddress
This node id.
Definition RHGenericDriver.h:267
virtual uint8_t headerTo()
Definition RHGenericDriver.cpp:140
volatile uint8_t _rxHeaderFrom
FROM header in the last received mesasge.
Definition RHGenericDriver.h:276
virtual bool waitPacketSent()
Definition RHGenericDriver.cpp:58
uint8_t _txHeaderTo
TO header to send in all messages.
Definition RHGenericDriver.h:285
virtual void waitAvailable(uint16_t polldelay=0)
Definition RHGenericDriver.cpp:29
RHMode
Defines different operating modes for the transport hardware.
Definition RHGenericDriver.h:49
@ RHModeIdle
Transport is idle.
Definition RHGenericDriver.h:52
@ RHModeTx
Transport is in the process of transmitting a message.
Definition RHGenericDriver.h:53
@ RHModeCad
Transport is in the process of detecting channel activity (if supported)
Definition RHGenericDriver.h:55
@ RHModeRx
Transport is in the process of receiving a message.
Definition RHGenericDriver.h:54
@ RHModeSleep
Transport hardware is in low power sleep mode (if supported)
Definition RHGenericDriver.h:51
@ RHModeInitialising
Transport is initialising. Initial default value until init() is called..
Definition RHGenericDriver.h:50
virtual RHMode mode()
Definition RHGenericDriver.cpp:165
virtual uint8_t headerId()
Definition RHGenericDriver.cpp:150
virtual uint8_t headerFrom()
Definition RHGenericDriver.cpp:145
virtual bool waitAvailableTimeout(uint16_t timeout, uint16_t polldelay=0)
Definition RHGenericDriver.cpp:42
virtual bool sleep()
Definition RHGenericDriver.cpp:175
volatile int16_t _lastRssi
The value of the last received RSSI value, in some transport specific units.
Definition RHGenericDriver.h:297
virtual void setMode(RHMode mode)
Sets the operating mode of the transport.
Definition RHGenericDriver.cpp:170
virtual int16_t lastRssi()
Definition RHGenericDriver.cpp:160
RHGenericDriver()
Constructor.
Definition RHGenericDriver.cpp:8
volatile uint16_t _rxGood
Count of the number of successfully transmitted messaged.
Definition RHGenericDriver.h:303
uint8_t _txHeaderFlags
FLAGS header to send in all messages.
Definition RHGenericDriver.h:294
volatile uint8_t _rxHeaderTo
TO header in the last received mesasge.
Definition RHGenericDriver.h:273
virtual bool waitCAD()
Definition RHGenericDriver.cpp:78
virtual void setHeaderFlags(uint8_t set, uint8_t clear=RH_FLAGS_APPLICATION_SPECIFIC)
Definition RHGenericDriver.cpp:134
virtual ~RHGenericDriver()
Generic destructor to prevent warnings when objects are dynamically allocated.
Definition RHGenericDriver.h:62
uint8_t _txHeaderId
ID header to send in all messages.
Definition RHGenericDriver.h:291
virtual bool isChannelActive()
Definition RHGenericDriver.cpp:104