RadioLib
Universal wireless communication library for Arduino
Loading...
Searching...
No Matches
PhysicalLayer.h
1#if !defined(_RADIOLIB_PHYSICAL_LAYER_H)
2#define _RADIOLIB_PHYSICAL_LAYER_H
3
4#include "../../TypeDef.h"
5#include "../../Module.h"
6
7// common IRQ values - the IRQ flags in RadioLibIrqFlags_t arguments are offset by this value
8enum RadioLibIrqType_t {
9 RADIOLIB_IRQ_TX_DONE = 0x00,
10 RADIOLIB_IRQ_RX_DONE = 0x01,
11 RADIOLIB_IRQ_PREAMBLE_DETECTED = 0x02,
12 RADIOLIB_IRQ_SYNC_WORD_VALID = 0x03,
13 RADIOLIB_IRQ_HEADER_VALID = 0x04,
14 RADIOLIB_IRQ_HEADER_ERR = 0x05,
15 RADIOLIB_IRQ_CRC_ERR = 0x06,
16 RADIOLIB_IRQ_CAD_DONE = 0x07,
17 RADIOLIB_IRQ_CAD_DETECTED = 0x08,
18 RADIOLIB_IRQ_TIMEOUT = 0x09,
19 RADIOLIB_IRQ_NOT_SUPPORTED = 0x1F, // this must be the last value, intentionally set to 31
20};
21
22// some commonly used default values - defined here to ensure all modules have the same default behavior
23#define RADIOLIB_IRQ_RX_DEFAULT_FLAGS ((1UL << RADIOLIB_IRQ_RX_DONE) | (1UL << RADIOLIB_IRQ_TIMEOUT) | (1UL << RADIOLIB_IRQ_CRC_ERR) | (1UL << RADIOLIB_IRQ_HEADER_VALID) | (1UL << RADIOLIB_IRQ_HEADER_ERR))
24#define RADIOLIB_IRQ_RX_DEFAULT_MASK ((1UL << RADIOLIB_IRQ_RX_DONE))
25#define RADIOLIB_IRQ_CAD_DEFAULT_FLAGS ((1UL << RADIOLIB_IRQ_CAD_DETECTED) | (1UL << RADIOLIB_IRQ_CAD_DONE))
26#define RADIOLIB_IRQ_CAD_DEFAULT_MASK ((1UL << RADIOLIB_IRQ_CAD_DETECTED) | (1UL << RADIOLIB_IRQ_CAD_DONE))
27
32struct LoRaRate_t {
35
37 float bandwidth;
38
40 uint8_t codingRate;
41};
42
47struct FSKRate_t {
49 float bitRate;
50
52 float freqDev;
53};
54
61 uint8_t bw;
62
64 uint8_t cr;
65
68};
69
84
88
91
94
97};
98
102
105
107 uint8_t crcLength;
108};
109
112 uint8_t hdrCount;
113};
114
123};
124
151
158 float limit;
159};
160
172
175 uint8_t mode;
176};
177
191
194 const uint8_t* data;
195
197 size_t len;
198
200 uint8_t addr;
201};
202
205 uint8_t mode;
206};
207
224
229enum ModemType_t {
230 RADIOLIB_MODEM_FSK = 0,
231 RADIOLIB_MODEM_LORA,
232 RADIOLIB_MODEM_LRFHSS,
233 RADIOLIB_MODEM_NONE, // last entry
234};
235
240enum RadioModeType_t {
241 RADIOLIB_RADIO_MODE_NONE = 0,
242 RADIOLIB_RADIO_MODE_STANDBY,
243 RADIOLIB_RADIO_MODE_RX,
244 RADIOLIB_RADIO_MODE_TX,
245 RADIOLIB_RADIO_MODE_SCAN,
246 RADIOLIB_RADIO_MODE_SLEEP,
247};
248
249#define RADIOLIB_LORA_SYNC_WORD_PRIVATE (0x12UL << 0) // 7 0 LoRa sync word: private network
250#define RADIOLIB_LORA_SYNC_WORD_PUBLIC (0x34UL << 0) // 7 0 public network (LoRaWAN)
251
252#define RADIOLIB_LR_FHSS_CR_5_6 (0x00UL << 0) // 7 0 LR-FHSS coding rate: 5/6
253#define RADIOLIB_LR_FHSS_CR_2_3 (0x01UL << 0) // 7 0 2/3
254#define RADIOLIB_LR_FHSS_CR_1_2 (0x02UL << 0) // 7 0 1/2
255#define RADIOLIB_LR_FHSS_CR_1_3 (0x03UL << 0) // 7 0 1/3
256#define RADIOLIB_LR_FHSS_BW_39_06 (0x00UL << 0) // 7 0 LR-FHSS bandwidth: 39.06 kHz
257#define RADIOLIB_LR_FHSS_BW_85_94 (0x01UL << 0) // 7 0 85.94 kHz
258#define RADIOLIB_LR_FHSS_BW_136_72 (0x02UL << 0) // 7 0 136.72 kHz
259#define RADIOLIB_LR_FHSS_BW_183_59 (0x03UL << 0) // 7 0 183.59 kHz
260#define RADIOLIB_LR_FHSS_BW_335_94 (0x04UL << 0) // 7 0 335.94 kHz
261#define RADIOLIB_LR_FHSS_BW_386_72 (0x05UL << 0) // 7 0 386.72 kHz
262#define RADIOLIB_LR_FHSS_BW_722_66 (0x06UL << 0) // 7 0 722.66 kHz
263#define RADIOLIB_LR_FHSS_BW_773_44 (0x07UL << 0) // 7 0 773.44 kHz
264#define RADIOLIB_LR_FHSS_BW_1523_4 (0x08UL << 0) // 7 0 1523.4 kHz
265#define RADIOLIB_LR_FHSS_BW_1574_2 (0x09UL << 0) // 7 0 1574.2 kHz
266
267#define RADIOLIB_FLRC_BR_2600 (0x00UL << 0) // 7 0 bitrate/bandwidth: 2600 kbps, 2666 kHz
268#define RADIOLIB_FLRC_BR_2080 (0x01UL << 0) // 7 0 2080 kbps, 2222 kHz
269#define RADIOLIB_FLRC_BR_1300 (0x02UL << 0) // 7 0 1300 kbps, 1333 kHz
270#define RADIOLIB_FLRC_BR_1040 (0x03UL << 0) // 7 0 1040 kbps, 1333 kHz
271#define RADIOLIB_FLRC_BR_650 (0x04UL << 0) // 7 0 650 kbps, 888 kHz
272#define RADIOLIB_FLRC_BR_520 (0x05UL << 0) // 7 0 520 kbps, 769 kHz
273#define RADIOLIB_FLRC_BR_325 (0x06UL << 0) // 7 0 325 kbps, 444 kHz
274#define RADIOLIB_FLRC_BR_260 (0x07UL << 0) // 7 0 260 kbps, 444 kHz
275#define RADIOLIB_FLRC_CR_1_2 (0x00UL << 0) // 7 0 coding rate: 1/2
276#define RADIOLIB_FLRC_CR_3_4 (0x01UL << 0) // 7 0 3/4
277#define RADIOLIB_FLRC_CR_1_0 (0x02UL << 0) // 7 0 1 (un-coded)
278#define RADIOLIB_FLRC_CR_2_3 (0x03UL << 0) // 7 0 2/3
279
282 float frequency = 434.0;
284 float bandwidth = 125.0;
286 uint8_t spreadingFactor = 9;
289 uint8_t codingRate = 7;
291 uint8_t syncWord = RADIOLIB_LORA_SYNC_WORD_PRIVATE;
293 int8_t power = 10;
295 uint16_t preambleLength = 8;
296};
297
300 float frequency = 434.0;
302 float bitRate = 4.8;
306 float receiverBandwidth = 125.0;
308 int8_t power = 10;
310 uint16_t preambleLength = 16;
311};
312
315 float frequency = 434.0;
317 float bitRate = 4.8;
319 int8_t power = 10;
320};
321
324 float frequency = 434.0;
326 float bitRate = 4.8;
328 float receiverBandwidth = 125.0;
330 int8_t power = 10;
332 uint16_t preambleLength = 16;
333};
334
337 float frequency = 434.0;
339 uint8_t bandwidth = RADIOLIB_LR_FHSS_BW_722_66;
341 uint8_t codingRate = RADIOLIB_LR_FHSS_CR_2_3;
343 bool narrowGrid = true;
345 int8_t power = 10;
346};
347
350 float frequency = 434.0;
352 float bitRate = 650.0;
354 uint8_t codingRate = RADIOLIB_FLRC_CR_2_3;
356 int8_t power = 10;
358 uint16_t preambleLength = 16;
361};
362
365 float frequency = 2400.0;
367 uint16_t bitRate = 800;
369 float frequencyDeviation = 400.0;
371 int8_t power = 10;
374};
375
391 public:
392
394 float freqStep;
395
398
404 bool resetOnStartup = true;
405
406 // constructor
407
412
416 virtual ~PhysicalLayer() = default;
417
418 // basic methods
419
420 #if defined(RADIOLIB_BUILD_ARDUINO)
427 int16_t transmit(__FlashStringHelper* fstr, uint8_t addr = 0);
428
435 int16_t transmit(String& str, uint8_t addr = 0);
436 #endif
437
444 int16_t transmit(const char* str, uint8_t addr = 0);
445
453 virtual int16_t transmit(const uint8_t* data, size_t len, uint8_t addr = 0);
454
455 #if defined(RADIOLIB_BUILD_ARDUINO)
464 int16_t receive(String& str, size_t len = 0, RadioLibTime_t timeout = 0);
465 #endif
466
471 virtual int16_t sleep();
472
477 virtual int16_t standby();
478
483 virtual int16_t standby(uint8_t mode);
484
489 virtual int16_t startReceive();
490
501 virtual int16_t startReceive(uint32_t timeout, RadioLibIrqFlags_t irqFlags = RADIOLIB_IRQ_RX_DEFAULT_FLAGS, RadioLibIrqFlags_t irqMask = RADIOLIB_IRQ_RX_DEFAULT_MASK, size_t len = 0);
502
511 virtual int16_t receive(uint8_t* data, size_t len, RadioLibTime_t timeout = 0);
512
513 #if defined(RADIOLIB_BUILD_ARDUINO)
521 int16_t startTransmit(String& str, uint8_t addr = 0);
522 #endif
523
531 int16_t startTransmit(const char* str, uint8_t addr = 0);
532
540 virtual int16_t startTransmit(const uint8_t* data, size_t len, uint8_t addr = 0);
541
546 virtual int16_t finishTransmit();
547
552 virtual int16_t finishReceive();
553
554 #if defined(RADIOLIB_BUILD_ARDUINO)
562 int16_t readData(String& str, size_t len = 0);
563 #endif
564
572 virtual int16_t readData(uint8_t* data, size_t len);
573
580 virtual int16_t transmitDirect(uint32_t frf = 0);
581
587 virtual int16_t receiveDirect();
588
589 // configuration methods
590
596 virtual int16_t setFrequency(float freq);
597
603 virtual int16_t setBitRate(float br);
604
611 virtual int16_t setFrequencyDeviation(float freqDev);
612
618 virtual int16_t setDataShaping(uint8_t sh);
619
625 virtual int16_t setEncoding(uint8_t encoding);
626
632 virtual int16_t invertIQ(bool enable);
633
639 virtual int16_t setOutputPower(int8_t power);
640
647 virtual int16_t checkOutputPower(int8_t power, int8_t* clipped);
648
655 virtual int16_t setSyncWord(uint8_t* sync, size_t len);
656
662 virtual int16_t setPreambleLength(size_t len);
663
671 virtual int16_t setDataRate(DataRate_t dr, ModemType_t modem = RADIOLIB_MODEM_NONE);
672
680 virtual int16_t checkDataRate(DataRate_t dr, ModemType_t modem = RADIOLIB_MODEM_NONE);
681
687 virtual size_t getPacketLength(bool update = true);
688
693 virtual float getRSSI();
694
699 virtual float getSNR();
700
709 virtual RadioLibTime_t calculateTimeOnAir(ModemType_t modem, DataRate_t dr, PacketConfig_t pc, size_t len);
710
716 virtual RadioLibTime_t getTimeOnAir(size_t len);
717
725
731 uint32_t getIrqMapped(RadioLibIrqFlags_t irq);
732
738 int16_t checkIrq(RadioLibIrqType_t irq);
739
747 int16_t setIrq(RadioLibIrqFlags_t irq);
748
756 int16_t clearIrq(RadioLibIrqFlags_t irq);
757
763 virtual uint32_t getIrqFlags();
764
771 virtual int16_t setIrqFlags(uint32_t irq);
772
779 virtual int16_t clearIrqFlags(uint32_t irq);
780
786 virtual int16_t startChannelScan();
787
794 virtual int16_t startChannelScan(const ChannelScanConfig_t &config);
795
800 virtual int16_t getChannelScanResult();
801
808 virtual int16_t scanChannel();
809
817 virtual int16_t scanChannel(const ChannelScanConfig_t &config);
818
824 int32_t random(int32_t max);
825
832 int32_t random(int32_t min, int32_t max);
833
838 virtual uint8_t randomByte();
839
845 int16_t startDirect();
846
847 #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
854 int16_t setDirectSyncWord(uint32_t syncWord, uint8_t len);
855
861 virtual void setDirectAction(void (*func)(void));
862
867 virtual void readBit(uint32_t pin);
868
873 int16_t available();
874
878 void dropSync();
879
886 uint8_t read(bool drop = true);
887 #endif
888
893 virtual void setPacketReceivedAction(void (*func)(void));
894
898 virtual void clearPacketReceivedAction();
899
904 virtual void setPacketSentAction(void (*func)(void));
905
909 virtual void clearPacketSentAction();
910
915 virtual void setChannelScanAction(void (*func)(void));
916
920 virtual void clearChannelScanAction();
921
928 virtual int16_t setModem(ModemType_t modem);
929
935 virtual int16_t getModem(ModemType_t* modem);
936
943 virtual int16_t stageMode(RadioModeType_t mode, RadioModeConfig_t* cfg);
944
949 virtual int16_t launchMode();
950
951 #if RADIOLIB_INTERRUPT_TIMING
952
958 void setInterruptSetup(void (*func)(uint32_t));
959
964 void setTimerFlag();
965
966 #endif
967
985 int16_t calculateRxDutyCycle(size_t txPreLen, size_t rxPreLen, uint16_t minSymbols, DataRate_t* dr, uint32_t* wakePeriod, uint32_t* sleepPeriod);
986
987#if !RADIOLIB_GODMODE
988 protected:
989#endif
990 uint32_t irqMap[10] = { 0 };
991 RadioModeType_t stagedMode = RADIOLIB_RADIO_MODE_NONE;
992
993#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
994 void updateDirectBuffer(uint8_t bit);
995#endif
996
997#if !RADIOLIB_GODMODE
998 private:
999#endif
1000
1001 #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
1002 uint8_t bufferBitPos = 0;
1003 uint8_t bufferWritePos = 0;
1004 uint8_t bufferReadPos = 0;
1005 uint8_t buffer[RADIOLIB_STATIC_ARRAY_SIZE] = { 0 };
1006 uint32_t syncBuffer = 0;
1007 uint32_t directSyncWord = 0;
1008 uint8_t directSyncWordLen = 0;
1009 uint32_t directSyncWordMask = 0;
1010 bool gotSync = false;
1011 #endif
1012
1013 virtual Module* getMod() = 0;
1014
1015 // allow specific classes access the private getMod method
1016 friend class AFSKClient;
1017 friend class RTTYClient;
1018 friend class MorseClient;
1019 friend class HellClient;
1020 friend class SSTVClient;
1021 friend class AX25Client;
1022 friend class FSK4Client;
1023 friend class PagerClient;
1024 friend class BellClient;
1025 friend class FT8Client;
1026 friend class LoRaWANNode;
1027 friend class M17Client;
1028};
1029
1030#endif
Client for audio-based transmissions. Requires Arduino tone() function, and a module capable of direc...
Definition AFSK.h:16
Client for AX25 communication.
Definition AX25.h:232
Client for Bell modem communication. The public interface is the same as Arduino Serial.
Definition BellModem.h:54
Client for FSK-4 communication. The public interface is the same as Arduino Serial.
Definition FSK4.h:15
Client for Hellschreiber transmissions.
Definition Hellschreiber.h:19
LoRaWAN-compatible node (class A device).
Definition LoRaWAN.h:552
Implements all common low-level methods to control the wireless module. Every module class contains o...
Definition Module.h:69
Client for Morse Code communication. The public interface is the same as Arduino Serial.
Definition Morse.h:23
Client for Pager communication.
Definition Pager.h:62
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN....
Definition PhysicalLayer.h:390
virtual int16_t stageMode(RadioModeType_t mode, RadioModeConfig_t *cfg)
Stage mode of the radio to be launched later using launchMode.
Definition PhysicalLayer.cpp:559
int16_t calculateRxDutyCycle(size_t txPreLen, size_t rxPreLen, uint16_t minSymbols, DataRate_t *dr, uint32_t *wakePeriod, uint32_t *sleepPeriod)
Calculates sleep and wake cycles for startReceiveDutyCycle methods so that the receiver should not mi...
Definition PhysicalLayer.cpp:581
virtual int16_t invertIQ(bool enable)
Set IQ inversion. Must be implemented in module class if the module supports it.
Definition PhysicalLayer.cpp:265
virtual void clearChannelScanAction()
Clears interrupt service routine to call when a channel scan is finished.
Definition PhysicalLayer.cpp:545
virtual int16_t checkOutputPower(int8_t power, int8_t *clipped)
Check if output power is configurable. Must be implemented in module class if the module supports it.
Definition PhysicalLayer.cpp:275
virtual int16_t startReceive()
Sets module to received mode using its default configuration.
Definition PhysicalLayer.cpp:131
virtual uint8_t randomByte()
Get one truly random byte from RSSI noise. Must be implemented in module class.
Definition PhysicalLayer.cpp:426
size_t maxPacketLength
Maximum length of packet that can be received by the module.
Definition PhysicalLayer.h:397
virtual int16_t finishTransmit()
Clean up after transmission is done.
Definition PhysicalLayer.cpp:174
int16_t checkIrq(RadioLibIrqType_t irq)
Check whether a specific IRQ bit is set (e.g. RxTimeout, CadDone).
Definition PhysicalLayer.cpp:347
virtual int16_t setFrequencyDeviation(float freqDev)
Sets FSK frequency deviation from carrier frequency. Only available in FSK mode. Must be implemented ...
Definition PhysicalLayer.cpp:250
virtual size_t getPacketLength(bool update=true)
Query modem for the packet length of received payload. Must be implemented in module class.
Definition PhysicalLayer.cpp:304
virtual void setPacketSentAction(void(*func)(void))
Sets interrupt service routine to call when a packet is sent.
Definition PhysicalLayer.cpp:533
virtual int16_t readData(uint8_t *data, size_t len)
Reads data that was received after calling startReceive method.
Definition PhysicalLayer.cpp:225
void dropSync()
Forcefully drop synchronization.
Definition PhysicalLayer.cpp:449
int16_t transmit(const char *str, uint8_t addr=0)
C-string transmit method.
Definition PhysicalLayer.cpp:53
uint8_t read(bool drop=true)
Get data from direct mode buffer.
Definition PhysicalLayer.cpp:456
virtual RadioLibTime_t getTimeOnAir(size_t len)
Get expected time-on-air for a given size of payload.
Definition PhysicalLayer.cpp:325
virtual int16_t launchMode()
Launch previously staged mode.
Definition PhysicalLayer.cpp:565
virtual int16_t getChannelScanResult()
Read the channel scan result.
Definition PhysicalLayer.cpp:386
virtual void clearPacketSentAction()
Clears interrupt service routine to call when a packet is sent.
Definition PhysicalLayer.cpp:537
virtual int16_t setSyncWord(uint8_t *sync, size_t len)
Set sync word. Must be implemented in module class if the module supports it.
Definition PhysicalLayer.cpp:281
virtual int16_t setModem(ModemType_t modem)
Set modem for the radio to use. Will perform full reset and reconfigure the radio using its default p...
Definition PhysicalLayer.cpp:549
virtual ~PhysicalLayer()=default
Default destructor.
virtual void clearPacketReceivedAction()
Clears interrupt service routine to call when a packet is received.
Definition PhysicalLayer.cpp:529
virtual RadioLibTime_t calculateRxTimeout(RadioLibTime_t timeoutUs)
Calculate the timeout value for this specific module / series (in number of symbols or units of time)...
Definition PhysicalLayer.cpp:330
int16_t setIrq(RadioLibIrqFlags_t irq)
Set interrupt on specific IRQ bit(s) (e.g. RxTimeout, CadDone). Keep in mind that not all radio modul...
Definition PhysicalLayer.cpp:355
virtual int16_t setPreambleLength(size_t len)
Set preamble length. Must be implemented in module class if the module supports it.
Definition PhysicalLayer.cpp:287
int16_t startDirect()
Configure module parameters for direct modes. Must be called prior to "ham" modes like RTTY or AX....
Definition PhysicalLayer.cpp:430
virtual int16_t setFrequency(float freq)
Sets carrier frequency. Must be implemented in module class.
Definition PhysicalLayer.cpp:240
virtual int16_t finishReceive()
Clean up after reception is done.
Definition PhysicalLayer.cpp:178
int16_t setDirectSyncWord(uint32_t syncWord, uint8_t len)
Set sync word to be used to determine start of packet in direct reception mode.
Definition PhysicalLayer.cpp:464
int16_t startTransmit(const char *str, uint8_t addr=0)
Interrupt-driven Arduino String transmit method. Unlike the standard transmit method,...
Definition PhysicalLayer.cpp:156
virtual int16_t checkDataRate(DataRate_t dr, ModemType_t modem=RADIOLIB_MODEM_NONE)
Check the data rate can be configured by this module. Must be implemented in module class if the modu...
Definition PhysicalLayer.cpp:298
virtual int16_t transmitDirect(uint32_t frf=0)
Enables direct transmission mode on pins DIO1 (clock) and DIO2 (data). Must be implemented in module ...
Definition PhysicalLayer.cpp:231
float freqStep
Frequency step of the synthesizer in Hz.
Definition PhysicalLayer.h:394
virtual float getRSSI()
Gets RSSI (Received Signal Strength Indicator) of the last received packet.
Definition PhysicalLayer.cpp:309
int16_t available()
Get the number of direct mode bytes currently available in buffer.
Definition PhysicalLayer.cpp:445
virtual int16_t scanChannel()
Check whether the current communication channel is free or occupied. Performs CAD for LoRa modules,...
Definition PhysicalLayer.cpp:390
virtual void setDirectAction(void(*func)(void))
Set interrupt service routine function to call when data bit is received in direct mode....
Definition PhysicalLayer.cpp:515
virtual RadioLibTime_t calculateTimeOnAir(ModemType_t modem, DataRate_t dr, PacketConfig_t pc, size_t len)
Calculate the expected time-on-air for a given modem, data rate, packet configuration and payload siz...
Definition PhysicalLayer.cpp:317
virtual int16_t clearIrqFlags(uint32_t irq)
Clear interrupt on a specific IRQ bit (e.g. RxTimeout, CadDone). Must be implemented in module class.
Definition PhysicalLayer.cpp:372
virtual int16_t setDataRate(DataRate_t dr, ModemType_t modem=RADIOLIB_MODEM_NONE)
Set data rate. Must be implemented in module class if the module supports it.
Definition PhysicalLayer.cpp:292
virtual int16_t setEncoding(uint8_t encoding)
Sets FSK data encoding. Only available in FSK mode. Must be implemented in module class.
Definition PhysicalLayer.cpp:260
virtual int16_t standby()
Sets module to standby.
Definition PhysicalLayer.cpp:122
int32_t random(int32_t max)
Get truly random number in range 0 - max.
Definition PhysicalLayer.cpp:399
virtual void readBit(uint32_t pin)
Function to read and process data bit in direct reception mode. Must be implemented in module class.
Definition PhysicalLayer.cpp:519
virtual int16_t setOutputPower(int8_t power)
Set output power. Must be implemented in module class if the module supports it.
Definition PhysicalLayer.cpp:270
virtual int16_t receiveDirect()
Enables direct reception mode on pins DIO1 (clock) and DIO2 (data). Must be implemented in module cla...
Definition PhysicalLayer.cpp:236
virtual void setChannelScanAction(void(*func)(void))
Sets interrupt service routine to call when a channel scan is finished.
Definition PhysicalLayer.cpp:541
virtual int16_t startChannelScan()
Interrupt-driven channel activity detection method. Interrupt will be activated when packet is detect...
Definition PhysicalLayer.cpp:377
uint32_t getIrqMapped(RadioLibIrqFlags_t irq)
Convert from radio-agnostic IRQ flags to radio-specific flags.
Definition PhysicalLayer.cpp:335
virtual int16_t receive(uint8_t *data, size_t len, RadioLibTime_t timeout=0)
Binary receive method. Must be implemented in module class.
Definition PhysicalLayer.cpp:111
virtual int16_t setDataShaping(uint8_t sh)
Sets GFSK data shaping. Only available in FSK mode. Must be implemented in module class.
Definition PhysicalLayer.cpp:255
virtual void setPacketReceivedAction(void(*func)(void))
Sets interrupt service routine to call when a packet is received.
Definition PhysicalLayer.cpp:525
virtual int16_t setBitRate(float br)
Sets FSK bit rate. Only available in FSK mode. Must be implemented in module class.
Definition PhysicalLayer.cpp:245
virtual float getSNR()
Gets SNR (Signal to Noise Ratio) of the last received packet. Only available for LoRa modem.
Definition PhysicalLayer.cpp:313
virtual int16_t getModem(ModemType_t *modem)
Get modem currently in use by the radio.
Definition PhysicalLayer.cpp:554
virtual int16_t sleep()
Sets module to sleep.
Definition PhysicalLayer.cpp:118
virtual uint32_t getIrqFlags()
Read currently active IRQ flags. Must be implemented in module class.
Definition PhysicalLayer.cpp:363
virtual int16_t setIrqFlags(uint32_t irq)
Set interrupt on DIO1 to be sent on a specific IRQ bit (e.g. RxTimeout, CadDone). Must be implemented...
Definition PhysicalLayer.cpp:367
int16_t clearIrq(RadioLibIrqFlags_t irq)
Clear interrupt on a specific IRQ bit (e.g. RxTimeout, CadDone). Keep in mind that not all radio modu...
Definition PhysicalLayer.cpp:359
PhysicalLayer()
Default constructor.
Definition PhysicalLayer.cpp:5
Client for RTTY communication. The public interface is the same as Arduino Serial.
Definition RTTY.h:17
Client for SSTV transmissions.
Definition SSTV.h:121
#define RADIOLIB_SHAPING_0_5
Gaussian shaping filter, BT = 0.5.
Definition TypeDef.h:27
bool resetOnStartup
Whether to reset the module on startup. Setting to false allows to restore radio operation by calling...
Definition PhysicalLayer.h:404
unsigned long RadioLibTime_t
Type used for durations in RadioLib.
Definition TypeDef.h:679
uint32_t RadioLibIrqFlags_t
Type used for radio-agnostic IRQ flags. IRQ to enable corresponds to the bit index (RadioLibIrq_t)....
Definition TypeDef.h:685
Channel scan configuration interpretation in case LoRa CAD is used.
Definition PhysicalLayer.h:129
RadioLibTime_t timeout
Timeout in microseconds.
Definition PhysicalLayer.h:143
uint8_t detPeak
Number of peak detection symbols.
Definition PhysicalLayer.h:134
uint8_t symNum
Number of symbols to consider signal present.
Definition PhysicalLayer.h:131
uint8_t exitMode
Exit mode after signal detection is complete - module-specific value.
Definition PhysicalLayer.h:140
RadioLibIrqFlags_t irqFlags
Optional IRQ flags to set, bits offset by the value of RADIOLIB_IRQ_.
Definition PhysicalLayer.h:146
RadioLibIrqFlags_t irqMask
Optional IRQ mask to set, bits offset by the value of RADIOLIB_IRQ_.
Definition PhysicalLayer.h:149
uint8_t detMin
Number of minimum detection symbols.
Definition PhysicalLayer.h:137
Definition PhysicalLayer.h:363
float frequency
Carrier frequency in MHz. Defaults to 2400.0 MHz.
Definition PhysicalLayer.h:365
float frequencyDeviation
BLE frequency deviation in kHz. Defaults to 400.0 kHz.
Definition PhysicalLayer.h:369
uint8_t dataShaping
Time-bandwidth product of the Gaussian filter to be used for shaping. Defaults to 0....
Definition PhysicalLayer.h:373
uint16_t bitRate
BLE bit rate in kbps. Defaults to 800 kbps.
Definition PhysicalLayer.h:367
int8_t power
Output power in dBm. Defaults to 10 dBm.
Definition PhysicalLayer.h:371
Definition PhysicalLayer.h:313
int8_t power
Output power in dBm. Defaults to 10 dBm.
Definition PhysicalLayer.h:319
float frequency
Carrier frequency in MHz. Defaults to 434.0 MHz.
Definition PhysicalLayer.h:315
float bitRate
FSK bit rate in kbps. Defaults to 4.8 kbps.
Definition PhysicalLayer.h:317
Definition PhysicalLayer.h:348
uint8_t codingRate
FLRC coding rate. Defaults to RADIOLIB_FLRC_CR_2_3 (coding rate 2/3).
Definition PhysicalLayer.h:354
float frequency
Carrier frequency in MHz. Defaults to 434.0 MHz.
Definition PhysicalLayer.h:350
uint16_t preambleLength
FLRC preamble length in bits. Defaults to 16 bits.
Definition PhysicalLayer.h:358
int8_t power
Output power in dBm. Defaults to 10 dBm.
Definition PhysicalLayer.h:356
float bitRate
FLRC bit rate in kbps. Defaults to 650 kbps.
Definition PhysicalLayer.h:352
uint8_t dataShaping
Time-bandwidth product of the Gaussian filter to be used for shaping. Defaults to 0....
Definition PhysicalLayer.h:360
Definition PhysicalLayer.h:298
float bitRate
FSK bit rate in kbps. Defaults to 4.8 kbps.
Definition PhysicalLayer.h:302
float receiverBandwidth
FSK receiver bandwidth in kHz. Defaults to 125.0 kHz.
Definition PhysicalLayer.h:306
uint16_t preambleLength
FSK preamble length in bits. Defaults to 16 bits.
Definition PhysicalLayer.h:310
float frequency
Carrier frequency in MHz. Defaults to 434.0 MHz.
Definition PhysicalLayer.h:300
int8_t power
Output power in dBm. Defaults to 10 dBm.
Definition PhysicalLayer.h:308
float frequencyDeviation
FSK frequency deviation in kHz. Defaults to 5.0 kHz.
Definition PhysicalLayer.h:304
Definition PhysicalLayer.h:335
uint8_t bandwidth
LR-FHSS bandwidth, one of RADIOLIB_LR_FHSS_BW_* values. Defaults to 722.66 kHz.
Definition PhysicalLayer.h:339
bool narrowGrid
Whether to use narrow (3.9 kHz) or wide (25.39 kHz) grid spacing. Defaults to true (narrow/non-FCC) g...
Definition PhysicalLayer.h:343
int8_t power
Output power in dBm. Defaults to 10 dBm.
Definition PhysicalLayer.h:345
uint8_t codingRate
LR-FHSS coding rate, one of RADIOLIB_LR_FHSS_CR_* values. Defaults to 2/3 coding rate.
Definition PhysicalLayer.h:341
float frequency
Carrier frequency in MHz. Defaults to 434.0 MHz.
Definition PhysicalLayer.h:337
Definition PhysicalLayer.h:280
uint16_t preambleLength
LoRa preamble length in symbols. Defaults to 8 symbols.
Definition PhysicalLayer.h:295
uint8_t codingRate
LoRa coding rate. Defaults to 7 (coding rate 4/7). Allowed values range from 4 to 8....
Definition PhysicalLayer.h:289
int8_t power
Output power in dBm. Defaults to 10 dBm.
Definition PhysicalLayer.h:293
uint8_t syncWord
1-byte LoRa sync word. Defaults to RADIOLIB_LORA_SYNC_WORD_PRIVATE (0x12).
Definition PhysicalLayer.h:291
float bandwidth
LoRa bandwidth in kHz. Defaults to 125.0 kHz.
Definition PhysicalLayer.h:284
uint8_t spreadingFactor
LoRa spreading factor. Defaults to 9.
Definition PhysicalLayer.h:286
float frequency
Carrier frequency in MHz. Defaults to 434.0 MHz.
Definition PhysicalLayer.h:282
Definition PhysicalLayer.h:322
int8_t power
Output power in dBm. Defaults to 10 dBm.
Definition PhysicalLayer.h:330
uint16_t preambleLength
FSK preamble length in bits. Defaults to 16 bits.
Definition PhysicalLayer.h:332
float bitRate
FSK bit rate in kbps. Defaults to 4.8 kbps.
Definition PhysicalLayer.h:326
float frequency
Carrier frequency in MHz. Defaults to 434.0 MHz.
Definition PhysicalLayer.h:324
float receiverBandwidth
FSK receiver bandwidth in kHz. Defaults to 125.0 kHz.
Definition PhysicalLayer.h:328
Definition PhysicalLayer.h:99
uint8_t crcLength
FSK CRC length in bytes.
Definition PhysicalLayer.h:107
uint8_t syncWordLength
Length of the sync word in bits.
Definition PhysicalLayer.h:104
uint16_t preambleLength
FSK preamble length in bits.
Definition PhysicalLayer.h:101
Data rate structure interpretation in case FSK is used.
Definition PhysicalLayer.h:47
float bitRate
FSK bit rate in kbps.
Definition PhysicalLayer.h:49
float freqDev
FSK frequency deviation in kHz.
Definition PhysicalLayer.h:52
Definition PhysicalLayer.h:85
bool implicitHeader
LoRa implicit header mode.
Definition PhysicalLayer.h:90
bool crcEnabled
LoRa CRC mode.
Definition PhysicalLayer.h:93
bool ldrOptimize
LoRa low data rate optimization.
Definition PhysicalLayer.h:96
uint16_t preambleLength
LoRa preamble length.
Definition PhysicalLayer.h:87
Data rate structure interpretation in case LoRa is used.
Definition PhysicalLayer.h:32
uint8_t spreadingFactor
LoRa spreading factor.
Definition PhysicalLayer.h:34
float bandwidth
LoRa bandwidth in kHz.
Definition PhysicalLayer.h:37
uint8_t codingRate
LoRa coding rate denominator.
Definition PhysicalLayer.h:40
Definition PhysicalLayer.h:110
uint8_t hdrCount
LR-FHSS header count (1 - 4)
Definition PhysicalLayer.h:112
Data rate structure interpretation in case LR-FHSS is used.
Definition PhysicalLayer.h:59
bool narrowGrid
Grid spacing.
Definition PhysicalLayer.h:67
uint8_t cr
Coding rate.
Definition PhysicalLayer.h:64
uint8_t bw
Bandwidth.
Definition PhysicalLayer.h:61
Channel scan configuration interpretation in case RSSI threshold is used.
Definition PhysicalLayer.h:156
float limit
RSSI limit in dBm.
Definition PhysicalLayer.h:158
Definition PhysicalLayer.h:178
RadioLibIrqFlags_t irqFlags
Sets the IRQ flags.
Definition PhysicalLayer.h:183
size_t len
Packet length, needed for some modules under special circumstances (e.g. LoRa implicit header mode).
Definition PhysicalLayer.h:189
uint32_t timeout
Raw timeout value. Some modules use this argument to specify operation mode (single vs....
Definition PhysicalLayer.h:180
RadioLibIrqFlags_t irqMask
Sets the mask of IRQ flags that will trigger the radio interrupt pin.
Definition PhysicalLayer.h:186
Definition PhysicalLayer.h:203
uint8_t mode
Module-specific sleep mode configuration.
Definition PhysicalLayer.h:205
Definition PhysicalLayer.h:173
uint8_t mode
Module-specific standby mode configuration.
Definition PhysicalLayer.h:175
Definition PhysicalLayer.h:192
const uint8_t * data
Binary data that will be transmitted.
Definition PhysicalLayer.h:194
uint8_t addr
Node address to transmit the packet to. Only used in FSK mode.
Definition PhysicalLayer.h:200
size_t len
Length of binary data to transmit (in bytes).
Definition PhysicalLayer.h:197
Common channel scan configuration structure.
Definition PhysicalLayer.h:165
RSSIScanConfig_t rssi
Interpretation for modems that use RSSI threshold.
Definition PhysicalLayer.h:170
CADScanConfig_t cad
Interpretation for modems that use CAD (usually LoRa modems)
Definition PhysicalLayer.h:167
Common data rate structure.
Definition PhysicalLayer.h:74
LrFhssRate_t lrFhss
Interpretation for LR-FHSS modems.
Definition PhysicalLayer.h:82
LoRaRate_t lora
Interpretation for LoRa modems.
Definition PhysicalLayer.h:76
FSKRate_t fsk
Interpretation for FSK modems.
Definition PhysicalLayer.h:79
Common packet configuration structure.
Definition PhysicalLayer.h:119
Definition PhysicalLayer.h:208
SleepConfig_t sleep
Interpretation for sleep mode.
Definition PhysicalLayer.h:222
StandbyConfig_t standby
Interpretation for standby mode.
Definition PhysicalLayer.h:210
ChannelScanConfig_t scan
Interpretation for scanning.
Definition PhysicalLayer.h:219
TransmitConfig_t transmit
Interpretation for Tx mode.
Definition PhysicalLayer.h:216
ReceiveConfig_t receive
Interpretation for Rx mode.
Definition PhysicalLayer.h:213