RadioLib Universal wireless communication library for Arduino

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
15 class PhysicalLayer {
16 public:
17
18 // constructor
19
25 PhysicalLayer(float step, size_t maxLen);
26
27 // basic methods
28
29 #if defined(RADIOLIB_BUILD_ARDUINO)
36 int16_t transmit(__FlashStringHelper* fstr, uint8_t addr = 0);
37
44 int16_t transmit(String& str, uint8_t addr = 0);
45 #endif
46
53 int16_t transmit(const char* str, uint8_t addr = 0);
54
62 virtual int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0);
63
64 #if defined(RADIOLIB_BUILD_ARDUINO)
71 int16_t receive(String& str, size_t len = 0);
72 #endif
73
78 virtual int16_t sleep();
79
84 virtual int16_t standby();
85
90 virtual int16_t standby(uint8_t mode);
91
102 virtual int16_t startReceive(uint32_t timeout, uint16_t irqFlags, uint16_t irqMask, size_t len);
103
110 virtual int16_t receive(uint8_t* data, size_t len);
111
112 #if defined(RADIOLIB_BUILD_ARDUINO)
120 int16_t startTransmit(String& str, uint8_t addr = 0);
121 #endif
122
130 int16_t startTransmit(const char* str, uint8_t addr = 0);
131
139 virtual int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0);
140
145 virtual int16_t finishTransmit();
146
147 #if defined(RADIOLIB_BUILD_ARDUINO)
155 int16_t readData(String& str, size_t len = 0);
156 #endif
157
165 virtual int16_t readData(uint8_t* data, size_t len);
166
173 virtual int16_t transmitDirect(uint32_t frf = 0);
174
180 virtual int16_t receiveDirect();
181
182 // configuration methods
183
189 virtual int16_t setFrequency(float freq);
190
196 virtual int16_t setBitRate(float br);
197
204 virtual int16_t setFrequencyDeviation(float freqDev);
205
211 virtual int16_t setDataShaping(uint8_t sh);
212
218 virtual int16_t setEncoding(uint8_t encoding);
219
224 float getFreqStep() const;
225
231 virtual size_t getPacketLength(bool update = true);
232
237 virtual float getRSSI();
238
243 virtual float getSNR();
244
250 int32_t random(int32_t max);
251
258 int32_t random(int32_t min, int32_t max);
259
264 virtual uint8_t randomByte();
265
271 int16_t startDirect();
272
273 #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
280 int16_t setDirectSyncWord(uint32_t syncWord, uint8_t len);
281
287 virtual void setDirectAction(void (*func)(void));
288
293 virtual void readBit(uint32_t pin);
294
299 int16_t available();
300
304 void dropSync();
305
312 uint8_t read(bool drop = true);
313 #endif
314
321 virtual int16_t setDIOMapping(uint32_t pin, uint32_t value);
322
327 virtual void setDio1Action(void (*func)(void));
328
332 virtual void clearDio1Action();
333
334 #if defined(RADIOLIB_INTERRUPT_TIMING)
335
341 void setInterruptSetup(void (*func)(uint32_t));
342
347 void setTimerFlag();
348
349 #endif
350
351 #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
352 protected:
353 void updateDirectBuffer(uint8_t bit);
354 #endif
355
356 #if !defined(RADIOLIB_GODMODE)
357 private:
358 #endif
359 float freqStep;
360 size_t maxPacketLength;
361
362 #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
363 uint8_t bufferBitPos;
364 uint8_t bufferWritePos;
365 uint8_t bufferReadPos;
366 uint8_t buffer[RADIOLIB_STATIC_ARRAY_SIZE];
367 uint32_t syncBuffer;
368 uint32_t directSyncWord;
369 uint8_t directSyncWordLen;
370 uint32_t directSyncWordMask;
371 bool gotSync;
372 #endif
373
374 virtual Module* getMod() = 0;
375
376 // allow specific classes access the private getMod method
377 friend class AFSKClient;
378 friend class RTTYClient;
379 friend class MorseClient;
380 friend class HellClient;
381 friend class SSTVClient;
382 friend class AX25Client;
383 friend class FSK4Client;
384 friend class PagerClient;
385 };
386
387 #endif
AFSKClient
Client for audio-based transmissions. Requires Arduino tone() function, and a module capable of direc...
Definition: AFSK.h:16
AX25Client
Client for AX25 communication.
Definition: AX25.h:249
FSK4Client
Client for FSK-4 communication. The public interface is the same as Arduino Serial.
Definition: FSK4.h:15
HellClient
Client for Hellschreiber transmissions.
Definition: Hellschreiber.h:89
Module
Implements all common low-level methods to control the wireless module. Every module class contains o...
Definition: Module.h:28
MorseClient
Client for Morse Code communication. The public interface is the same as Arduino Serial.
Definition: Morse.h:92
PagerClient
Client for Pager communication.
Definition: Pager.h:68
PhysicalLayer
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN....
Definition: PhysicalLayer.h:15
PhysicalLayer::startReceive
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....
Definition: PhysicalLayer.cpp:131
PhysicalLayer::randomByte
virtual uint8_t randomByte()
Get one truly random byte from RSSI noise. Must be implemented in module class.
Definition: PhysicalLayer.cpp:290
PhysicalLayer::finishTransmit
virtual int16_t finishTransmit()
Clean up after transmission is done.
Definition: PhysicalLayer.cpp:156
PhysicalLayer::setFrequencyDeviation
virtual int16_t setFrequencyDeviation(float freqDev)
Sets FSK frequency deviation from carrier frequency. Only available in FSK mode. Must be implemented ...
Definition: PhysicalLayer.cpp:230
PhysicalLayer::getPacketLength
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:249
PhysicalLayer::setDIOMapping
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).
Definition: PhysicalLayer.cpp:389
PhysicalLayer::readData
virtual int16_t readData(uint8_t *data, size_t len)
Reads data that was received after calling startReceive method.
Definition: PhysicalLayer.cpp:205
PhysicalLayer::dropSync
void dropSync()
Forcefully drop synchronization.
Definition: PhysicalLayer.cpp:313
PhysicalLayer::transmit
int16_t transmit(const char *str, uint8_t addr=0)
C-string transmit method.
Definition: PhysicalLayer.cpp:52
PhysicalLayer::read
uint8_t read(bool drop=true)
Get data from direct mode buffer.
Definition: PhysicalLayer.cpp:320
PhysicalLayer::setDio1Action
virtual void setDio1Action(void(*func)(void))
Sets interrupt service routine to call when DIO1 activates.
Definition: PhysicalLayer.cpp:395
PhysicalLayer::startDirect
int16_t startDirect()
Configure module parameters for direct modes. Must be called prior to "ham" modes like RTTY or AX....
Definition: PhysicalLayer.cpp:294
PhysicalLayer::setFrequency
virtual int16_t setFrequency(float freq)
Sets carrier frequency. Must be implemented in module class.
Definition: PhysicalLayer.cpp:220
PhysicalLayer::setDirectSyncWord
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:328
PhysicalLayer::startTransmit
int16_t startTransmit(const char *str, uint8_t addr=0)
Interrupt-driven Arduino String transmit method. Unlike the standard transmit method,...
Definition: PhysicalLayer.cpp:145
PhysicalLayer::getFreqStep
float getFreqStep() const
Gets the module frequency step size that was set in constructor.
Definition: PhysicalLayer.cpp:245
PhysicalLayer::transmitDirect
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:211
PhysicalLayer::getRSSI
virtual float getRSSI()
Gets RSSI (Recorded Signal Strength Indicator) of the last received packet.
Definition: PhysicalLayer.cpp:254
PhysicalLayer::available
int16_t available()
Get the number of direct mode bytes currently available in buffer.
Definition: PhysicalLayer.cpp:309
PhysicalLayer::receive
virtual int16_t receive(uint8_t *data, size_t len)
Binary receive method. Must be implemented in module class.
Definition: PhysicalLayer.cpp:112
PhysicalLayer::setDirectAction
virtual void setDirectAction(void(*func)(void))
Set interrupt service routine function to call when data bit is receveid in direct mode....
Definition: PhysicalLayer.cpp:379
PhysicalLayer::setEncoding
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:240
PhysicalLayer::standby
virtual int16_t standby()
Sets module to standby.
Definition: PhysicalLayer.cpp:122
PhysicalLayer::random
int32_t random(int32_t max)
Get truly random number in range 0 - max.
Definition: PhysicalLayer.cpp:262
PhysicalLayer::readBit
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:383
PhysicalLayer::clearDio1Action
virtual void clearDio1Action()
Clears interrupt service routine to call when DIO1 activates.
Definition: PhysicalLayer.cpp:399
PhysicalLayer::receiveDirect
virtual int16_t receiveDirect()
Enables direct reception mode on pins DIO1 (clock) and DIO2 (data). Must be implemented in module cla...
Definition: PhysicalLayer.cpp:216
PhysicalLayer::PhysicalLayer
PhysicalLayer(float step, size_t maxLen)
Default constructor.
Definition: PhysicalLayer.cpp:4
PhysicalLayer::setDataShaping
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:235
PhysicalLayer::setBitRate
virtual int16_t setBitRate(float br)
Sets FSK bit rate. Only available in FSK mode. Must be implemented in module class.
Definition: PhysicalLayer.cpp:225
PhysicalLayer::getSNR
virtual float getSNR()
Gets SNR (Signal to Noise Ratio) of the last received packet. Only available for LoRa modem.
Definition: PhysicalLayer.cpp:258
PhysicalLayer::sleep
virtual int16_t sleep()
Sets module to sleep.
Definition: PhysicalLayer.cpp:118
RTTYClient
Client for RTTY communication. The public interface is the same as Arduino Serial.
Definition: RTTY.h:84
SSTVClient
Client for SSTV transmissions.
Definition: SSTV.h:117