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