12#include <RHGenericDriver.h>
13#if (RH_PLATFORM == RH_PLATFORM_STM32F2)
14 #define HardwareSerial USARTSerial
15#elif defined (ARDUINO_ARCH_STM32F4)
16 #include <libmaple/HardwareSerial.h>
17#elif (RH_PLATFORM == RH_PLATFORM_ATTINY_MEGA)
19#elif (RH_PLATFORM == RH_PLATFORM_ARDUINO) && defined(ARDUINO_attinyxy6)
21 #define HardwareSerial UartClass
23 #include <HardwareSerial.h>
33#define RH_SERIAL_MAX_PAYLOAD_LEN 64
37#define RH_SERIAL_HEADER_LEN 4
44#ifndef RH_SERIAL_MAX_MESSAGE_LEN
45#define RH_SERIAL_MAX_MESSAGE_LEN (RH_SERIAL_MAX_PAYLOAD_LEN - RH_SERIAL_HEADER_LEN)
199 virtual bool recv(uint8_t* buf, uint8_t* len);
207 virtual bool send(
const uint8_t* data, uint8_t len);
259 uint8_t
_rxBuf[RH_SERIAL_MAX_PAYLOAD_LEN];
Abstract base class for a RadioHead driver.
Definition RHGenericDriver.h:42
Driver to send and receive unaddressed, unreliable datagrams via a serial connection.
Definition RH_Serial.h:153
uint16_t _rxFcs
Progressive FCS calc (CCITT CRC-16 covering all received data (but not stuffed DLEs),...
Definition RH_Serial.h:253
RxState _rxState
The current state of the Rx state machine.
Definition RH_Serial.h:250
virtual uint8_t maxMessageLength()
void handleRx(uint8_t ch)
bool _rxBufValid
True if the data in the Rx buffer is value and uncorrupted and complete message is available for coll...
Definition RH_Serial.h:265
uint16_t _rxRecdFcs
The received FCS at the end of the current message.
Definition RH_Serial.h:256
uint8_t _rxBufLen
Current length of data in the Rx buffer.
Definition RH_Serial.h:262
RH_Serial(HardwareSerial &serial)
virtual bool send(const uint8_t *data, uint8_t len)
virtual bool waitAvailableTimeout(uint16_t timeout, uint16_t polldelay=0)
HardwareSerial & serial()
RxState
Defines different receiver states in teh receiver state machine.
Definition RH_Serial.h:218
@ RxStateWaitFCS1
Got DLE ETX, waiting for first FCS octet.
Definition RH_Serial.h:224
@ RxStateInitialising
Before init() is called.
Definition RH_Serial.h:219
@ RxStateData
Receiving data.
Definition RH_Serial.h:222
@ RxStateDLE
Waiting for the DLE after STX.
Definition RH_Serial.h:221
@ RxStateEscape
Got a DLE while receiving data.
Definition RH_Serial.h:223
@ RxStateIdle
Waiting for an STX.
Definition RH_Serial.h:220
@ RxStateWaitFCS2
Waiting for second FCS octet.
Definition RH_Serial.h:225
uint8_t _rxBuf[RH_SERIAL_MAX_PAYLOAD_LEN]
The Rx buffer.
Definition RH_Serial.h:259
void clearRxBuf()
Empties the Rx buffer.
void appendRxBuf(uint8_t ch)
Adds a charater to the Rx buffer.
virtual bool recv(uint8_t *buf, uint8_t *len)
HardwareSerial & _serial
Reference to the HardwareSerial port we will use.
Definition RH_Serial.h:247
uint16_t _txFcs
FCS for transmitted data.
Definition RH_Serial.h:268
virtual void waitAvailable(uint16_t polldelay=0)