9 #include <RHGenericDriver.h>
13 #define RH_ASK_MAX_PAYLOAD_LEN 67
17 #define RH_ASK_HEADER_LEN 4
22 #ifndef RH_ASK_MAX_MESSAGE_LEN
23 #define RH_ASK_MAX_MESSAGE_LEN (RH_ASK_MAX_PAYLOAD_LEN - RH_ASK_HEADER_LEN - 3)
26 #if !defined(RH_ASK_RX_SAMPLES_PER_BIT)
28 #define RH_ASK_RX_SAMPLES_PER_BIT 8
29 #endif //RH_ASK_RX_SAMPLES_PER_BIT
32 #define RH_ASK_RX_RAMP_LEN 160
40 #define RH_ASK_RAMP_INC (RH_ASK_RX_RAMP_LEN/RH_ASK_RX_SAMPLES_PER_BIT)
42 #define RH_ASK_RAMP_TRANSITION RH_ASK_RX_RAMP_LEN/2
44 #define RH_ASK_RAMP_ADJUST 9
46 #define RH_ASK_RAMP_INC_RETARD (RH_ASK_RAMP_INC-RH_ASK_RAMP_ADJUST)
48 #define RH_ASK_RAMP_INC_ADVANCE (RH_ASK_RAMP_INC+RH_ASK_RAMP_ADJUST)
58 #define RH_ASK_PREAMBLE_LEN 8
278 RH_ASK(uint16_t
speed = 2000, uint8_t rxPin = 11, uint8_t txPin = 12, uint8_t pttPin = 10,
bool pttInverted =
false);
302 RH_INTERRUPT_ATTR
virtual bool recv(uint8_t* buf, uint8_t* len);
310 virtual bool send(
const uint8_t* data, uint8_t len);
336 #if (RH_PLATFORM == RH_PLATFORM_ESP8266)
338 uint32_t _timerIncrement;
343 uint8_t
timerCalc(uint16_t
speed, uint16_t max_ticks, uint16_t *nticks);
349 RH_INTERRUPT_ATTR
bool readRx();
358 RH_INTERRUPT_ATTR uint8_t
symbol_6to4(uint8_t symbol);
438 uint8_t
_txBuf[(RH_ASK_MAX_PAYLOAD_LEN * 2) + RH_ASK_PREAMBLE_LEN];
volatile uint16_t _rxGood
Count of the number of successfully transmitted messaged.
Definition: RHGenericDriver.h:292
uint8_t _txIndex
Index of the next symbol to send. Ranges from 0 to vw_tx_len.
Definition: RH_ASK.h:429
void timerSetup()
Set up the timer and its interrutps so the interrupt handler is called at the right frequency.
Definition: RH_ASK.cpp:159
volatile uint8_t _rxHeaderFrom
FROM header in the last received mesasge.
Definition: RHGenericDriver.h:265
volatile uint8_t _rxActive
Definition: RH_ASK.h:411
RH_INTERRUPT_ATTR bool readRx()
Read the rxPin in a platform dependent way, taking into account whether it is inverted or not.
Definition: RH_ASK.cpp:577
virtual RH_INTERRUPT_ATTR bool recv(uint8_t *buf, uint8_t *len)
Definition: RH_ASK.cpp:493
volatile uint8_t _rxBitCount
How many bits of message we have received. Ranges from 0 to 12.
Definition: RH_ASK.h:417
virtual bool send(const uint8_t *data, uint8_t len)
Definition: RH_ASK.cpp:513
volatile uint16_t _rxBad
Count of the number of bad messages (eg bad checksum etc) received.
Definition: RHGenericDriver.h:289
volatile uint8_t _rxCount
The incoming message expected length.
Definition: RH_ASK.h:423
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
void validateRxBuf()
Definition: RH_ASK.cpp:756
Abstract base class for a RadioHead driver.
Definition: RHGenericDriver.h:41
volatile uint8_t _rxPllRamp
Definition: RH_ASK.h:407
void transmitTimer()
The transmitter handler function, called a 8 times the bit rate.
Definition: RH_ASK.cpp:873
void setModeTx()
Definition: RH_ASK.cpp:463
bool _pttInverted
True of the sense of the pttPin is to be inverted.
Definition: RH_ASK.h:387
RH_INTERRUPT_ATTR void handleTimerInterrupt()
dont call this it used by the interrupt handler
Definition: RH_ASK.cpp:901
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
bool _rxInverted
True of the sense of the rxPin is to be inverted.
Definition: RH_ASK.h:384
virtual bool init()
Definition: RH_ASK.cpp:63
bool _promiscuous
Whether the transport is in promiscuous mode.
Definition: RHGenericDriver.h:259
volatile bool _rxBufValid
Buf is full and valid.
Definition: RH_ASK.h:394
volatile uint8_t _rxHeaderFlags
FLAGS header in the last received mesasge.
Definition: RHGenericDriver.h:271
RH_INTERRUPT_ATTR void setModeIdle()
Definition: RH_ASK.cpp:441
void writePtt(bool value)
Write the txPin in a platform dependent way, taking into account whether it is inverted or not.
Definition: RH_ASK.cpp:601
uint8_t _pttPin
The configured transmitter enable pin.
Definition: RH_ASK.h:381
volatile bool _rxLastSample
Last digital input from the rx data pin.
Definition: RH_ASK.h:397
volatile bool _rxBufFull
Buf is filled but not validated.
Definition: RH_ASK.h:391
uint8_t _txBit
Bit number of next bit to send.
Definition: RH_ASK.h:432
void writeTx(bool value)
Write the txPin in a platform dependent way.
Definition: RH_ASK.cpp:589
Driver to send and receive unaddressed, unreliable datagrams via inexpensive ASK (Amplitude Shift Key...
Definition: RH_ASK.h:268
void receiveTimer()
The receiver handler function, called a 8 times the bit rate.
Definition: RH_ASK.cpp:784
uint8_t _txBuf[(RH_ASK_MAX_PAYLOAD_LEN *2)+RH_ASK_PREAMBLE_LEN]
The transmitter buffer in symbols not data octets.
Definition: RH_ASK.h:438
RH_ASK(uint16_t speed=2000, uint8_t rxPin=11, uint8_t txPin=12, uint8_t pttPin=10, bool pttInverted=false)
Definition: RH_ASK.cpp:47
uint8_t _txHeaderId
ID header to send in all messages.
Definition: RHGenericDriver.h:280
volatile uint8_t _rxBufLen
The incoming message buffer length received so far.
Definition: RH_ASK.h:426
uint8_t _txHeaderTo
TO header to send in all messages.
Definition: RHGenericDriver.h:274
uint8_t timerCalc(uint16_t speed, uint16_t max_ticks, uint16_t *nticks)
Helper function for calculating timer ticks.
Definition: RH_ASK.cpp:107
virtual bool init()
Definition: RHGenericDriver.cpp:23
RH_INTERRUPT_ATTR uint8_t symbol_6to4(uint8_t symbol)
Translates a 6 bit symbol to its 4 bit plaintext equivalent.
Definition: RH_ASK.cpp:737
uint8_t _txHeaderFlags
FLAGS header to send in all messages.
Definition: RHGenericDriver.h:283
virtual bool available()
Definition: RH_ASK.cpp:480
uint8_t _txPin
The configure transmitter pin.
Definition: RH_ASK.h:378
volatile uint8_t _rxHeaderId
ID header in the last received mesasge.
Definition: RHGenericDriver.h:268
volatile uint8_t _rxIntegrator
Definition: RH_ASK.h:401
uint8_t _rxBuf[RH_ASK_MAX_PAYLOAD_LEN]
The incoming message buffer.
Definition: RH_ASK.h:420
uint8_t _rxPin
The configure receiver pin.
Definition: RH_ASK.h:375
@ RHModeIdle
Transport is idle.
Definition: RHGenericDriver.h:52
virtual uint8_t maxMessageLength()
Definition: RH_ASK.cpp:616
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
uint16_t speed()
Definition: RH_ASK.h:334
RH_INTERRUPT_ATTR void setModeRx()
Definition: RH_ASK.cpp:452
uint8_t _txBufLen
Number of symbols in _txBuf to be sent;.
Definition: RH_ASK.h:441
volatile uint16_t _rxBits
Last 12 bits received, so we can look for the start symbol.
Definition: RH_ASK.h:414
@ RHModeRx
Transport is in the process of receiving a message.
Definition: RHGenericDriver.h:54
uint8_t _txSample
Sample number for the transmitter. Runs 0 to 7 during one bit interval.
Definition: RH_ASK.h:435
virtual bool waitCAD()
Definition: RHGenericDriver.cpp:72
uint16_t _speed
Configure bit rate in bits per second.
Definition: RH_ASK.h:372