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