RadioLib
Universal wireless communication library for Arduino
Si443x Class Reference

Base class for Si443x series. All derived classes for Si443x (e.g. Si4431 or Si4432) inherit from this base class. This class should not be instantiated directly from Arduino sketch, only from its derived classes. More...

#include <Si443x.h>

Inheritance diagram for Si443x:
PhysicalLayer Si4432 Si4430 Si4431

Public Member Functions

 Si443x (Module *mod)
 Default constructor. More...
 
int16_t begin (float br, float freqDev, float rxBw, uint8_t preambleLen)
 Initialization method. More...
 
void reset ()
 Reset method. Will reset the chip to the default state using SDN pin.
 
int16_t transmit (uint8_t *data, size_t len, uint8_t addr=0) override
 Binary transmit method. Will transmit arbitrary binary data up to 64 bytes long. For overloads to transmit Arduino String or C-string, see PhysicalLayer::transmit. More...
 
int16_t receive (uint8_t *data, size_t len) override
 Binary receive method. Will attempt to receive arbitrary binary data up to 64 bytes long. For overloads to receive Arduino String, see PhysicalLayer::receive. More...
 
int16_t sleep ()
 Sets the module to sleep to save power. Module will not be able to transmit or receive any data while in sleep mode. Module will wake up automatically when methods like transmit or receive are called. More...
 
int16_t standby () override
 Sets the module to standby. More...
 
int16_t transmitDirect (uint32_t frf=0) override
 Enables direct transmission mode. While in direct mode, the module will not be able to transmit or receive packets. More...
 
int16_t receiveDirect () override
 Enables direct reception mode. While in direct mode, the module will not be able to transmit or receive packets. More...
 
int16_t packetMode ()
 Disables direct mode and enables packet mode, allowing the module to receive packets. More...
 
void setIrqAction (void(*func)(void))
 Sets interrupt service routine to call when IRQ activates. More...
 
void clearIrqAction ()
 Clears interrupt service routine to call when IRQ activates.
 
int16_t startTransmit (uint8_t *data, size_t len, uint8_t addr=0) override
 Interrupt-driven binary transmit method. Will start transmitting arbitrary binary data up to 64 bytes long. More...
 
int16_t startReceive ()
 Interrupt-driven receive method. IRQ will be activated when full valid packet is received. More...
 
int16_t readData (uint8_t *data, size_t len) override
 Reads data that was received after calling startReceive method. This method reads len characters. More...
 
int16_t setBitRate (float br)
 Sets FSK bit rate. Allowed values range from 0.123 to 256.0 kbps. More...
 
int16_t setFrequencyDeviation (float freqDev) override
 Sets FSK frequency deviation from carrier frequency. Allowed values range from 0.625 to 320.0 kHz. More...
 
int16_t setRxBandwidth (float rxBw)
 Sets receiver bandwidth. Allowed values range from 2.6 to 620.7 kHz. More...
 
int16_t setSyncWord (uint8_t *syncWord, size_t len)
 Sets sync word. Up to 4 bytes can be set as sync word. More...
 
int16_t setPreambleLength (uint8_t preambleLen)
 Sets preamble length. More...
 
size_t getPacketLength (bool update=true) override
 Query modem for the packet length of received payload. More...
 
int16_t setEncoding (uint8_t encoding) override
 Sets transmission encoding. Only available in FSK mode. Allowed values are RADIOLIB_ENCODING_NRZ, RADIOLIB_ENCODING_MANCHESTER and RADIOLIB_ENCODING_WHITENING. More...
 
int16_t setDataShaping (uint8_t sh) override
 Sets Gaussian filter bandwidth-time product that will be used for data shaping. Only available in FSK mode with FSK modulation. Allowed values are RADIOLIB_SHAPING_0_3, RADIOLIB_SHAPING_0_5 or RADIOLIB_SHAPING_1_0. Set to RADIOLIB_SHAPING_NONE to disable data shaping. More...
 
void setRfSwitchPins (RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn)
 Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state. When using automatic RF switch control, DO NOT change the pin mode of rxEn or txEn from Arduino sketch! More...
 
uint8_t random ()
 Get one truly random byte from RSSI noise. More...
 
int16_t getChipVersion ()
 Read version SPI register. Should return SI443X_DEVICE_VERSION (0x06) if Si443x is connected and working. More...
 
void setDirectAction (void(*func)(void))
 Set interrupt service routine function to call when data bit is receveid in direct mode. More...
 
void readBit (RADIOLIB_PIN_TYPE pin)
 Function to read and process data bit in direct reception mode. 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 () const
 Gets the module frequency step size that was set in constructor. More...
 
int32_t random (int32_t max)
 Get truly random number in range 0 - max. More...
 
int32_t random (int32_t min, int32_t max)
 Get truly random number in range min - max. More...
 
int16_t startDirect ()
 Configure module parameters for direct modes. Must be called prior to "ham" modes like RTTY or AX.25. Only available in FSK mode. More...
 
int16_t setDirectSyncWord (uint32_t syncWord, uint8_t len)
 Set sync word to be used to determine start of packet in direct reception mode. More...
 
int16_t available ()
 Get the number of direct mode bytes currently available in buffer. More...
 
uint8_t read ()
 Get data from direct mode buffer. More...
 

Detailed Description

Base class for Si443x series. All derived classes for Si443x (e.g. Si4431 or Si4432) inherit from this base class. This class should not be instantiated directly from Arduino sketch, only from its derived classes.

Constructor & Destructor Documentation

◆ Si443x()

Si443x::Si443x ( Module mod)

Default constructor.

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

Member Function Documentation

◆ begin()

int16_t Si443x::begin ( float  br,
float  freqDev,
float  rxBw,
uint8_t  preambleLen 
)

Initialization method.

Parameters
brBit rate of the FSK transmission in kbps (kilobits per second).
freqDevFrequency deviation of the FSK transmission in kHz.
rxBwReceiver bandwidth in kHz.
preambleLenPreamble Length in bits.
Returns
Status Codes

◆ getChipVersion()

int16_t Si443x::getChipVersion ( )

Read version SPI register. Should return SI443X_DEVICE_VERSION (0x06) if Si443x is connected and working.

Returns
Version register contents or Status Codes

◆ getPacketLength()

size_t Si443x::getPacketLength ( bool  update = true)
overridevirtual

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.
Todo:
variable length mode

Implements PhysicalLayer.

◆ packetMode()

int16_t Si443x::packetMode ( )

Disables direct mode and enables packet mode, allowing the module to receive packets.

Returns
Status Codes

◆ random()

uint8_t Si443x::random ( )
virtual

Get one truly random byte from RSSI noise.

Returns
TRNG byte.

Implements PhysicalLayer.

◆ readBit()

void Si443x::readBit ( RADIOLIB_PIN_TYPE  pin)
virtual

Function to read and process data bit in direct reception mode.

Parameters
pinPin on which to read.

Implements PhysicalLayer.

◆ 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 Si443x::readData ( uint8_t *  data,
size_t  len 
)
overridevirtual

Reads data that was received after calling startReceive method. This method reads len characters.

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 Si443x::receive ( uint8_t *  data,
size_t  len 
)
overridevirtual

Binary receive method. Will attempt to receive arbitrary binary data up to 64 bytes long. For overloads to receive Arduino String, see PhysicalLayer::receive.

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.

◆ 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 Si443x::receiveDirect ( )
overridevirtual

Enables direct reception mode. While in direct mode, the module will not be able to transmit or receive packets.

Returns
Status Codes

Implements PhysicalLayer.

◆ setBitRate()

int16_t Si443x::setBitRate ( float  br)

Sets FSK bit rate. Allowed values range from 0.123 to 256.0 kbps.

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

◆ setDataShaping()

int16_t Si443x::setDataShaping ( uint8_t  sh)
overridevirtual

Sets Gaussian filter bandwidth-time product that will be used for data shaping. Only available in FSK mode with FSK modulation. Allowed values are RADIOLIB_SHAPING_0_3, RADIOLIB_SHAPING_0_5 or RADIOLIB_SHAPING_1_0. Set to RADIOLIB_SHAPING_NONE to disable data shaping.

Parameters
shGaussian shaping bandwidth-time product that will be used for data shaping
Returns
Status Codes
Todo:
implement fiter configuration - docs claim this should be possible, but seems undocumented

Implements PhysicalLayer.

◆ setDirectAction()

void Si443x::setDirectAction ( void(*)(void)  func)
virtual

Set interrupt service routine function to call when data bit is receveid in direct mode.

Parameters
funcPointer to interrupt service routine.

Implements PhysicalLayer.

◆ setEncoding()

int16_t Si443x::setEncoding ( uint8_t  encoding)
overridevirtual

Sets transmission encoding. Only available in FSK mode. Allowed values are RADIOLIB_ENCODING_NRZ, RADIOLIB_ENCODING_MANCHESTER and RADIOLIB_ENCODING_WHITENING.

Parameters
encodingEncoding to be used.
Returns
Status Codes
Todo:
  • add inverted Manchester?

Implements PhysicalLayer.

◆ setFrequencyDeviation()

int16_t Si443x::setFrequencyDeviation ( float  freqDev)
overridevirtual

Sets FSK frequency deviation from carrier frequency. Allowed values range from 0.625 to 320.0 kHz.

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

Implements PhysicalLayer.

◆ setIrqAction()

void Si443x::setIrqAction ( void(*)(void)  func)

Sets interrupt service routine to call when IRQ activates.

Parameters
funcISR to call.

◆ setPreambleLength()

int16_t Si443x::setPreambleLength ( uint8_t  preambleLen)

Sets preamble length.

Parameters
preambleLenPreamble length to be set (in bits).
Returns
Status Codes

◆ setRfSwitchPins()

void Si443x::setRfSwitchPins ( RADIOLIB_PIN_TYPE  rxEn,
RADIOLIB_PIN_TYPE  txEn 
)

Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state. When using automatic RF switch control, DO NOT change the pin mode of rxEn or txEn from Arduino sketch!

Parameters
rxEnRX enable pin.
txEnTX enable pin.

◆ setRxBandwidth()

int16_t Si443x::setRxBandwidth ( float  rxBw)

Sets receiver bandwidth. Allowed values range from 2.6 to 620.7 kHz.

Parameters
rxBwReceiver bandwidth to be set in kHz.
Returns
Status Codes
Todo:
float tolerance equality as macro?

◆ setSyncWord()

int16_t Si443x::setSyncWord ( uint8_t *  syncWord,
size_t  len 
)

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

Parameters
syncWordPointer to the array of sync word bytes.
lenSync word length in bytes.

◆ sleep()

int16_t Si443x::sleep ( )

Sets the module to sleep to save power. Module will not be able to transmit or receive any data while in sleep mode. Module will wake up automatically when methods like transmit or receive are called.

Returns
Status Codes

◆ standby()

int16_t Si443x::standby ( )
overridevirtual

Sets the module to standby.

Returns
Status Codes

Implements PhysicalLayer.

◆ startReceive()

int16_t Si443x::startReceive ( )

Interrupt-driven receive method. IRQ will be activated when full valid 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 Si443x::startTransmit ( uint8_t *  data,
size_t  len,
uint8_t  addr = 0 
)
overridevirtual

Interrupt-driven binary transmit method. Will start transmitting arbitrary binary data up to 64 bytes long.

Parameters
dataBinary data that will be transmitted.
lenLength of binary data to transmit (in bytes).
addrNode address to transmit the packet to.
Returns
Status Codes
Todo:
variable packet length
Todo:
use header as address field?

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 Si443x::transmit ( uint8_t *  data,
size_t  len,
uint8_t  addr = 0 
)
overridevirtual

Binary transmit method. Will transmit arbitrary binary data up to 64 bytes long. For overloads to transmit Arduino String or C-string, see PhysicalLayer::transmit.

Parameters
dataBinary data that will be transmitted.
lenLength of binary data to transmit (in bytes).
addrNode address to transmit the packet to.
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 Si443x::transmitDirect ( uint32_t  frf = 0)
overridevirtual

Enables direct transmission mode. While in direct mode, the module will not be able to transmit or receive packets.

Parameters
FRF24-bit raw frequency value to start transmitting at. Required for quick frequency shifts in RTTY.
Returns
Status Codes
Todo:
integers only

Implements PhysicalLayer.


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