RadioLib
Universal wireless communication library for Arduino
|
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN. Also extracts some common module-independent methods. Using this interface class allows to use the protocols on various modules without much code duplicity. Because this class is used mainly as interface, all of its virtual members must be implemented in the module class. More...
#include <PhysicalLayer.h>
Public Member Functions | |
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... | |
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 | standby ()=0 |
Sets module to standby. 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... | |
virtual int16_t | transmitDirect (uint32_t frf=0)=0 |
Enables direct transmission mode on pins DIO1 (clock) and DIO2 (data). Must be implemented in module class. While in direct mode, the module will not be able to transmit or receive packets. Can only be activated in FSK mode. More... | |
virtual int16_t | receiveDirect ()=0 |
Enables direct reception mode on pins DIO1 (clock) and DIO2 (data). Must be implemented in module class. While in direct mode, the module will not be able to transmit or receive packets. Can only be activated in FSK mode. More... | |
virtual int16_t | setFrequencyDeviation (float freqDev)=0 |
Sets FSK frequency deviation from carrier frequency. Allowed values depend on bit rate setting and must be lower than 200 kHz. Only available in FSK mode. Must be implemented in module class. More... | |
virtual int16_t | setDataShaping (uint8_t sh)=0 |
Sets GFSK data shaping. Only available in FSK mode. Must be implemented in module class. More... | |
virtual int16_t | setEncoding (uint8_t encoding)=0 |
Sets FSK data encoding. Only available in FSK mode. Must be implemented in module class. More... | |
float | getFreqStep () const |
Gets the module frequency step size that was set in constructor. More... | |
virtual size_t | getPacketLength (bool update=true)=0 |
Query modem for the packet length of received payload. Must be implemented in module class. 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... | |
virtual uint8_t | random ()=0 |
Get one truly random byte from RSSI noise. Must be implemented in module class. More... | |
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN. Also extracts some common module-independent methods. Using this interface class allows to use the protocols on various modules without much code duplicity. Because this class is used mainly as interface, all of its virtual members must be implemented in the module class.
PhysicalLayer::PhysicalLayer | ( | float | freqStep, |
size_t | maxPacketLength | ||
) |
Default constructor.
freqStep | Frequency step of the synthesizer in Hz. |
maxPacketLength | Maximum length of packet that can be received by the module- |
float PhysicalLayer::getFreqStep | ( | ) | const |
Gets the module frequency step size that was set in constructor.
|
pure virtual |
Query modem for the packet length of received payload. Must be implemented in module class.
update | Update received packet length. Will return cached value when set to false. |
Implemented in SX127x, CC1101, SX126x, Si443x, RF69, SX128x, and nRF24.
int32_t PhysicalLayer::random | ( | int32_t | max | ) |
Get truly random number in range 0 - max.
max | The maximum value of the random number (non-inclusive). |
int32_t PhysicalLayer::random | ( | int32_t | min, |
int32_t | max | ||
) |
Get truly random number in range min - max.
min | The minimum value of the random number (inclusive). |
max | The maximum value of the random number (non-inclusive). |
|
pure virtual |
int16_t PhysicalLayer::readData | ( | String & | str, |
size_t | len = 0 |
||
) |
Reads data that was received after calling startReceive method.
str | Address of Arduino String to save the received data. |
len | Expected number of characters in the message. |
|
pure virtual |
Reads data that was received after calling startReceive method.
data | Pointer to array to save the received binary data. |
len | Number of bytes that will be received. Must be known in advance for binary transmissions. |
Implemented in SX127x, Si443x, CC1101, RF69, SX128x, SX126x, and nRF24.
int16_t PhysicalLayer::receive | ( | String & | str, |
size_t | len = 0 |
||
) |
Arduino String receive method.
str | Address of Arduino String to save the received data. |
len | Expected number of characters in the message. Leave as 0 if expecting a unknown size packet |
|
pure virtual |
Binary receive method. Must be implemented in module class.
data | Pointer to array to save the received binary data. |
len | Number of bytes that will be received. Must be known in advance for binary transmissions. |
Implemented in Si443x, SX127x, CC1101, RF69, SX128x, SX126x, and nRF24.
|
pure virtual |
Enables direct reception mode on pins DIO1 (clock) and DIO2 (data). Must be implemented in module class. While in direct mode, the module will not be able to transmit or receive packets. Can only be activated in FSK mode.
Implemented in SX127x, Si443x, CC1101, RF69, SX128x, SX126x, and nRF24.
|
pure virtual |
Sets GFSK data shaping. Only available in FSK mode. Must be implemented in module class.
sh | Shaping to be set. See Data shaping filter values aliases. for possible values. |
Implemented in CC1101, RF69, Si443x, SX126x, SX128x, nRF24, SX1278, and SX1272.
|
pure virtual |
Sets FSK data encoding. Only available in FSK mode. Must be implemented in module class.
enc | Encoding to be used. See Encoding type aliases. for possible values. |
Implemented in SX127x, CC1101, SX126x, RF69, Si443x, SX128x, and nRF24.
|
pure virtual |
Sets FSK frequency deviation from carrier frequency. Allowed values depend on bit rate setting and must be lower than 200 kHz. Only available in FSK mode. Must be implemented in module class.
freqDev | Frequency deviation to be set (in kHz). |
Implemented in SX127x, Si443x, CC1101, RF69, SX128x, SX126x, and nRF24.
|
pure virtual |
int16_t PhysicalLayer::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.
str | Address of Arduino String that will be transmitted. |
addr | Node address to transmit the packet to. Only used in FSK mode. |
int16_t PhysicalLayer::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.
str | C-string that will be transmitted. |
addr | Node address to transmit the packet to. Only used in FSK mode. |
|
pure virtual |
Interrupt-driven binary transmit method.
data | Binary data that will be transmitted. |
len | Length of binary data to transmit (in bytes). |
addr | Node address to transmit the packet to. Only used in FSK mode. |
Implemented in SX127x, Si443x, CC1101, RF69, SX128x, SX126x, and nRF24.
int16_t PhysicalLayer::transmit | ( | __FlashStringHelper * | fstr, |
uint8_t | addr = 0 |
||
) |
Arduino Flash String transmit method.
str | Pointer to Arduino Flash String that will be transmitted. |
addr | Node address to transmit the packet to. Only used in FSK mode. |
int16_t PhysicalLayer::transmit | ( | String & | str, |
uint8_t | addr = 0 |
||
) |
Arduino String transmit method.
str | Address of Arduino string that will be transmitted. |
addr | Node address to transmit the packet to. Only used in FSK mode. |
int16_t PhysicalLayer::transmit | ( | const char * | str, |
uint8_t | addr = 0 |
||
) |
C-string transmit method.
str | C-string that will be transmitted. |
addr | Node address to transmit the packet to. Only used in FSK mode. |
|
pure virtual |
Binary transmit method. Must be implemented in module class.
data | Binary data that will be transmitted. |
len | Length of binary data to transmit (in bytes). |
addr | Node address to transmit the packet to. Only used in FSK mode. |
Implemented in Si443x, SX127x, CC1101, RF69, SX128x, SX126x, and nRF24.
|
pure virtual |
Enables direct transmission mode on pins DIO1 (clock) and DIO2 (data). Must be implemented in module class. While in direct mode, the module will not be able to transmit or receive packets. Can only be activated in FSK mode.
frf | 24-bit raw frequency value to start transmitting at. Required for quick frequency shifts in RTTY. |
Implemented in SX127x, Si443x, CC1101, RF69, SX128x, SX126x, and nRF24.