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 (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) |
Binary transmit method. Must be implemented in module class. More... | |
virtual int16_t | sleep () |
Sets module to sleep. More... | |
virtual int16_t | standby () |
Sets module to standby. More... | |
virtual int16_t | standby (uint8_t mode) |
Sets module to a specific standby mode. More... | |
virtual int16_t | startReceive (uint32_t timeout, uint16_t irqFlags, uint16_t irqMask, size_t len) |
Interrupt-driven receive method. A DIO pin will be activated when full packet is received. Must be implemented in module class. More... | |
virtual int16_t | receive (uint8_t *data, size_t len) |
Binary receive method. Must be implemented in module class. 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) |
Interrupt-driven binary transmit method. More... | |
virtual int16_t | finishTransmit () |
Clean up after transmission is done. More... | |
virtual int16_t | readData (uint8_t *data, size_t len) |
Reads data that was received after calling startReceive method. More... | |
virtual int16_t | transmitDirect (uint32_t frf=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 () |
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 | setFrequency (float freq) |
Sets carrier frequency. Must be implemented in module class. More... | |
virtual int16_t | setBitRate (float br) |
Sets FSK bit rate. Only available in FSK mode. Must be implemented in module class. More... | |
virtual int16_t | setFrequencyDeviation (float freqDev) |
Sets FSK frequency deviation from carrier frequency. Only available in FSK mode. Must be implemented in module class. More... | |
virtual int16_t | setDataShaping (uint8_t sh) |
Sets GFSK data shaping. Only available in FSK mode. Must be implemented in module class. More... | |
virtual int16_t | setEncoding (uint8_t encoding) |
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) |
Query modem for the packet length of received payload. Must be implemented in module class. More... | |
virtual float | getRSSI () |
Gets RSSI (Recorded Signal Strength Indicator) of the last received packet. More... | |
virtual float | getSNR () |
Gets SNR (Signal to Noise Ratio) of the last received packet. Only available for LoRa modem. 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 | randomByte () |
Get one truly random byte from RSSI noise. Must be implemented in module class. 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... | |
virtual void | setDirectAction (void(*func)(void)) |
Set interrupt service routine function to call when data bit is receveid in direct mode. Must be implemented in module class. More... | |
virtual void | readBit (uint32_t pin) |
Function to read and process data bit in direct reception mode. Must be implemented in module class. More... | |
int16_t | available () |
Get the number of direct mode bytes currently available in buffer. More... | |
void | dropSync () |
Forcefully drop synchronization. | |
uint8_t | read (bool drop=true) |
Get data from direct mode buffer. More... | |
virtual int16_t | setDIOMapping (uint32_t pin, uint32_t value) |
Configure DIO pin mapping to get a given signal on a DIO pin (if available). More... | |
virtual void | setDio1Action (void(*func)(void)) |
Sets interrupt service routine to call when DIO1 activates. More... | |
virtual void | clearDio1Action () |
Clears interrupt service routine to call when DIO1 activates. | |
Friends | |
class | AFSKClient |
class | RTTYClient |
class | MorseClient |
class | HellClient |
class | SSTVClient |
class | AX25Client |
class | FSK4Client |
class | PagerClient |
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. |
int16_t PhysicalLayer::available | ( | ) |
Get the number of direct mode bytes currently available in buffer.
|
virtual |
float PhysicalLayer::getFreqStep | ( | ) | const |
Gets the module frequency step size that was set in constructor.
|
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. |
Reimplemented in SX128x, SX127x, SX126x, Si443x, RF69, nRF24, and CC1101.
|
virtual |
|
virtual |
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). |
|
virtual |
uint8_t PhysicalLayer::read | ( | bool | drop = true | ) |
Get data from direct mode buffer.
drop | Drop synchronization on read - next reading will require waiting for the sync word again. Defaults to true. |
|
virtual |
|
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 read. When set to 0, the packet length will be retreived automatically. When more bytes than received are requested, only the number of bytes requested will be returned. |
Reimplemented in SX128x, SX127x, SX126x, Si443x, RF69, nRF24, and CC1101.
|
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. |
Reimplemented in SX128x, SX127x, SX126x, Si443x, RF69, nRF24, and CC1101.
|
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.
Reimplemented in SX128x, SX127x, SX126x, Si443x, RF69, nRF24, and CC1101.
|
virtual |
|
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. |
Reimplemented in SX128x, SX1278, SX1272, SX126x, Si443x, RF69, nRF24, and CC1101.
|
virtual |
|
virtual |
Configure DIO pin mapping to get a given signal on a DIO pin (if available).
pin | Pin number onto which a signal is to be placed. |
value | The value that indicates which function to place on that pin. See chip datasheet for details. |
|
virtual |
int16_t PhysicalLayer::setDirectSyncWord | ( | uint32_t | syncWord, |
uint8_t | len | ||
) |
Set sync word to be used to determine start of packet in direct reception mode.
syncWord | Sync word bits. |
len | Sync word length in bits. Set to zero to disable sync word matching. |
|
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. |
Reimplemented in SX128x, SX127x, SX126x, Si443x, RF69, nRF24, and CC1101.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
int16_t PhysicalLayer::startDirect | ( | ) |
Configure module parameters for direct modes. Must be called prior to "ham" modes like RTTY or AX.25. Only available in FSK mode.
|
virtual |
Interrupt-driven receive method. A DIO pin will be activated when full packet is received. Must be implemented in module class.
timeout | Raw timeout value. Some modules use this argument to specify operation mode (single vs. continuous receive). |
irqFlags | Sets the IRQ flags. |
irqMask | Sets the mask of IRQ flags that will trigger the DIO pin. |
len | Packet length, needed for some modules under special circumstances (e.g. LoRa implicit header mode). |
Reimplemented in SX126x, Si443x, RF69, nRF24, CC1101, and SX127x.
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. |
|
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. |
Reimplemented in SX128x, SX127x, SX126x, Si443x, RF69, CC1101, and nRF24.
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. |
|
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. |
Reimplemented in SX128x, SX127x, SX126x, Si443x, RF69, CC1101, and nRF24.
|
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. |
Reimplemented in SX128x, SX127x, SX126x, Si443x, RF69, nRF24, and CC1101.