RadioHead
RadioHead.h
1// RadioHead.h
2// Author: Mike McCauley DO NOT CONTACT THE AUTHOR DIRECTLY
3// Copyright (C) 2014 Mike McCauley
4// $Id: RadioHead.h,v 1.89 2020/08/05 04:32:19 mikem Exp mikem $
5
6/*! \mainpage RadioHead Packet Radio library for embedded microprocessors
7
8This is the RadioHead Packet Radio library for embedded microprocessors.
9It provides a complete object-oriented library for sending and receiving packetized messages
10via a variety of common data radios and other transports on a range of embedded microprocessors.
11
12\par Download
13
14The version of the package that this documentation refers to can be downloaded
15from https://www.airspayce.com/mikem/arduino/RadioHead/RadioHead-1.145.zip
16
17You can always find the latest version of this documentation at
18https://www.airspayce.com/mikem/arduino/RadioHead
19
20You can also find online help and discussion at
21https://groups.google.com/group/radiohead-arduino
22Please use that group for all questions and discussions on this topic.
23Do not contact the author directly, unless it is to discuss commercial licensing.
24Before asking a question or reporting a bug, please read
25- https://en.wikipedia.org/wiki/Wikipedia:Reference_desk/How_to_ask_a_software_question
26- https://www.catb.org/esr/faqs/smart-questions.html
27- https://www.chiark.greenend.org.uk/~shgtatham/bugs.html
28
29Caution: Developing this type of software and using data radios
30successfully is challenging and requires a substantial knowledge
31base in software and radio and data transmission technologies and
32theory. It may not be an appropriate project for beginners. If
33you are a beginner, you will need to spend some time gaining
34knowledge in these areas first.
35
36\par Overview
37
38RadioHead consists of 2 main sets of classes: Drivers and Managers.
39
40- Drivers provide low level access to a range of different packet radios and other packetized message transports.
41- Managers provide high level message sending and receiving facilities for a range of different requirements.
42
43Every RadioHead program will have an instance of a Driver to
44provide access to the data radio or transport, and usually an instance of a
45Manager that uses that driver to send and receive messages for the
46application. The programmer is required to instantiate a Driver
47and a Manager, and to initialise the Manager. Thereafter the
48facilities of the Manager can be used to send and receive
49messages.
50
51It is also possible to use a Driver on its own, without a Manager, although this only allows unaddressed,
52unreliable transport via the Driver's facilities.
53
54In some specialised use cases, it is possible to instantiate more than one Driver and more than one Manager.
55
56A range of different common embedded microprocessor platforms are supported, allowing your project to run
57on your choice of processor.
58
59Example programs are included to show the main modes of use.
60
61\par Drivers
62
63The following Drivers are provided:
64
65- RH_RF22
66Works with Hope-RF
67RF22B and RF23B based transceivers, and compatible chips and modules,
68including the RFM22B transceiver module such as
69hthis bare module: https://www.sparkfun.com/products/10153
70and this shield: https://www.sparkfun.com/products/11018
71and this board: https://www.anarduino.com/miniwireless
72and RF23BP modules such as: https://www.anarduino.com/details.jsp?pid=130
73Supports GFSK, FSK and OOK. Access to other chip
74features such as on-chip temperature measurement, analog-digital
75converter, transmitter power control etc is also provided.
76
77- RH_RF24
78Works with Silicon Labs Si4460/4461/4463/4464 family of transceivers chip, and the equivalent
79HopeRF RF24/26/27 family of chips and the HopeRF RFM24W/26W/27W modules.
80Supports GFSK, FSK and OOK. Access to other chip
81features such as on-chip temperature measurement, analog-digital
82converter, transmitter power control etc is also provided.
83
84- RH_RF69
85Works with Hope-RF
86RF69B based radio modules, such as the RFM69 module, (as used on the excellent Moteino and Moteino-USB
87boards from LowPowerLab https://lowpowerlab.com/moteino/ )
88and compatible chips and modules such as RFM69W, RFM69HW, RFM69CW, RFM69HCW (Semtech SX1231, SX1231H).
89Also works with Anarduino MiniWireless -CW and -HW boards https://www.anarduino.com/miniwireless/ including
90the marvellous high powered MinWireless-HW (with 20dBm output for excellent range).
91Supports GFSK, FSK.
92
93- RH_NRF24
94Works with Nordic nRF24 based 2.4GHz radio modules, such as nRF24L01 and others.
95Also works with Hope-RF RFM73
96and compatible devices (such as BK2423). nRF24L01 and RFM73 can interoperate
97with each other.
98
99- RH_NRF905
100Works with Nordic nRF905 based 433/868/915 MHz radio modules.
101
102- RH_NRF51
103Works with Nordic nRF51 compatible 2.4 GHz SoC/devices such as the nRF51822.
104Also works with Sparkfun nRF52832 breakout board, with Arduino 1.8.9 and
105Sparkfun nRF52 boards manager 0.2.3.
106
107- RH_RF95
108Works with Semtech SX1276/77/78/79, Modtronix inAir4 and inAir9,
109and HopeRF RFM95/96/97/98 and other similar LoRa capable radios.
110Supports Long Range (LoRa) with spread spectrum frequency hopping, large payloads etc.
111FSK/GFSK/OOK modes are not (yet) supported.
112Also works with the same chips on Linux using LoRa-file-ops Linux driver ioctls to
113transmit and receive RadioHead compatible messages.
114Requires a modified version of LoRa-file-ops driver to be installed,
115and a compatible radio to be connected appropriately:
116https://github.com/starnight/LoRa/tree/file-ops
117See the RH_LoRaFileOps class documentation for more information.
118
119- RH_MRF89
120Works with Microchip MRF89XA and compatible transceivers.
121and modules such as MRF89XAM9A and MRF89XAM8A.
122
123- RH_CC110
124Works with Texas Instruments CC110L transceivers and compatible modules such as
125Anaren AIR BoosterPack 430BOOST-CC110L
126
127- RH_E32
128Works with EBYTE E32-TTL-1W serial radio transceivers (and possibly other transceivers in the same family)
129
130- RH_ASK
131Works with a range of inexpensive ASK (amplitude shift keying) RF transceivers such as RX-B1
132(also known as ST-RX04-ASK) receiver; TX-C1 transmitter and DR3100 transceiver; FS1000A/XY-MK-5V transceiver;
133HopeRF RFM83C / RFM85. Supports ASK (OOK).
134
135- RH_ABZ
136Works with EcoNode SmartTrap, Tlera Grasshopper and family. Almost any board equipped with a muRata cmwx1zzabz module
137should work. Tested with EcoNode SmartTrap, Arduino 1.8.9, GrumpyOldPizza Arduino Core for STM32L0.
138When building for EcoNode SmartTrap in Arduino IDE, select board type Grasshopper-L082CZ.
139This chip and GrumpyOldPizza Arduino Core for STM32L0 are now supported by PlatformIO:
140https://docs.platformio.org/en/latest/platforms/ststm32.html#arduino-stm32l0-configuration-system
141
142- RH_SX126x
143Works with Semtech SX1261/2/8 LoRa capable transceivers and compatible, such as LLCCC68
144Can be configured to automatically control any digital output pins required to control external
145RF switches or amplifiers.
146Tested with NiceRF LoRa1268-915 and Teensy 3.1.
147https://www.nicerf.com/lora-module/915mhz-lora-module-lora1262.html
148Tested with LLCC68 in Ra-01SC module and Teensy 3.1.
149Tested with Heltec Cube Cell HTCC-AB01 and Teensy 3.1.
150
151- RH_STM32WLx
152Works with STM32WLE5xx and STM32WLE4xx family processors that include a SX1261/2 multi power amplifier transceiver.
153Automatically manages the dedicated SPI interface and interrupt, and the internal SPI slave select and reset pins to the radio.
154Examples provided. Requires the stm32duino package using these instructions:
155https://community.st.com/t5/stm32-mcus/stm32-arduino-stm32duino-tutorial/ta-p/49649
156
157- RH_Serial
158Works with RS232, RS422, RS485, RS488 and other point-to-point and multidropped serial connections,
159or with TTL serial UARTs such as those on Arduino and many other processors,
160or with data radios with a
161serial port interface. RH_Serial provides packetization and error detection over any hardware or
162virtual serial connection. Also builds and runs on Linux and OSX.
163
164- RH_TCP
165For use with simulated sketches compiled and running on Linux.
166Works with tools/etherSimulator.pl to pass messages between simulated sketches, allowing
167testing of Manager classes on Linux and without need for real radios or other transport hardware.
168
169- RHEncryptedDriver
170Adds encryption and decryption to any RadioHead transport driver, using any encrpytion cipher
171supported by ArduinoLibs Cryptographic Library https://rweather.github.io/arduinolibs/crypto.html
172which also supports the newly adopted ASCON lightweight cryptography standard for IoT, as announced by
173National Institute of Standards and Technology (NIST).
174
175Drivers can be used on their own to provide unaddressed, unreliable datagrams.
176All drivers have the same identical API.
177Or you can use any Driver with any of the Managers described below.
178
179We welcome contributions of well tested and well documented code to support other transports.
180
181If your radio or transciever is not on the list above, there is a good chance it
182won't work without modifying RadioHead to suit it. If you wish for
183support for another radio or transciever, and you send at least 2 of them to
184AirSpayce Pty Ltd, we will consider adding support for it.
185
186\par Managers
187
188The drivers above all provide for unaddressed, unreliable (ie unacknowleged), variable
189length messages, but if you need more than that, the following
190Managers are provided:
191
192- RHDatagram
193 Addressed, unreliable variable length messages, with optional broadcast facilities.
194
195- RHReliableDatagram
196 Addressed, reliable, retransmitted, acknowledged variable length messages.
197
198- RHRouter
199 Multi-hop delivery of RHReliableDatagrams from source node to destination node via 0 or more
200 intermediate nodes, with manual, pre-programmed routing.
201
202- RHMesh
203 Multi-hop delivery of RHReliableDatagrams with automatic route discovery and rediscovery.
204
205Any Manager may be used with any Driver.
206
207\par Platforms
208
209A range of processors and platforms are supported:
210
211- Arduino and the Arduino IDE (version 1.0 to 1.8.1 and 2.1.1 and later)
212Including Diecimila, Uno, Mega, Leonardo, Yun, Due, Zero, Minima and possibly others from https://arduino.cc/,
213 Also similar boards such as
214 - Moteino https://lowpowerlab.com/moteino/
215 - Anarduino Mini https://www.anarduino.com/mini/
216 - RedBearLab Blend V1.0 https://redbearlab.com/blend/ (with Arduino 1.0.5 and RedBearLab Blend Add-On version 20140701)
217 - MoteinoMEGA https://lowpowerlab.com/shop/moteinomega
218 (with Arduino 1.0.5 and the MoteinoMEGA Arduino Core
219 https://github.com/LowPowerLab/Moteino/tree/master/MEGA/Core)
220 - ESP8266 on Arduino IDE and Boards Manager per https://github.com/esp8266/Arduino
221 Tested using Arduino 1.6.8 with esp8266 by ESP8266 Community version 2.1.0
222 Also Arduino 1.8.1 with esp8266 by SparkFun Electronics 2.5.2
223 Examples serial_reliable_datagram_* and ask_* are shown to work.
224 CAUTION: The GHz radio included in the ESP8266 is
225 not yet supported.
226 CAUTION: tests here show that when powered by an FTDI USB-Serial converter,
227 the ESP8266 can draw so much power when transmitting on its GHz WiFi that VCC will sag
228 causing random crashes. We strongly recommend a large cap, say 1000uF 10V on VCC if you are also using the WiFi.
229 - Various Talk2 Whisper boards eg https://wisen.com.au/store/products/whisper-node-lora.
230 Use Arduino Board Manager to install the Talk2 code support.
231 - etc.
232
233- STM32 F4 Discover board, using Arduino 1.8.2 or later and
234 Roger Clarkes Arduino_STM from https://github.com/rogerclarkmelbourne/Arduino_STM32
235 Caution: with this library and board, sending text to Serial causes the board to hang in mysterious ways.
236 Serial2 emits to PA2. The default SPI pins are SCK: PB3, MOSI PB5, MISO PB4.
237 We tested with PB0 as slave select and PB1 as interrupt pin for various radios. RH_ASK and RH_Serial also work.
238 Also works with stm32duino 1.8.0 from https://github.com/stm32duino/Arduino_Core_STM32, wich can be
239 installed on Arduino with BoardManager. Select board: STM32 Discovery F407.
240
241- ChipKIT Core with Arduino IDE on any ChipKIT Core supported Digilent processor (tested on Uno32)
242 https://chipkit.net/wiki/index.php?title=ChipKIT_core
243
244- Maple and Flymaple boards with libmaple and the Maple-IDE development environment
245 https://leaflabs.com/devices/maple/ and https://www.open-drone.org/flymaple
246
247- Teensy including Teensy 3.1 and earlier built using Arduino IDE 1.0.5 to 1.6.4 and later with
248 teensyduino addon 1.18 to 1.23 and later.
249 https://www.pjrc.com/teensy
250
251- Particle Photon https://store.particle.io/collections/photon and ARM3 based CPU with built-in
252 Wi-Fi transceiver and extensive IoT software suport. RadioHead does not support the built-in transceiver
253 but can be used to control other SPI based radios, Serial ports etc.
254 See below for details on how to build RadioHead for Photon
255
256- ATTiny built using Arduino IDE 1.8 and the ATTiny core from
257 https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json
258 using the instructions at
259 https://medium.com/jungletronics/attiny85-easy-flashing-through-arduino-b5f896c48189
260 (Caution: these are very small processors and not all RadioHead features may be available, depending on memory requirements)
261 (Caution: we have not had good success building RH_ASK sketches for ATTiny 85 with SpenceKonde ATTinyCore)
262
263- ATtiny Mega (tinyAVR 1-series) chips supported by Spencer Konde's megaTinyCore
264 (https://github.com/SpenceKonde/megaTinyCore)
265 (on Arduino 1.8.9 or later) such as AtTiny 3216, ATtiny 1616 etc. These chips can be easily programmed through their
266 UPDI pin, using an ordinary Arduino board programmed as a jtag2updi programmer as described in
267 https://github.com/SpenceKonde/megaTinyCore/blob/master/MakeUPDIProgrammer.md.
268 Make sure you set the programmer type to jtag2updi in the Arduino Tools->Programmer menu.
269 See https://github.com/SpenceKonde/megaTinyCore/blob/master/megaavr/extras/ImportantInfo.md for links to pinouts
270 and pin numbering information for all the suported chips.
271
272- nRF51 compatible Arm chips such as nRF51822 with Arduino 1.6.4 and later using the procedures
273 in https://redbearlab.com/getting-started-nrf51822/
274
275- nRF52 compatible Arm chips such as as Adafruit BLE Feather board
276 https://www.adafruit.com/product/3406
277
278- Adafruit Feather. These are excellent boards that are available with a variety of radios. We tested with the
279 Feather 32u4 with RFM69HCW radio, with Arduino IDE 1.6.8 and the Adafruit AVR Boards board manager version 1.6.10.
280 https://www.adafruit.com/products/3076
281
282- Adafruit Feather M0 boards with Arduino 1.8.1 and later, using the Arduino and Adafruit SAMD board support.
283 https://learn.adafruit.com/adafruit-feather-m0-basic-proto/using-with-arduino-ide
284
285- ESP32 built using Arduino IDE 1.8.9 or later using the ESP32 toolchain installed per
286 https://github.com/espressif/arduino-esp32 or from the Arduino IDE Board Manager. Tested up to version 3.0.2.
287 The internal 2.4GHz radio is not yet supported. Tested with RFM22 using SPI interface.
288 Uses the VSPI SPI bus by default.
289 You can enable use of the alternative HSPI bus for SPI by defining RH_ESP32_USE_HSPI in RadioHead.h.
290
291- Raspberry Pi
292 Uses BCM2835 library for GPIO https://www.airspayce.com/mikem/bcm2835/
293 Currently works only with RH_NRF24 driver or other drivers that do not require interrupt support.
294 Contributed by Mike Poublon.
295
296- Linux and OSX
297 Using the RHutil/HardwareSerial class, the RH_Serial driver and any manager will
298 build and run on Linux and OSX. These can be used to build programs that talk securely and reliably to
299 Arduino and other processors or to other Linux or OSX hosts on a reliable, error detected (and possibly encrypted) datagram
300 protocol over various types of serial line.
301
302- Mongoose OS, courtesy Paul Austen. Mongoose OSis an Internet of Things Firmware Development Framework
303 available under Apache License Version 2.0. It supports low power, connected microcontrollers such as:
304 ESP32, ESP8266, TI CC3200, TI CC3220, STM32.
305 https://mongoose-os.com/
306
307- muRata cmwx1zzabz module, which includes an STM32L0 processor,
308 a SX1276 LoRa radio and an antenna switch.
309
310- Raspberry Pi Pico, on Arduino, using either the Raspberry Pi Pico/RP2040 core by Earle F. Philhower, version 1.93,
311 installed per https://arduino-pico.readthedocs.io/_/downloads/en/latest/pdf/
312 or the alternative Arduino MBED OS RP2040 core version 2.4.1. At this stage support is partial: RH_ASK works
313 but radio drivers that use interrupts do not (yet) work in either core.
314
315- Heltec Cube Cell family, eg HTCC-AB01:
316 https://heltec.org/project/htcc-ab01-v2/
317 https://resource.heltec.cn/download/CubeCell/HTCC-AB01/HTCC-AB01_SchematicDiagram.pdf
318 These modules have an ASR6501 or ASR6502 ARM Cortex M0+ processor https://www.microchip.ua/wireless/ASR6501.pdf
319 which includes a built-in LoRa capable SX1262 radio, and which is supported by the RadioHead RH_SX126x driver.
320 Demonstrated interoperation with RH_RF95 driver.
321 Build with the CubeCell board support 1.5.0 via the Arduino Board Manager per
322 https://docs.heltec.org/en/node/asr650x/asr650x_general_docs/quick_start/cubecell-use-arduino-board-manager.html
323 Tested with 1.5.0 in Arduino IDE.
324 RH_ASK driver works with this board, but since the timer interrupt
325 takes the timeout in milliseconds, not microseconds, the fastest bit rate
326 we can support is 1000 / 8 = 125 bits per second.
327
328Other platforms are partially supported, such as Generic AVR 8 bit processors, MSP430.
329We welcome contributions that will expand the range of supported platforms.
330
331If your processor is not on the list above, there is a good chance it
332wont work without modifying RadioHead to suit it. If you wish for
333support for another processor, and you send 2 of them to
334AirSpayce Pty Ltd, we will consider adding support for it.
335
336RadioHead is available (through the efforts of others)
337for PlatformIO. PlatformIO is a cross-platform code builder and the missing library manager.
338https://platformio.org/#!/lib/show/124/RadioHead
339
340\par History
341
342RadioHead was created in April 2014, substantially based on code from some of our other earlier Radio libraries:
343
344- RHMesh, RHRouter, RHReliableDatagram and RHDatagram are derived from the RF22 library version 1.39.
345- RH_RF22 is derived from the RF22 library version 1.39.
346- RH_RF69 is derived from the RF69 library version 1.2.
347- RH_ASK is based on the VirtualWire library version 1.26, after significant conversion to C++.
348- RH_Serial was new.
349- RH_NRF24 is based on the NRF24 library version 1.12, with some significant changes.
350
351During this combination and redevelopment, we have tried to retain all the processor dependencies and support from
352the libraries that were contributed by other people. However not all platforms can be tested by us, so if you
353find that support from some platform has not been successfully migrated, please feel free to fix it and send us a
354patch.
355
356Users of RHMesh, RHRouter, RHReliableDatagram and RHDatagram in the previous RF22 library will find that their
357existing code will run mostly without modification. See the RH_RF22 documentation for more details.
358
359\par Installation
360
361For Arduino IDE, install in the usual way: unzip the distribution zip file to the libraries
362sub-folder of your sketchbook.
363The example sketches will be visible in in your Arduino, mpide, maple-ide or whatever.
364https://arduino.cc/en/Guide/Libraries
365
366\par Building for Particle Photon
367
368The Photon is not supported by the Arduino IDE, so it takes a little effort to set up a build environment.
369Heres what we did to enable building of RadioHead example sketches on Linux,
370but there are other ways to skin this cat.
371Basic reference for getting started is: https://particle-firmware.readthedocs.org/en/develop/build/
372- Download the ARM gcc cross compiler binaries and unpack it in a suitable place:
373\code
374cd /tmp
375wget https://launchpad.net/gcc-arm-embedded/5.0/5-2015-q4-major/+download/gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2
376tar xvf gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2
377\endcode
378- If dfu-util and friends not installed on your platform, download dfu-util and friends to somewhere in your path
379\code
380cd ~/bin
381wget https://dfu-util.sourceforge.net/releases/dfu-util-0.8-binaries/linux-i386/dfu-util
382wget https://dfu-util.sourceforge.net/releases/dfu-util-0.8-binaries/linux-i386/dfu-suffix
383wget https://dfu-util.sourceforge.net/releases/dfu-util-0.8-binaries/linux-i386/dfu-prefix
384\endcode
385- Download the Particle firmware (contains headers and libraries require to compile Photon sketches)
386 to a suitable place:
387\code
388cd /tmp
389wget https://github.com/spark/firmware/archive/develop.zip
390unzip develop.zip
391\endcode
392- Make a working area containing the RadioHead library source code and your RadioHead sketch. You must
393 rename the sketch from .pde or .ino to application.cpp
394\code
395cd /tmp
396mkdir RadioHead
397cd RadioHead
398cp /usr/local/projects/arduino/libraries/RadioHead/ *.h .
399cp /usr/local/projects/arduino/libraries/RadioHead/ *.cpp .
400cp /usr/local/projects/arduino/libraries/RadioHead/examples/cc110/cc110_client/cc110_client.pde application.cpp
401\endcode
402- Edit application.cpp and comment out any \#include <SPI.h> so it looks like:
403\code
404 // #include <SPI.h>
405\endcode
406- Connect your Photon by USB. Put it in DFU mode as descibed in Photon documentation. Light should be flashing yellow
407- Compile the RadioHead sketch and install it as the user program (this does not update the rest of the
408 Photon firmware, just the user part:
409\code
410cd /tmp/firmware-develop/main
411PATH=$PATH:/tmp/gcc-arm-none-eabi-5_2-2015q4/bin make APPDIR=/tmp/RadioHead all PLATFORM=photon program-dfu
412\endcode
413- You should see RadioHead compile without errors and download the finished sketch into the Photon.
414
415\par Compatible Hardware Suppliers
416
417We have had good experiences with the following suppliers of RadioHead compatible hardware:
418
419- LittleBird https://littlebirdelectronics.com.au in Australia for all manner of Arduinos and radios.
420- LowPowerLab https://lowpowerlab.com/moteino in USA for the excellent Moteino and Moteino-USB
421 boards which include Hope-RF RF69B radios on-board.
422- Anarduino and HopeRF USA (https://www.hoperfusa.com and https://www.anarduino.com) who have a wide range
423 of HopeRF radios and Arduino integrated modules.
424- SparkFun https://www.sparkfun.com/ in USA who design and sell a wide range of Arduinos and radio modules.
425- Wisen https://wisen.com.au who design and sell a wide range of integrated radio/processor modules including the
426 excellent Talk2 range.
427
428\par Coding Style
429
430RadioHead is designed so it can run on small processors with very
431limited resources and strict timing contraints. As a result, we
432tend only to use the simplest and least demanding (in terms of memory and CPU) C++
433facilities. In particular we avoid as much as possible dynamic
434memory allocation, and the use of complex objects like C++
435strings, IO and buffers. We are happy with this, but we are aware
436that some people may think we are leaving useful tools on the
437table. You should not use this code as an example of how to do
438generalised C++ programming on well resourced processors.
439
440\par Code Contributions
441
442We welcome, and will consider for merging into the mainline, contributions of fixes, patches, improvements etc.
443that meet the following criteria:
444
445- Are generally useful to more than a few people.
446- Are thoroughly tested.
447- Dont break anything else.
448- Are backwards compatible.
449- Are properly and completely documented.
450- Conform to the coding style of the rest of the library.
451- Clearly transfer the ownership of the intellectual property to Mike McCauley.
452- Are posted on the Google group as a patch in unified Diff format,
453 made against the latest version of the library, downloaded from airspayce.com, as described above.
454
455There is currently no known fully up-to-date git repository, and at
456present we have no intentions of making one ourselves.
457
458\par Donations
459
460This library is offered under a free GPL license for those who want to use it that way.
461We try hard to keep it up to date, fix bugs
462and to provide free support. If this library has helped you save time or money, please consider donating at
463https://www.airspayce.com or here:
464
465\htmlonly <form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_donations" /> <input type="hidden" name="business" value="mikem@airspayce.com" /> <input type="hidden" name="lc" value="AU" /> <input type="hidden" name="item_name" value="Airspayce" /> <input type="hidden" name="item_number" value="RadioHead" /> <input type="hidden" name="currency_code" value="USD" /> <input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHosted" /> <input type="image" alt="PayPal — The safer, easier way to pay online." name="submit" src="https://www.paypalobjects.com/en_AU/i/btn/btn_donateCC_LG.gif" /> <img alt="" src="https://www.paypalobjects.com/en_AU/i/scr/pixel.gif" width="1" height="1" border="0" /></form> \endhtmlonly
466
467\subpage packingdata "Passing Sensor Data Between RadioHead nodes"
468
469\par Trademarks
470
471RadioHead is a trademark of AirSpayce Pty Ltd. The RadioHead mark was first used on April 12 2014 for
472international trade, and is used only in relation to data communications hardware and software and related services.
473It is not to be confused with any other similar marks covering other goods and services.
474
475\par Copyright
476
477This software is Copyright (C) 2011-2022 Mike McCauley. Use is subject to license
478conditions. The main licensing options available are GPL V3 or Commercial:
479
480\par Open Source Licensing GPL V3
481
482This is the appropriate option if you want to share the source code of your
483application with everyone you distribute it to, and you also want to give them
484the right to share who uses it. If you wish to use this software under Open
485Source Licensing, you must contribute all your source code to the open source
486community in accordance with the GPL Version 3 when your application is
487distributed. See https://www.gnu.org/licenses/gpl-3.0.html
488
489\par Commercial Licensing
490
491This is the appropriate option if you are creating proprietary applications
492and you are not prepared to distribute and share the source code of your
493application. To purchase a commercial license, contact info@airspayce.com
494
495\par Revision History
496\version 1.1 2014-04-14<br>
497 Initial public release
498\version 1.2 2014-04-23<br>
499 Fixed various typos. <br>
500 Added links to compatible Anarduino products.<br>
501 Added RHNRFSPIDriver, RH_NRF24 classes to support Nordic NRF24 based radios.
502\version 1.3 2014-04-28<br>
503 Various documentation fixups.<br>
504 RHDatagram::setThisAddress() did not set the local copy of thisAddress. Reported by Steve Childress.<br>
505 Fixed a problem on Teensy with RF22 and RF69, where the interrupt pin needs to be set for input, <br>
506 else pin interrupt doesn't work properly. Reported by Steve Childress and patched by
507 Adrien van den Bossche. Thanks.<br>
508 Fixed a problem that prevented RF22 honouring setPromiscuous(true). Reported by Steve Childress.<br>
509 Updated documentation to clarify some issues to do with maximum message lengths
510 reported by Steve Childress.<br>
511 Added support for yield() on systems that support it (currently Arduino 1.5.5 and later)
512 so that spin-loops can suport multitasking. Suggested by Steve Childress.<br>
513 Added RH_RF22::setGpioReversed() so the reversal it can be configured at run-time after
514 radio initialisation. It must now be called _after_ init(). Suggested by Steve Childress.<br>
515\version 1.4 2014-04-29<br>
516 Fixed further problems with Teensy compatibility for RH_RF22. Tested on Teensy 3.1.
517 The example/rf22_* examples now run out of the box with the wiring connections as documented for Teensy
518 in RH_RF22.<br>
519 Added YIELDs to spin-loops in RHRouter, RHMesh and RHReliableDatagram, RH_NRF24.<br>
520 Tested RH_Serial examples with Teensy 3.1: they now run out of the box.<br>
521 Tested RH_ASK examples with Teensy 3.1: they now run out of the box.<br>
522 Reduced default SPI speed for NRF24 from 8MHz to 1MHz on Teensy, to improve reliability when
523 poor wiring is in use.<br>
524 on some devices such as Teensy.<br>
525 Tested RH_NRF24 examples with Teensy 3.1: they now run out of the box.<br>
526\version 1.5 2014-04-29<br>
527 Added support for Nordic Semiconductor nRF905 transceiver with RH_NRF905 driver. Also
528 added examples for nRF905 and tested on Teensy 3.1
529\version 1.6 2014-04-30<br>
530 NRF905 examples were missing
531\version 1.7 2014-05-03<br>
532 Added support for Arduino Due. Tested with RH_NRF905, RH_Serial, RH_ASK.
533 IMPORTANT CHANGE to interrupt pins on Arduino with RH_RF22 and RH_RF69 constructors:
534 previously, you had to specify the interrupt _number_ not the interrupt _pin_. Arduinos and Uno32
535 are now consistent with all other platforms: you must specify the interrupt pin number. Default
536 changed to pin 2 (a common choice with RF22 shields).
537 Removed examples/maple/maple_rf22_reliable_datagram_client and
538 examples/maple/maple_rf22_reliable_datagram_client since the rf22 examples now work out
539 of the box with Flymaple.
540 Removed examples/uno32/uno32_rf22_reliable_datagram_client and
541 examples/uno32/uno32_rf22_reliable_datagram_client since the rf22 examples now work out
542 of the box with ChipKit Uno32.
543\version 1.8 2014-05-08 <br>
544 Added support for YIELD in Teensy 2 and 3, suggested by Steve Childress.<br>
545 Documentation updates. Clarify use of headers and Flags<br>
546 Fixed misalignment in RH_RF69 between ModemConfigChoice definitions and the implemented choices
547 which meant you didnt get the choice you thought and GFSK_Rb55555Fd50 hung the transmitter.<br>
548 Preliminary work on Linux simulator.
549\version 1.9 2014-05-14 <br>
550 Added support for using Timer 2 instead of Timer 1 on Arduino in RH_ASK when
551 RH_ASK_ARDUINO_USE_TIMER2 is defined. With the kind assistance of
552 Luc Small. Thanks!<br>
553 Updated comments in RHReliableDatagram concerning servers, retries, timeouts and delays.
554 Fixed an error in RHReliableDatagram where recvfrom return value was not checked.
555 Reported by Steve Childress.<br>
556 Added Linux simulator support so simple RadioHead sketches can be compiled and run on Linux.<br>
557 Added RH_TCP driver to permit message passing between simulated sketches on Linux.<br>
558 Added example simulator sketches.<br>
559 Added tools/etherSimulator.pl, a simulator of the 'Luminiferous Ether' that passes
560 messages between simulated sketches and can simulate random message loss etc.<br>
561 Fixed a number of typos and improved some documentation.<br>
562\version 1.10 2014-05-15 <br>
563 Added support for RFM73 modules to RH_NRF24. These 2 radios are very similar, and can interoperate
564 with each other. Added new RH_NRF24::TransmitPower enums for the RFM73, which has a different
565 range of available powers<br>
566 reduced the default SPI bus speed for RH_NRF24 to 1MHz, since so many modules and CPU have problems
567 with 8MHz.<br>
568\version 1.11 2014-05-18<br>
569 Testing RH_RF22 with RFM23BP and 3.3V Teensy 3.1 and 5V Arduinos.
570 Updated documentation with respect to GPIO and antenna
571 control pins for RFM23. Updated documentation with respect to transmitter power control for RFM23<br>
572 Fixed a problem with RH_RF22 driver, where GPIO TX and RX pins were not configured during
573 initialisation, causing poor transmit power and sensitivity on those RF22/RF23 devices where GPIO controls
574 the antenna selection pins.
575\version 1.12 2014-05-20<br>
576 Testing with RF69HW and the RH_RF69 driver. Works well with the Anarduino MiniWireless -CW and -HW
577 boards https://www.anarduino.com/miniwireless/ including
578 the marvellous high powered MinWireless-HW (with 20dBm output for excellent range).<br>
579 Clarified documentation of RH_RF69::setTxPower values for different models of RF69.<br>
580 Added RHReliableDatagram::resetRetransmissions().<br>
581 Retransmission count precision increased to uin32_t.<br>
582 Added data about actual power measurements from RFM22 module.<br>
583\version 1.13 2014-05-23<br>
584 setHeaderFlags(flags) changed to setHeaderFlags(set, clear), enabling any flags to be
585 individually set and cleared by either RadioHead or application code. Requested by Steve Childress.<br>
586 Fixed power output setting for boost power on RF69HW for 18, 19 and 20dBm.<br>
587 Added data about actual power measurements from RFM69W and RFM69HW modules.<br>
588\version 1.14 2014-05-26<br>
589 RH_RF69::init() now always sets the PA boost back to the default settings, else can get invalid
590 PA power modes after uploading new sketches without a power cycle. Reported by Bryan.<br>
591 Added new macros RH_VERSION_MAJOR RH_VERSION_MINOR, with automatic maintenance in Makefile.<br>
592 Improvements to RH_TCP: constructor now honours the server argument in the form "servername:port".<br>
593 Added YIELD to RHReliableDatagram::recvfromAckTimeout. Requested by Steve Childress.<br>
594 Fixed a problem with RH_RF22 reliable datagram acknowledgements that was introduced in version 1.13.
595 Reported by Steve Childress.<br>
596\version 1.15 2014-05-27<br>
597 Fixed a problem with the RadioHead .zip link.
598\version 1.16 2014-05-30 <br>
599 Fixed RH_RF22 so that lastRssi() returns the signal strength in dBm. Suggested by Steve Childress.<br>
600 Added support for getLastPreambleTime() to RH_RF69. Requested by Steve Childress.<br>
601 RH_NRF24::init() now checks if there is a device connected and responding, else init() will fail.
602 Suggested by Steve Brown.<br>
603 RHSoftwareSPI now initialises default values for SPI pins MOSI = 12, MISO = 11 and SCK = 13.<br>
604 Fixed some problems that prevented RH_NRF24 working with mixed software and hardware SPI
605 on different devices: a race condition
606 due to slow SPI transfers and fast acknowledgement.<br>
607\version 1.17 2014-06-02 <br>
608 Fixed a debug typo in RHReliableDatagram that was introduced in 1.16.<br>
609 RH_NRF24 now sets default power, data rate and channel in init(), in case another
610 app has previously set different values without powerdown.<br>
611 Caution: there are still problems with RH_NRF24 and Software SPI. Do not use.<br>
612\version 1.18 2014-06-02<br>
613 Improvements to performance of RH_NRF24 statusRead, allowing RH_NRF24 and Software SPI
614 to operate on slow devices like Arduino Uno.<br>
615\version 1.19 2014-06-19<br>
616 Added examples ask_transmitter.pde and ask_receiver.pde.<br>
617 Fixed an error in the RH_RF22 doc for connection of Teensy to RF22.<br>
618 Improved documentation of start symbol bit patterns in RH_ASK.cpp
619\version 1.20 2014-06-24<br>
620 Fixed a problem with compiling on platforms such as ATtiny where SS is not defined.<br>
621 Added YIELD to RHMesh::recvfromAckTimeout().<br>
622\version 1.21 2014-06-24<br>
623 Fixed an issue in RH_Serial where characters might be lost with back-to-back frames.
624 Suggested by Steve Childress.<br>
625 Brought previous RHutil/crc16.h code into mainline RHCRC.cpp to prevent name collisions
626 with other similarly named code in other libraries. Suggested by Steve Childress.<br>
627k Fix SPI bus speed errors on 8MHz Arduinos.
628\version 1.22 2014-07-01<br>
629 Update RH_ASK documentation for common wiring connections.<br>
630 Testing RH_ASK with HopeRF RFM83C/RFM85 courtesy Anarduino https://www.anarduino.com/<br>
631 Testing RH_NRF24 with Itead Studio IBoard Pro https://imall.iteadstudio.com/iboard-pro.html
632 using both hardware SPI on the ITDB02 Parallel LCD Module Interface pins and software SPI
633 on the nRF24L01+ Module Interface pins. Documented wiring required.<br>
634 Added support for AVR 1284 and 1284p, contributed by Peter Scargill.
635 Added support for Semtech SX1276/77/78 and HopeRF RFM95/96/97/98 and other similar LoRa capable radios
636 in LoRa mode only. Tested with the excellent MiniWirelessLoRa from
637 Anarduino https://www.anarduino.com/miniwireless<br>
638\version 1.23 2014-07-03<br>
639 Changed the default modulation for RH_RF69 to GFSK_Rb250Fd250, since the previous default
640 was not very reliable.<br>
641 Documented RH_RF95 range tests.<br>
642 Improvements to RH_RF22 RSSI readings so that lastRssi correctly returns the last message in dBm.<br>
643\version 1.24 2014-07-18
644 Added support for building RadioHead for STM32F4 Discovery boards, using the native STM Firmware libraries,
645 in order to support Codec2WalkieTalkie (https://www.airspayce.com/mikem/Codec2WalkieTalkie)
646 and other projects. See STM32ArduinoCompat.<br>
647 Default modulation for RH_RF95 was incorrectly set to a very slow Bw125Cr48Sf4096
648\version 1.25 2014-07-25
649 The available() function will longer terminate any current transmission, and force receive mode.
650 Now, if there is no unprocessed incoming message and an outgoing message is currently being transmitted,
651 available() will return false.<br>
652 RHRouter::sendtoWait(uint8_t*, uint8_t, uint8_t, uint8_t) renamed to sendtoFromSourceWait due to conflicts
653 with new sendtoWait() with optional flags.<br>
654 RHMEsh and RHRouter already supported end-to-end application layer flags, but RHMesh::sendtoWait()
655 and RHRouter::sendToWait have now been extended to expose a way to send optional application layer flags.
656\version 1.26 2014-08-12
657 Fixed a Teensy 2.0 compile problem due yield() not available on Teensy < 3.0. <br>
658 Adjusted the algorithm of RH_RF69::temperatureRead() to more closely reflect reality.<br>
659 Added functions to RHGenericDriver to get driver packet statistics: rxBad(), rxGood(), txGood().<br>
660 Added RH_RF69::printRegisters().<br>
661 RH_RF95::printRegisters() was incorrectly printing the register index instead of the address.
662 Reported by Phang Moh Lim.<br>
663 RH_RF95, added definitions for some more registers that are usable in LoRa mode.<br>
664 RH_RF95::setTxPower now uses RH_RF95_PA_DAC_ENABLE to achieve 21, 22 and 23dBm.<br>
665 RH_RF95, updated power output measurements.<br>
666 Testing RH_RF69 on Teensy 3.1 with RF69 on PJRC breakout board. OK.<br>
667 Improvements so RadioHead will build under Arduino where SPI is not supported, such as
668 ATtiny.<br>
669 Improvements so RadioHead will build for ATTiny using Arduino IDE and tinycore arduino-tiny-0100-0018.zip.<br>
670 Testing RH_ASK on ATTiny85. Reduced RAM footprint.
671 Added helpful documentation. Caution: RAM memory is *very* tight on this platform.<br>
672 RH_RF22 and RH_RF69, added setIdleMode() function to allow the idle mode radio operating state
673 to be controlled for lower idle power consumption at the expense of slower transitions to TX and RX.<br>
674\version 1.27 2014-08-13
675 All RH_RF69 modulation schemes now have data whitening enabled by default.<br>
676 Tested and added a number of OOK modulation schemes to RH_RF69 Modem config table.<br>
677 Minor improvements to a number of the faster RH_RF69 modulation schemes, but some slower ones
678 are still not working correctly.<br>
679\version 1.28 2014-08-20
680 Added new RH_RF24 driver to support Si446x, RF24/26/26, RFM24/26/27 family of transceivers.
681 Tested with the excellent
682 Anarduino Mini and RFM24W and RFM26W with the generous assistance of the good people at
683 Anarduino https://www.anarduino.com.
684\version 1.29 2014-08-21
685 Fixed a compile error in RH_RF24 introduced at the last minute in hte previous release.<br>
686 Improvements to RH_RF69 modulation schemes: now include the AFCBW in teh ModemConfig.<br>
687 ModemConfig RH_RF69::FSK_Rb2Fd5 and RH_RF69::GFSK_Rb2Fd5 are now working.<br>
688\version 1.30 2014-08-25
689 Fixed some compile problems with ATtiny84 on Arduino 1.5.5 reported by Glen Cook.<br>
690\version 1.31 2014-08-27
691 Changed RH_RF69 FSK and GFSK modulations from Rb2_4Fd2_4 to Rb2_4Fd4_8 and FSK_Rb4_8Fd4_8 to FSK_Rb4_8Fd9_6
692 since the previous ones were unreliable (they had modulation indexes of 1).<br>
693\version 1.32 2014-08-28
694 Testing with RedBearLab Blend board https://redbearlab.com/blend/. OK.<br>
695 Changed more RH_RF69 FSK and GFSK slowish modulations to have modulation index of 2 instead of 1.
696 This required chnaging the symbolic names.<br>
697\version 1.33 2014-09-01
698 Added support for sleep mode in RHGeneric driver, with new mode
699 RHModeSleep and new virtual function sleep().<br>
700 Added support for sleep to RH_RF69, RH_RF22, RH_NRF24, RH_RF24, RH_RF95 drivers.<br>
701\version 1.34 2014-09-19
702 Fixed compile errors in example rf22_router_test.<br>
703 Fixed a problem with RH_NRF24::setNetworkAddress, also improvements to RH_NRF24 register printing.
704 Patched by Yveaux.<br>
705 Improvements to RH_NRF24 initialisation for version 2.0 silicon.<br>
706 Fixed problem with ambigiguous print call in RH_RFM69 when compiling for Codec2.<br>
707 Fixed a problem with RH_NRF24 on RFM73 where the LNA gain was not set properly, reducing the sensitivity
708 of the receiver.
709\version 1.35 2014-09-19
710 Fixed a problem with interrupt setup on RH_RF95 with Teensy3.1. Reported by AD.<br>
711\version 1.36 2014-09-22
712 Improvements to interrupt pin assignments for __AVR_ATmega1284__ and__AVR_ATmega1284P__, provided by
713 Peter Scargill.<br>
714 Work around a bug in Arduino 1.0.6 where digitalPinToInterrupt is defined but NOT_AN_INTERRUPT is not.<br>
715 \version 1.37 2014-10-19
716 Updated doc for connecting RH_NRF24 to Arduino Mega.<br>
717 Changes to RHGenericDriver::setHeaderFlags(), so that the default for the clear argument
718 is now RH_FLAGS_APPLICATION_SPECIFIC, which is less surprising to users.
719 Testing with the excellent MoteinoMEGA from LowPowerLab
720 https://lowpowerlab.com/shop/moteinomega with on-board RFM69W.
721 \version 1.38 2014-12-29
722 Fixed compile warning on some platforms where RH_RF24::send and RH_RF24::writeTxFifo
723 did not return a value.<br>
724 Fixed some more compiler warnings in RH_RF24 on some platforms.<br>
725 Refactored printRegisters for some radios. Printing to Serial
726 is now controlled by the definition of RH_HAVE_SERIAL.<br>
727 Added partial support for ARM M4 w/CMSIS with STM's Hardware Abstraction lib for
728 Steve Childress.<br>
729 \version 1.39 2014-12-30
730 Fix some compiler warnings under IAR.<br>
731 RH_HAVE_SERIAL and Serial.print calls removed for ATTiny platforms.<br>
732 \version 1.40 2015-03-09
733 Added notice about availability on PlatformIO, thanks to Ivan Kravets.<br>
734 Fixed a problem with RH_NRF24 where short packet lengths would occasionally not be trasmitted
735 due to a race condition with RH_NRF24_TX_DS. Reported by Mark Fox.<br>
736 \version 1.41 2015-03-29
737 RH_RF22, RH_RF24, RH_RF69 and RH_RF95 improved to allow driver.init() to be called multiple
738 times without reallocating a new interrupt, allowing the driver to be reinitialised
739 after sleeping or powering down.
740 \version 1.42 2015-05-17
741 Added support for RH_NRF24 driver on Raspberry Pi, using BCM2835
742 library for GPIO pin IO. Contributed by Mike Poublon.<br>
743 Tested RH_NRF24 module with NRF24L01+PA+LNA SMA Antenna Wireless Transceiver modules
744 similar to: https://www.elecfreaks.com/wiki/index.php?title=2.4G_Wireless_nRF24L01p_with_PA_and_LNA
745 works with no software changes. Measured max power output 18dBm.<br>
746 \version 1.43 2015-08-02
747 Added RH_NRF51 driver to support Nordic nRF51 family processor with 2.4GHz radio such
748 as nRF51822, to be built on Arduino 1.6.4 and later. Tested with RedBearLabs nRF51822 board
749 and BLE Nano kit<br>
750 \version 1.44 2015-08-08
751 Fixed errors with compiling on some platforms without serial, such as ATTiny.
752 Reported by Friedrich Müller.<br>
753 \version 1.45 2015-08-13
754 Added support for using RH_Serial on Linux and OSX (new class RHutil/HardwareSerial
755 encapsulates serial ports on those platforms). Example examples/serial upgraded
756 to build and run on Linux and OSX using the tools/simBuild builder.
757 RHMesh, RHRouter and RHReliableDatagram updated so they can use RH_Serial without
758 polling loops on Linux and OSX for CPU efficiency.<br>
759 \version 1.46 2015-08-14
760 Amplified some doc concerning Linux and OSX RH_Serial. Added support for 230400
761 baud rate in HardwareSerial.<br>
762 Added sample sketches nrf51_audio_tx and nrf51_audio_rx which show how to
763 build an audio TX/RX pair with RedBear nRF51822 boards and a SparkFun MCP4725 DAC board.
764 Uses the built-in ADC of the nRF51822 to sample audio at 5kHz and transmit packets
765 to the receiver which plays them via the DAC.<br>
766\version 1.47 2015-09-18
767 Removed top level Makefile from distribution: its only used by the developer and
768 its presence confuses some people.<br>
769 Fixed a problem with RHReliableDatagram with some versions of Raspberry Pi random() that causes
770 problems: random(min, max) sometimes exceeds its max limit.
771\version 1.48 2015-09-30
772 Added support for Arduino Zero. Tested on Arduino Zero Pro.
773\version 1.49 2015-10-01
774 Fixed problems that prevented interrupts working correctly on Arduino Zero and Due.
775 Builds and runs with 1.6.5 (with 'Arduino SAMD Boards' for Zero version 1.6.1) from arduino.cc.
776 Arduino version 1.7.7 from arduino.org is not currently supported.
777\version 1.50 2015-10-25
778 Verified correct building and operation with Arduino 1.7.7 from arduino.org.
779 Caution: You must burn the bootloader from 1.7.7 to the Arduino Zero before it will
780 work with Arduino 1.7.7 from arduino.org. Conversely, you must burn the bootloader from 1.6.5
781 to the Arduino Zero before it will
782 work with Arduino 1.6.5 from arduino.cc. Sigh.
783 Fixed a problem with RH_NRF905 that prevented the power and frequency ranges being set
784 properly. Reported by Alan Webber.
785\version 1.51 2015-12-11
786 Changes to RH_RF6::setTxPower() to be compatible with SX1276/77/78/79 modules that
787 use RFO transmitter pins instead of PA_BOOST, such as the excellent
788 Modtronix inAir4 https://modtronix.com/inair4.html
789 and inAir9 modules https://modtronix.com/inair9.html. With the kind assistance of
790 David from Modtronix.
791\version 1.52 2015-12-17
792 Added RH_MRF89 module to suport Microchip MRF89XA and compatible transceivers.
793 and modules.<br>
794\version 1.53 2016-01-02
795 Added RH_CC110 module to support Texas Instruments CC110L and compatible transceivers and modules.<br>
796\version 1.54 2016-01-29
797 Added support for ESP8266 processor on Arduino IDE. Examples serial_reliable_datagram_* are shown to work.
798 CAUTION: SPI not supported yet. Timers used by RH_ASK are not tested.
799 The GHz radio included in the ESP8266 is not yet supported.
800\version 1.55 2016-02-12
801 Added macros for htons() and friends to RadioHead.h.
802 Added example sketch serial_gateway.pde. Acts as a transparent gateway between RH_RF22 and RH_Serial,
803 and with minor mods acts as a universal gateway between any 2 RadioHead driver networks.
804 Initial work on supporting STM32 F2 on Particle Photon: new platform type defined.
805 Fixed many warnings exposed by test building for Photon.
806 Particle Photon tested support for RH_Serial, RH_ASK, SPI, RH_CC110 etc.
807 Added notes on how to build RadioHead sketches for Photon.
808\version 1.56 2016-02-18
809 Implemented timers for RH_ASK on ESP8266, added some doc on IO pin selection.
810\version 1.57 2016-02-23
811 Fixed an issue reported by S3B, where RH_RF22 would sometimes not clear the rxbufvalid flag.
812\version 1.58 2-16-04-04
813 Tested RH_RF69 with Arduino Due. OK. Updated doc.<br>
814 Added support for all ChipKIT Core supported boards
815 https://chipkit.net/wiki/index.php?title=ChipKIT_core
816 Tested on ChipKIT Uno32.<br>
817 Digilent Uno32 under the old MPIDE is no longer formally
818 supported but may continue to work for some time.<br>
819\version 1.59 2016-04-12
820 Testing with the excellent Rocket Scream Mini Ultra Pro with the RFM95W and RFM69HCW modules from
821 https://www.rocketscream.com/blog/product/mini-ultra-pro-with-radio/ (915MHz versions). Updated
822 documentation with hints to suit. Caution: requires Arduino 1.6.8 and Arduino SAMD Boards 1.6.5.
823 See also https://www.rocketscream.com/blog/2016/03/10/radio-range-test-with-rfm69hcw/
824 for the vendors tests and range with the RFM69HCW version. They also have an RF95 version equipped with
825 TCXO temperature controllled oscillator for extra frequency stability and support of very slow and
826 long range protocols.
827 These boards are highly recommended. They also include battery charging support.
828\version 1.60 2016-06-25
829 Tested with the excellent talk2 Whisper Node boards
830 (https://talk2.wisen.com.au/ and https://bitbucket.org/talk2/),
831 an Arduino Nano compatible board, which include an on-board RF69 radio, external antenna,
832 run on 2xAA batteries and support low power operations. RF69 examples work without modification.
833 Added support for ESP8266 SPI, provided by David Skinner.
834\version 1.61 2016-07-07
835 Patch to RH_ASK.cpp for ESP8266, to prevent crashes in interrupt handlers. Patch from Alexander Mamchits.
836\version 1.62 2016-08-17
837 Fixed a problem in RH_ASK where _rxInverted was not properly initialised. Reported by "gno.sun.sop".
838 Added support for waitCAD() and isChannelActive() and setCADTimeout() to RHGeneric.
839 Implementation of RH_RF95::isChannelActive() allows the RF95 module to support
840 Channel Activity Detection (CAD). Based on code contributed by Bent Guldbjerg Christensen.
841 Implmentations of isChannelActive() plus documentation for other radio modules wil be welcomed.
842\version 1.63 2016-10-20
843 Testing with Adafruit Feather 32u4 with RFM69HCW. Updated documentation to reflect.<br>
844\version 1.64 2016-12-10
845 RHReliableDatagram now initialises _seenids. Fix from Ben Lim.<br>
846 In RH_NRF51, added get_temperature().<br>
847 In RH_NRF51, added support for AES packet encryption, which required a slight change
848 to the on-air message format.<br>
849\version 1.65 2017-01-11
850 Fixed a race condition with RH_NRF51 that prevented ACKs being reliably received.<br>
851 Removed code in RH_NRF51 that enabled the DC-DC converter. This seems not to be a necessary condition
852 for the radio to work and is now left to the application if that is required.<br>
853 Proven interoperation between nRF51822 and nRF52832.<br>
854 Modification and testing of RH_NRF51 so it works with nRF52 family processors,
855 such Sparkfun nRF52832 breakout board, with Arduino 1.6.13 and
856 Sparkfun nRF52 boards manager 0.2.3 using the procedures outlined in
857 https://learn.sparkfun.com/tutorials/nrf52832-breakout-board-hookup-guide<br>
858 Caution, the Sparkfun development system for Arduino is still immature. We had to
859 rebuild the nrfutil program since the supplied one was not suitable for
860 the Linux host we were developing on. See https://forum.sparkfun.com/viewtopic.php?f=32&t=45071
861 Also, after downloading a sketch in the nRF52832, the program does not start executing cleanly:
862 you have to reset the processor again by pressing the reset button.
863 This appears to be a problem with nrfutil, rather than a bug in RadioHead.
864\version 1.66 2017-01-15
865 Fixed some errors in (unused) register definitions in RH_RF95.h.<br>
866 Fixed a problem that caused compilation errors in RH_NRF51 if the appropriate board
867 support was not installed.
868\version 1.67 2017-01-24
869 Added RH_RF95::frequencyError() to return the estimated centre frequency offset in Hz
870 of the last received message
871\version 1.68 2017-01-25
872 Fixed arithmetic error in RH_RF95::frequencyError() for some platforms.
873\version 1.69 2017-02-02
874 Added RH_RF95::lastSNR() and improved lastRssi() calculations per the manual.
875\version 1.70 2017-02-03
876 Added link to Binpress commercial license purchasing.
877\version 1.71 2017-02-07
878 Improved support for STM32. Patch from Bent Guldbjerg Christensen.
879\version 1.72 2017-03-02
880 In RH_RF24, fixed a problem where some important properties were not set by the ModemConfig.
881 Added properties 2007, 2008, 2009. Also properties 200a was not being set in the chip.
882 Reported by Shannon Bailey and Alan Adamson.
883 Fixed corresponding convert.pl and added it to the distribution.
884\version 1.73 2017-03-04
885 Significant changes to RH_RF24 and its API. It is no longer possible to change the modulation scheme
886 programatically: it proved impossible to cater for all the possible crystal frequencies,
887 base frequency and modulation schemes. Instead you can use one of a small set of supplied radio
888 configuration header files, or generate your own with Silicon Labs WDS application. Changing
889 modulation scheme required editing RH_RF24.cpp to specify the appropriate header and recompiling.
890 convert.pl is now redundant and removed from the distribution.
891\version 1.74 2017-03-08
892 Changed RHReliableDatagram so it would not ACK messages heard addressed to other nodes
893 in promiscuous mode.<br>
894 Added RH_RF24::deviceType() to return the integer value of the connected device.<br>
895 Added documentation about how to connect RFM69 to an ESP8266. Tested OK.<br>
896 RH_RF24 was not correctly changing state in sleep() and setModeIdle().<br>
897 Added example rf24_lowpower_client.pde showing how to put an arduino and radio into a low power
898 mode between transmissions to save battery power.<br>
899 Improvements to RH_RF69::setTxPower so it now takes an optional ishighpowermodule
900 flag to indicate if the connected module is a high power RFM69HW, and so set the power level
901 correctly. Based on code contributed by bob.
902\version 1.75 2017-06-22
903 Fixed broken compiler issues with RH_RF95::frequencyError() reported by Steve Rogerson.<br>
904 Testing with the very excellent Rocket Scream boards equipped with RF95 TCXO modules. The
905 temperature controlled oscillator stabilises the chip enough to be able to use even the slowest
906 protocol Bw125Cr48Sf4096. Caution, the TCXO model radios are not low power when in sleep (consuming
907 about ~600 uA, reported by Phang Moh Lim).<br>
908 Added support for EBYTE E32-TTL-1W and family serial radio transceivers. These RF95 LoRa based radios
909 can deliver reliable messages at up to 7km measured.
910\version 1.76 2017-06-23
911 Fixed a problem with RH_RF95 hanging on transmit under some mysterious circumstances.
912 Reported by several people at https://forum.pjrc.com/threads/41878-Probable-race-condition-in-Radiohead-library?p=146601#post146601 <br>
913 Increased the size of rssi variables to 16 bits to permit RSSI less than -128 as reported by RF95.
914\version 1.77 2017-06-25
915 Fixed a compilation error with lastRssi().<br>
916\version 1.78 2017-07-19
917 Fixed a number of unused variable warnings from g++.<br>
918 Added new module RHEncryptedDriver and examples, contributed by Philippe Rochat, which
919 adds encryption and decryption to any RadioHead transport driver, using any encryption cipher
920 supported by ArduinoLibs Cryptographic Library https://rweather.github.io/arduinolibs/crypto.html
921 Includes several examples.<br>
922\version 1.79 2017-07-25
923 Added documentation about 'Passing Sensor Data Between RadioHead nodes'.<br>
924 Changes to RH_CC110 driver to calculate RSSI in dBm, based on a patch from Jurie Pieterse.<br>
925 Added missing passthroughmethoids to RHEncryptedDriver, allowing it to be used with RHDatagram,
926 RHReliableDatagram etc. Tested with RH_Serial. Added examples
927\version 1.80 2017-10-04
928 Testing with the very fine Talk2 Whisper Node LoRa boards https://wisen.com.au/store/products/whisper-node-lora
929 an Arduino compatible board, which include an on-board RFM95/96 LoRa Radio (Semtech SX1276), external antenna,
930 run on 2xAAA batteries and support low power operations. RF95 examples work without modification.
931 Use Arduino Board Manager to install the Talk2 code support. Upload the code with an FTDI adapter set to 5V.<br>
932 Added support for SPI transactions in development environments that support it with SPI_HAS_TRANSACTION.
933 Tested on ESP32 with RFM-22 and Teensy 3.1 with RF69
934 Added support for ESP32, tested with RFM-22 connected by SPI.<br>
935\version 1.81 2017-11-15
936 RH_CC110, moved setPaTable() from protected to public.<br>
937 RH_RF95 modem config Bw125Cr48Sf4096 altered to enable slow daat rate in register 26
938 as suggested by Dieter Kneffel.
939 Added support for nRF52 compatible Arm chips such as as Adafruit BLE Feather board
940 https://www.adafruit.com/product/3406, with a patch from Mike Bell.<br>
941 Fixed a problem where rev 1.80 broke Adafruit M0 LoRa support by declaring
942 bitOrder variable always as a unsigned char. Reported by Guilherme Jardim.<br>
943 In RH_RF95, all modes now have AGC enabled, as suggested by Dieter Kneffel.<br>
944\version 1.82 2018-01-07
945 Added guard code to RH_NRF24::waitPacketSent() so that if the transmit never completes for some
946 reason, the code will eventually return with FALSE.
947 Added the low-datarate-optimization bit to config for RH_RF95::Bw125Cr48Sf4096.
948 Fix from Jurie Pieterse to ensure RH_CC110::sleep always enters sleep mode.
949 Update ESP32 support to include ASK timers. RH_ASK module is now working on ESP32.
950\version 1.83 2018-02-12
951 Testing adafruit M0 Feather with E32. Updated RH_E32 documentation to show suggested connections
952 and contructor initialisation.<br>
953 Fixed a problem with RHEncryptedDriver that could cause a crash on some platforms when used
954 with RHReliableDatagram. Reported by Joachim Baumann.<br>
955 Improvments to doxygen doc layout in RadioHead.h
956\version 1.84 2018-05-07
957 Compiles with Roger Clarkes Arduino_STM32 https://github.com/rogerclarkmelbourne/Arduino_STM32,
958 to support STM32F103C etc, and STM32 F4 Discovery etc.<br>
959 Tested STM32 F4 Discovery board with RH_RF22, RH_ASK and RH_Serial.
960
961\version 1.85 2018-07-09
962 RHGenericDriver methods changed to virtual, to allow overriding by RHEncrypredDriver:
963 lastRssi(), mode(), setMode(). Reported by Eyal Gal.<br>
964 Fixed a problem with compiling RH_E32 on some older IDEs, contributed by Philippe Rochat.<br>
965 Improvements to RH_RF95 to improve detection of bad packets, contributed by PiNi.<br>
966 Fixed an error in RHEncryptedDriver that caused incorrect message lengths for messages multiples of 16 bytes
967 when STRICT_CONTENT_LEN is defined.<br>
968 Fixed a bug in RHMesh which causes the creation of a route to the address which is the byte
969 behind the end of the route array. Reported by Pascal Gillès de Pélichy.<br>
970\version 1.86 2018-08-28
971 Update commercial licensing, remove binpress.
972\version 1.87 2018-10-06
973 RH_RF22 now resets all registers to default state before initialisation commences. Suggested by Wothke.<br>
974 Added RH_ENABLE_EXPLICIT_RETRY_DEDUP which improves the handling of duplicate detection especially
975 in the case where a transmitter periodically wakes up and start transmitting from the first sequence number.
976 Patch courtesy Justin Newitter. Thanks.
977\version 1.88 2018-11-13
978 Updated to support ATTiny using instructions in
979 https://medium.com/jungletronics/attiny85-easy-flashing-through-arduino-b5f896c48189
980 Updated examples ask_transmitter and ask_receiver to compile cleanly on ATTiny.
981 Tested using ATTiny85 and Arduino 1.8.1. <br>
982\version 1.89 2018-11-15
983 Testing with ATTiny core from https://github.com/SpenceKonde/ATTinyCore and RH_ASK,
984 using example ask_transmitter. This resulted in 'Low Memory, instability may occur',
985 and the resulting sketch would transmit only one packet. Suggest ATTiny users do not use this core, but use
986 the one from https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json
987 as described in https://medium.com/jungletronics/attiny85-easy-flashing-through-arduino-b5f896c48189 <br>
988 Added support for RH_RF95::setSpreadingFactor(), RH_RF95::setSignalBandwidth(), RH_RF95::setLowDatarate() and
989 RH_RF95::setPayloadCRC(). Patch from Brian Norman. Thanks.<br>
990
991\version 1.90 2019-05-21
992 Fixed a block size error in RhEncryptedDriver for the case when
993 using STRICT_CONTENT_LEN and sending messages of exactly _blockcipher.blockSize() bytes in length.
994 Reported and patched by Philippe Rochat.
995 Patch from Samuel Archibald to prevent compile errors with RH_AAK.cpp fo ATSAMD51.
996 Fixed a probem in RH_RF69::setSyncWords that prevented setSyncWords(NULL, 0) correctly
997 disabling sync detection and generation. Reported by Federico Maggi.
998 RHHardwareSPI::usingInterrupt() was a noop. Fixed to call SPI.usingInterrupt(interrupt);.
999
1000\version 1.91 2019-06-01
1001 Fixed a problem with new RHHardwareSPI::usingInterrupt() that prevented compilation on ESP8266
1002 which does not have that call.
1003
1004\version 1.92 2019-07-14
1005 Retested serial_reliable_datagram_client.pde and serial_reliable_datagram_server.pde built on Linux
1006 as described in their headers, and with USB-RS485 adapters. No changes, working correctly.
1007 Testing of nRF5232 with Sparkfun nRF52 board support 0.2.3 shows that there appears to be a problem with
1008 interrupt handlers on this board, and none of the interrupt based radio drivers can be expected to work
1009 with this chip.
1010 Ensured all interrupt routines are flagged with ICACHE_RAM_ATTR when compiled for ESP8266, to prevent crashes.
1011
1012\version 1.94 2019-09-02
1013 Fixed a bug in RHSoftwareSPI where RHGenericSPI::setBitOrder() has no effect for
1014 on RHSoftwareSPI. Reported by Peter.<br>
1015 Added support in RHRouter for a node to optionally be leaf node, and not participate as a router in the
1016 network. See RHRouter::setNodeTypePatch from Alex Evans.<br>
1017 Fixed a problem with ESP32 causing compile errors over missing SPI.usingInterrupt().<br>
1018
1019\version 1.95 2019-10-14
1020 Fixed some typos in RH_RF05.h macro definitions reported by Clayton Smith.<br>
1021 Patch from Michael Cain from RH_ASK on ESP32, untested by me.<br>
1022 Added support for RPi Zero and Zero W for the RF95, contributed by Brody Mahoney.
1023 Not tested by me.<br>
1024
1025\version 1.96 2019-10-14
1026 Added examples for RPi Zero and Zero W to examples/raspi/rf95, contributed by Brody Mahoney
1027 not tested by me. <br>
1028
1029\version 1.97 2019-11-02
1030 Added support for Mongoose OS, contributed by Paul Austen.
1031
1032\version 1.98 2020-01-06
1033 Rationalised use of RH_PLATFORM_ATTINY to be consistent with other platforms.<br>
1034 Added support for RH_PLATFORM_ATTINY_MEGA, for use with Spencer Konde's megaTinyCore
1035 https://github.com/SpenceKonde/megaTinyCore on Atmel megaAVR ATtiny 1-series chips.
1036 Tested with AtTiny 3217, 3216 and 1614, using
1037 RH_Serial, RH_ASK, and RH_RF22 drivers.<br>
1038
1039\version 1.99 2020-03-07
1040 Release under GPL V3
1041
1042\version 1.100 2020-03-12
1043 Fixed a problem that prevented compilation of RH_NRF51
1044 on Arduino for Sparkfun nRF52832 Breakout board.<br>
1045
1046\version 1.101 2020-04-10
1047 Tested nRF52832 with RFM69W module and RH_RF69, using Software SPI and hardware interrutps OK.<br>
1048 Fixed warnings about 'deleting object of polymorphic class' if driver is dynamically allocated.<br>
1049 Fixed problems in RH_ASK and HardwareSPI to work with STM32F4 Discovery with latest
1050 version of stm32duino https://github.com/stm32duino/Arduino_Core_STM32.
1051 Testing with stm32duino 1.8.0 downloaded with Board Manager per
1052 https://github.com/stm32duino/Arduino_Core_STM32 .
1053 Now builds and run RH_ASK examples with STM32F4 Discovery board.
1054 Build without error for STM32 F1 and F4 but Does not compile for Generic STM32F3.
1055
1056\version 1.102 2020-05-15
1057 Updated RH_RF95::setPayloadCRC to affect CRC generation on outgoing packets as well
1058 as CRC detection and checking on incoming packets.
1059 Added new modem config for RH_RF95. RH_RF95::Bw125Cr45Sf2048
1060 Bw = 125 kHz, Cr = 4/5, Sf = 2048chips/symbol, CRC on. Slow+long range. Tested
1061 against RPI with LoRa-file-ops driver https://github.com/starnight/LoRa/tree/file-ops
1062 and send.c test program.
1063 Fixed a problem with (re-)definition of SS on ESP32, reported and fixed by Justin Newitter.
1064
1065\version 1.103 2020-05-30
1066 Fixed some errors in RH_RF95::setTxPower which cased the power levels to be set incorrectly.
1067 Checked operation and improved documentation. Valid settings are:
1068 2 to 20 (useRFO false) and 0 to 15 (useRFO true). 18, 19 and 20 (useRFO false) turn on the PA_DAC.
1069 Fixed RF95 examples to reflect correct use.
1070 Added RH_ABZ driver, which supports the muRata CMWX1ZZABZ (TypeABZ) module
1071 which includes an STM32L0 processor, a SX1276 LoRa radio and an antenna switch.
1072 Requires the Grumpy Old Pizza Arduino Core installed per https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0
1073 Examples provided.
1074
1075\version 1.104 2020-06-08
1076 Fixed a problem with new RH_ABZ module that prevents compilation with standard 0.0.10 version of STM32L0 <br>
1077 Arduino Core installed with Board Manager: STM32L0_EXTI_CONTROL_PRIORITY_CRITICAL
1078 is only available in later versions.<br>
1079
1080\version 1.105 2020-06-03
1081 Added support for RH_ABZ on STM32L072xx on Grumpy Old Pizza Arduino Core<br>
1082
1083\version 1.106 2020-06-16
1084 Patch from Livio Tenze for RH_RF22 to fix a problem with interrupts on on ESP8266.<br>
1085 Added examples/rf22/rf22_cw, with example showing how to emit a carrier wave (CW).<br>
1086 Reverted delay in RHSPIDriver::init() back to 100ms for all platforms except ABZ, where
1087 100ms interferes with the USB serial port with at least some versions of the core.<br>
1088 Updated and clarified documentation about TCXO use in RH_ABZ and examples.<br>
1089 Fixed documentation SS->NSEL pin for RH_RF22 with AtMega. Seems that SS on that platform
1090 is now defined as pin 10, not 53. Dont know when that changed.<br>
1091
1092\version 1.107 2020-06-26
1093 Improvements to RHEncryptedDriver, so that you will get an explanatory error message if you
1094 include RHEncryptedDriver.h without enabling the class with RH_ENABLE_ENCRYPTION_MODULE in RadioHead.h.<br>
1095 Fixed newly introduced errors when compiling for ATTiny 25/45/85.<br>
1096
1097\version 1.108 2020-07-05
1098 Fixed a problem with RH_RF22 on ESP8266 introcuced in version 1.106 which prevented
1099 messages being received. Some other cleanups in RH_RF22<br>
1100
1101\version 1.109 2020-07-23
1102 Fixed a problem that prevented RHEncryptedDriver compiling when RH_ENCRYPTED_DRIVER was enabled.<br>
1103 Added optiona hops argument to RHRouter and RHMesh recvfromAck() and receivedFomAckTimeout()
1104 to allow the hop count to be retreived if desired.
1105\version 1.110 2020-07-28
1106 Fixed a problem where _spi.beginTransaction and _spi.endTransaction were missing from RHSPIDriver::spiRead.
1107\version 1.111 2020-07-30
1108 Fixed some compilation problems on some platforms with RH_PLATFORM_ATTINY_MEGA and Kondes MegaTinyCore 1.1.2.<br>
1109 Fixed some other errors with Kondes MegaTinyCore 2.0.5: F_CPU_CORRECTED no longer exists,
1110 bitOrder and PinStatus no longer needed.<br>
1111 Improved detection of RH_PLATFORM_ATTINY_MEGA by looking for defined(MEGATINYCORE), defined
1112 in later versions of MegaTinyCore.
1113
1114\version 1.112 2020-08-05
1115 Fixed some compiler warnings in STM32 Discovery and other processors.<br>
1116 Added support for ST's Arduino Core STM32, https://github.com/stm32duino/Arduino_Core_STM32
1117 to RH_ASK, per https://github.com/r-map/rmap/commit/edf9931b21cb7df5b4f67835307255e0fcb301bb.<br>
1118 Added documentation about requirements for code contributions.<br>
1119 Added library.properties file that some IDEs need.<br>
1120 Added support for multithreaded RH_RF95 support on Raspberry Pi, courtesy Tilman Glötzner.<br>
1121 Includes example programs, including for the Dragino Lora/GPS Hat which
1122 send GPS coordinates.<br>
1123
1124\version 1.113 2020-10-15
1125 Changes to RH_ASK on SpenceKonde's megaTinyCore so it will use TCB0 on platforms
1126 where TCB1 is not available.<br>
1127 Minor imprvements to documentation.<br>
1128 Move to local git for source code control.<br>
1129 Added support for RH_ABZ::deinit() for Matt Way.
1130 Fixed compilation error in RH_ASK caused by changes to interrupt API in Arduino_Core_STM32 1.9
1131
1132\version 1.114 2021-03-24
1133 Fixed compile warnings, errors on some platforms, in RH_ASK.cpp for STM32 core 1.9.0
1134 to do with odd behaviour of callback_function_t.<br>
1135 Fixed some problems with SPI transactions in RH_RF69 and RH_RF24 that affected
1136 operations with STM32F030F4. Reported and patched by Adam De Muri.<br>
1137 Added tools/createGPX.pl, contributed by Tilman Glötzner: A perl script to process the dump files that can be
1138 produced with the Dragino LoRa-GPS-hat and rf95_client2 + rf95_server2.
1139 The programs exchange sequence numbers, timestamps and gps coordinates
1140 via Lora which can be used for range measurements or visualization. The
1141 perl script is meant for post processing and converts the log files
1142 into Gpx-files which in turn can be imported to google maps.<br>
1143 Added support for MRF89XAM8A, which has support for different frequency bands to RH_MRF89. Patch courtesy
1144 Michael Kefeder.
1145
1146\version 1.115 2021-03-24
1147 Fix compile error in new MRF89XAM8A support.
1148
1149\version 1.116 2021-03-30
1150 Patch from Vlasta Hajek: 1. Made RH_ASK usable again for ATTINY after breaking changes.
1151 2. Added the possibility to use Timer 1 on ATtiny8x. Tested on ATtiny 85
1152 and ATtiny84 for more than a year.
1153 3. Added patch for ESP32 from jPerotto. This finally makes receiving via
1154 RH_ASK on ESP32 without panics. Tested for more than 6 months.<br>
1155
1156\version 1.117 2021-05-26
1157 Added documention to RH_MRF89 about how to achieve 1μA power consumption in sleep mode.
1158 Courtesy Fernando Faria.<br>
1159 Improved documentation for the meaning of 'len' in all recv*, as suggested by Sean. E. Sean.<br>
1160 waitAvailable and waitAvaiableTimeout now take an optional polldelay argument that
1161 can be useful for introducing on multitasking systems where a driver requires polling.<br>
1162 Fixed compile errors with forward declarations in RH_E32.h and RH_Serial.h on Ardiono IDE on Windows
1163 reported by Skywodd.
1164
1165\version 1.118 2021-07-16
1166 Added a 1 us delay in RHSPIDriver::spiWrite as recommended in
1167 https://forum.pjrc.com/attachment.php?attachmentid=10948&d=1499109224
1168 for corect operation with some fast processors. <br>
1169 Tested Ebyte E22-900T22S radios with serial interface and the examples from
1170 examples/serial/serial_reliable_datagram_* on Linux.
1171 These radios implement a transparent serial connection
1172 using LORA. They can also be configured as independent relays.
1173 You can alter the default configuration of the radios (including frequency,
1174 transmission rates, node addresses etc) by using the
1175 Ebyte RF Settings for E22 tool from https://www.cdebyte.net/download-tools and after
1176 setting the device to configuraiotn mode (M1 high: temporarily remove the M1 link).
1177 Caution, to use this
1178 tool on Windows, you also must install the CH340 USB-Serial port driver, see
1179 https://learn.sparkfun.com/tutorials/how-to-install-ch340-drivers/all#windows-710
1180 These modules can also be configured programatically, but this is not supported by RadioHead. <br>
1181 Fixed compile errors to do with RH_DRAM_ATTR on non-ESP-32 platforms. <br>
1182 Fixed problems reported with crashes in RH_ASK on STM32 boards with core >= 1.9.0 due to
1183 incorrect declaration of interrupt function. <br>
1184
1185\version 1.119 2021-08-02
1186 Changes to RadioHead.h RHHardwareSPI.cpp and RHSPIDriver.cpp for ESP32 support
1187 provided by Juliano Perotto.
1188
1189\version 1.120 2021-11-13
1190 Added intial support for Raspberry Pi Pico, using the Raspberry Pi Pico/RP2040 core by Earle F. Philhower, version 1.93,
1191 installed per https://arduino-pico.readthedocs.io/_/downloads/en/latest/pdf/
1192 RH_ASK works with default pins (11 and 12). But it seems that interrupt callbacks (needed by most SPI based
1193 radio drivers in RadioHead) are not working (yet) in this core, at least when compiled on our Linux platform.
1194 It appears
1195 there is some bug in std::map that causes the interrupt handling to not work correctly
1196 (which I have been able to reproduce in a simple sketch that only uses std::map). This is very strange.
1197 Interrupts _are_ supported and work in the alternative Arduino MBED OS RP2040 core version 2.4.1,
1198 but there are other mysterious crashes RadioHead when a radio driver reads SPI inside an interrupt.
1199 But RH_ASK also works with this core.
1200 So the result (so far) is partial support of RadioHead using either core (so far).
1201 We will revisit this when either core is updated<br>
1202 On ESP32, added support for using the non-default HSPI bus by defining RH_ESP32_USE_HSPI.<br>
1203 Improved the reading of RSSI for the last packet in RH_CC110: seems that it was being read too soon. Now
1204 read it from the end received packet with RH_CC110_APPEND_STATUS.<br>
1205 Added RH_LoRaFileOps, driver on RPi+Linux and using LoRa-file-ops Linux driver ioctls to
1206 transmit and receive RadioHead compatible messages via SX1276/77/78/79
1207 and compatible radios. Requires a modified version of LoRa-file-ops driver to be installed,
1208 and a compatible radio to be connected appropriately:
1209 https://github.com/starnight/LoRa/tree/file-ops <br>
1210
1211\version 1.121 2022-02-02
1212 Restored RH_RF95 code to clear the IRQ flags (twice).<br>
1213
1214\version 1.122 2023-05-20
1215 Added RHRouter::getNextValidRoutingTableEntry() contributed by w...<br>
1216 Various compatibility imnprovements for STM32L0 etc from Calin Radoni.<br>
1217 Added ability to overriding the value of RH_ENABLE_EXPLICIT_RETRY_DEDUP
1218 via a compiler arg. Example from PlatformIO:
1219 build_flags =
1220 -D"RH_ENABLE_EXPLICIT_RETRY_DEDUP=1"
1221 Contributed by Justin Newitter.<br>
1222 Fixed an error in the header lengths in RH_TCP, which could result in the last octet
1223 of the payload being lost. checkForEvents() now returns false instead of exit() in case of IO failure<br>
1224
1225\version 1.123 2023-08-07
1226 Added support for Arduino Uno R4 Minima.
1227
1228\version 1.124 2023-08-09
1229 Extended support for Arduino Uno R4 to Arduino Uno R4 WIFI
1230
1231\version 1.125 2023-08-14
1232 Improved support for Arduino Uno R4: ATOMIC_BLOCK_START and ATOMIC_BLOCK_END are no
1233 longer defined since they hang on R4, and are not necessary since they have SPI_HAS_TRANSACTION
1234
1235\version 1.126 2023-11-24
1236 ESP8266 support now uses IRAM_ATTR instead of ICACHE_RAM_ATTR. This should work fine with core 2.7.4 and later.<br>
1237 Changes to definitions of ATOMIC_BLOCK_START and ATOMIC_BLOCK_END for RH_PLATFORM_ESP32: Previous
1238 use of XTOS_DISABLE_ALL_INTERRUPTS not suported for ESP32C3. Now uses ATOMIC_ENTER_CRITICAL()
1239 and ATOMIC_EXIT_CRITICAL() which appear to be supported for all platforms in Arduino esp32 package.<br>
1240
1241\version 1.127 2024-01-07
1242 Added support for SX126x family radios, and also for the STM32WLE5xx and STM32WLE4xx families of ARM procedssors that
1243 have a SX126x radio built in, and as used in the LoRa-E5-HF module (which is used in WiO-E5 mini development board),
1244 the LoRa-E5-LF module and the NUCLEO_WL55JC1 development board. Tested with WiO-E5 mini development board, but no standalone
1245 SPI versions of this radio.
1246
1247\version 1.128 2024-01-12
1248 Added missing sx126x examples to distribution.
1249
1250\version 1.129 2024-03-21
1251 Rename all .pde sketches to .ino
1252 Significant changes to RH_SX126x to support other modules such as the NiceRF LoRa1262 family.
1253 https://www.nicerf.com/lora-module/915mhz-lora-module-lora1262.html
1254 Sample client and server sketches demonstrating use, compatible with Teensy and other 3.3V compatible Arduinos.
1255
1256\version 1.130 2024-04-12
1257 Adjustments to RHHardwareSPI fopr compatibility with RAKwireless RAK4360/RAK4361, contributed by gfja.
1258 Fixed a preprocessor typo in unused code in RHHardwareSPI.cpp, reported by brodymahoney.
1259
1260\version 1.131 2024-07-02
1261 Fixed problem with failed compilation in RH_ASK.cpp, when used with ESP 32 board library version 3.o or greated because
1262 the Espressif library timer API changed.<br>
1263
1264\version 1.132 2024-07-08
1265 Fixed problem with SX126x where a packet recieved with a CRC error would leave the chip in standby mode
1266 but RH_SX126x thought it was still in RX mode. Reported by kalev.<br>
1267
1268\version 1.133 2024-07-08
1269 Revisit SX126x RX CRC error handling with the assistance of kalev.
1270
1271\version 1.134 2024-07-10
1272 Improvements to SX126x contributed by kalev:<br>
1273 1. Save IRQ flags for debugging outside interrupt handler.
1274 every time the handler is invoked save IRQ flags and rise _iflag.<br>
1275 2. runtime set on/off IRQ mask. This gives possibility to
1276 investigate erroneous packets. <br>
1277 3. introduce raw mode send and receive for debugging.<br>
1278 4. add getFrequencyError() If receiver and sender
1279 main clock frequencies are off ( usually when pairing sx126x and
1280 sx127x ) it's difficult to adjust other party's ( usually sx127x ) frequency.<br>
1281
1282\version 1.135 2024-07-12
1283 Fixed a problem in RHSPIDriver: if the Slave Select pin was set to 0xff, then it would still drive the
1284 SS pin. This broke use of EEPROM on STM32wl. Reported and fixed by Craig Zych.
1285
1286\version 1.136 2024-07-25
1287 Fixed a typo in the comments for the MOSI pin number for the alternative ESP32 HSPI interface.<br>
1288 Examples were not included in idstribution since names changed to .ino
1289
1290\version 1.137 2025-01-03
1291 Fixed a problem where Timer definitions for RP2350 are differnet to RP2340
1292 Reported and patched by Conor O'Neill.
1293
1294\version 1.138 2025-01-05
1295 Added support for Heltec CubeCell modules, including the builtin SX126x radio.
1296 Updated sx1262_client.ino and sx1262_server.ino to demonstrate usage.
1297
1298\version 1.139 2025-01-07
1299 Updated CubeCell support for Heltec CubeCell board 1.5.0 installed in Arduino IDE
1300 per https://docs.heltec.org/en/node/asr650x/asr650x_general_docs/quick_start/cubecell-use-arduino-board-manager.html
1301
1302\version 1.140 2025-01-07
1303 Fixed a compile problem on some platforms like PlatformIO to do with nullptr.
1304
1305\version 1.141 2025-01-08
1306 Fixed another nullptr compile problem on Arduino 2.3.4
1307
1308\version 1.142 2025-01-11
1309 Improvements to RH_SX126x to support sleep mode better, This requires us to waituntilNotBusy() _after_ NSS has been
1310 asserted, not before.
1311
1312\version 1.143 2025-01-21
1313 Extended Cube Cell Board support to all Cube Cell board variants currently supported by Cube Cell 1.5.0.
1314
1315\version 1.144 2026-01-02
1316 Removed some leftover test code from RH_RF69.
1317 Fixed typos in RH_RF24.h
1318 Added RSSItodBm() to RH_RF24
1319 Tested RH_SX126x driver with LLCC68 (almost identical to SX1262) in Ra-01SC module. This required
1320 a incompatible update to RH_SX126x: The Ra-01SC does not have a TCXO, but RH_SX126x always
1321 configured a TCXO: which prevents it working with radio modules without a TCXO. The call in init() to
1322 setTCXO(3.3, 100) has been removed. Now if you have a TCXO, you _must_ make the call to setTCXO()
1323 yourself after init() returns.
1324 Some changes to RH_SX126x to ensure waitUntilNotBusy() is not called inside
1325 an ATOMIC_BLOCK as it is thought this might interfere with timekeeping on some systems with FreeRTOS.
1326 Updated documentation and examples to suit LLCC68
1327
1328\version 1.145 2026-01-05
1329 Fixed a bug in RH_SX126x driver where receipt of an invalid message would prevent further messages being received.<br>
1330
1331\author Mike McCauley. DO NOT CONTACT THE AUTHOR DIRECTLY. USE THE GOOGLE GROUP GIVEN ABOVE
1332*/
1333
1334/*! \page packingdata
1335\par Passing Sensor Data Between RadioHead nodes
1336
1337People often ask about how to send data (such as numbers, sensor
1338readings etc) from one RadioHead node to another. Although this issue
1339is not specific to RadioHead, and more properly lies in the area of
1340programming for networks, we will try to give some guidance here.
1341
1342One reason for the uncertainty and confusion in this area, especially
1343amongst beginners, is that there is no *best* way to do it. The best
1344solution for your project may depend on the range of processors and
1345data that you have to deal with. Also, it gets more difficult if you
1346need to send several numbers in one packet, and/or deal with floating
1347point numbers and/or different types of processors.
1348
1349The principal cause of difficulty is that different microprocessors of
1350the kind that run RadioHead may have different ways of representing
1351binary data such as integers. Some processors are little-endian and
1352some are big-endian in the way they represent multi-byte integers
1353(https://en.wikipedia.org/wiki/Endianness). And different processors
1354and maths libraries may represent floating point numbers in radically
1355different ways:
1356(https://en.wikipedia.org/wiki/Floating-point_arithmetic)
1357
1358All the RadioHead examples show how to send and receive simple NUL
1359terminated ASCII strings, and if thats all you want, refer to the
1360examples folder in your RadioHead distribution. But your needs may be
1361more complicated than that.
1362
1363The essence of all engineering is compromise so it will be up to you to
1364decide whats best for your particular needs. The main choices are:
1365- Raw Binary
1366- Network Order Binary
1367- ASCII
1368
1369\par Raw Binary
1370
1371With this technique you just pack the raw binary numbers into the packet:
1372
1373\code
1374// Sending a single 16 bit unsigned integer
1375// in the transmitter:
1376...
1377uint16_t data = getsomevalue();
1378if (!driver.send((uint8_t*)&data, sizeof(data)))
1379{
1380 ...
1381\endcode
1382
1383\code
1384// and in the receiver:
1385...
1386uint16_t data;
1387uint8_t datalen = sizeof(data);
1388if ( driver.recv((uint8_t*)&data, &datalen)
1389 && datalen == sizeof(data))
1390{
1391 // Have the data, so do something with it
1392 uint16_t xyz = data;
1393 ...
1394\endcode
1395
1396If you need to send more than one number at a time, its best to pack
1397them into a structure
1398
1399\code
1400// Sending several 16 bit unsigned integers in a structure
1401// in a common header for your project:
1402typedef struct
1403{
1404 uint16_t dataitem1;
1405 uint16_t dataitem2;
1406} MyDataStruct;
1407...
1408\endcode
1409
1410\code
1411// In the transmitter
1412...
1413MyDataStruct data;
1414data.dataitem1 = getsomevalue();
1415data.dataitem2 = getsomeothervalue();
1416if (!driver.send((uint8_t*)&data, sizeof(data)))
1417{
1418 ...
1419\endcode
1420
1421\code
1422// in the receiver
1423MyDataStruct data;
1424uint8_t datalen = sizeof(data);
1425if ( driver.recv((uint8_t*)&data, &datalen)
1426 && datalen == sizeof(data))
1427{
1428 // Have the data, so do something with it
1429 uint16_t pqr = data.dataitem1;
1430 uint16_t xyz = data.dataitem2;
1431 ....
1432\endcode
1433
1434
1435The disadvantage with this simple technique becomes apparent if your
1436transmitter and receiver have different endianness: the integers you
1437receive will not be the same as the ones you sent (actually they are,
1438but with the internal bytes swapped around, so they probably wont make
1439sense to you). Endianness is not a problem if *every* data item you
1440send is a just single byte (uint8_t or int8_t or char), or if the
1441transmitter and receiver have the same endianness.
1442
1443So you should only adopt this technique if:
1444- You only send data items of a single byte each, or
1445- You are absolutely sure (now and forever into the future) that you
1446will only ever use the same processor endianness in the transmitter and receiver.
1447
1448\par Network Order Binary
1449
1450One solution to the issue of endianness in your processors is to
1451always convert your data from the processor's native byte order to
1452'network byte order' before transmission and then convert it back to
1453the receiver's native byte order on reception. You do this with the
1454htons (host to network short) macro and friends. These functions may
1455be a no-op on big-endian processors.
1456
1457With this technique you convert every multi-byte number to and from
1458network byte order (note that in most Arduino processors an integer is
1459in fact a short, and is the same as int16_t. We prefer to use types
1460that explicitly specify their size so we can be sure of applying the
1461right conversions):
1462
1463\code
1464// Sending a single 16 bit unsigned integer
1465// in the transmitter:
1466...
1467uint16_t data = htons(getsomevalue());
1468if (!driver.send((uint8_t*)&data, sizeof(data)))
1469{
1470 ...
1471\endcode
1472\code
1473// and in the receiver:
1474...
1475uint16_t data;
1476uint8_t datalen = sizeof(data);
1477if ( driver.recv((uint8_t*)&data, &datalen)
1478 && datalen == sizeof(data))
1479{
1480 // Have the data, so do something with it
1481 uint16_t xyz = ntohs(data);
1482 ...
1483\endcode
1484
1485If you need to send more than one number at a time, its best to pack
1486them into a structure
1487
1488\code
1489// Sending several 16 bit unsigned integers in a structure
1490// in a common header for your project:
1491typedef struct
1492{
1493 uint16_t dataitem1;
1494 uint16_t dataitem2;
1495} MyDataStruct;
1496...
1497\endcode
1498\code
1499// In the transmitter
1500...
1501MyDataStruct data;
1502data.dataitem1 = htons(getsomevalue());
1503data.dataitem2 = htons(getsomeothervalue());
1504if (!driver.send((uint8_t*)&data, sizeof(data)))
1505{
1506 ...
1507\endcode
1508\code
1509// in the receiver
1510MyDataStruct data;
1511uint8_t datalen = sizeof(data);
1512if ( driver.recv((uint8_t*)&data, &datalen)
1513 && datalen == sizeof(data))
1514{
1515 // Have the data, so do something with it
1516 uint16_t pqr = ntohs(data.dataitem1);
1517 uint16_t xyz = ntohs(data.dataitem2);
1518 ....
1519\endcode
1520
1521This technique is quite general for integers but may not work if you
1522want to send floating point number between transmitters and receivers
1523that have different floating point number representations.
1524
1525
1526\par ASCII
1527
1528In this technique, you transmit the printable ASCII equivalent of
1529each floating point and then convert it back to a float in the receiver:
1530
1531\code
1532// In the transmitter
1533...
1534float data = getsomevalue();
1535uint8_t buf[15]; // Bigger than the biggest possible ASCII
1536snprintf(buf, sizeof(buf), "%f", data);
1537if (!driver.send(buf, strlen(buf) + 1)) // Include the trailing NUL
1538{
1539 ...
1540\endcode
1541\code
1542
1543// In the receiver
1544...
1545float data;
1546uint8_t buf[15]; // Bigger than the biggest possible ASCII
1547uint8_t buflen = sizeof(buf);
1548if (driver.recv(buf, &buflen))
1549{
1550 // Have the data, so do something with it
1551 float data = atof(buf); // String to float
1552 ...
1553\endcode
1554
1555\par Conclusion:
1556
1557- This is just a basic introduction to the issues. You may need to
1558extend your study into related C/C++ programming techniques.
1559
1560- You can extend these ideas to signed 16 bit (int16_t) and 32 bit
1561(uint32_t, int32_t) numbers.
1562
1563- Things can be simple or complicated depending on the needs of your
1564project.
1565
1566- We are not going to write your code for you: its up to you to take
1567these examples and explanations and extend them to suit your needs.
1568
1569*/
1570
1571
1572
1573#ifndef RadioHead_h
1574#define RadioHead_h
1575
1576// Official version numbers are maintained automatically by Makefile:
1577#define RH_VERSION_MAJOR 1
1578#define RH_VERSION_MINOR 145
1579
1580// Symbolic names for currently supported platform types
1581#define RH_PLATFORM_ARDUINO 1
1582#define RH_PLATFORM_MSP430 2
1583#define RH_PLATFORM_STM32 3
1584#define RH_PLATFORM_GENERIC_AVR8 4
1585#define RH_PLATFORM_UNO32 5
1586#define RH_PLATFORM_UNIX 6
1587#define RH_PLATFORM_STM32STD 7
1588#define RH_PLATFORM_STM32F4_HAL 8
1589#define RH_PLATFORM_RASPI 9
1590#define RH_PLATFORM_NRF51 10
1591#define RH_PLATFORM_ESP8266 11
1592#define RH_PLATFORM_STM32F2 12
1593#define RH_PLATFORM_CHIPKIT_CORE 13
1594#define RH_PLATFORM_ESP32 14
1595#define RH_PLATFORM_NRF52 15
1596#define RH_PLATFORM_MONGOOSE_OS 16
1597#define RH_PLATFORM_ATTINY 17
1598// Spencer Kondes megaTinyCore:
1599#define RH_PLATFORM_ATTINY_MEGA 18
1600#define RH_PLATFORM_STM32L0 19
1601#define RH_PLATFORM_RASPI_PICO 20
1602
1603////////////////////////////////////////////////////
1604// Select platform automatically, if possible
1605#ifndef RH_PLATFORM
1606 #if (defined(MPIDE) && MPIDE>=150 && defined(ARDUINO))
1607 // Using ChipKIT Core on Arduino IDE
1608 #define RH_PLATFORM RH_PLATFORM_CHIPKIT_CORE
1609 #elif defined(MPIDE)
1610 // Uno32 under old MPIDE, which has been discontinued:
1611 #define RH_PLATFORM RH_PLATFORM_UNO32
1612 #elif defined(NRF51) || defined(NRF52)
1613 #define RH_PLATFORM RH_PLATFORM_NRF51
1614 #elif defined(NRF52)
1615 #define RH_PLATFORM RH_PLATFORM_NRF52
1616 #elif defined(ESP8266)
1617 #define RH_PLATFORM RH_PLATFORM_ESP8266
1618 #elif defined(ESP32)
1619 #define RH_PLATFORM RH_PLATFORM_ESP32
1620 #elif defined(STM32L0) || defined(ARDUINO_ARCH_STM32L0)
1621 #define RH_PLATFORM RH_PLATFORM_STM32L0
1622 #elif defined(MGOS)
1623 #define RH_PLATFORM RH_PLATFORM_MONGOOSE_OS
1624#elif defined(MEGATINYCORE) || defined(ARDUINO_attinyxy2) || defined(ARDUINO_attinyxy4) || defined(ARDUINO_attinyxy6) || defined(ARDUINO_attinyxy7)
1625 #define RH_PLATFORM RH_PLATFORM_ATTINY_MEGA
1626 #elif defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtinyX4__) || defined(__AVR_ATtinyX5__) || defined(__AVR_ATtiny2313__) || defined(__AVR_ATtiny4313__) || defined(__AVR_ATtinyX313__) || defined(ARDUINO_attiny)
1627 #define RH_PLATFORM RH_PLATFORM_ATTINY
1628 #elif defined(ARDUINO)
1629 #define RH_PLATFORM RH_PLATFORM_ARDUINO
1630 #elif defined(__MSP430G2452__) || defined(__MSP430G2553__)
1631 #define RH_PLATFORM RH_PLATFORM_MSP430
1632 #elif defined(MCU_STM32F103RE)
1633 #define RH_PLATFORM RH_PLATFORM_STM32
1634 #elif defined(STM32F2XX)
1635 #define RH_PLATFORM RH_PLATFORM_STM32F2
1636 #elif defined(USE_STDPERIPH_DRIVER)
1637 #define RH_PLATFORM RH_PLATFORM_STM32STD
1638 #elif defined(RASPBERRY_PI)
1639 #define RH_PLATFORM RH_PLATFORM_RASPI
1640 #elif defined(__unix__) // Linux
1641 #define RH_PLATFORM RH_PLATFORM_UNIX
1642 #elif defined(__APPLE__) // OSX
1643 #define RH_PLATFORM RH_PLATFORM_UNIX
1644
1645 #else
1646 #error Platform not defined!
1647 #endif
1648#endif
1649
1650////////////////////////////////////////////////////
1651// Platform specific headers:
1652#if (RH_PLATFORM == RH_PLATFORM_ARDUINO)
1653 #if (ARDUINO >= 100)
1654 #include <Arduino.h>
1655 #else
1656 #include <wiring.h>
1657 #endif
1658 #include <SPI.h>
1659 #define RH_HAVE_HARDWARE_SPI
1660 #define RH_HAVE_SERIAL
1661
1662 #if defined(ARDUINO_ARCH_STM32F4)
1663 // output to Serial causes hangs on STM32 F4 Discovery board
1664 // There seems to be no way to output text to the USB connection
1665 #undef Serial
1666 #define Serial Serial2
1667
1668 #elif defined(ARDUINO_ARCH_RP2040)
1669 #if defined(PICO_RP2350)
1670 // Raspi Pico 2350
1671 #define RH_ASK_PICO_ALARM_IRQ TIMER0_IRQ_1
1672 #else
1673 // Raspi Pico 2040
1674 #define RH_ASK_PICO_ALARM_IRQ TIMER_IRQ_1
1675 #endif
1676 #define RH_ASK_PICO_ALARM_NUM 1
1677
1678 #elif defined(ARDUINO_LORA_E5_MINI)
1679 // WiO-E5 mini, or boards conating Seeed LoRa-E5-LF or LoRa-E5-HF, processor is STM32WLE5JC
1680 #include <SubGhz.h>
1681
1682#elif defined(CubeCell_Board) || defined(CubeCell_Board_V2) || defined(CubeCell_Capsule) || defined(CubeCell_Module) || defined(CubeCell_Module_V2) || defined(CubeCell_BoardPlus) || defined(CubeCell_GPS) || defined(CubeCell_ModulePlus) || defined(CubeCell_HalfAA) || defined(CubeCell_BoardP)
1683 #define RH_CUBE_CELL_BOARD
1684 #define RH_MISSING_SPIUSINGINTERRUPT
1685 #include <board-config.h> // For Radio pin definitions
1686
1687 #endif
1688
1689#elif (RH_PLATFORM == RH_PLATFORM_ATTINY)
1690 #include <Arduino.h>
1691// #warning Arduino TinyCore does not support hardware SPI. Use software SPI instead.
1692#elif (RH_PLATFORM == RH_PLATFORM_ATTINY_MEGA)
1693 #include <SPI.h>
1694 #define RH_HAVE_HARDWARE_SPI
1695 #define RH_HAVE_SERIAL
1696 // On most AT_TINY_MEGA, Timer A is used for millis/micros, and B 0 or 1 for Tone by default.
1697 // But not all devices support TCB1, so we use TCB0 on some variants.
1698 // This is the same strategy for timer selection that Tone uses:
1699 #if defined(MILLIS_USE_TIMERB0) && defined(TCB1)
1700 #define RH_ATTINY_MEGA_ASK_TIMER TCB1
1701 #define RH_ATTINY_MEGA_ASK_TIMER_VECTOR TCB1_INT_vect
1702 #else
1703 #define RH_ATTINY_MEGA_ASK_TIMER TCB0
1704 #define RH_ATTINY_MEGA_ASK_TIMER_VECTOR TCB0_INT_vect
1705 #endif
1706
1707#elif (RH_PLATFORM == RH_PLATFORM_ESP8266) // ESP8266 processor on Arduino IDE
1708 #include <Arduino.h>
1709 #include <SPI.h>
1710 #define RH_HAVE_HARDWARE_SPI
1711 #define RH_HAVE_SERIAL
1712 #define RH_MISSING_SPIUSINGINTERRUPT
1713
1714#elif (RH_PLATFORM == RH_PLATFORM_ESP32) // ESP32 processor on Arduino IDE
1715 #include <Arduino.h>
1716 #include <SPI.h>
1717 #define RH_HAVE_HARDWARE_SPI
1718 #define RH_HAVE_SERIAL
1719 #define RH_MISSING_SPIUSINGINTERRUPT
1720 // ESP32 has 2 user SPI buses: VSPI and HSPI. They are essentially identical, but use different pins.
1721 // The usual, default bus VSPI (available as SPI object in Arduino) uses pins:
1722 // SCLK: 18
1723 // MISO: 19
1724 // MOSI: 23
1725 // SS: 5
1726 // The other HSPI bus uses pins
1727 // SCLK: 14
1728 // MISO: 12
1729 // MOSI: 13
1730 // SS: 15
1731 // By default RadioHead uses VSPI, but you can make it use HSPI by defining this:
1732 //#define RH_ESP32_USE_HSPI
1733
1734#elif (RH_PLATFORM == RH_PLATFORM_MONGOOSE_OS) // Mongoose OS platform
1735 #include <mgos.h>
1736 #include <mgos_adc.h>
1737 #include <mgos_pwm.h>
1738 #include <MGOSCompat/HardwareSerial.h>
1739 #include <MGOSCompat/HardwareSPI.h>
1740 #include <MGOSCompat/MGOS.h>
1741 #include <math.h> // We use the floor() math function.
1742 #define RH_HAVE_HARDWARE_SPI
1743 //If a Radio is connected via a serial port then this defines the serial
1744 //port the radio is connected to.
1745 #if defined(RH_SERIAL_PORT)
1746 #if RH_SERIAL_PORT == 0
1747 #define Serial Serial0
1748 #elif RH_SERIAL_PORT == 1
1749 #define Serial Serial1
1750 #elif RH_SERIAL_PORT == 2
1751 #define Serial Serial2
1752 #endif
1753 #else
1754 #warning "RH_SERIAL_PORT not defined. Therefore serial port 0 selected"
1755 #define Serial Serial0
1756 #endif
1757 #define RH_HAVE_SERIAL
1758
1759#elif (RH_PLATFORM == RH_PLATFORM_MSP430) // LaunchPad specific
1760 #include "legacymsp430.h"
1761 #include "Energia.h"
1762 #include <SPI.h>
1763 #define RH_HAVE_HARDWARE_SPI
1764 #define RH_HAVE_SERIAL
1765
1766#elif (RH_PLATFORM == RH_PLATFORM_UNO32 || RH_PLATFORM == RH_PLATFORM_CHIPKIT_CORE)
1767 #include <WProgram.h>
1768 #include <string.h>
1769 #include <SPI.h>
1770 #define RH_HAVE_HARDWARE_SPI
1771 #define memcpy_P memcpy
1772 #define RH_HAVE_SERIAL
1773
1774#elif (RH_PLATFORM == RH_PLATFORM_STM32) // Maple, Flymaple etc
1775 #include <STM32ArduinoCompat/wirish.h>
1776 #include <stdint.h>
1777 #include <string.h>
1778 #include <STM32ArduinoCompat/HardwareSPI.h>
1779 #define RH_HAVE_HARDWARE_SPI
1780 // Defines which timer to use on Maple
1781 #define MAPLE_TIMER 1
1782 #define PROGMEM
1783 #define memcpy_P memcpy
1784 #define Serial SerialUSB
1785 #define RH_HAVE_SERIAL
1786
1787#elif (RH_PLATFORM == RH_PLATFORM_STM32L0)
1788 #include <Arduino.h>
1789 #include <SPI.h>
1790 // Can define this in platformio.ini
1791 #ifndef RH_EXCLUDE_STM32L0_INCLUDES
1792 // https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0
1793 #include <stm32l0_gpio.h>
1794 #include <stm32l0_exti.h>
1795 #include <stm32l0_rtc.h>
1796 #endif
1797 #define RH_HAVE_HARDWARE_SPI
1798 #define RH_HAVE_SERIAL
1799
1800#elif (RH_PLATFORM == RH_PLATFORM_STM32F2) // Particle Photon with firmware-develop
1801 #include <stm32f2xx.h>
1802 #include <application.h>
1803 #include <math.h> // floor
1804 #define RH_HAVE_SERIAL
1805 #define RH_HAVE_HARDWARE_SPI
1806
1807#elif (RH_PLATFORM == RH_PLATFORM_STM32STD) // STM32 with STM32F4xx_StdPeriph_Driver
1808 #include <stm32f4xx.h>
1809 #include <wirish.h>
1810 #include <stdint.h>
1811 #include <string.h>
1812 #include <math.h>
1813 #include <HardwareSPI.h>
1814 #define RH_HAVE_HARDWARE_SPI
1815 #define Serial SerialUSB
1816 #define RH_HAVE_SERIAL
1817
1818#elif (RH_PLATFORM == RH_PLATFORM_GENERIC_AVR8)
1819 #include <avr/io.h>
1820 #include <avr/interrupt.h>
1821 #include <util/delay.h>
1822 #include <string.h>
1823 #include <stdbool.h>
1824 #define RH_HAVE_HARDWARE_SPI
1825 #include <SPI.h>
1826
1827// For Steve Childress port to ARM M4 w/CMSIS with STM's Hardware Abstraction lib.
1828// See ArduinoWorkarounds.h (not supplied)
1829#elif (RH_PLATFORM == RH_PLATFORM_STM32F4_HAL)
1830 #include <ArduinoWorkarounds.h>
1831 #include <stm32f4xx.h> // Also using ST's CubeMX to generate I/O and CPU setup source code for IAR/EWARM, not GCC ARM.
1832 #include <stdint.h>
1833 #include <string.h>
1834 #include <math.h>
1835 #define RH_HAVE_HARDWARE_SPI // using HAL (Hardware Abstraction Libraries from ST along with CMSIS, not arduino libs or pins concept.
1836
1837#elif (RH_PLATFORM == RH_PLATFORM_RASPI)
1838 #define RH_HAVE_HARDWARE_SPI
1839 #define RH_HAVE_SERIAL
1840 #define PROGMEM
1841// You can enable MUTEX to protect critical sections for multithreading
1842// #define RH_USE_MUTEX
1843 #if (__has_include (<pigpio.h>))
1844 #include <RHutil_pigpio/RasPi.h>
1845 #else
1846 #include <RHutil/RasPi.h>
1847 #endif
1848 #include <string.h>
1849 //Define SS for CS0 or pin 24
1850 #define SS 8
1851
1852#elif (RH_PLATFORM == RH_PLATFORM_NRF51)
1853 #define RH_HAVE_SERIAL
1854 #define PROGMEM
1855 #include <Arduino.h>
1856
1857#elif (RH_PLATFORM == RH_PLATFORM_NRF52)
1858 #include <SPI.h>
1859 #define RH_HAVE_HARDWARE_SPI
1860 #define RH_HAVE_SERIAL
1861 #define RH_HAVE_SPI_ATTACH_INTERRUPT
1862 #define PROGMEM
1863 #include <Arduino.h>
1864
1865#elif (RH_PLATFORM == RH_PLATFORM_UNIX)
1866 // Simulate the sketch on Linux and OSX
1867 #include <RHutil/simulator.h>
1868 #define RH_HAVE_SERIAL
1869#include <netinet/in.h> // For htons and friends
1870
1871#else
1872 #error Platform unknown!
1873#endif
1874
1875////////////////////////////////////////////////////
1876// This is an attempt to make a portable atomic block
1877#if (RH_PLATFORM == RH_PLATFORM_ARDUINO)
1878 #if defined(RH_CUBE_CELL_BOARD)
1879 // No atomic header file available
1880 #elif defined(__arm__)
1881 #include <RHutil/atomic.h>
1882 #else
1883 #include <util/atomic.h>
1884 #endif
1885
1886 #if defined(ARDUINO_ARCH_MBED_RP2040) || defined(ARDUINO_UNOR4_MINIMA) || defined(ARDUINO_UNOR4_WIFI) || defined(RH_CUBE_CELL_BOARD)
1887 // Standard arduino ATOMIC block crashes on MBED version of Pico as at 2021-08-12 // and ius not available/required for UNO R4
1888 #define ATOMIC_BLOCK_START {
1889 #define ATOMIC_BLOCK_END }
1890 #else
1891 // Most Arduinos
1892 #define ATOMIC_BLOCK_START ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
1893 #define ATOMIC_BLOCK_END }
1894 #endif
1895#elif (RH_PLATFORM == RH_PLATFORM_CHIPKIT_CORE)
1896 // UsingChipKIT Core on Arduino IDE
1897 #define ATOMIC_BLOCK_START unsigned int __status = disableInterrupts(); {
1898 #define ATOMIC_BLOCK_END } restoreInterrupts(__status);
1899#elif (RH_PLATFORM == RH_PLATFORM_UNO32)
1900 // Under old MPIDE, which has been discontinued:
1901 #include <peripheral/int.h>
1902 #define ATOMIC_BLOCK_START unsigned int __status = INTDisableInterrupts(); {
1903 #define ATOMIC_BLOCK_END } INTRestoreInterrupts(__status);
1904#elif (RH_PLATFORM == RH_PLATFORM_STM32L0)
1905 #define ATOMIC_BLOCK_START uint32_t primask = __get_PRIMASK(); __disable_irq(); {
1906 #define ATOMIC_BLOCK_END } __set_PRIMASK(primask);
1907#elif (RH_PLATFORM == RH_PLATFORM_STM32F2) // Particle Photon with firmware-develop
1908 #define ATOMIC_BLOCK_START { int __prev = HAL_disable_irq();
1909 #define ATOMIC_BLOCK_END HAL_enable_irq(__prev); }
1910#elif (RH_PLATFORM == RH_PLATFORM_ESP8266)
1911// See hardware/esp8266/2.0.0/cores/esp8266/Arduino.h
1912 #define ATOMIC_BLOCK_START { uint32_t __savedPS = xt_rsil(15);
1913 #define ATOMIC_BLOCK_END xt_wsr_ps(__savedPS);}
1914#elif (RH_PLATFORM == RH_PLATFORM_ESP32)
1915// jPerotto see hardware/esp32/1.0.4/tools/sdk/include/esp32/xtensa/xruntime.h
1916// No, not supported on ESP32C3
1917// #define ATOMIC_BLOCK_START uint32_t volatile register ilevel = XTOS_DISABLE_ALL_INTERRUPTS;
1918// #define ATOMIC_BLOCK_END XTOS_RESTORE_INTLEVEL(ilevel);
1919// This compiles for all ESP32 but is it correct?
1920// #define ATOMIC_BLOCK_START int RH_ATOMIC_state = portSET_INTERRUPT_MASK_FROM_ISR();
1921// #define ATOMIC_BLOCK_END portCLEAR_INTERRUPT_MASK_FROM_ISR(RH_ATOMIC_state);
1922// These appear to be defined for all ESP32 type:
1923 #include "freertos/atomic.h"
1924 #define ATOMIC_BLOCK_START ATOMIC_ENTER_CRITICAL()
1925 #define ATOMIC_BLOCK_END ATOMIC_EXIT_CRITICAL()
1926#else
1927 // TO BE DONE:
1928 #define ATOMIC_BLOCK_START
1929 #define ATOMIC_BLOCK_END
1930#endif
1931
1932////////////////////////////////////////////////////
1933// Try to be compatible with systems that support yield() and multitasking
1934// instead of spin-loops
1935// Recent Arduino IDE or Teensy 3 has yield()
1936#if (RH_PLATFORM == RH_PLATFORM_ARDUINO) && defined(RH_CUBE_CELL_BOARD)
1937 #define YIELD
1938#elif (RH_PLATFORM == RH_PLATFORM_ARDUINO && ARDUINO >= 155) || (defined(TEENSYDUINO) && defined(__MK20DX128__))
1939 #define YIELD yield();
1940#elif (RH_PLATFORM == RH_PLATFORM_ESP8266)
1941// ESP8266 also has it
1942 #define YIELD yield();
1943#elif (RH_PLATFORM == RH_PLATFORM_STM32L0)
1944 #define YIELD yield();
1945#elif (RH_PLATFORM == RH_PLATFORM_MONGOOSE_OS)
1946 //ESP32 and ESP8266 use freertos so we include calls
1947 //that we would normall exit a function and return to
1948 //the rtos in mgosYield() (E.G flush TX uart buffer
1949 extern "C" {
1950 void mgosYield(void);
1951 }
1952 #define YIELD mgosYield()
1953#elif (RH_PLATFORM == RH_PLATFORM_ESP32)
1954 // ESP32 also has it
1955 #define YIELD yield();
1956#else
1957 #define YIELD
1958#endif
1959
1960////////////////////////////////////////////////////
1961// digitalPinToInterrupt is not available prior to Arduino 1.5.6 and 1.0.6
1962// See https://arduino.cc/en/Reference/attachInterrupt
1963#ifndef NOT_AN_INTERRUPT
1964 #define NOT_AN_INTERRUPT -1
1965#endif
1966#ifndef digitalPinToInterrupt
1967 #if (RH_PLATFORM == RH_PLATFORM_ARDUINO) && !defined(__arm__)
1968
1969 #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
1970 // Arduino Mega, Mega ADK, Mega Pro
1971 // 2->0, 3->1, 21->2, 20->3, 19->4, 18->5
1972 #define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : ((p) >= 18 && (p) <= 21 ? 23 - (p) : NOT_AN_INTERRUPT)))
1973
1974 #elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)
1975 // Arduino 1284 and 1284P - See Manicbug and Optiboot
1976 // 10->0, 11->1, 2->2
1977 #define digitalPinToInterrupt(p) ((p) == 10 ? 0 : ((p) == 11 ? 1 : ((p) == 2 ? 2 : NOT_AN_INTERRUPT)))
1978
1979 #elif defined(__AVR_ATmega32U4__)
1980 // Leonardo, Yun, Micro, Pro Micro, Flora, Esplora
1981 // 3->0, 2->1, 0->2, 1->3, 7->4
1982 #define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT)))))
1983
1984 #else
1985 // All other arduino except Due:
1986 // Serial Arduino, Extreme, NG, BT, Uno, Diecimila, Duemilanove, Nano, Menta, Pro, Mini 04, Fio, LilyPad, Ethernet etc
1987 // 2->0, 3->1
1988 #define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT))
1989
1990 #endif
1991
1992 #elif (RH_PLATFORM == RH_PLATFORM_UNO32) || (RH_PLATFORM == RH_PLATFORM_CHIPKIT_CORE)
1993 // Hmmm, this is correct for Uno32, but what about other boards on ChipKIT Core?
1994 #define digitalPinToInterrupt(p) ((p) == 38 ? 0 : ((p) == 2 ? 1 : ((p) == 7 ? 2 : ((p) == 8 ? 3 : ((p) == 735 ? 4 : NOT_AN_INTERRUPT)))))
1995
1996 #elif (RH_PLATFORM == RH_PLATFORM_ESP32)
1997 #define digitalPinToInterrupt(p) (((p) < 40) ? (p) : -1)
1998
1999 #elif (RH_PLATFORM == RH_PLATFORM_ESP8266)
2000 #define digitalPinToInterrupt(p) (((p) < EXTERNAL_NUM_INTERRUPTS)? (p) : NOT_AN_INTERRUPT)
2001
2002
2003 #else
2004 // Everything else (including Due and Teensy) interrupt number the same as the interrupt pin number
2005 #define digitalPinToInterrupt(p) (p)
2006 #endif
2007#endif
2008
2009// On some platforms, attachInterrupt() takes a pin number, not an interrupt number
2010#if (RH_PLATFORM == RH_PLATFORM_ARDUINO) && defined (__arm__) && (defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_SAM_DUE)) || defined(ARDUINO_ARCH_STM32L0)
2011 #define RH_ATTACHINTERRUPT_TAKES_PIN_NUMBER
2012#endif
2013
2014// Slave select pin, some platforms such as ATTiny do not define it.
2015// ESP32 pins_arduino.h uses static const uint8_t SS = <UINT>; instead
2016// of a #define to declare the SS constant.
2017#if (RH_PLATFORM != RH_PLATFORM_ESP32)
2018 #ifndef SS
2019 #define SS 10
2020 #endif
2021#endif
2022
2023// Some platforms require special attributes for interrupt routines
2024#if (RH_PLATFORM == RH_PLATFORM_ESP8266)
2025 // interrupt handler and related code must be in RAM on ESP8266,
2026 // according to issue #46.
2027 // 2023-09-19: ESP8266 is now compatible with ESP 32 and uses IRAM_ATTR
2028 #define RH_INTERRUPT_ATTR IRAM_ATTR
2029
2030#elif (RH_PLATFORM == RH_PLATFORM_ESP32)
2031 #define RH_INTERRUPT_ATTR IRAM_ATTR
2032#else
2033 #define RH_INTERRUPT_ATTR
2034#endif
2035
2036// These defs cause trouble on some versions of Arduino
2037#undef abs
2038#undef round
2039#undef double
2040
2041// Sigh: there is no widespread adoption of htons and friends in the base code, only in some WiFi headers etc
2042// that have a lot of excess baggage
2043#if RH_PLATFORM != RH_PLATFORM_UNIX && !defined(htons)
2044// #ifndef htons
2045// These predefined macros available on modern GCC compilers
2046 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
2047 // Atmel processors
2048 #define htons(x) ( ((x)<<8) | (((x)>>8)&0xFF) )
2049 #define ntohs(x) htons(x)
2050 #define htonl(x) ( ((x)<<24 & 0xFF000000UL) | \
2051 ((x)<< 8 & 0x00FF0000UL) | \
2052 ((x)>> 8 & 0x0000FF00UL) | \
2053 ((x)>>24 & 0x000000FFUL) )
2054 #define ntohl(x) htonl(x)
2055
2056 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
2057 // Others
2058 #define htons(x) (x)
2059 #define ntohs(x) (x)
2060 #define htonl(x) (x)
2061 #define ntohl(x) (x)
2062
2063 #else
2064 #error "RadioHead.h: Dont know how to define htons and friends for this processor"
2065 #endif
2066#endif
2067
2068// Some platforms need a mutex for multihreaded case
2069#ifdef RH_USE_MUTEX
2070 #include <pthread.h>
2071 #define RH_DECLARE_MUTEX(X) pthread_mutex_t X;
2072 #define RH_MUTEX_INIT(X) pthread_mutex_init(&X, NULL)
2073 #define RH_MUTEX_LOCK(X) pthread_mutex_lock(&X)
2074 #define RH_MUTEX_UNLOCK(X) pthread_mutex_unlock(&X)
2075#else
2076 #define RH_DECLARE_MUTEX(X)
2077 #define RH_MUTEX_INIT(X)
2078 #define RH_MUTEX_LOCK(X)
2079 #define RH_MUTEX_UNLOCK(X)
2080#endif
2081
2082// This is the address that indicates a broadcast
2083#define RH_BROADCAST_ADDRESS 0xff
2084
2085// Specifies an invalid IO pin selection
2086#define RH_INVALID_PIN 0xff
2087
2088// Here we have some system wide macros you can define to alter the baviour of RadioHead
2089// in various ways. The Ardiono IDE has no way to configure such things at compile time so
2090// on that pltform you are forced to edit these macros here.
2091// On platformio you can add them to platformio.ini like, say:
2092// -D RH_ACK_DELAY=10`
2093
2094// Uncomment this to add a delay before acknowledgement in RHReliableDatagram.
2095// In some networks with mixed processor speeds, may need this delay to prevent a
2096// fast processor sending an ack before the receiver is ready for it.
2097// The time is in milliseconds
2098// #define RH_ACK_DELAY 10
2099
2100// RH_Uncomment this to control which timer used by RH_ASK in some platforms like
2101// STM32:
2102// #define RH_HW_TIMER TIM21`
2103
2104// Uncomment this is to enable Encryption (see RHEncryptedDriver):
2105// But ensure you have installed the Crypto directory from arduinolibs first:
2106// https://rweather.github.io/arduinolibs/index.html
2107//#define RH_ENABLE_ENCRYPTION_MODULE
2108
2109// Some platforms like RocketScream need this to see debug Serial output from within RH
2110// and if it goes to Serial, get a hang after a few minutes.
2111//#define Serial SerialUSB
2112
2113#endif