RadioHead
RH_ASK.h
1 // RH_ASK.h
2 //
3 // Copyright (C) 2014 Mike McCauley
4 // $Id: RH_ASK.h,v 1.21 2020/01/07 23:35:02 mikem Exp mikem $
5 
6 #ifndef RH_ASK_h
7 #define RH_ASK_h
8 
9 #include <RHGenericDriver.h>
10 
11 // Maximum message length (including the headers, byte count and FCS) we are willing to support
12 // This is pretty arbitrary
13 #define RH_ASK_MAX_PAYLOAD_LEN 67
14 
15 // The length of the headers we add (To, From, Id, Flags)
16 // The headers are inside the payload and are therefore protected by the FCS
17 #define RH_ASK_HEADER_LEN 4
18 
19 // This is the maximum message length that can be supported by this library.
20 // Can be pre-defined to a smaller size (to save SRAM) prior to including this header
21 // Here we allow for 1 byte message length, 4 bytes headers, user data and 2 bytes of FCS
22 #ifndef RH_ASK_MAX_MESSAGE_LEN
23  #define RH_ASK_MAX_MESSAGE_LEN (RH_ASK_MAX_PAYLOAD_LEN - RH_ASK_HEADER_LEN - 3)
24 #endif
25 
26 #if !defined(RH_ASK_RX_SAMPLES_PER_BIT)
27 /// Number of samples per bit
28  #define RH_ASK_RX_SAMPLES_PER_BIT 8
29 #endif //RH_ASK_RX_SAMPLES_PER_BIT
30 
31 /// The size of the receiver ramp. Ramp wraps modulo this number
32 #define RH_ASK_RX_RAMP_LEN 160
33 
34 // Ramp adjustment parameters
35 // Standard is if a transition occurs before RH_ASK_RAMP_TRANSITION (80) in the ramp,
36 // the ramp is retarded by adding RH_ASK_RAMP_INC_RETARD (11)
37 // else by adding RH_ASK_RAMP_INC_ADVANCE (29)
38 // If there is no transition it is adjusted by RH_ASK_RAMP_INC (20)
39 /// Internal ramp adjustment parameter
40 #define RH_ASK_RAMP_INC (RH_ASK_RX_RAMP_LEN/RH_ASK_RX_SAMPLES_PER_BIT)
41 /// Internal ramp adjustment parameter
42 #define RH_ASK_RAMP_TRANSITION RH_ASK_RX_RAMP_LEN/2
43 /// Internal ramp adjustment parameter
44 #define RH_ASK_RAMP_ADJUST 9
45 /// Internal ramp adjustment parameter
46 #define RH_ASK_RAMP_INC_RETARD (RH_ASK_RAMP_INC-RH_ASK_RAMP_ADJUST)
47 /// Internal ramp adjustment parameter
48 #define RH_ASK_RAMP_INC_ADVANCE (RH_ASK_RAMP_INC+RH_ASK_RAMP_ADJUST)
49 
50 /// Outgoing message bits grouped as 6-bit words
51 /// 36 alternating 1/0 bits, followed by 12 bits of start symbol (together called the preamble)
52 /// Followed immediately by the 4-6 bit encoded byte count,
53 /// message buffer and 2 byte FCS
54 /// Each byte from the byte count on is translated into 2x6-bit words
55 /// Caution, each symbol is transmitted LSBit first,
56 /// but each byte is transmitted high nybble first
57 /// This is the number of 6 bit nibbles in the preamble
58 #define RH_ASK_PREAMBLE_LEN 8
59 
60 /////////////////////////////////////////////////////////////////////
61 /// \class RH_ASK RH_ASK.h <RH_ASK.h>
62 /// \brief Driver to send and receive unaddressed, unreliable datagrams via inexpensive ASK (Amplitude Shift Keying) or
63 /// OOK (On Off Keying) RF transceivers.
64 ///
65 /// The message format and software technology is based on our earlier VirtualWire library
66 /// (http://www.airspayce.com/mikem/arduino/VirtualWire), with which it is compatible.
67 /// See http://www.airspayce.com/mikem/arduino/VirtualWire.pdf for more details.
68 /// VirtualWire is now obsolete and unsupported and is replaced by this library.
69 ///
70 /// RH_ASK is a Driver for Arduino, Maple and others that provides features to send short
71 /// messages, without addressing, retransmit or acknowledgment, a bit like UDP
72 /// over wireless, using ASK (amplitude shift keying). Supports a number of
73 /// inexpensive radio transmitters and receivers. All that is required is
74 /// transmit data, receive data and (for transmitters, optionally) a PTT
75 /// transmitter enable. Can also be used over various analog connections (not just a data radio),
76 /// such as the audio channel of an A/V sender, or long TTL lines.
77 ///
78 /// It is intended to be compatible with the RF Monolithics (www.rfm.com)
79 /// Virtual Wire protocol, but this has not been tested.
80 ///
81 /// Does not use the Arduino UART. Messages are sent with a training preamble,
82 /// message length and checksum. Messages are sent with 4-to-6 bit encoding
83 /// for good DC balance, and a CRC checksum for message integrity.
84 ///
85 /// But why not just use a UART connected directly to the
86 /// transmitter/receiver? As discussed in the RFM documentation, ASK receivers
87 /// require a burst of training pulses to synchronize the transmitter and
88 /// receiver, and also requires good balance between 0s and 1s in the message
89 /// stream in order to maintain the DC balance of the message. UARTs do not
90 /// provide these. They work a bit with ASK wireless, but not as well as this
91 /// code.
92 ///
93 /// \par Theory of operation
94 ///
95 /// See ASH Transceiver Software Designer's Guide of 2002.08.07
96 /// http://wireless.murata.com/media/products/apnotes/tr_swg05.pdf?ref=rfm.com
97 ///
98 /// http://web.engr.oregonstate.edu/~moon/research/files/cas2_mar_07_dpll.pdf while not directly relevant
99 /// is also interesting.
100 ///
101 /// \par Implementation Details
102 ///
103 /// Messages of up to RH_ASK_MAX_PAYLOAD_LEN (67) bytes can be sent
104 /// Each message is transmitted as:
105 ///
106 /// - 36 bit training preamble consisting of 0-1 bit pairs
107 /// - 12 bit start symbol 0xb38
108 /// - 1 byte of message length byte count (4 to 30), count includes byte count and FCS bytes
109 /// - n message bytes (uincluding 4 bytes of header), maximum n is RH_ASK_MAX_MESSAGE_LEN + 4 (64)
110 /// - 2 bytes FCS, sent low byte-hi byte
111 ///
112 /// Everything after the start symbol is encoded 4 to 6 bits, Therefore a byte in the message
113 /// is encoded as 2x6 bit symbols, sent hi nybble, low nybble. Each symbol is sent LSBit
114 /// first. The message may consist of any binary digits.
115 ///
116 /// The Arduino Diecimila clock rate is 16MHz => 62.5ns/cycle.
117 /// For an RF bit rate of 2000 bps, need 500microsec bit period.
118 /// The ramp requires 8 samples per bit period, so need 62.5microsec per sample => interrupt tick is 62.5microsec.
119 ///
120 /// The maximum packet length consists of
121 /// (6 + 2 + RH_ASK_MAX_MESSAGE_LEN*2) * 6 = 768 bits = 0.384 secs (at 2000 bps).
122 /// where RH_ASK_MAX_MESSAGE_LEN is RH_ASK_MAX_PAYLOAD_LEN - 7 (= 60).
123 /// The code consists of an ISR interrupt handler. Most of the work is done in the interrupt
124 /// handler for both transmit and receive, but some is done from the user level. Expensive
125 /// functions like CRC computations are always done in the user level.
126 ///
127 /// \par Supported Hardware
128 ///
129 /// A range of communications
130 /// hardware is supported. The ones listed below are available in common retail
131 /// outlets in Australia and other countries for under $10 per unit. Many
132 /// other modules may also work with this software.
133 ///
134 /// Runs on a wide range of Arduino processors using Arduino IDE 1.0 or later.
135 /// Also runs on on Energia,
136 /// with MSP430G2553 / G2452 and Arduino with ATMega328 (courtesy Yannick DEVOS - XV4Y),
137 /// but untested by us. It also runs on Teensy 3.0 (courtesy of Paul
138 /// Stoffregen), but untested by us. Also compiles and runs on ATtiny85 in
139 /// Arduino environment, courtesy r4z0r7o3. Also compiles on maple-ide-v0.0.12,
140 /// and runs on Maple, flymaple 1.1 etc. Runs on ATmega8/168 (Arduino Diecimila,
141 /// Uno etc), ATmega328 and can run on almost any other AVR8 platform,
142 /// without relying on the Arduino framework, by properly configuring the
143 /// library editing the RH_ASK.h header file for describing the access
144 /// to IO pins and for setting up the timer.
145 /// Runs on ChipKIT Core supported processors such as Uno32 etc.
146 ///
147 /// - Receivers
148 /// - RX-B1 (433.92MHz) (also known as ST-RX04-ASK)
149 /// - RFM83C from HopeRF http://www.hoperfusa.com/details.jsp?pid=126
150 /// - SYN480R and other similar ASK receivers
151 /// - Transmitters:
152 /// - TX-C1 (433.92MHz)
153 /// - RFM85 from HopeRF http://www.hoperfusa.com/details.jsp?pid=127
154 /// - SYN115, F115 and other similar ASK transmitters
155 /// - Transceivers
156 /// - DR3100 (433.92MHz)
157 ///
158 /// \par Connecting to Arduino
159 ///
160 /// Most transmitters can be connected to Arduino like this:
161 /// \code
162 /// Arduino Transmitter
163 /// GND------------------------------GND
164 /// D12------------------------------Data
165 /// 5V-------------------------------VCC
166 /// \endcode
167 ///
168 /// Most receivers can be connected to Arduino like this:
169 /// \code
170 /// Arduino Receiver
171 /// GND------------------------------GND
172 /// D11------------------------------Data
173 /// 5V-------------------------------VCC
174 /// SHUT (not connected)
175 /// WAKEB (not connected)
176 /// GND |
177 /// ANT |- connect to your antenna syetem
178 /// \endcode
179 ///
180 /// RH_ASK works with ATTiny85, using Arduino 1.0.5 and tinycore from
181 /// https://code.google.com/p/arduino-tiny/downloads/detail?name=arduino-tiny-0100-0018.zip
182 /// Tested with the examples ask_transmitter and ask_receiver on ATTiny85.
183 /// Caution: The RAM memory requirements on an ATTiny85 are *very* tight. Even the bare bones
184 /// ask_transmitter sketch barely fits in eh RAM available on the ATTiny85. Its unlikely to work on
185 /// smaller ATTinys such as the ATTiny45 etc. If you have wierd behaviour, consider
186 /// reducing the size of RH_ASK_MAX_PAYLOAD_LEN to the minimum you can work with.
187 /// Caution: the default internal clock speed on an ATTiny85 is 1MHz. You MUST set the internal clock speed
188 /// to 8MHz. You can do this with Arduino IDE, tineycore and ArduinoISP by setting the board type to "ATtiny85@8MHz',
189 /// setting theProgrammer to 'Arduino as ISP' and selecting Tools->Burn Bootloader. This does not actually burn a
190 /// bootloader into the tiny, it just changes the fuses so the chip runs at 8MHz.
191 /// If you run the chip at 1MHz, you will get RK_ASK speeds 1/8th of the expected.
192 ///
193 /// Initialise RH_ASK for ATTiny85 like this:
194 /// \code
195 /// // #include <SPI.h> // comment this out, not needed
196 /// RH_ASK driver(2000, 4, 3); // 200bps, TX on D3 (pin 2), RX on D4 (pin 3)
197 /// \endcode
198 /// then:
199 /// Connect D3 (pin 2) as the output to the transmitter
200 /// Connect D4 (pin 3) as the input from the receiver.
201 ///
202 /// With AtTiny x17 (such as 3217 etc) using Spencer Kondes megaTinyCore, You can initialise like this:
203 /// RH_ASK driver(2000, 6, 7);
204 /// which will transmit on digital pin 7 == PB4 == physical pin 12 on Attiny x17
205 /// and receive on digital pin 6 == PB5 == physical pin 11 on Attiny x17
206 /// Uses Timer B1.
207 ///
208 /// With AtTiny x16 (such as 3216 etc) using Spencer Kondes megaTinyCore, You can initialise like this:
209 /// RH_ASK driver(2000, 11, 12);
210 /// which will transmit on digital pin 12 == PC2 == physical pin 14 on Attiny x16
211 /// and receive on digital pin 11 == PC1 == physical pin 13 on Attiny x16
212 /// Uses Timer B1.
213 ///
214 /// With AtTiny x14 (such as 1614 etc) using Spencer Kondes megaTinyCore, You can initialise like this:
215 /// RH_ASK driver(2000, 6, 7);
216 /// which will transmit on digital pin 7 == PB0 == physical pin 9 on Attiny x14
217 /// and receive on digital pin 6 == PB1 == physical pin 8 on Attiny x16
218 /// Uses Timer B1.
219 ///
220 /// For testing purposes you can connect 2 Arduino RH_ASK instances directly, by
221 /// connecting pin 12 of one to 11 of the other and vice versa, like this for a duplex connection:
222 ///
223 /// \code
224 /// Arduino 1 wires Arduino 1
225 /// D11-----------------------------D12
226 /// D12-----------------------------D11
227 /// GND-----------------------------GND
228 /// \endcode
229 ///
230 /// You can also connect 2 RH_ASK instances over a suitable analog
231 /// transmitter/receiver, such as the audio channel of an A/V transmitter/receiver. You may need
232 /// buffers at each end of the connection to convert the 0-5V digital output to a suitable analog voltage.
233 ///
234 /// Measured power output from RFM85 at 5V was 18dBm.
235 ///
236 /// \par ESP8266
237 /// This module has been tested with the ESP8266 using an ESP-12 on a breakout board
238 /// ESP-12E SMD Adaptor Board with Power Regulator from tronixlabs
239 /// http://tronixlabs.com.au/wireless/esp8266/esp8266-esp-12e-smd-adaptor-board-with-power-regulator-australia/
240 /// compiled on Arduino 1.6.5 and the ESP8266 support 2.0 installed with Board Manager.
241 /// CAUTION: do not use pin 11 for IO with this chip: it will cause the sketch to hang. Instead
242 /// use constructor arguments to configure different pins, eg:
243 /// \code
244 /// RH_ASK driver(2000, 2, 4, 5);
245 /// \endcode
246 /// Which will initialise the driver at 2000 bps, recieve on GPIO2, transmit on GPIO4, PTT on GPIO5.
247 /// Caution: on the tronixlabs breakout board, pins 4 and 5 may be labelled vice-versa.
248 ///
249 /// \par Timers
250 /// The RH_ASK driver uses a timer-driven interrupt to generate 8 interrupts per bit period. RH_ASK
251 /// takes over a timer on Arduino-like platforms. By default it takes over Timer 1. You can force it
252 /// to use Timer 2 instead by enabling the define RH_ASK_ARDUINO_USE_TIMER2 near the top of RH_ASK.cpp
253 /// On Arduino Zero it takes over timer TC3. On Arduino Due it takes over timer
254 /// TC0. On ESP8266, takes over timer0 (which conflicts with ServoTimer0).
255 ///
256 /// Caution: ATTiny85 has only 2 timers, one (timer 0) usually used for
257 /// millis() and one (timer 1) for PWM analog outputs. The RH_ASK Driver
258 /// library, when built for ATTiny85, takes over timer 0, which prevents use
259 /// of millis() etc but does permit analog outputs. This will affect the accuracy of millis() and time
260 /// measurement.
261 ///
262 /// \par STM32 F4 Discovery with Arduino and Arduino_STM32
263 /// You can initialise the driver like this:
264 /// \code
265 /// RH_ASK driver(2000, PA3, PA4);
266 /// \endcode
267 /// and connect the serail to pins PA3 and PA4
268 class RH_ASK : public RHGenericDriver
269 {
270 public:
271  /// Constructor.
272  /// At present only one instance of RH_ASK per sketch is supported.
273  /// \param[in] speed The desired bit rate in bits per second
274  /// \param[in] rxPin The pin that is used to get data from the receiver
275  /// \param[in] txPin The pin that is used to send data to the transmitter
276  /// \param[in] pttPin The pin that is connected to the transmitter controller. It will be set HIGH to enable the transmitter (unless pttInverted is true).
277  /// \param[in] pttInverted true if you desire the pttin to be inverted so that LOW wil enable the transmitter.
278  RH_ASK(uint16_t speed = 2000, uint8_t rxPin = 11, uint8_t txPin = 12, uint8_t pttPin = 10, bool pttInverted = false);
279 
280  /// Initialise the Driver transport hardware and software.
281  /// Make sure the Driver is properly configured before calling init().
282  /// \return true if initialisation succeeded.
283  virtual bool init();
284 
285  /// Tests whether a new message is available
286  /// from the Driver.
287  /// On most drivers, this will also put the Driver into RHModeRx mode until
288  /// a message is actually received bythe transport, when it wil be returned to RHModeIdle.
289  /// This can be called multiple times in a timeout loop
290  /// \return true if a new, complete, error-free uncollected message is available to be retreived by recv()
291  virtual bool available();
292 
293  /// Turns the receiver on if it not already on.
294  /// If there is a valid message available, copy it to buf and return true
295  /// else return false.
296  /// If a message is copied, *len is set to the length (Caution, 0 length messages are permitted).
297  /// You should be sure to call this function frequently enough to not miss any messages
298  /// It is recommended that you call it in your main loop.
299  /// \param[in] buf Location to copy the received message
300  /// \param[in,out] len Pointer to available space in buf. Set to the actual number of octets copied.
301  /// \return true if a valid message was copied to buf
302  RH_INTERRUPT_ATTR virtual bool recv(uint8_t* buf, uint8_t* len);
303 
304  /// Waits until any previous transmit packet is finished being transmitted with waitPacketSent().
305  /// Then loads a message into the transmitter and starts the transmitter. Note that a message length
306  /// of 0 is NOT permitted.
307  /// \param[in] data Array of data to be sent
308  /// \param[in] len Number of bytes of data to send (> 0)
309  /// \return true if the message length was valid and it was correctly queued for transmit
310  virtual bool send(const uint8_t* data, uint8_t len);
311 
312  /// Returns the maximum message length
313  /// available in this Driver.
314  /// \return The maximum legal message length
315  virtual uint8_t maxMessageLength();
316 
317  /// If current mode is Rx or Tx changes it to Idle. If the transmitter or receiver is running,
318  /// disables them.
319  RH_INTERRUPT_ATTR void setModeIdle();
320 
321  /// If current mode is Tx or Idle, changes it to Rx.
322  /// Starts the receiver in the RF69.
323  RH_INTERRUPT_ATTR void setModeRx();
324 
325  /// If current mode is Rx or Idle, changes it to Rx. F
326  /// Starts the transmitter in the RF69.
327  void setModeTx();
328 
329  /// dont call this it used by the interrupt handler
330  RH_INTERRUPT_ATTR void handleTimerInterrupt();
331 
332  /// Returns the current speed in bits per second
333  /// \return The current speed in bits per second
334  uint16_t speed() { return _speed;}
335 
336 #if (RH_PLATFORM == RH_PLATFORM_ESP8266)
337  /// ESP8266 timer0 increment value
338  uint32_t _timerIncrement;
339 #endif
340 
341 protected:
342  /// Helper function for calculating timer ticks
343  uint8_t timerCalc(uint16_t speed, uint16_t max_ticks, uint16_t *nticks);
344 
345  /// Set up the timer and its interrutps so the interrupt handler is called at the right frequency
346  void timerSetup();
347 
348  /// Read the rxPin in a platform dependent way, taking into account whether it is inverted or not
349  RH_INTERRUPT_ATTR bool readRx();
350 
351  /// Write the txPin in a platform dependent way
352  void writeTx(bool value);
353 
354  /// Write the txPin in a platform dependent way, taking into account whether it is inverted or not
355  void writePtt(bool value);
356 
357  /// Translates a 6 bit symbol to its 4 bit plaintext equivalent
358  RH_INTERRUPT_ATTR uint8_t symbol_6to4(uint8_t symbol);
359 
360  /// The receiver handler function, called a 8 times the bit rate
361  void receiveTimer();
362 
363  /// The transmitter handler function, called a 8 times the bit rate
364  void transmitTimer();
365 
366  /// Check whether the latest received message is complete and uncorrupted
367  /// We should always check the FCS at user level, not interrupt level
368  /// since it is slow
369  void validateRxBuf();
370 
371  /// Configure bit rate in bits per second
372  uint16_t _speed;
373 
374  /// The configure receiver pin
375  uint8_t _rxPin;
376 
377  /// The configure transmitter pin
378  uint8_t _txPin;
379 
380  /// The configured transmitter enable pin
381  uint8_t _pttPin;
382 
383  /// True of the sense of the rxPin is to be inverted
385 
386  /// True of the sense of the pttPin is to be inverted
388 
389  // Used in the interrupt handlers
390  /// Buf is filled but not validated
391  volatile bool _rxBufFull;
392 
393  /// Buf is full and valid
394  volatile bool _rxBufValid;
395 
396  /// Last digital input from the rx data pin
397  volatile bool _rxLastSample;
398 
399  /// This is the integrate and dump integral. If there are <5 0 samples in the PLL cycle
400  /// the bit is declared a 0, else a 1
401  volatile uint8_t _rxIntegrator;
402 
403  /// PLL ramp, varies between 0 and RH_ASK_RX_RAMP_LEN-1 (159) over
404  /// RH_ASK_RX_SAMPLES_PER_BIT (8) samples per nominal bit time.
405  /// When the PLL is synchronised, bit transitions happen at about the
406  /// 0 mark.
407  volatile uint8_t _rxPllRamp;
408 
409  /// Flag indicates if we have seen the start symbol of a new message and are
410  /// in the processes of reading and decoding it
411  volatile uint8_t _rxActive;
412 
413  /// Last 12 bits received, so we can look for the start symbol
414  volatile uint16_t _rxBits;
415 
416  /// How many bits of message we have received. Ranges from 0 to 12
417  volatile uint8_t _rxBitCount;
418 
419  /// The incoming message buffer
420  uint8_t _rxBuf[RH_ASK_MAX_PAYLOAD_LEN];
421 
422  /// The incoming message expected length
423  volatile uint8_t _rxCount;
424 
425  /// The incoming message buffer length received so far
426  volatile uint8_t _rxBufLen;
427 
428  /// Index of the next symbol to send. Ranges from 0 to vw_tx_len
429  uint8_t _txIndex;
430 
431  /// Bit number of next bit to send
432  uint8_t _txBit;
433 
434  /// Sample number for the transmitter. Runs 0 to 7 during one bit interval
435  uint8_t _txSample;
436 
437  /// The transmitter buffer in _symbols_ not data octets
438  uint8_t _txBuf[(RH_ASK_MAX_PAYLOAD_LEN * 2) + RH_ASK_PREAMBLE_LEN];
439 
440  /// Number of symbols in _txBuf to be sent;
441  uint8_t _txBufLen;
442 
443 };
444 
445 /// @example ask_reliable_datagram_client.pde
446 /// @example ask_reliable_datagram_server.pde
447 /// @example ask_transmitter.pde
448 /// @example ask_receiver.pde
449 #endif
RHGenericDriver::_rxGood
volatile uint16_t _rxGood
Count of the number of successfully transmitted messaged.
Definition: RHGenericDriver.h:292
RH_ASK::_txIndex
uint8_t _txIndex
Index of the next symbol to send. Ranges from 0 to vw_tx_len.
Definition: RH_ASK.h:429
RH_ASK::timerSetup
void timerSetup()
Set up the timer and its interrutps so the interrupt handler is called at the right frequency.
Definition: RH_ASK.cpp:159
RHGenericDriver::_rxHeaderFrom
volatile uint8_t _rxHeaderFrom
FROM header in the last received mesasge.
Definition: RHGenericDriver.h:265
RH_ASK::_rxActive
volatile uint8_t _rxActive
Definition: RH_ASK.h:411
RH_ASK::readRx
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
RH_ASK::recv
virtual RH_INTERRUPT_ATTR bool recv(uint8_t *buf, uint8_t *len)
Definition: RH_ASK.cpp:493
RH_ASK::_rxBitCount
volatile uint8_t _rxBitCount
How many bits of message we have received. Ranges from 0 to 12.
Definition: RH_ASK.h:417
RH_ASK::send
virtual bool send(const uint8_t *data, uint8_t len)
Definition: RH_ASK.cpp:513
RHGenericDriver::_rxBad
volatile uint16_t _rxBad
Count of the number of bad messages (eg bad checksum etc) received.
Definition: RHGenericDriver.h:289
RH_ASK::_rxCount
volatile uint8_t _rxCount
The incoming message expected length.
Definition: RH_ASK.h:423
RHGenericDriver::_rxHeaderTo
volatile uint8_t _rxHeaderTo
TO header in the last received mesasge.
Definition: RHGenericDriver.h:262
RHGenericDriver::_txHeaderFrom
uint8_t _txHeaderFrom
FROM header to send in all messages.
Definition: RHGenericDriver.h:277
RH_ASK::validateRxBuf
void validateRxBuf()
Definition: RH_ASK.cpp:756
RHGenericDriver
Abstract base class for a RadioHead driver.
Definition: RHGenericDriver.h:41
RH_ASK::_rxPllRamp
volatile uint8_t _rxPllRamp
Definition: RH_ASK.h:407
RH_ASK::transmitTimer
void transmitTimer()
The transmitter handler function, called a 8 times the bit rate.
Definition: RH_ASK.cpp:873
RH_ASK::setModeTx
void setModeTx()
Definition: RH_ASK.cpp:463
RH_ASK::_pttInverted
bool _pttInverted
True of the sense of the pttPin is to be inverted.
Definition: RH_ASK.h:387
RH_ASK::handleTimerInterrupt
RH_INTERRUPT_ATTR void handleTimerInterrupt()
dont call this it used by the interrupt handler
Definition: RH_ASK.cpp:901
RHGenericDriver::_thisAddress
uint8_t _thisAddress
This node id.
Definition: RHGenericDriver.h:256
RHGenericDriver::_txGood
volatile uint16_t _txGood
Count of the number of bad messages (correct checksum etc) received.
Definition: RHGenericDriver.h:295
RH_ASK::_rxInverted
bool _rxInverted
True of the sense of the rxPin is to be inverted.
Definition: RH_ASK.h:384
RH_ASK::init
virtual bool init()
Definition: RH_ASK.cpp:63
RHGenericDriver::_promiscuous
bool _promiscuous
Whether the transport is in promiscuous mode.
Definition: RHGenericDriver.h:259
RH_ASK::_rxBufValid
volatile bool _rxBufValid
Buf is full and valid.
Definition: RH_ASK.h:394
RHGenericDriver::_rxHeaderFlags
volatile uint8_t _rxHeaderFlags
FLAGS header in the last received mesasge.
Definition: RHGenericDriver.h:271
RH_ASK::setModeIdle
RH_INTERRUPT_ATTR void setModeIdle()
Definition: RH_ASK.cpp:441
RH_ASK::writePtt
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
RH_ASK::_pttPin
uint8_t _pttPin
The configured transmitter enable pin.
Definition: RH_ASK.h:381
RH_ASK::_rxLastSample
volatile bool _rxLastSample
Last digital input from the rx data pin.
Definition: RH_ASK.h:397
RH_ASK::_rxBufFull
volatile bool _rxBufFull
Buf is filled but not validated.
Definition: RH_ASK.h:391
RH_ASK::_txBit
uint8_t _txBit
Bit number of next bit to send.
Definition: RH_ASK.h:432
RH_ASK::writeTx
void writeTx(bool value)
Write the txPin in a platform dependent way.
Definition: RH_ASK.cpp:589
RH_ASK
Driver to send and receive unaddressed, unreliable datagrams via inexpensive ASK (Amplitude Shift Key...
Definition: RH_ASK.h:268
RH_ASK::receiveTimer
void receiveTimer()
The receiver handler function, called a 8 times the bit rate.
Definition: RH_ASK.cpp:784
RH_ASK::_txBuf
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::RH_ASK
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
RHGenericDriver::_txHeaderId
uint8_t _txHeaderId
ID header to send in all messages.
Definition: RHGenericDriver.h:280
RH_ASK::_rxBufLen
volatile uint8_t _rxBufLen
The incoming message buffer length received so far.
Definition: RH_ASK.h:426
RHGenericDriver::_txHeaderTo
uint8_t _txHeaderTo
TO header to send in all messages.
Definition: RHGenericDriver.h:274
RH_ASK::timerCalc
uint8_t timerCalc(uint16_t speed, uint16_t max_ticks, uint16_t *nticks)
Helper function for calculating timer ticks.
Definition: RH_ASK.cpp:107
RHGenericDriver::init
virtual bool init()
Definition: RHGenericDriver.cpp:23
RH_ASK::symbol_6to4
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
RHGenericDriver::_txHeaderFlags
uint8_t _txHeaderFlags
FLAGS header to send in all messages.
Definition: RHGenericDriver.h:283
RH_ASK::available
virtual bool available()
Definition: RH_ASK.cpp:480
RH_ASK::_txPin
uint8_t _txPin
The configure transmitter pin.
Definition: RH_ASK.h:378
RHGenericDriver::_rxHeaderId
volatile uint8_t _rxHeaderId
ID header in the last received mesasge.
Definition: RHGenericDriver.h:268
RH_ASK::_rxIntegrator
volatile uint8_t _rxIntegrator
Definition: RH_ASK.h:401
RH_ASK::_rxBuf
uint8_t _rxBuf[RH_ASK_MAX_PAYLOAD_LEN]
The incoming message buffer.
Definition: RH_ASK.h:420
RH_ASK::_rxPin
uint8_t _rxPin
The configure receiver pin.
Definition: RH_ASK.h:375
RHGenericDriver::RHModeIdle
@ RHModeIdle
Transport is idle.
Definition: RHGenericDriver.h:52
RH_ASK::maxMessageLength
virtual uint8_t maxMessageLength()
Definition: RH_ASK.cpp:616
RHGenericDriver::waitPacketSent
virtual bool waitPacketSent()
Definition: RHGenericDriver.cpp:52
RHGenericDriver::_mode
volatile RHMode _mode
The current transport operating mode.
Definition: RHGenericDriver.h:253
RHGenericDriver::RHModeTx
@ RHModeTx
Transport is in the process of transmitting a message.
Definition: RHGenericDriver.h:53
RH_ASK::speed
uint16_t speed()
Definition: RH_ASK.h:334
RH_ASK::setModeRx
RH_INTERRUPT_ATTR void setModeRx()
Definition: RH_ASK.cpp:452
RH_ASK::_txBufLen
uint8_t _txBufLen
Number of symbols in _txBuf to be sent;.
Definition: RH_ASK.h:441
RH_ASK::_rxBits
volatile uint16_t _rxBits
Last 12 bits received, so we can look for the start symbol.
Definition: RH_ASK.h:414
RHGenericDriver::RHModeRx
@ RHModeRx
Transport is in the process of receiving a message.
Definition: RHGenericDriver.h:54
RH_ASK::_txSample
uint8_t _txSample
Sample number for the transmitter. Runs 0 to 7 during one bit interval.
Definition: RH_ASK.h:435
RHGenericDriver::waitCAD
virtual bool waitCAD()
Definition: RHGenericDriver.cpp:72
RH_ASK::_speed
uint16_t _speed
Configure bit rate in bits per second.
Definition: RH_ASK.h:372