RadioHead
|
Driver to send and receive unaddressed, unreliable datagrams via an RF69 and compatible radio transceiver. More...
#include <RH_RF69.h>
Classes | |
struct | ModemConfig |
Defines register values for a set of modem configuration registers. More... | |
Public Types | |
enum | ModemConfigChoice { FSK_Rb2Fd5 = 0 , FSK_Rb2_4Fd4_8 , FSK_Rb4_8Fd9_6 , FSK_Rb9_6Fd19_2 , FSK_Rb19_2Fd38_4 , FSK_Rb38_4Fd76_8 , FSK_Rb57_6Fd120 , FSK_Rb125Fd125 , FSK_Rb250Fd250 , FSK_Rb55555Fd50 , GFSK_Rb2Fd5 , GFSK_Rb2_4Fd4_8 , GFSK_Rb4_8Fd9_6 , GFSK_Rb9_6Fd19_2 , GFSK_Rb19_2Fd38_4 , GFSK_Rb38_4Fd76_8 , GFSK_Rb57_6Fd120 , GFSK_Rb125Fd125 , GFSK_Rb250Fd250 , GFSK_Rb55555Fd50 , OOK_Rb1Bw1 , OOK_Rb1_2Bw75 , OOK_Rb2_4Bw4_8 , OOK_Rb4_8Bw9_6 , OOK_Rb9_6Bw19_2 , OOK_Rb19_2Bw38_4 , OOK_Rb32Bw64 } |
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_RF69 (uint8_t slaveSelectPin=SS, uint8_t interruptPin=2, RHGenericSPI &spi=hardware_spi) | |
bool | init () |
int8_t | temperatureRead () |
bool | setFrequency (float centre, float afcPullInRange=0.05) |
int8_t | rssiRead () |
void | setOpMode (uint8_t mode) |
void | setModeIdle () |
void | setModeRx () |
void | setModeTx () |
void | setTxPower (int8_t power, bool ishighpowermodule=RH_RF69_DEFAULT_HIGHPOWER) |
void | setModemRegisters (const ModemConfig *config) |
bool | setModemConfig (ModemConfigChoice index) |
bool | available () |
bool | recv (uint8_t *buf, uint8_t *len) |
bool | send (const uint8_t *data, uint8_t len) |
void | setPreambleLength (uint16_t bytes) |
void | setSyncWords (const uint8_t *syncWords=NULL, uint8_t len=0) |
void | setEncryptionKey (uint8_t *key=NULL) |
uint32_t | getLastPreambleTime () |
uint8_t | maxMessageLength () |
bool | printRegister (uint8_t reg) |
bool | printRegisters () |
void | setIdleMode (uint8_t idleMode) |
virtual bool | sleep () |
uint16_t | deviceType () |
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 bool | isChannelActive () |
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 | |
void | handleInterrupt () |
void | readFifo () |
Protected Member Functions inherited from RHSPIDriver | |
virtual void | beginTransaction () |
virtual void | endTransaction () |
virtual void | selectSlave () |
virtual void | deselectSlave () |
Protected Attributes | |
uint8_t | _interruptPin |
The configured interrupt pin connected to this instance. | |
uint8_t | _myInterruptIndex |
uint8_t | _idleMode |
The radio OP mode to use when mode is RHModeIdle. | |
uint8_t | _deviceType |
The reported device type. | |
int8_t | _power |
The selected output power in dBm. | |
volatile uint8_t | _bufLen |
The message length in _buf. | |
uint8_t | _buf [RH_RF69_MAX_MESSAGE_LEN] |
Array of octets of teh last received message or the next to transmit message. | |
volatile bool | _rxBufValid |
True when there is a valid message in the Rx buffer. | |
uint32_t | _lastPreambleTime |
Time in millis since the last preamble was received (and the last time the RSSI was measured) | |
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. | |
Static Protected Attributes | |
static RH_RF69 * | _deviceForInterrupt [] = {0, 0, 0} |
Array of instances connected to interrupts 0 and 1. | |
static uint8_t | _interruptCount = 0 |
Index of next interrupt number to use in _deviceForInterrupt. | |
Additional Inherited Members | |
Static Public Member Functions inherited from RHGenericDriver | |
static void | printBuffer (const char *prompt, const uint8_t *buf, uint8_t len) |
Driver to send and receive unaddressed, unreliable datagrams via an RF69 and compatible radio transceiver.
Works with
This class provides basic functions for sending and receiving unaddressed, unreliable datagrams of arbitrary length to 64 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 RF69B and compatible radio modules, such as the RFM69 module.
The Hope-RF (http://www.hoperf.com) RF69 is a low-cost ISM transceiver chip. It supports FSK, GFSK, OOK over a wide range of frequencies and programmable data rates. It also suports AES encryption of up to 64 octets of payload It is available prepackaged on modules such as the RFM69W. And such modules can be prepacked on processor boards such as the Moteino from LowPowerLabs (which is what we used to develop the RH_RF69 driver)
This Driver provides functions for sending and receiving messages of up to 60 octets on any frequency supported by the RF69, in a range of predefined data rates and frequency deviations. 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 RF69B modules can be connected to an Arduino (3 on a Mega), permitting the construction of translators and frequency changers, etc.
The following modulation types are suppported with a range of modem configurations for common data rates and frequency deviations:
Support for other RF69 features such as on-chip temperature measurement, transmitter power control etc is also provided.
Tested on USB-Moteino with arduino-1.0.5 on OpenSuSE 13.1
All messages sent and received by this RH_RF69 Driver conform to this packet format:
For technical reasons, the message format is not protocol compatible with the 'HopeRF Radio Transceiver Message Library for Arduino' http://www.airspayce.com/mikem/arduino/HopeRF from the same author. Nor is it compatible with messages sent by 'Virtual Wire' http://www.airspayce.com/mikem/arduino/VirtualWire.pdf also from the same author. Nor is it compatible with messages sent by 'RF22' http://www.airspayce.com/mikem/arduino/RF22 also from the same author.
We tested with Moteino, which is an Arduino Uno compatible with the RFM69W 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 RFM69W that you want to connect to an Arduino, you might use these connections: CAUTION: you must use a 3.3V type Arduino, otherwise you will also need voltage level shifters between the Arduino and the RFM69. CAUTION, you must also ensure you connect an antenna
For Arduino Due, use these connections:
With these connections, you can then use the default constructor RH_RF69(). You can override the default settings for the SS pin and the interrupt in the RH_RF69 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).
If you have a Teensy 3.1 and a compatible RFM69 breakout board, you will need to construct the RH_RF69 instance like this:
If you have a MoteinoMEGA https://lowpowerlab.com/shop/moteinomega with RFM69 on board, you dont need to make any wiring connections (the RFM69 module is soldered onto the MotienoMEGA), but you must initialise the RH_RF69 constructor like this:
Make sure you have the MoteinoMEGA core installed in your Arduino hardware folder as described in the documentation for the MoteinoMEGA.
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:
If you have a Rocket Scream Mini Ultra Pro with the RFM69HCW
If you have a talk2 Whisper Node board with on-board RF69 radio, the example rf69_* sketches work without modifications. Initialise the radio like with the default constructor:
If you have a Feather 32u4 with RFM69HCW you need to initialise the driver like:
and since the radio is the high power HCW model, you must set the Tx power in the range 14 to 20 like this:
If you are connecting an RF69 to a ESP8266 board breakout board that exposes pins 12, 13, 14, 15 (ie NOT an ESP-01) you can connect like this:
and initialise with
If you are connecting an RF69 to a Sparkfun nRF52832 Breakout board with Arduino 1.8.9 with board: "SparkFun nRF52 Boards by Sparkfun Electronics version 0.2.3", you can connect like this:
and initialise with
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 RF69 module may be relevant in some circumstances: RF69 modules are capable of pulling 45mA+ at full power, where Arduino's 3.3V line can give 50mA. You may need to make provision for alternate power supply for the RF69, especially if you wish to use full transmit power, and/or you have other shields demanding power. Inadequate power for the RF69 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
This driver support the on-chip AES encryption provided by the RF69. You can enable encryption by calling setEncryptionKey() after init() has been called. If both transmitter and receiver have been configured with the same AES key, then the receiver will recover the unencrypted message sent by the receiver. However, you should note that there is no way for RF69 nor for the RadioHead drivers to know whether the AES key for a message is 'correct' or not. This is because the RF69 CRC covers the encrypted payload not the plaintext.
In RadioHead managers that support addressing, the RF69 AES encryption includes the RadioHead payload and the TO and FROM addresses, so occasionally (average one in 256 messages), a message encrypted with the 'wrong' key will have the 'correct' destination address, and will therefore be accepted by RadioHead as a 'random' message content from a 'random' sender. Its up to your code to figure out whether the message makes sense or not.
The RH_RF69 driver uses interrupts to react to events in the RF69 module, such as the reception of a new packet, or the completion of transmission of a packet. The RH_RF69 driver interrupt service routine reads status from and writes data to the the RF69 module via the SPI interface. It is very important therefore, that if you are using the RH_RF69 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.
The RH_RF69 driver requires non-trivial amounts of memory. The sample programs above 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_RF69 driver.
It is often hard to accurately identify when you are hitting RAM limits on Arduino. The symptoms can include:
The RF69 module is configured by the RH_RF69 driver to always use AFC.
You can control the transmitter power on the RF69 transceiver with the RH_RF69::setTxPower() function. The argument can be any of -18 to +13 (for RF69W) or -14 to 20 (for RF69HW) The default is 13. Eg:
We have made some actual power measurements against programmed power for Moteino (with RF69W)
Some simple speed performance tests have been conducted. In general packet transmission rate will be limited by the modulation scheme. Also, if your code does any slow operations like Serial printing it will also limit performance. We disabled any printing in the tests below. We tested with RH_RF69::GFSK_Rb250Fd250, which is probably the fastest scheme available. We tested with a 13 octet message length, over a very short distance of 10cm.
Transmission (no reply) tests with modulation RH_RF69::GFSK_Rb250Fd250 and a 13 octet message show about 152 messages per second transmitted and received.
Transmit-and-wait-for-a-reply tests with modulation RH_RF69::GFSK_Rb250Fd250 and a 13 octet message (send and receive) show about 68 round trips per second.
Choices for setModemConfig() for a selected subset of common modulation types, and data rates. If you need another configuration, use the register calculator. and call setModemRegisters() with your desired settings.
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: some of these configurations do not work corectly and are marked as such.
RH_RF69::RH_RF69 | ( | 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.
[in] | slaveSelectPin | the Arduino pin number of the output to use to select the RF69 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 RF69 DIO0 interrupt line. Defaults to pin 2. 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] | spi | Pointer to the SPI interface object to use. Defaults to the standard Arduino hardware SPI interface |
References _idleMode, _interruptPin, and _myInterruptIndex.
|
virtual |
Starts the receiver and checks whether a received message is available. This can be called multiple times in a timeout loop
Implements RHGenericDriver.
References RHGenericDriver::_mode, _rxBufValid, RHGenericDriver::RHModeTx, and setModeRx().
Referenced by recv().
|
inline |
Return the integer value of the device type as read from the device in from RH_RF69_REG_10_VERSION. Expect 0x24, depending on the type of device actually connected.
References _deviceType.
uint32_t RH_RF69::getLastPreambleTime | ( | ) |
Returns the time in millis since the most recent preamble was received, and when the most recent RSSI measurement was made.
|
protected |
This is a low level function to handle the interrupts for one instance of RF69. Called automatically by isr*() Should not need to be called by user code.
References _lastPreambleTime, RHGenericDriver::_lastRssi, RHGenericDriver::_mode, RHGenericDriver::_txGood, readFifo(), RHGenericDriver::RHModeRx, RHGenericDriver::RHModeTx, setModeIdle(), and RHSPIDriver::spiRead().
|
virtual |
Initialises this instance and the radio module connected to it. The following steps are taken:
Reimplemented from RHGenericDriver.
References _deviceForInterrupt, _deviceType, _interruptCount, _interruptPin, _myInterruptIndex, GFSK_Rb250Fd250, RHSPIDriver::init(), isr0(), isr1(), isr2(), setEncryptionKey(), setFrequency(), setModeIdle(), setModemConfig(), setPreambleLength(), setSyncWords(), setTxPower(), RHSPIDriver::spiRead(), RHSPIDriver::spiUsingInterrupt(), and RHSPIDriver::spiWrite().
|
virtual |
The maximum message length supported by this driver
Implements RHGenericDriver.
bool RH_RF69::printRegister | ( | uint8_t | reg | ) |
Prints the value of a single register to the Serial device if RH_HAVE_SERIAL is defined for the current platform For debugging/testing only
References RHSPIDriver::spiRead().
Referenced by printRegisters().
bool RH_RF69::printRegisters | ( | ) |
Prints the value of all the RF69 registers to the Serial device if RH_HAVE_SERIAL is defined for the current platform For debugging/testing only
References printRegister().
|
protected |
Low level function to read the FIFO and put the received data into the receive buffer Should not need to be called by user code.
References _buf, _bufLen, RHGenericDriver::_promiscuous, _rxBufValid, RHGenericDriver::_rxGood, RHGenericDriver::_rxHeaderFlags, RHGenericDriver::_rxHeaderFrom, RHGenericDriver::_rxHeaderId, RHGenericDriver::_rxHeaderTo, RHSPIDriver::_slaveSelectPin, RHSPIDriver::_spi, RHGenericDriver::_thisAddress, RHGenericSPI::beginTransaction(), RHGenericSPI::endTransaction(), and RHGenericSPI::transfer().
Referenced by handleInterrupt().
|
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.
[in] | buf | Location to copy the received message |
[in,out] | len | Pointer to the number of octets available in buf. The number be reset to the actual number of octets copied. |
Implements RHGenericDriver.
References _buf, _bufLen, _rxBufValid, and available().
int8_t RH_RF69::rssiRead | ( | ) |
Reads and returns the current RSSI value. Causes the current signal strength to be measured and returned If you want to find the RSSI of the last received message, use lastRssi() instead.
References RHSPIDriver::spiRead(), and RHSPIDriver::spiWrite().
|
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 NOT permitted.
[in] | data | Array of data to be sent |
[in] | len | Number of bytes of data to send (> 0) |
Implements RHGenericDriver.
References RHSPIDriver::_slaveSelectPin, RHSPIDriver::_spi, RHGenericDriver::_txHeaderFlags, RHGenericDriver::_txHeaderFrom, RHGenericDriver::_txHeaderId, RHGenericDriver::_txHeaderTo, RHGenericSPI::beginTransaction(), RHGenericSPI::endTransaction(), setModeIdle(), setModeTx(), RHGenericSPI::transfer(), RHGenericDriver::waitCAD(), and RHGenericDriver::waitPacketSent().
void RH_RF69::setEncryptionKey | ( | uint8_t * | key = NULL | ) |
Enables AES encryption and sets the AES encryption key, used to encrypt and decrypt all messages. The default is disabled.
[in] | key | The key to use. Must be 16 bytes long. The same key must be installed in other instances of RF69, otherwise communications will not work correctly. If key is NULL, encryption is disabled, which is the default. |
References RHSPIDriver::spiBurstWrite(), RHSPIDriver::spiRead(), and RHSPIDriver::spiWrite().
Referenced by init().
bool RH_RF69::setFrequency | ( | float | centre, |
float | afcPullInRange = 0.05 |
||
) |
Sets the transmitter and receiver centre frequency
[in] | centre | Frequency in MHz. 240.0 to 960.0. Caution, RF69 comes in several different frequency ranges, and setting a frequency outside that range of your radio will probably not work |
[in] | afcPullInRange | Not used |
References RHSPIDriver::spiWrite().
Referenced by init().
void RH_RF69::setIdleMode | ( | uint8_t | idleMode | ) |
Sets the radio operating mode for the case when the driver is idle (ie not transmitting or receiving), allowing you to control the idle mode power requirements at the expense of slower transitions to transmit and receive modes. By default, the idle mode is RH_RF69_OPMODE_MODE_STDBY, but eg setIdleMode(RH_RF69_OPMODE_MODE_SLEEP) will provide a much lower idle current but slower transitions. Call this function after init().
[in] | idleMode | The chip operating mode to use when the driver is idle. One of RH_RF69_OPMODE_* |
References _idleMode.
void RH_RF69::setModeIdle | ( | ) |
If current mode is Rx or Tx changes it to Idle. If the transmitter or receiver is running, disables them.
References _idleMode, RHGenericDriver::_mode, _power, RHGenericDriver::RHModeIdle, setOpMode(), and RHSPIDriver::spiWrite().
Referenced by handleInterrupt(), init(), and send().
bool RH_RF69::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. The default after init() is RH_RF69::GFSK_Rb250Fd250.
[in] | index | The configuration choice. |
References setModemRegisters().
Referenced by init().
void RH_RF69::setModemRegisters | ( | const ModemConfig * | config | ) |
Sets all the registers required to configure the data modem in the RF69, including the data rate, bandwidths etc. You can use this to configure the modem with custom configurations if none of the canned configurations in ModemConfigChoice suit you.
[in] | config | A ModemConfig structure containing values for the modem configuration registers. |
References RH_RF69::ModemConfig::reg_02, RH_RF69::ModemConfig::reg_19, RH_RF69::ModemConfig::reg_37, RHSPIDriver::spiBurstWrite(), and RHSPIDriver::spiWrite().
Referenced by setModemConfig().
void RH_RF69::setModeRx | ( | ) |
If current mode is Tx or Idle, changes it to Rx. Starts the receiver in the RF69.
References RHGenericDriver::_mode, _power, RHGenericDriver::RHModeRx, setOpMode(), and RHSPIDriver::spiWrite().
Referenced by available().
void RH_RF69::setModeTx | ( | ) |
If current mode is Rx or Idle, changes it to Rx. F Starts the transmitter in the RF69.
References RHGenericDriver::_mode, _power, RHGenericDriver::RHModeTx, setOpMode(), and RHSPIDriver::spiWrite().
Referenced by send().
void RH_RF69::setOpMode | ( | uint8_t | mode | ) |
Sets the parameters for the RF69 OPMODE. This is a low level device access function, and should not normally ned to be used by user code. Instead can use stModeRx(), setModeTx(), setModeIdle()
[in] | mode | RF69 OPMODE to set, one of RH_RF69_OPMODE_MODE_*. |
References RHGenericDriver::mode(), RHSPIDriver::spiRead(), and RHSPIDriver::spiWrite().
Referenced by setModeIdle(), setModeRx(), and setModeTx().
void RH_RF69::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 4. Sets the message preamble length in REG_0?_PREAMBLE?SB
[in] | bytes | Preamble length in bytes. |
References RHSPIDriver::spiWrite().
Referenced by init().
void RH_RF69::setSyncWords | ( | const uint8_t * | syncWords = NULL , |
uint8_t | len = 0 |
||
) |
Sets the sync words for transmit and receive Caution: SyncWords should be set to the same value on all nodes in your network. Nodes with different SyncWords set will never receive each others messages, so different SyncWords can be used to isolate different networks from each other. Default is { 0x2d, 0xd4 }. Caution: tests here show that with a single sync word (ie where len == 1), RFM69 reception can be unreliable. To disable sync word generation and detection, call with the defaults: setSyncWords();
[in] | syncWords | Array of sync words, 1 to 4 octets long. NULL if no sync words to be used. |
[in] | len | Number of sync words to set, 1 to 4. 0 if no sync words to be used. |
References RHSPIDriver::spiBurstWrite(), RHSPIDriver::spiRead(), and RHSPIDriver::spiWrite().
Referenced by init().
void RH_RF69::setTxPower | ( | int8_t | power, |
bool | ishighpowermodule = RH_RF69_DEFAULT_HIGHPOWER |
||
) |
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. After init(), the power will be set to 13dBm for a low power module. If you are using a high p[ower modfule such as an RFM69HW, you MUST set the power level with the ishighpowermodule flag set to true. Else you wil get no measurable power output. Simlarly if you are not using a high power module, you must NOT set the ishighpowermodule (which is the default)
[in] | power | Transmitter power level in dBm. For RF69W (ishighpowermodule = false), valid values are from -18 to +13.; Values outside this range are trimmed. For RF69HW (ishighpowermodule = true), valid values are from -2 to +20. Caution: at +20dBm, duty cycle is limited to 1% and a maximum VSWR of 3:1 at the antenna port. |
ishighpowermodule | Set to true if the connected module is a high power module RFM69HW |
References _power, and RHSPIDriver::spiWrite().
Referenced by init().
|
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.
Reimplemented from RHGenericDriver.
References RHGenericDriver::_mode, RHGenericDriver::RHModeSleep, and RHSPIDriver::spiWrite().
int8_t RH_RF69::temperatureRead | ( | ) |
Reads the on-chip temperature sensor. The RF69 must be in Idle mode (= RF69 Standby) to measure temperature. The measurement is uncalibrated and without calibration, you can expect it to be far from correct.
References RHSPIDriver::spiRead(), and RHSPIDriver::spiWrite().
|
protected |