Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
RH_RF95 Class Reference
Driver to send and receive unaddressed, unreliable datagrams via a LoRa capable radio transceiver. More...
#include <RH_RF95.h>
Inherits RHSPIDriver.
Data Structures | |
struct | ModemConfig |
Defines register values for a set of modem configuration registers. More... | |
Public Types | |
enum | ModemConfigChoice { Bw125Cr45Sf128 = 0, Bw500Cr45Sf128, Bw31_25Cr48Sf512, Bw125Cr48Sf4096 } |
Choices for setModemConfig() for a selected subset of common data rates. More... | |
enum | RHMode { RHModeInitialising = 0, RHModeSleep, RHModeIdle, RHModeTx, RHModeRx } |
Defines different operating modes for the transport hardware. More... | |
Public Member Functions | |
RH_RF95 (PINS slaveSelectPin, PINS interruptPin, RHGenericSPI &spi=hardware_spi) | |
Constructor. | |
virtual bool | init () |
Initialise the Driver transport hardware and software. | |
bool | 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. | |
void | setModemRegisters (const ModemConfig *config) |
Sets all the registered required to configure the data modem in the RF95/96/97/98, including the bandwidth, spreading factor etc. | |
bool | setModemConfig (ModemConfigChoice index) |
Select one of the predefined modem configurations. | |
virtual bool | available () |
Tests whether a new message is available from the Driver. | |
virtual bool | recv (uint8_t *buf, uint8_t *len) |
Turns the receiver on if it not already on. | |
virtual bool | send (const uint8_t *data, uint8_t len) |
Waits until any previous transmit packet is finished being transmitted with waitPacketSent(). | |
void | setPreambleLength (uint16_t bytes) |
Sets the length of the preamble in bytes. | |
virtual uint8_t | maxMessageLength () |
Returns the maximum message length available in this Driver. | |
bool | setFrequency (float centre) |
Sets the transmitter and receiver centre frequency. | |
void | setModeIdle () |
If current mode is Rx or Tx changes it to Idle. | |
void | setModeRx () |
If current mode is Tx or Idle, changes it to Rx. | |
void | setModeTx () |
If current mode is Rx or Idle, changes it to Rx. | |
void | setTxPower (int8_t power) |
Sets the transmitter power output level. | |
virtual bool | sleep () |
Sets the radio into low-power sleep mode. | |
uint8_t | spiRead (uint8_t reg) |
Reads a single register from the SPI device. | |
uint8_t | spiWrite (uint8_t reg, uint8_t val) |
Writes a single byte to the SPI device. | |
uint8_t | spiBurstRead (uint8_t reg, uint8_t *dest, uint8_t len) |
Reads a number of consecutive registers from the SPI device using burst read mode. | |
uint8_t | spiBurstWrite (uint8_t reg, const uint8_t *src, uint8_t len) |
Write a number of consecutive registers using burst write mode. | |
virtual void | waitAvailable () |
Starts the receiver and blocks until a valid received message is available. | |
virtual bool | waitPacketSent () |
Blocks until the transmitter is no longer transmitting. | |
virtual bool | waitPacketSent (uint16_t timeout) |
Blocks until the transmitter is no longer transmitting. | |
virtual bool | waitAvailableTimeout (uint16_t timeout) |
Starts the receiver and blocks until a received message is available or a timeout. | |
virtual void | setThisAddress (uint8_t thisAddress) |
Sets the address of this node. | |
virtual void | setHeaderTo (uint8_t to) |
Sets the TO header to be sent in all subsequent messages. | |
virtual void | setHeaderFrom (uint8_t from) |
Sets the FROM header to be sent in all subsequent messages. | |
virtual void | setHeaderId (uint8_t id) |
Sets the ID header to be sent in all subsequent messages. | |
virtual void | setHeaderFlags (uint8_t set, uint8_t clear=RH_FLAGS_APPLICATION_SPECIFIC) |
Sets and clears bits in the FLAGS header to be sent in all subsequent messages First it clears he FLAGS according to the clear argument, then sets the flags according to the set argument. | |
virtual void | setPromiscuous (bool promiscuous) |
Tells the receiver to accept messages with any TO address, not just messages addressed to thisAddress or the broadcast address. | |
virtual uint8_t | headerTo () |
Returns the TO header of the last received message. | |
virtual uint8_t | headerFrom () |
Returns the FROM header of the last received message. | |
virtual uint8_t | headerId () |
Returns the ID header of the last received message. | |
virtual uint8_t | headerFlags () |
Returns the FLAGS header of the last received message. | |
int8_t | lastRssi () |
Returns the most recent RSSI (Receiver Signal Strength Indicator). | |
RHMode | mode () |
Returns the operating mode of the library. | |
void | setMode (RHMode mode) |
Sets the operating mode of the transport. | |
uint16_t | rxBad () |
Returns the count of the number of bad received packets (ie packets with bad lengths, checksum etc) which were rejected and not delivered to the application. | |
uint16_t | rxGood () |
Returns the count of the number of good received packets. | |
uint16_t | txGood () |
Returns the count of the number of packets successfully transmitted (though not necessarily received by the destination) | |
Static Public Member Functions | |
static void | printBuffer (const char *prompt, const uint8_t *buf, uint8_t len) |
Prints a data buffer in HEX. | |
Protected Member Functions | |
void | handleInterrupt () |
This is a low level function to handle the interrupts for one instance of RH_RF95. | |
void | validateRxBuf () |
Examine the revceive buffer to determine whether the message is for this node. | |
void | clearRxBuf () |
Clear our local receive buffer. | |
Protected Attributes | |
RHGenericSPI & | _spi |
Reference to the RHGenericSPI instance to use to trasnfer data with teh SPI device. | |
DigitalOut | _slaveSelectPin |
The pin number of the Slave Selct pin that is used to select the desired device. | |
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 int8_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. |
Detailed Description
Driver to send and receive unaddressed, unreliable datagrams via a LoRa capable radio transceiver.
For Semtech SX1276/77/78 and HopeRF RFM95/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 FSK/GFSK/OOK modes are not (yet) supported.
Works with
- the excellent MiniWirelessLoRa from Anarduino http://www.anarduino.com/miniwireless
- 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) and compatible radio modules in LoRa mode.
The Hope-RF (http://www.hoperf.com) RFM95/96/97/98(W) 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 RFM95/96/97/98(W) 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
- Packet Format
All messages sent and received by this RH_RF95 Driver conform to this packet format:
- LoRa mode:
- 8 symbol PREAMBLE
- Explicit header with header CRC (handled internally by the radio)
- 4 octets HEADER: (TO, FROM, ID, FLAGS)
- 0 to 251 octets DATA
- CRC (handled internally by the radio)
- Connecting RFM95/96/97/98 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 (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).
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:
- reset's/bootups terminate with "init failed" messages
- random termination of communication after 5-30 packets sent/received
- "fake ok" state, where initialization passes fluently, but communication doesn't happen
- shields hang Arduino boards, especially during the flashing
- 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 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:
- Mysterious crashes and restarts
- Changes in behaviour when seemingly unrelated changes are made (such as adding print() statements)
- Hanging
- Output from Serial.print() not appearing
- Range
We have made some simple range tests under the following conditions:
- rf95_client base station connected to a VHF discone antenna at 8m height above ground
- rf95_server mobile connected to 17.3cm 1/4 wavelength antenna at 1m height, no ground plane.
- Both configured for 13dBm, 434MHz, Bw = 125 kHz, Cr = 4/8, Sf = 4096chips/symbol, CRC on. Slow+long range
- Minimum reported RSSI seen for successful comms was about -91
- Range over flat ground through heavy trees and vegetation approx 2km.
- At 20dBm (100mW) otherwise identical conditions approx 3km.
- At 20dBm, along salt water flat sandy beach, 3.2km.
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.
- Range over flat ground through heavy trees and vegetation approx 2km.
- Transmitter Power
You can control the transmitter power on the RF transceiver with the RH_RF95::setTxPower() function. The argument can be any of +5 to +23 The default is 13. Eg:
driver.setTxPower(10);
We have made some actual power measurements against programmed power for Anarduino MiniWirelessLoRa (which has RFM96W-433Mhz installed)
- MiniWirelessLoRa RFM96W-433Mhz, USB power
- 30cm RG316 soldered direct to RFM96W module ANT and GND
- SMA connector
- 12db attenuator
- SMA connector
- MiniKits AD8307 HF/VHF Power Head (calibrated against Rohde&Schwartz 806.2020 test set)
- Tektronix TDS220 scope to measure the Vout from power head (Caution: we dont claim laboratory accuracy for these measurements) You would not expect to get anywhere near these powers to air with a simple 1/4 wavelength wire antenna.
Program power Measured Power dBm dBm 5 5 7 7 9 8 11 11 13 13 15 15 17 16 19 18 20 20 21 21 22 22 23 23
Definition at line 401 of file RH_RF95.h.
Member Enumeration Documentation
enum 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).
- Enumerator:
enum RHMode [inherited] |
Defines different operating modes for the transport hardware.
These are the different values that can be adopted by the _mode variable and returned by the mode() member function,
- Enumerator:
RHModeInitialising Transport is initialising. Initial default value until init() is called..
RHModeSleep Transport hardware is in low power sleep mode (if supported)
RHModeIdle Transport is idle.
RHModeTx Transport is in the process of transmitting a message.
RHModeRx Transport is in the process of receiving a message.
Definition at line 45 of file RHGenericDriver.h.
Constructor & Destructor Documentation
RH_RF95 | ( | PINS | slaveSelectPin, |
PINS | interruptPin, | ||
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] slaveSelectPin the 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] interruptPin The 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 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] spi Pointer to the SPI interface object to use. Defaults to the standard Arduino hardware SPI interface
Definition at line 26 of file RH_RF95.cpp.
Member Function Documentation
bool 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 wil 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.
Definition at line 209 of file RH_RF95.cpp.
void clearRxBuf | ( | ) | [protected] |
Clear our local receive buffer.
Definition at line 217 of file RH_RF95.cpp.
void handleInterrupt | ( | ) | [protected] |
This is a low level function to handle the interrupts for one instance of RH_RF95.
Called automatically by isr*() Should not need to be called by user code.
Definition at line 133 of file RH_RF95.cpp.
uint8_t headerFlags | ( | ) | [virtual, inherited] |
Returns the FLAGS header of the last received message.
- Returns:
- The FLAGS header
Definition at line 119 of file RHGenericDriver.cpp.
uint8_t headerFrom | ( | ) | [virtual, inherited] |
Returns the FROM header of the last received message.
- Returns:
- The FROM header
Definition at line 109 of file RHGenericDriver.cpp.
uint8_t headerId | ( | ) | [virtual, inherited] |
Returns the ID header of the last received message.
- Returns:
- The ID header
Definition at line 114 of file RHGenericDriver.cpp.
uint8_t headerTo | ( | ) | [virtual, inherited] |
Returns the TO header of the last received message.
- Returns:
- The TO header
Definition at line 104 of file RHGenericDriver.cpp.
bool init | ( | ) | [virtual] |
Initialise the Driver transport hardware and software.
Make sure the Driver is properly configured before calling init().
- Returns:
- true if initialisation succeeded.
Reimplemented from RHSPIDriver.
Definition at line 35 of file RH_RF95.cpp.
int8_t lastRssi | ( | ) | [inherited] |
Returns the most recent RSSI (Receiver Signal Strength Indicator).
Usually it is the RSSI of the last received message, which is measured when the preamble is received. If you called readRssi() more recently, it will return that more recent value.
- Returns:
- The most recent RSSI measurement in dBm.
Definition at line 124 of file RHGenericDriver.cpp.
uint8_t maxMessageLength | ( | ) | [virtual] |
Returns the maximum message length available in this Driver.
- Returns:
- The maximum legal message length
Implements RHGenericDriver.
Definition at line 282 of file RH_RF95.cpp.
RHGenericDriver::RHMode mode | ( | ) | [inherited] |
Returns the operating mode of the library.
- Returns:
- the current mode, one of RF69_MODE_*
Definition at line 129 of file RHGenericDriver.cpp.
void printBuffer | ( | const char * | prompt, |
const uint8_t * | buf, | ||
uint8_t | len | ||
) | [static, inherited] |
Prints a data buffer in HEX.
For diagnostic use
- Parameters:
-
[in] prompt string to preface the print [in] buf Location of the buffer to print [in] len Length of the buffer in octets.
Definition at line 145 of file RHGenericDriver.cpp.
bool 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
Definition at line 266 of file RH_RF95.cpp.
bool 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] buf Location to copy the received message [in,out] len Pointer to available space in buf. Set to the actual number of octets copied.
- Returns:
- true if a valid message was copied to buf
Implements RHGenericDriver.
Definition at line 225 of file RH_RF95.cpp.
uint16_t rxBad | ( | ) | [inherited] |
Returns the count of the number of bad received packets (ie packets with bad lengths, checksum etc) which were rejected and not delivered to the application.
Caution: not all drivers can correctly report this count. Some underlying hardware only report good packets.
- Returns:
- The number of bad packets received.
Definition at line 165 of file RHGenericDriver.cpp.
uint16_t rxGood | ( | ) | [inherited] |
Returns the count of the number of good received packets.
- Returns:
- The number of good packets received.
Definition at line 170 of file RHGenericDriver.cpp.
bool send | ( | const uint8_t * | data, |
uint8_t | len | ||
) | [virtual] |
Waits until any previous transmit packet is finished being transmitted with waitPacketSent().
Then loads a message into the transmitter and starts the transmitter. Note that a message length of 0 is permitted.
- Parameters:
-
[in] data Array of data to be sent [in] len Number of bytes of data to send
- Returns:
- true if the message length was valid and it was correctly queued for transmit
Implements RHGenericDriver.
Definition at line 242 of file RH_RF95.cpp.
bool setFrequency | ( | float | centre ) |
Sets the transmitter and receiver centre frequency.
- Parameters:
-
[in] centre Frequency 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
Definition at line 287 of file RH_RF95.cpp.
void setHeaderFlags | ( | uint8_t | set, |
uint8_t | clear = RH_FLAGS_APPLICATION_SPECIFIC |
||
) | [virtual, inherited] |
Sets and clears bits in the FLAGS header to be sent in all subsequent messages First it clears he FLAGS according to the clear argument, then sets the flags according to the set argument.
The default for clear always clears the application specific flags.
- Parameters:
-
[in] set bitmask of bits to be set. Flags are cleared with the clear mask before being set. [in] clear bitmask of flags to clear. Defaults to RH_FLAGS_APPLICATION_SPECIFIC which clears the application specific flags, resultiung in new application specific flags identical to the set.
Definition at line 98 of file RHGenericDriver.cpp.
void setHeaderFrom | ( | uint8_t | from ) | [virtual, inherited] |
Sets the FROM header to be sent in all subsequent messages.
- Parameters:
-
[in] from The new FROM header value
Definition at line 88 of file RHGenericDriver.cpp.
void setHeaderId | ( | uint8_t | id ) | [virtual, inherited] |
Sets the ID header to be sent in all subsequent messages.
- Parameters:
-
[in] id The new ID header value
Definition at line 93 of file RHGenericDriver.cpp.
void setHeaderTo | ( | uint8_t | to ) | [virtual, inherited] |
Sets the TO header to be sent in all subsequent messages.
- Parameters:
-
[in] to The new TO header value
Definition at line 83 of file RHGenericDriver.cpp.
void setMode | ( | RHMode | mode ) | [inherited] |
Sets the operating mode of the transport.
Definition at line 134 of file RHGenericDriver.cpp.
void setModeIdle | ( | ) |
If current mode is Rx or Tx changes it to Idle.
If the transmitter or receiver is running, disables them.
Definition at line 298 of file RH_RF95.cpp.
bool 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.
- Parameters:
-
[in] index The configuration choice.
- Returns:
- true if index is a valid choice.
Definition at line 376 of file RH_RF95.cpp.
void setModemRegisters | ( | const ModemConfig * | config ) |
Sets all the registered required to configure the data modem in the RF95/96/97/98, 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] config A ModemConfig structure containing values for the modem configuration registers.
Definition at line 367 of file RH_RF95.cpp.
void setModeRx | ( | ) |
If current mode is Tx or Idle, changes it to Rx.
Starts the receiver in the RF95/96/97/98.
Definition at line 317 of file RH_RF95.cpp.
void setModeTx | ( | ) |
If current mode is Rx or Idle, changes it to Rx.
F Starts the transmitter in the RF95/96/97/98.
Definition at line 327 of file RH_RF95.cpp.
void 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] bytes Preamble length in bytes.
Definition at line 388 of file RH_RF95.cpp.
void setPromiscuous | ( | bool | promiscuous ) | [virtual, inherited] |
Tells the receiver to accept messages with any TO address, not just messages addressed to thisAddress or the broadcast address.
- Parameters:
-
[in] promiscuous true if you wish to receive messages with any TO address
Reimplemented in RH_RF22.
Definition at line 73 of file RHGenericDriver.cpp.
void setThisAddress | ( | uint8_t | thisAddress ) | [virtual, inherited] |
Sets the address of this node.
Defaults to 0xFF. Subclasses or the user may want to change this. This will be used to test the adddress in incoming messages. In non-promiscuous mode, only messages with a TO header the same as thisAddress or the broadcast addess (0xFF) will be accepted. In promiscuous mode, all messages will be accepted regardless of the TO header. In a conventional multinode system, all nodes will have a unique address (which you could store in EEPROM). You would normally set the header FROM address to be the same as thisAddress (though you dont have to, allowing the possibilty of address spoofing).
- Parameters:
-
[in] thisAddress The address of this node.
Reimplemented in RH_RF22, and RH_TCP.
Definition at line 78 of file RHGenericDriver.cpp.
void setTxPower | ( | int8_t | power ) |
Sets the transmitter power output level.
Be a good neighbour and set the lowest power level you need. Caution: legal power limits may apply in certain countries. At powers above 20dBm, PA_DAC is enabled. After init(), the power will be set to 13dBm.
- Parameters:
-
[in] power Transmitter power level in dBm. For RFM95/96/97/98 LORA, valid values are from +5 to +23
Definition at line 337 of file RH_RF95.cpp.
bool 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.
Definition at line 307 of file RH_RF95.cpp.
uint8_t spiBurstRead | ( | uint8_t | reg, |
uint8_t * | dest, | ||
uint8_t | len | ||
) | [inherited] |
Reads a number of consecutive registers from the SPI device using burst read mode.
- Parameters:
-
[in] reg Register number of the first register [in] dest Array to write the register values to. Must be at least len bytes [in] len Number of bytes to read
- Returns:
- Some devices return a status byte during the first data transfer. This byte is returned. it may or may not be meaningfule depending on the the type of device being accessed.
Definition at line 56 of file RHSPIDriver.cpp.
uint8_t spiBurstWrite | ( | uint8_t | reg, |
const uint8_t * | src, | ||
uint8_t | len | ||
) | [inherited] |
Write a number of consecutive registers using burst write mode.
- Parameters:
-
[in] reg Register number of the first register [in] src Array of new register values to write. Must be at least len bytes [in] len Number of bytes to write
- Returns:
- Some devices return a status byte during the first data transfer. This byte is returned. it may or may not be meaningfule depending on the the type of device being accessed.
Definition at line 69 of file RHSPIDriver.cpp.
uint8_t spiRead | ( | uint8_t | reg ) | [inherited] |
Reads a single register from the SPI device.
- Parameters:
-
[in] reg Register number
- Returns:
- The value of the register
Definition at line 32 of file RHSPIDriver.cpp.
uint8_t spiWrite | ( | uint8_t | reg, |
uint8_t | val | ||
) | [inherited] |
Writes a single byte to the SPI device.
- Parameters:
-
[in] reg Register number [in] val The value to write
- Returns:
- Some devices return a status byte during the first data transfer. This byte is returned. it may or may not be meaningfule depending on the the type of device being accessed.
Definition at line 44 of file RHSPIDriver.cpp.
uint16_t txGood | ( | ) | [inherited] |
Returns the count of the number of packets successfully transmitted (though not necessarily received by the destination)
- Returns:
- The number of packets successfully transmitted
Definition at line 175 of file RHGenericDriver.cpp.
void validateRxBuf | ( | ) | [protected] |
Examine the revceive buffer to determine whether the message is for this node.
Definition at line 191 of file RH_RF95.cpp.
void waitAvailable | ( | ) | [virtual, inherited] |
Starts the receiver and blocks until a valid received message is available.
Reimplemented in RH_TCP.
Definition at line 33 of file RHGenericDriver.cpp.
bool waitAvailableTimeout | ( | uint16_t | timeout ) | [virtual, inherited] |
Starts the receiver and blocks until a received message is available or a timeout.
- Parameters:
-
[in] timeout Maximum time to wait in milliseconds.
- Returns:
- true if a message is available
Reimplemented in RH_TCP.
Definition at line 42 of file RHGenericDriver.cpp.
bool waitPacketSent | ( | uint16_t | timeout ) | [virtual, inherited] |
Blocks until the transmitter is no longer transmitting.
or until the timeout occuers, whichever happens first
- Parameters:
-
[in] timeout Maximum time to wait in milliseconds.
- Returns:
- true if the RF22 completed transmission within the timeout period. False if it timed out.
Definition at line 61 of file RHGenericDriver.cpp.
bool waitPacketSent | ( | ) | [virtual, inherited] |
Blocks until the transmitter is no longer transmitting.
Reimplemented in RH_NRF24, RH_NRF51, and RH_NRF905.
Definition at line 54 of file RHGenericDriver.cpp.
Field Documentation
volatile int8_t _lastRssi [protected, inherited] |
The value of the last received RSSI value, in some transport specific units.
Definition at line 249 of file RHGenericDriver.h.
The current transport operating mode.
Definition at line 216 of file RHGenericDriver.h.
bool _promiscuous [protected, inherited] |
Whether the transport is in promiscuous mode.
Definition at line 222 of file RHGenericDriver.h.
volatile uint16_t _rxBad [protected, inherited] |
Count of the number of bad messages (eg bad checksum etc) received.
Definition at line 252 of file RHGenericDriver.h.
volatile uint16_t _rxGood [protected, inherited] |
Count of the number of successfully transmitted messaged.
Definition at line 255 of file RHGenericDriver.h.
volatile uint8_t _rxHeaderFlags [protected, inherited] |
FLAGS header in the last received mesasge.
Definition at line 234 of file RHGenericDriver.h.
volatile uint8_t _rxHeaderFrom [protected, inherited] |
FROM header in the last received mesasge.
Definition at line 228 of file RHGenericDriver.h.
volatile uint8_t _rxHeaderId [protected, inherited] |
ID header in the last received mesasge.
Definition at line 231 of file RHGenericDriver.h.
volatile uint8_t _rxHeaderTo [protected, inherited] |
TO header in the last received mesasge.
Definition at line 225 of file RHGenericDriver.h.
DigitalOut _slaveSelectPin [protected, inherited] |
The pin number of the Slave Selct pin that is used to select the desired device.
Definition at line 86 of file RHSPIDriver.h.
RHGenericSPI& _spi [protected, inherited] |
Reference to the RHGenericSPI instance to use to trasnfer data with teh SPI device.
Definition at line 82 of file RHSPIDriver.h.
uint8_t _thisAddress [protected, inherited] |
This node id.
Definition at line 219 of file RHGenericDriver.h.
volatile uint16_t _txGood [protected, inherited] |
Count of the number of bad messages (correct checksum etc) received.
Definition at line 258 of file RHGenericDriver.h.
uint8_t _txHeaderFlags [protected, inherited] |
FLAGS header to send in all messages.
Definition at line 246 of file RHGenericDriver.h.
uint8_t _txHeaderFrom [protected, inherited] |
FROM header to send in all messages.
Definition at line 240 of file RHGenericDriver.h.
uint8_t _txHeaderId [protected, inherited] |
ID header to send in all messages.
Definition at line 243 of file RHGenericDriver.h.
uint8_t _txHeaderTo [protected, inherited] |
TO header to send in all messages.
Definition at line 237 of file RHGenericDriver.h.
Generated on Tue Jul 12 2022 18:05:56 by
