RadioHead
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
RH_RF95 Class Reference

Driver to send and receive unaddressed, unreliable datagrams via a LoRa capable radio transceiver. More...

#include <RH_RF95.h>

Inheritance diagram for RH_RF95:
RHSPIDriver RHGenericDriver RH_ABZ

Classes

struct  ModemConfig
 Defines register values for a set of modem configuration registers. More...
 

Public Types

enum  ModemConfigChoice {
  Bw125Cr45Sf128 = 0 , Bw500Cr45Sf128 , Bw31_25Cr48Sf512 , Bw125Cr48Sf4096 ,
  Bw125Cr45Sf2048
}
 
- Public Types inherited from RHGenericDriver
enum  RHMode {
  RHModeInitialising = 0 , RHModeSleep , RHModeIdle , RHModeTx ,
  RHModeRx , RHModeCad
}
 Defines different operating modes for the transport hardware. More...
 

Public Member Functions

 RH_RF95 (uint8_t slaveSelectPin=SS, uint8_t interruptPin=2, RHGenericSPI &spi=hardware_spi)
 
virtual bool init ()
 
bool printRegisters ()
 
void setModemRegisters (const ModemConfig *config)
 
bool setModemConfig (ModemConfigChoice index)
 
virtual bool available ()
 
virtual bool recv (uint8_t *buf, uint8_t *len)
 
virtual bool send (const uint8_t *data, uint8_t len)
 
void setPreambleLength (uint16_t bytes)
 
virtual uint8_t maxMessageLength ()
 
bool setFrequency (float centre)
 
void setModeIdle ()
 
void setModeRx ()
 
void setModeTx ()
 
void setTxPower (int8_t power, bool useRFO=false)
 
virtual bool sleep ()
 
virtual bool isChannelActive ()
 
void enableTCXO (bool on=true)
 
int frequencyError ()
 
int lastSNR ()
 
void setSpreadingFactor (uint8_t sf)
 
void setSignalBandwidth (long sbw)
 
void setCodingRate4 (uint8_t denominator)
 
void setLowDatarate ()
 
void setPayloadCRC (bool on)
 
uint8_t getDeviceVersion ()
 
- Public Member Functions inherited from RHSPIDriver
 RHSPIDriver (uint8_t slaveSelectPin=SS, RHGenericSPI &spi=hardware_spi)
 
bool init ()
 
uint8_t spiRead (uint8_t reg)
 
uint8_t spiWrite (uint8_t reg, uint8_t val)
 
uint8_t spiBurstRead (uint8_t reg, uint8_t *dest, uint8_t len)
 
uint8_t spiBurstWrite (uint8_t reg, const uint8_t *src, uint8_t len)
 
void setSlaveSelectPin (uint8_t slaveSelectPin)
 
void spiUsingInterrupt (uint8_t interruptNumber)
 
- Public Member Functions inherited from RHGenericDriver
 RHGenericDriver ()
 Constructor.
 
virtual ~RHGenericDriver ()
 Generic destructor to prevent warnings when objects are dynamically allocated.
 
virtual void waitAvailable (uint16_t polldelay=0)
 
virtual bool waitPacketSent ()
 
virtual bool waitPacketSent (uint16_t timeout)
 
virtual bool waitAvailableTimeout (uint16_t timeout, uint16_t polldelay=0)
 
virtual bool waitCAD ()
 
void setCADTimeout (unsigned long cad_timeout)
 
virtual void setThisAddress (uint8_t thisAddress)
 
virtual void setHeaderTo (uint8_t to)
 
virtual void setHeaderFrom (uint8_t from)
 
virtual void setHeaderId (uint8_t id)
 
virtual void setHeaderFlags (uint8_t set, uint8_t clear=RH_FLAGS_APPLICATION_SPECIFIC)
 
virtual void setPromiscuous (bool promiscuous)
 
virtual uint8_t headerTo ()
 
virtual uint8_t headerFrom ()
 
virtual uint8_t headerId ()
 
virtual uint8_t headerFlags ()
 
virtual int16_t lastRssi ()
 
virtual RHMode mode ()
 
virtual void setMode (RHMode mode)
 Sets the operating mode of the transport.
 
virtual uint16_t rxBad ()
 
virtual uint16_t rxGood ()
 
virtual uint16_t txGood ()
 

Protected Member Functions

bool setupInterruptHandler ()
 Do whatever is necesary to establish the interrupt handler. Subclasses may have different needs.
 
void handleInterrupt ()
 
void validateRxBuf ()
 Examine the revceive buffer to determine whether the message is for this node.
 
void clearRxBuf ()
 Clear our local receive buffer.
 
virtual bool modeWillChange (RHMode)
 
- Protected Member Functions inherited from RHSPIDriver
virtual void beginTransaction ()
 
virtual void endTransaction ()
 
virtual void selectSlave ()
 
virtual void deselectSlave ()
 

Protected Attributes

bool _useRFO
 
- Protected Attributes inherited from RHSPIDriver
RHGenericSPI_spi
 Reference to the RHGenericSPI instance to use to transfer data with the SPI device.
 
uint8_t _slaveSelectPin
 The pin number of the Slave Select pin that is used to select the desired device.
 
- Protected Attributes inherited from RHGenericDriver
volatile RHMode _mode
 The current transport operating mode.
 
uint8_t _thisAddress
 This node id.
 
bool _promiscuous
 Whether the transport is in promiscuous mode.
 
volatile uint8_t _rxHeaderTo
 TO header in the last received mesasge.
 
volatile uint8_t _rxHeaderFrom
 FROM header in the last received mesasge.
 
volatile uint8_t _rxHeaderId
 ID header in the last received mesasge.
 
volatile uint8_t _rxHeaderFlags
 FLAGS header in the last received mesasge.
 
uint8_t _txHeaderTo
 TO header to send in all messages.
 
uint8_t _txHeaderFrom
 FROM header to send in all messages.
 
uint8_t _txHeaderId
 ID header to send in all messages.
 
uint8_t _txHeaderFlags
 FLAGS header to send in all messages.
 
volatile int16_t _lastRssi
 The value of the last received RSSI value, in some transport specific units.
 
volatile uint16_t _rxBad
 Count of the number of bad messages (eg bad checksum etc) received.
 
volatile uint16_t _rxGood
 Count of the number of successfully transmitted messaged.
 
volatile uint16_t _txGood
 Count of the number of bad messages (correct checksum etc) received.
 
volatile bool _cad
 Channel activity detected.
 
unsigned int _cad_timeout
 Channel activity timeout in ms.
 

Additional Inherited Members

- Static Public Member Functions inherited from RHGenericDriver
static void printBuffer (const char *prompt, const uint8_t *buf, uint8_t len)
 

Detailed Description

Driver to send and receive unaddressed, unreliable datagrams via a LoRa capable radio transceiver.

For an excellent discussion of LoRa range and modulations, see https://medium.com/home-wireless/testing-lora-radios-with-the-limesdr-mini-part-2-37fa481217ff

For Semtech SX1276/77/78/79 and HopeRF RF95/96/97/98 and other similar LoRa capable radios. Based on http://www.hoperf.com/upload/rf/RFM95_96_97_98W.pdf and http://www.hoperf.cn/upload/rfchip/RF96_97_98.pdf and http://www.semtech.com/images/datasheet/LoraDesignGuide_STD.pdf and http://www.semtech.com/images/datasheet/sx1276.pdf and http://www.semtech.com/images/datasheet/sx1276_77_78_79.pdf FSK/GFSK/OOK modes are not (yet) supported.

Works with

Overview

This class provides basic functions for sending and receiving unaddressed, unreliable datagrams of arbitrary length to 251 octets per packet.

Manager classes may use this class to implement reliable, addressed datagrams and streams, mesh routers, repeaters, translators etc.

Naturally, for any 2 radios to communicate that must be configured to use the same frequency and modulation scheme.

This Driver provides an object-oriented interface for sending and receiving data messages with Hope-RF RFM95/96/97/98(W), Semtech SX1276/77/78/79 and compatible radio modules in LoRa mode.

The Hope-RF (http://www.hoperf.com) RFM95/96/97/98(W) and Semtech SX1276/77/78/79 is a low-cost ISM transceiver chip. It supports FSK, GFSK, OOK over a wide range of frequencies and programmable data rates, and it also supports the proprietary LoRA (Long Range) mode, which is the only mode supported in this RadioHead driver.

This Driver provides functions for sending and receiving messages of up to 251 octets on any frequency supported by the radio, in a range of predefined Bandwidths, Spreading Factors and Coding Rates. Frequency can be set with 61Hz precision to any frequency from 240.0MHz to 960.0MHz. Caution: most modules only support a more limited range of frequencies due to antenna tuning.

Up to 2 modules can be connected to an Arduino (3 on a Mega), permitting the construction of translators and frequency changers, etc.

Support for other features such as transmitter power control etc is also provided.

Tested on MinWirelessLoRa with arduino-1.0.5 on OpenSuSE 13.1. Also tested with Teensy3.1, Modtronix inAir4 and Arduino 1.6.5 on OpenSuSE 13.1

Packet Format

All messages sent and received by this RH_RF95 Driver conform to this packet format, which is compatible with RH_SX126x:

Connecting RFM95/96/97/98 and Semtech SX1276/77/78/79 to Arduino

We tested with Anarduino MiniWirelessLoRA, which is an Arduino Duemilanove compatible with a RFM96W module on-board. Therefore it needs no connections other than the USB programming connection and an antenna to make it work.

If you have a bare RFM95/96/97/98 that you want to connect to an Arduino, you might use these connections (untested): CAUTION: you must use a 3.3V type Arduino, otherwise you will also need voltage level shifters between the Arduino and the RFM95. CAUTION, you must also ensure you connect an antenna.

Arduino RFM95/96/97/98
GND----------GND (ground in)
3V3----------3.3V (3.3V in)
interrupt 0 pin D2-----------DIO0 (interrupt request out)
SS pin D10----------NSS (CS chip select in)
SCK pin D13----------SCK (SPI clock in)
MOSI pin D11----------MOSI (SPI Data in)
MISO pin D12----------MISO (SPI Data out)

With these connections, you can then use the default constructor RH_RF95(). You can override the default settings for the SS pin and the interrupt in the RH_RF95 constructor if you wish to connect the slave select SS to other than the normal one for your Arduino (D10 for Diecimila, Uno etc and D53 for Mega) or the interrupt request to other than pin D2 (Caution, different processors have different constraints as to the pins available for interrupts).

You can connect a Modtronix inAir4 or inAir9 directly to a 3.3V part such as a Teensy 3.1 like this (tested).

Teensy inAir4 inAir9
GND----------0V (ground in)
3V3----------3.3V (3.3V in)
interrupt 0 pin D2-----------D0 (interrupt request out)
SS pin D10----------CS (CS chip select in)
SCK pin D13----------CK (SPI clock in)
MOSI pin D11----------SI (SPI Data in)
MISO pin D12----------SO (SPI Data out)

With these connections, you can then use the default constructor RH_RF95(). you must also set the transmitter power with useRFO: driver.setTxPower(13, true);

Note that if you are using Modtronix inAir4 or inAir9,or any other module which uses the transmitter RFO pins and not the PA_BOOST pins that you must configure the power transmitter power for -1 to 14 dBm and with useRFO true. Failure to do that will result in extremely low transmit powers.

If you have an Arduino M0 Pro from arduino.org, you should note that you cannot use Pin 2 for the interrupt line (Pin 2 is for the NMI only). The same comments apply to Pin 4 on Arduino Zero from arduino.cc. Instead you can use any other pin (we use Pin 3) and initialise RH_RF69 like this:

// Slave Select is pin 10, interrupt is Pin 3
RH_RF95 driver(10, 3);
Driver to send and receive unaddressed, unreliable datagrams via a LoRa capable radio transceiver.
Definition RH_RF95.h:573

You can use the same constructor for Arduino Due, and this pinout diagram may be useful: http://www.robgray.com/temp/Due-pinout-WEB.png

If you have a Rocket Scream Mini Ultra Pro with the RFM95W:

For Adafruit Feather M0 with RFM95, construct the driver like this:

RH_RF95 rf95(8, 3);

If you have a talk2 Whisper Node LoRa board with on-board RF95 radio, the example rf95_* sketches work without modification. Initialise the radio like with the default constructor:

RH_RF95 driver;

It is possible to have 2 or more radios connected to one Arduino, provided each radio has its own SS and interrupt line (SCK, SDI and SDO are common to all radios)

Caution: on some Arduinos such as the Mega 2560, if you set the slave select pin to be other than the usual SS pin (D53 on Mega 2560), you may need to set the usual SS pin to be an output to force the Arduino into SPI master mode.

Caution: Power supply requirements of the RFM module may be relevant in some circumstances: RFM95/96/97/98 modules are capable of pulling 120mA+ at full power, where Arduino's 3.3V line can give 50mA. You may need to make provision for alternate power supply for the RFM module, especially if you wish to use full transmit power, and/or you have other shields demanding power. Inadequate power for the RFM is likely to cause symptoms such as:

Interrupts

The RH_RF95 driver uses interrupts to react to events in the RFM module, such as the reception of a new packet, or the completion of transmission of a packet. The driver configures the radio so the required interrupt is generated by the radio's DIO0 pin. The RH_RF95 driver interrupt service routine reads status from and writes data to the the RFM module via the SPI interface. It is very important therefore, that if you are using the RH_RF95 driver with another SPI based deviced, that you disable interrupts while you transfer data to and from that other device. Use cli() to disable interrupts and sei() to reenable them.

Memory

The RH_RF95 driver requires non-trivial amounts of memory. The sample programs all compile to about 8kbytes each, which will fit in the flash proram memory of most Arduinos. However, the RAM requirements are more critical. Therefore, you should be vary sparing with RAM use in programs that use the RH_RF95 driver.

It is often hard to accurately identify when you are hitting RAM limits on Arduino. The symptoms can include:

Range

We have made some simple range tests under the following conditions:

It should be noted that at this data rate, a 12 octet message takes 2 seconds to transmit.

At 20dBm (100mW) with Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on. (Default medium range) in the conditions described above.

Caution: the performance of this radio, especially with narrow bandwidths is strongly dependent on the accuracy and stability of the chip clock. HopeRF and Semtech do not appear to recommend bandwidths of less than 62.5 kHz unless you have the optional Temperature Compensated Crystal Oscillator (TCXO) installed and enabled on your radio module. See the refernece manual for more data. Also https://lowpowerlab.com/forum/rf-range-antennas-rfm69-library/lora-library-experiences-range/15/ and http://www.semtech.com/images/datasheet/an120014-xo-guidance-lora-modulation.pdf

Transmitter Power

You can control the transmitter power on the RF transceiver with the RH_RF95::setTxPower() function. The argument can be any of +2 to +20 (for modules that use PA_BOOST) 0 to +15 (for modules that use RFO transmitter pin) The default is 13. Eg:

driver.setTxPower(10); // use PA_BOOST transmitter pin
driver.setTxPower(10, true); // use PA_RFO pin transmitter pin instead of PA_BOOST
void setTxPower(int8_t power, bool useRFO=false)
Definition RH_RF95.cpp:444

We have made some actual power measurements against programmed power for Anarduino MiniWirelessLoRa (which has RFM96W-433Mhz installed, and which includes an RF power amp for addition 3dBm of power

We have also measured the actual power output from a Modtronix inAir4 http://modtronix.com/inair4.html connected to a Teensy 3.1: Teensy 3.1 this is a 3.3V part, connected directly to: Modtronix inAir4 with SMA antenna connector, connected as above: 10cm SMA-SMA cable

Member Enumeration Documentation

◆ ModemConfigChoice

Choices for setModemConfig() for a selected subset of common data rates. If you need another configuration, determine the necessary settings and call setModemRegisters() with your desired settings. It might be helpful to use the LoRa calculator mentioned in http://www.semtech.com/images/datasheet/LoraDesignGuide_STD.pdf These are indexes into MODEM_CONFIG_TABLE. We strongly recommend you use these symbolic definitions and not their integer equivalents: its possible that new values will be introduced in later versions (though we will try to avoid it). Caution: if you are using slow packet rates and long packets with RHReliableDatagram or subclasses you may need to change the RHReliableDatagram timeout for reliable operations. Caution: for some slow rates nad with ReliableDatagrams you may need to increase the reply timeout with manager.setTimeout() to deal with the long transmission times. Caution: SX1276 family errata suggests alternate settings for some LoRa registers when 500kHz bandwidth is in use. See the Semtech SX1276/77/78 Errata Note. These are not implemented by RH_RF95.

Enumerator
Bw125Cr45Sf128 

Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on. Default medium range.

Bw500Cr45Sf128 

Bw = 500 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on. Fast+short range.

Bw31_25Cr48Sf512 

Bw = 31.25 kHz, Cr = 4/8, Sf = 512chips/symbol, CRC on. Slow+long range.

Bw125Cr48Sf4096 

Bw = 125 kHz, Cr = 4/8, Sf = 4096chips/symbol, low data rate, CRC on. Slow+long range.

Bw125Cr45Sf2048 

Bw = 125 kHz, Cr = 4/5, Sf = 2048chips/symbol, CRC on. Slow+long range.

Constructor & Destructor Documentation

◆ RH_RF95()

RH_RF95::RH_RF95 ( uint8_t  slaveSelectPin = SS,
uint8_t  interruptPin = 2,
RHGenericSPI spi = hardware_spi 
)

Constructor. You can have multiple instances, but each instance must have its own interrupt and slave select pin. After constructing, you must call init() to initialise the interface and the radio module. A maximum of 3 instances can co-exist on one processor, provided there are sufficient distinct interrupt lines, one for each instance.

Parameters
[in]slaveSelectPinthe Arduino pin number of the output to use to select the RH_RF22 before accessing it. Defaults to the normal SS pin for your Arduino (D10 for Diecimila, Uno etc, D53 for Mega, D10 for Maple)
[in]interruptPinThe interrupt Pin number that is connected to the RFM DIO0 interrupt line. Defaults to pin 2, as required by Anarduino MinWirelessLoRa module. Caution: You must specify an interrupt capable pin. On many Arduino boards, there are limitations as to which pins may be used as interrupts. On Leonardo pins 0, 1, 2 or 3. On Mega2560 pins 2, 3, 18, 19, 20, 21. On Due and Teensy, any digital pin. On Arduino Zero from arduino.cc, any digital pin other than 4. On Arduino M0 Pro from arduino.org, any digital pin other than 2. On other Arduinos pins 2 or 3. See http://arduino.cc/en/Reference/attachInterrupt for more details. On Chipkit Uno32, pins 38, 2, 7, 8, 35. On other boards, any digital pin may be used.
[in]spiPointer to the SPI interface object to use. Defaults to the standard Arduino hardware SPI interface

References _useRFO.

Member Function Documentation

◆ available()

bool RH_RF95::available ( )
virtual

Tests whether a new message is available from the Driver. On most drivers, this will also put the Driver into RHModeRx mode until a message is actually received by the transport, when it will be returned to RHModeIdle. This can be called multiple times in a timeout loop

Returns
true if a new, complete, error-free uncollected message is available to be retreived by recv()

Implements RHGenericDriver.

References RHGenericDriver::_mode, RHGenericDriver::RHModeTx, and setModeRx().

Referenced by recv().

◆ enableTCXO()

void RH_RF95::enableTCXO ( bool  on = true)

Enable TCXO mode Call this immediately after init(), to force your radio to use an external frequency source, such as a Temperature Compensated Crystal Oscillator (TCXO), if available. See the comments in the main documentation about the sensitivity of this radio to clock frequency especially when using narrow bandwidths. Leaves the module in sleep mode. Caution: the TCXO model radios are not low power when in sleep (consuming about ~600 uA, reported by Phang Moh Lim.
Caution: if you enable TCXO and there is no exernal TCXO signal connected to the radio or if the exerrnal TCXO is not powered up, the radio will not work< >

Parameters
[in]onIf true (the default) enables the radio to use the external TCXO.

References sleep(), RHSPIDriver::spiRead(), and RHSPIDriver::spiWrite().

◆ frequencyError()

int RH_RF95::frequencyError ( )

Returns the last measured frequency error. The LoRa receiver estimates the frequency offset between the receiver centre frequency and that of the received LoRa signal. This function returns the estimates offset (in Hz) of the last received message. Caution: this measurement is not absolute, but is measured relative to the local receiver's oscillator. Apparent errors may be due to the transmitter, the receiver or both.

Returns
The estimated centre frequency offset in Hz of the last received message. If the modem bandwidth selector in register RH_RF95_REG_1D_MODEM_CONFIG1 is invalid, returns 0.

References RHSPIDriver::spiRead().

◆ getDeviceVersion()

uint8_t RH_RF95::getDeviceVersion ( )

tilma.nosp@m.n_1@.nosp@m.gloet.nosp@m.zner.nosp@m..net Returns device version from register 42

Parameters
none
Returns
uint8_t deviceID

References RHSPIDriver::spiRead().

◆ handleInterrupt()

void RH_RF95::handleInterrupt ( )
protected

◆ init()

bool RH_RF95::init ( )
virtual

Initialise the Driver transport hardware and software. Leaves the radio in idle mode, with default configuration of: 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on

Returns
true if initialisation succeeded.

Reimplemented from RHGenericDriver.

Reimplemented in RH_ABZ.

References Bw125Cr45Sf128, RHSPIDriver::init(), setFrequency(), setModeIdle(), setModemConfig(), setPreambleLength(), setTxPower(), setupInterruptHandler(), RHSPIDriver::spiRead(), and RHSPIDriver::spiWrite().

◆ isChannelActive()

bool RH_RF95::isChannelActive ( )
virtual

Use the radio's Channel Activity Detect (CAD) function to detect channel activity. Sets the RF95 radio into CAD mode and waits until CAD detection is complete. To be used in a listen-before-talk mechanism (Collision Avoidance) with a reasonable time backoff algorithm. This is called automatically by waitCAD().

Returns
true if channel is in use.

Reimplemented from RHGenericDriver.

References RHGenericDriver::_cad, RHGenericDriver::_mode, modeWillChange(), RHGenericDriver::RHModeCad, and RHSPIDriver::spiWrite().

◆ lastSNR()

int RH_RF95::lastSNR ( )

Returns the Signal-to-noise ratio (SNR) of the last received message, as measured by the receiver.

Returns
SNR of the last received message in dB

◆ maxMessageLength()

uint8_t RH_RF95::maxMessageLength ( )
virtual

Returns the maximum message length available in this Driver.

Returns
The maximum legal message length

Implements RHGenericDriver.

◆ modeWillChange()

virtual bool RH_RF95::modeWillChange ( RHMode  )
inlineprotectedvirtual

Called by RH_RF95 when the radio mode is about to change to a new setting. Can be used by subclasses to implement antenna switching etc.

Parameters
[in]modeRHMode the new mode about to take effect
Returns
true if the subclasses changes successful

Reimplemented in RH_ABZ.

Referenced by isChannelActive(), setModeIdle(), setModeRx(), setModeTx(), and sleep().

◆ printRegisters()

bool RH_RF95::printRegisters ( )

Prints the value of all chip registers to the Serial device if RH_HAVE_SERIAL is defined for the current platform For debugging purposes only.

Returns
true on success

References RHSPIDriver::spiRead().

◆ recv()

bool RH_RF95::recv ( uint8_t *  buf,
uint8_t *  len 
)
virtual

Turns the receiver on if it not already on. If there is a valid message available, copy it to buf and return true else return false. If a message is copied, *len is set to the length (Caution, 0 length messages are permitted). You should be sure to call this function frequently enough to not miss any messages It is recommended that you call it in your main loop.

Parameters
[in]bufLocation to copy the received message
[in,out]lenPointer to the number of octets available in buf. The number be reset to the actual number of octets copied.
Returns
true if a valid message was copied to buf

Implements RHGenericDriver.

References available(), and clearRxBuf().

◆ send()

bool RH_RF95::send ( const uint8_t *  data,
uint8_t  len 
)
virtual

Waits until any previous transmit packet is finished being transmitted with waitPacketSent(). Then optionally waits for Channel Activity Detection (CAD) to show the channnel is clear (if the radio supports CAD) by calling waitCAD(). Then loads a message into the transmitter and starts the transmitter. Note that a message length of 0 is permitted.

Parameters
[in]dataArray of data to be sent
[in]lenNumber of bytes of data to send specify the maximum time in ms to wait. If 0 (the default) do not wait for CAD before transmitting.
Returns
true if the message length was valid and it was correctly queued for transmit. Return false if CAD was requested and the CAD timeout timed out before clear channel was detected.

Implements RHGenericDriver.

References RHGenericDriver::_txHeaderFlags, RHGenericDriver::_txHeaderFrom, RHGenericDriver::_txHeaderId, RHGenericDriver::_txHeaderTo, setModeIdle(), setModeTx(), RHSPIDriver::spiBurstWrite(), RHSPIDriver::spiWrite(), RHGenericDriver::waitCAD(), and RHGenericDriver::waitPacketSent().

◆ setCodingRate4()

void RH_RF95::setCodingRate4 ( uint8_t  denominator)

brian.nosp@m..n.n.nosp@m.orman.nosp@m.@gma.nosp@m.il.co.nosp@m.m 9th Nov 2018 Sets the coding rate to 4/5, 4/6, 4/7 or 4/8. Valid denominator values are 5, 6, 7 or 8. A value of 5 sets the coding rate to 4/5 etc. Values below 5 are clamped at 5 values above 8 are clamped at 8. Default for all standard modem config options is 4/5.

Parameters
[in]denominatoruint8_t range 5..8

References RHSPIDriver::spiRead(), and RHSPIDriver::spiWrite().

◆ setFrequency()

bool RH_RF95::setFrequency ( float  centre)

Sets the transmitter and receiver centre frequency.

Parameters
[in]centreFrequency in MHz. 137.0 to 1020.0. Caution: RFM95/96/97/98 comes in several different frequency ranges, and setting a frequency outside that range of your radio will probably not work
Returns
true if the selected frquency centre is within range

References RHSPIDriver::spiWrite().

Referenced by init().

◆ setLowDatarate()

void RH_RF95::setLowDatarate ( )

brian.nosp@m..n.n.nosp@m.orman.nosp@m.@gma.nosp@m.il.co.nosp@m.m 9th Nov 2018 sets the low data rate flag if symbol time exceeds 16ms ref: https://www.thethingsnetwork.org/forum/t/a-point-to-note-lora-low-data-rate-optimisation-flag/12007 called by setBandwidth() and setSpreadingfactor() since these affect the symbol time.

References RHSPIDriver::spiRead(), and RHSPIDriver::spiWrite().

Referenced by setSignalBandwidth(), and setSpreadingFactor().

◆ setModeIdle()

void RH_RF95::setModeIdle ( )

If current mode is Rx or Tx changes it to Idle. If the transmitter or receiver is running, disables them.

References RHGenericDriver::_mode, modeWillChange(), RHGenericDriver::RHModeIdle, and RHSPIDriver::spiWrite().

Referenced by handleInterrupt(), init(), and send().

◆ setModemConfig()

bool RH_RF95::setModemConfig ( ModemConfigChoice  index)

Select one of the predefined modem configurations. If you need a modem configuration not provided here, use setModemRegisters() with your own ModemConfig. Caution: the slowest protocols may require a radio module with TCXO temperature controlled oscillator for reliable operation.

Parameters
[in]indexThe configuration choice.
Returns
true if index is a valid choice.

References setModemRegisters().

Referenced by init().

◆ setModemRegisters()

void RH_RF95::setModemRegisters ( const ModemConfig config)

Sets all the registers required to configure the data modem in the radio, including the bandwidth, spreading factor etc. You can use this to configure the modem with custom configurations if none of the canned configurations in ModemConfigChoice suit you.

Parameters
[in]configA ModemConfig structure containing values for the modem configuration registers.

References RH_RF95::ModemConfig::reg_1d, RH_RF95::ModemConfig::reg_1e, RH_RF95::ModemConfig::reg_26, and RHSPIDriver::spiWrite().

Referenced by setModemConfig().

◆ setModeRx()

void RH_RF95::setModeRx ( )

If current mode is Tx or Idle, changes it to Rx. Starts the receiver in the RF95/96/97/98.

References RHGenericDriver::_mode, modeWillChange(), RHGenericDriver::RHModeRx, and RHSPIDriver::spiWrite().

Referenced by available().

◆ setModeTx()

void RH_RF95::setModeTx ( )

If current mode is Rx or Idle, changes it to Rx. F Starts the transmitter in the RF95/96/97/98.

References RHGenericDriver::_mode, modeWillChange(), RHGenericDriver::RHModeTx, and RHSPIDriver::spiWrite().

Referenced by send().

◆ setPayloadCRC()

void RH_RF95::setPayloadCRC ( bool  on)

brian.nosp@m..n.n.nosp@m.orman.nosp@m.@gma.nosp@m.il.co.nosp@m.m 9th Nov 2018 Allows the CRC to be turned on/off. Default is true (enabled) When true, RH_RF95 sends a CRC in outgoing packets and requires a valid CRC to be present and correct on incoming packets. When false, does not send CRC in outgoing packets and does not require a CRC to be present on incoming packets. However if a CRC is present, it must be correct. Normally this should be left on (the default) so that packets with a bad CRC are rejected. If turned off you will be much more likely to receive false noise packets.

Parameters
[in]onbool, true enables CRCs in incoming and outgoing packets, false disables them

References RHSPIDriver::spiRead(), and RHSPIDriver::spiWrite().

◆ setPreambleLength()

void RH_RF95::setPreambleLength ( uint16_t  bytes)

Sets the length of the preamble in bytes. Caution: this should be set to the same value on all nodes in your network. Default is 8. Sets the message preamble length in RH_RF95_REG_??_PREAMBLE_?SB

Parameters
[in]bytesPreamble length in bytes.

References RHSPIDriver::spiWrite().

Referenced by init().

◆ setSignalBandwidth()

void RH_RF95::setSignalBandwidth ( long  sbw)

brian.nosp@m..n.n.nosp@m.orman.nosp@m.@gma.nosp@m.il.co.nosp@m.m 9th Nov 2018 Sets the radio signal bandwidth sbw ranges and resultant settings are as follows:- sbw range actual bw (kHz) 0-7800 7.8 7801-10400 10.4 10401-15600 15.6 15601-20800 20.8 20801-31250 31.25 31251-41700 41.7 41701-62500 62.5 62501-12500 125.0 12501-250000 250.0 >250000 500.0 NOTE caution Earlier - Semtech do not recommend BW below 62.5 although, in testing I managed 31.25 with two devices in close proximity.

Parameters
[in]sbwlong, signal bandwidth e.g. 125000

References setLowDatarate(), RHSPIDriver::spiRead(), and RHSPIDriver::spiWrite().

◆ setSpreadingFactor()

void RH_RF95::setSpreadingFactor ( uint8_t  sf)

brian.nosp@m..n.n.nosp@m.orman.nosp@m.@gma.nosp@m.il.co.nosp@m.m 9th Nov 2018 Sets the radio spreading factor. valid values are 6 through 12. Out of range values below 6 are clamped to 6 Out of range values above 12 are clamped to 12 See Semtech DS SX1276/77/78/79 page 27 regarding SF6 configuration.

Parameters
[in]uint8_tsf (spreading factor 6..12)
Returns
nothing

References setLowDatarate(), RHSPIDriver::spiRead(), and RHSPIDriver::spiWrite().

◆ setTxPower()

void RH_RF95::setTxPower ( int8_t  power,
bool  useRFO = false 
)

Sets the transmitter power output level, and configures the transmitter pin. Be a good neighbour and set the lowest power level you need. Some SX1276/77/78/79 and compatible modules (such as RFM95/96/97/98) use the PA_BOOST transmitter pin for high power output (and optionally the PA_DAC) while some (such as the Modtronix inAir4 and inAir9) use the RFO transmitter pin for lower power but higher efficiency. You must set the appropriate power level and useRFO argument for your module. Check with your module manufacturer which transmtter pin is used on your module to ensure you are setting useRFO correctly. Failure to do so will result in very low transmitter power output. Caution: legal power limits may apply in certain countries. After init(), the power will be set to 13dBm, with useRFO false (ie PA_BOOST enabled).

Parameters
[in]powerTransmitter power level in dBm. For RFM95/96/97/98 LORA with useRFO false, valid values are from +2 to +20. For 18, 19 and 20, PA_DAC is enabled, For Modtronix inAir4 and inAir9 with useRFO true (ie RFO pins in use), valid values are from 0 to 15.
[in]useRFOIf true, enables the use of the RFO transmitter pins instead of the PA_BOOST pin (false). Choose the correct setting for your module.

References _useRFO, and RHSPIDriver::spiWrite().

Referenced by init().

◆ sleep()

bool RH_RF95::sleep ( )
virtual

Sets the radio into low-power sleep mode. If successful, the transport will stay in sleep mode until woken by changing mode it idle, transmit or receive (eg by calling send(), recv(), available() etc) Caution: there is a time penalty as the radio takes a finite time to wake from sleep mode.

Returns
true if sleep mode was successfully entered.

Reimplemented from RHGenericDriver.

References RHGenericDriver::_mode, modeWillChange(), RHGenericDriver::RHModeSleep, and RHSPIDriver::spiWrite().

Referenced by enableTCXO().

Member Data Documentation

◆ _useRFO

bool RH_RF95::_useRFO
protected

False if the PA_BOOST transmitter output pin is to be used. True if the RFO transmitter output pin is to be used.

Referenced by RH_RF95(), and setTxPower().


The documentation for this class was generated from the following files: