ClusterDuck Protocol
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
RF69 Class Reference

Control class for RF69 module. Also serves as base class for SX1231. More...

#include <RF69.h>

Inheritance diagram for RF69:
PhysicalLayer SX1231

Public Member Functions

 RF69 (Module *module)
 Default constructor. More...
 
int16_t begin (float freq=434.0, float br=48.0, float freqDev=50.0, float rxBw=125.0, int8_t power=13)
 Initialization method. More...
 
void reset ()
 Reset method. Will reset the chip to the default state using RST pin.
 
int16_t transmit (uint8_t *data, size_t len, uint8_t addr=0)
 Blocking binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer. More...
 
int16_t receive (uint8_t *data, size_t len)
 Blocking binary receive method. Overloads for string-based transmissions are implemented in PhysicalLayer. More...
 
int16_t sleep ()
 Sets the module to sleep mode. More...
 
int16_t standby ()
 Sets the module to standby mode. More...
 
int16_t transmitDirect (uint32_t frf=0)
 Starts direct mode transmission. More...
 
int16_t receiveDirect ()
 Starts direct mode reception. More...
 
int16_t packetMode ()
 Stops direct mode. It is required to call this method to switch from direct transmissions to packet-based transmissions.
 
void setAESKey (uint8_t *key)
 Sets AES key. More...
 
int16_t enableAES ()
 Enables AES encryption. More...
 
int16_t disableAES ()
 Disables AES encryption. More...
 
void setDio0Action (void(*func)(void))
 Sets interrupt service routine to call when DIO0 activates. More...
 
void clearDio0Action ()
 Clears interrupt service routine to call when DIO0 activates.
 
void setDio1Action (void(*func)(void))
 Sets interrupt service routine to call when DIO1 activates. More...
 
void clearDio1Action ()
 Clears interrupt service routine to call when DIO1 activates.
 
int16_t startTransmit (uint8_t *data, size_t len, uint8_t addr=0)
 Interrupt-driven binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer. More...
 
int16_t startReceive ()
 Interrupt-driven receive method. GDO0 will be activated when full packet is received. More...
 
int16_t readData (uint8_t *data, size_t len)
 Reads data received after calling startReceive method. More...
 
int16_t setFrequency (float freq)
 Sets carrier frequency. Allowed values are in bands 290.0 to 340.0 MHz, 431.0 to 510.0 MHz and 862.0 to 1020.0 MHz. More...
 
int16_t setBitRate (float br)
 Sets bit rate. Allowed values range from 1.2 to 300.0 kbps. More...
 
int16_t setRxBandwidth (float rxBw)
 Sets receiver bandwidth. Allowed values are 2.6, 3.1, 3.9, 5.2, 6.3, 7.8, 10.4, 12.5, 15.6, 20.8, 25.0, 31.3, 41.7, 50.0, 62.5, 83.3, 100.0, 125.0, 166.7, 200.0, 250.0, 333.3, 400.0 and 500.0 kHz. More...
 
int16_t setFrequencyDeviation (float freqDev)
 Sets frequency deviation. More...
 
int16_t setOutputPower (int8_t power)
 Sets output power. Allowed values are -30, -20, -15, -10, 0, 5, 7 or 10 dBm. More...
 
int16_t setSyncWord (uint8_t *syncWord, size_t len, uint8_t maxErrBits=0)
 Sets sync word. Up to 8 bytes can be set as sync word. More...
 
int16_t setNodeAddress (uint8_t nodeAddr)
 Sets node address. Calling this method will also enable address filtering for node address only. More...
 
int16_t setBroadcastAddress (uint8_t broadAddr)
 Sets broadcast address. Calling this method will also enable address filtering for node and broadcast address. More...
 
int16_t disableAddressFiltering ()
 Disables address filtering. Calling this method will also erase previously set addresses. More...
 
void setAmbientTemperature (int16_t tempAmbient)
 Sets ambient temperature. Required to correct values from on-board temperature sensor. More...
 
int16_t getTemperature ()
 Measures temperature. More...
 
size_t getPacketLength (bool update=true)
 Query modem for the packet length of received payload. More...
 
int16_t fixedPacketLengthMode (uint8_t len=RF69_MAX_PACKET_LENGTH)
 Set modem in fixed packet length mode. More...
 
int16_t variablePacketLengthMode (uint8_t maxLen=RF69_MAX_PACKET_LENGTH)
 Set modem in variable packet length mode. More...
 
int16_t enableSyncWordFiltering (uint8_t maxErrBits=0)
 Enable sync word filtering and generation. More...
 
int16_t disableSyncWordFiltering ()
 Disable preamble and sync word filtering and generation. More...
 
int16_t setCrcFiltering (bool crcOn=true)
 Enable CRC filtering and generation. More...
 
int16_t setPromiscuousMode (bool promiscuous=true)
 Set modem in "sniff" mode: no packet filtering (e.g., no preamble, sync word, address, CRC). More...
 
int16_t setDataShaping (float sh)
 Sets Gaussian filter bandwidth-time product that will be used for data shaping. Allowed values are 0.3, 0.5 or 1.0. Set to 0 to disable data shaping. More...
 
int16_t setEncoding (uint8_t encoding)
 Sets transmission encoding. More...
 
int16_t transmit (__FlashStringHelper *fstr, uint8_t addr=0)
 Arduino Flash String transmit method. More...
 
int16_t transmit (String &str, uint8_t addr=0)
 Arduino String transmit method. More...
 
int16_t transmit (const char *str, uint8_t addr=0)
 C-string transmit method. More...
 
virtual int16_t transmit (uint8_t *data, size_t len, uint8_t addr=0)=0
 Binary transmit method. Must be implemented in module class. More...
 
int16_t receive (String &str, size_t len=0)
 Arduino String receive method. More...
 
virtual int16_t receive (uint8_t *data, size_t len)=0
 Binary receive method. Must be implemented in module class. More...
 
int16_t startTransmit (String &str, uint8_t addr=0)
 Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking. Interrupt pin will be activated when transmission finishes. More...
 
int16_t startTransmit (const char *str, uint8_t addr=0)
 Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking. Interrupt pin will be activated when transmission finishes. More...
 
virtual int16_t startTransmit (uint8_t *data, size_t len, uint8_t addr=0)=0
 Interrupt-driven binary transmit method. More...
 
int16_t readData (String &str, size_t len=0)
 Reads data that was received after calling startReceive method. More...
 
virtual int16_t readData (uint8_t *data, size_t len)=0
 Reads data that was received after calling startReceive method. More...
 
- Public Member Functions inherited from PhysicalLayer
 PhysicalLayer (float freqStep, size_t maxPacketLength)
 Default constructor. More...
 
int16_t transmit (__FlashStringHelper *fstr, uint8_t addr=0)
 Arduino Flash String transmit method. More...
 
int16_t transmit (String &str, uint8_t addr=0)
 Arduino String transmit method. More...
 
int16_t transmit (const char *str, uint8_t addr=0)
 C-string transmit method. More...
 
int16_t receive (String &str, size_t len=0)
 Arduino String receive method. More...
 
int16_t startTransmit (String &str, uint8_t addr=0)
 Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking. Interrupt pin will be activated when transmission finishes. More...
 
int16_t startTransmit (const char *str, uint8_t addr=0)
 Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking. Interrupt pin will be activated when transmission finishes. More...
 
int16_t readData (String &str, size_t len=0)
 Reads data that was received after calling startReceive method. More...
 
float getFreqStep ()
 Gets the module frequency step size that was set in constructor. More...
 

Public Attributes

float lastPacketRSSI
 RSSI value of the last received packet.
 

Protected Member Functions

int16_t config ()
 
int16_t directMode ()
 
int16_t setPacketMode (uint8_t mode, uint8_t len)
 

Protected Attributes

Module_mod
 
float _br
 
float _rxBw
 
int16_t _tempOffset
 
size_t _packetLength
 
bool _packetLengthQueried
 
uint8_t _packetLengthConfig
 
bool _promiscuous
 
uint8_t _syncWordLength
 

Detailed Description

Control class for RF69 module. Also serves as base class for SX1231.

Constructor & Destructor Documentation

◆ RF69()

RF69::RF69 ( Module module)

Default constructor.

Parameters
modInstance of Module that will be used to communicate with the radio.

Member Function Documentation

◆ begin()

int16_t RF69::begin ( float  freq = 434.0,
float  br = 48.0,
float  freqDev = 50.0,
float  rxBw = 125.0,
int8_t  power = 13 
)

Initialization method.

Parameters
freqCarrier frequency in MHz. Defaults to 434.0 MHz.
brBit rate to be used in kbps. Defaults to 48.0 kbps.
freqDevFrequency deviation from carrier frequency in kHz Defaults to 50.0 kHz.
rxBwReceiver bandwidth in kHz. Defaults to 125.0 kHz.
powerOutput power in dBm. Defaults to 13 dBm.
Returns
Status Codes

◆ disableAddressFiltering()

int16_t RF69::disableAddressFiltering ( )

Disables address filtering. Calling this method will also erase previously set addresses.

Returns
Status Codes

◆ disableAES()

int16_t RF69::disableAES ( )

Disables AES encryption.

Returns
Status Codes

◆ disableSyncWordFiltering()

int16_t RF69::disableSyncWordFiltering ( )

Disable preamble and sync word filtering and generation.

Returns
Status Codes

◆ enableAES()

int16_t RF69::enableAES ( )

Enables AES encryption.

Returns
Status Codes

◆ enableSyncWordFiltering()

int16_t RF69::enableSyncWordFiltering ( uint8_t  maxErrBits = 0)

Enable sync word filtering and generation.

Parameters
numBitsSync word length in bits.
Returns
Status Codes

◆ fixedPacketLengthMode()

int16_t RF69::fixedPacketLengthMode ( uint8_t  len = RF69_MAX_PACKET_LENGTH)

Set modem in fixed packet length mode.

Parameters
lenPacket length.
Returns
Status Codes

◆ getPacketLength()

size_t RF69::getPacketLength ( bool  update = true)
virtual

Query modem for the packet length of received payload.

Parameters
updateUpdate received packet length. Will return cached value when set to false.
Returns
Length of last received packet in bytes.

Implements PhysicalLayer.

◆ getTemperature()

int16_t RF69::getTemperature ( )

Measures temperature.

Returns
Measured temperature in degrees Celsius.

◆ readData() [1/3]

int16_t PhysicalLayer::readData

Reads data that was received after calling startReceive method.

Parameters
strAddress of Arduino String to save the received data.
lenExpected number of characters in the message.
Returns
Status Codes

◆ readData() [2/3]

int16_t RF69::readData ( uint8_t *  data,
size_t  len 
)
virtual

Reads data received after calling startReceive method.

Parameters
dataPointer to array to save the received binary data.
lenNumber of bytes that will be received. Must be known in advance for binary transmissions.
Returns
Status Codes

Implements PhysicalLayer.

◆ readData() [3/3]

virtual int16_t PhysicalLayer::readData

Reads data that was received after calling startReceive method.

Parameters
dataPointer to array to save the received binary data.
lenNumber of bytes that will be received. Must be known in advance for binary transmissions.
Returns
Status Codes

◆ receive() [1/3]

int16_t PhysicalLayer::receive

Arduino String receive method.

Parameters
strAddress of Arduino String to save the received data.
lenExpected number of characters in the message. Leave as 0 if expecting a unknown size packet
Returns
Status Codes

◆ receive() [2/3]

int16_t RF69::receive ( uint8_t *  data,
size_t  len 
)
virtual

Blocking binary receive method. Overloads for string-based transmissions are implemented in PhysicalLayer.

Parameters
dataBinary data to be sent.
lenNumber of bytes to send.
Returns
Status Codes

Implements PhysicalLayer.

◆ receive() [3/3]

virtual int16_t PhysicalLayer::receive

Binary receive method. Must be implemented in module class.

Parameters
dataPointer to array to save the received binary data.
lenNumber of bytes that will be received. Must be known in advance for binary transmissions.
Returns
Status Codes

◆ receiveDirect()

int16_t RF69::receiveDirect ( )
virtual

Starts direct mode reception.

Returns
Status Codes

Implements PhysicalLayer.

◆ setAESKey()

void RF69::setAESKey ( uint8_t *  key)

Sets AES key.

Parameters
Keyto be used for AES encryption. Must be exactly 16 bytes long.

◆ setAmbientTemperature()

void RF69::setAmbientTemperature ( int16_t  tempAmbient)

Sets ambient temperature. Required to correct values from on-board temperature sensor.

Parameters
tempAmbientAmbient temperature in degrees Celsius.

◆ setBitRate()

int16_t RF69::setBitRate ( float  br)

Sets bit rate. Allowed values range from 1.2 to 300.0 kbps.

Parameters
brBit rate to be set in kbps.
Returns
Status Codes

◆ setBroadcastAddress()

int16_t RF69::setBroadcastAddress ( uint8_t  broadAddr)

Sets broadcast address. Calling this method will also enable address filtering for node and broadcast address.

Parameters
broadAddrNode address to be set.
Returns
Status Codes

◆ setCrcFiltering()

int16_t RF69::setCrcFiltering ( bool  crcOn = true)

Enable CRC filtering and generation.

Parameters
crcOnSet or unset promiscuous mode.
Returns
Status Codes

◆ setDataShaping()

int16_t RF69::setDataShaping ( float  sh)
virtual

Sets Gaussian filter bandwidth-time product that will be used for data shaping. Allowed values are 0.3, 0.5 or 1.0. Set to 0 to disable data shaping.

Parameters
shGaussian shaping bandwidth-time product that will be used for data shaping
Returns
Status Codes

Implements PhysicalLayer.

◆ setDio0Action()

void RF69::setDio0Action ( void(*)(void)  func)

Sets interrupt service routine to call when DIO0 activates.

Parameters
funcISR to call.

◆ setDio1Action()

void RF69::setDio1Action ( void(*)(void)  func)

Sets interrupt service routine to call when DIO1 activates.

Parameters
funcISR to call.

◆ setEncoding()

int16_t RF69::setEncoding ( uint8_t  encoding)
virtual

Sets transmission encoding.

Parameters
encodingEncoding to be used. Set to 0 for NRZ, 1 for Manchester and 2 for whitening.
Returns
Status Codes

Implements PhysicalLayer.

◆ setFrequency()

int16_t RF69::setFrequency ( float  freq)

Sets carrier frequency. Allowed values are in bands 290.0 to 340.0 MHz, 431.0 to 510.0 MHz and 862.0 to 1020.0 MHz.

Parameters
freqCarrier frequency to be set in MHz.
Returns
Status Codes

◆ setFrequencyDeviation()

int16_t RF69::setFrequencyDeviation ( float  freqDev)
virtual

Sets frequency deviation.

Parameters
freqDevFrequency deviation to be set in kHz.
Returns
Status Codes

Implements PhysicalLayer.

◆ setNodeAddress()

int16_t RF69::setNodeAddress ( uint8_t  nodeAddr)

Sets node address. Calling this method will also enable address filtering for node address only.

Parameters
nodeAddrNode address to be set.
Returns
Status Codes

◆ setOutputPower()

int16_t RF69::setOutputPower ( int8_t  power)

Sets output power. Allowed values are -30, -20, -15, -10, 0, 5, 7 or 10 dBm.

Parameters
powerOutput power to be set in dBm.
Returns
Status Codes

◆ setPromiscuousMode()

int16_t RF69::setPromiscuousMode ( bool  promiscuous = true)

Set modem in "sniff" mode: no packet filtering (e.g., no preamble, sync word, address, CRC).

Parameters
promiscuousSet or unset promiscuous mode.
Returns
Status Codes

◆ setRxBandwidth()

int16_t RF69::setRxBandwidth ( float  rxBw)

Sets receiver bandwidth. Allowed values are 2.6, 3.1, 3.9, 5.2, 6.3, 7.8, 10.4, 12.5, 15.6, 20.8, 25.0, 31.3, 41.7, 50.0, 62.5, 83.3, 100.0, 125.0, 166.7, 200.0, 250.0, 333.3, 400.0 and 500.0 kHz.

Parameters
rxBwReceiver bandwidth to be set in kHz.
Returns
Status Codes

◆ setSyncWord()

int16_t RF69::setSyncWord ( uint8_t *  syncWord,
size_t  len,
uint8_t  maxErrBits = 0 
)

Sets sync word. Up to 8 bytes can be set as sync word.

Parameters
syncWordPointer to the array of sync word bytes.
lenSync word length in bytes.
maxErrBitsMaximum allowed number of bit errors in received sync word. Defaults to 0.

◆ sleep()

int16_t RF69::sleep ( )

Sets the module to sleep mode.

Returns
Status Codes

◆ standby()

int16_t RF69::standby ( )
virtual

Sets the module to standby mode.

Returns
Status Codes

Implements PhysicalLayer.

◆ startReceive()

int16_t RF69::startReceive ( )

Interrupt-driven receive method. GDO0 will be activated when full packet is received.

Returns
Status Codes

◆ startTransmit() [1/4]

int16_t PhysicalLayer::startTransmit

Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking. Interrupt pin will be activated when transmission finishes.

Parameters
strC-string that will be transmitted.
addrNode address to transmit the packet to. Only used in FSK mode.
Returns
Status Codes

◆ startTransmit() [2/4]

int16_t PhysicalLayer::startTransmit

Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking. Interrupt pin will be activated when transmission finishes.

Parameters
strAddress of Arduino String that will be transmitted.
addrNode address to transmit the packet to. Only used in FSK mode.
Returns
Status Codes

◆ startTransmit() [3/4]

int16_t RF69::startTransmit ( uint8_t *  data,
size_t  len,
uint8_t  addr = 0 
)
virtual

Interrupt-driven binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer.

Parameters
dataBinary data to be sent.
lenNumber of bytes to send.
addrAddress to send the data to. Will only be added if address filtering was enabled.
Returns
Status Codes

Implements PhysicalLayer.

◆ startTransmit() [4/4]

virtual int16_t PhysicalLayer::startTransmit

Interrupt-driven binary transmit method.

Parameters
dataBinary data that will be transmitted.
lenLength of binary data to transmit (in bytes).
addrNode address to transmit the packet to. Only used in FSK mode.
Returns
Status Codes

◆ transmit() [1/5]

int16_t PhysicalLayer::transmit

Arduino Flash String transmit method.

Parameters
strPointer to Arduino Flash String that will be transmitted.
addrNode address to transmit the packet to. Only used in FSK mode.
Returns
Status Codes

◆ transmit() [2/5]

int16_t PhysicalLayer::transmit

C-string transmit method.

Parameters
strC-string that will be transmitted.
addrNode address to transmit the packet to. Only used in FSK mode.
Returns
Status Codes

◆ transmit() [3/5]

int16_t PhysicalLayer::transmit

Arduino String transmit method.

Parameters
strAddress of Arduino string that will be transmitted.
addrNode address to transmit the packet to. Only used in FSK mode.
Returns
Status Codes

◆ transmit() [4/5]

int16_t RF69::transmit ( uint8_t *  data,
size_t  len,
uint8_t  addr = 0 
)
virtual

Blocking binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer.

Parameters
dataBinary data to be sent.
lenNumber of bytes to send.
addrAddress to send the data to. Will only be added if address filtering was enabled.
Returns
Status Codes

Implements PhysicalLayer.

◆ transmit() [5/5]

virtual int16_t PhysicalLayer::transmit

Binary transmit method. Must be implemented in module class.

Parameters
dataBinary data that will be transmitted.
lenLength of binary data to transmit (in bytes).
addrNode address to transmit the packet to. Only used in FSK mode.
Returns
Status Codes

◆ transmitDirect()

int16_t RF69::transmitDirect ( uint32_t  frf = 0)
virtual

Starts direct mode transmission.

Parameters
frfRaw RF frequency value. Defaults to 0, required for quick frequency shifts in RTTY.
Returns
Status Codes

Implements PhysicalLayer.

◆ variablePacketLengthMode()

int16_t RF69::variablePacketLengthMode ( uint8_t  maxLen = RF69_MAX_PACKET_LENGTH)

Set modem in variable packet length mode.

Parameters
lenMaximum packet length.
Returns
Status Codes

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