[SX127x] Sync with LoRaLib 8.0.4
This commit is contained in:
parent
606e841aca
commit
608dad60c8
4 changed files with 436 additions and 530 deletions
File diff suppressed because it is too large
Load diff
|
@ -267,7 +267,7 @@
|
|||
|
||||
// SX127X_REG_RX_BW
|
||||
#define SX127X_RX_BW_MANT_16 0b00000000 // 4 3 channel filter bandwidth: RxBw = F(XOSC) / (RxBwMant * 2^(RxBwExp + 2)) [kHz]
|
||||
#define SX127X_RX_BW_MANT_20 0b00001000 // 4 3
|
||||
#define SX127X_RX_BW_MANT_20 0b00001000 // 4 3
|
||||
#define SX127X_RX_BW_MANT_24 0b00010000 // 4 3 default RxBwMant parameter
|
||||
#define SX127X_RX_BW_EXP 0b00000101 // 2 0 default RxBwExp parameter
|
||||
|
||||
|
@ -492,20 +492,20 @@
|
|||
#define SX127X_FLAG_LOW_BAT 0b00000001 // 0 0 battery voltage dropped below threshold
|
||||
|
||||
// SX127X_REG_DIO_MAPPING_1
|
||||
#define SX127X_DIO0_CONT_SYNC_ADDRESS 0b00000000 // 7 6
|
||||
#define SX127X_DIO0_CONT_TX_READY 0b00000000 // 7 6
|
||||
#define SX127X_DIO0_CONT_RSSI_PREAMBLE_DETECTED 0b01000000 // 7 6
|
||||
#define SX127X_DIO0_CONT_RX_READY 0b10000000 // 7 6
|
||||
#define SX127X_DIO0_PACK_PAYLOAD_READY 0b00000000 // 7 6
|
||||
#define SX127X_DIO0_PACK_PACKET_SENT 0b00000000 // 7 6
|
||||
#define SX127X_DIO0_PACK_CRC_OK 0b01000000 // 7 6
|
||||
#define SX127X_DIO0_PACK_TEMP_CHANGE_LOW_BAT 0b11000000 // 7 6
|
||||
#define SX127X_DIO1_CONT_DCLK 0b00000000 // 5 4
|
||||
#define SX127X_DIO1_CONT_RSSI_PREAMBLE_DETECTED 0b00010000 // 5 4
|
||||
#define SX127X_DIO1_PACK_FIFO_LEVEL 0b00000000 // 5 4
|
||||
#define SX127X_DIO1_PACK_FIFO_EMPTY 0b00010000 // 5 4
|
||||
#define SX127X_DIO1_PACK_FIFO_FULL 0b00100000 // 5 4
|
||||
#define SX127X_DIO2_CONT_DATA 0b00000000 // 3 2
|
||||
#define SX127X_DIO0_CONT_SYNC_ADDRESS 0b00000000 // 7 6
|
||||
#define SX127X_DIO0_CONT_TX_READY 0b00000000 // 7 6
|
||||
#define SX127X_DIO0_CONT_RSSI_PREAMBLE_DETECTED 0b01000000 // 7 6
|
||||
#define SX127X_DIO0_CONT_RX_READY 0b10000000 // 7 6
|
||||
#define SX127X_DIO0_PACK_PAYLOAD_READY 0b00000000 // 7 6
|
||||
#define SX127X_DIO0_PACK_PACKET_SENT 0b00000000 // 7 6
|
||||
#define SX127X_DIO0_PACK_CRC_OK 0b01000000 // 7 6
|
||||
#define SX127X_DIO0_PACK_TEMP_CHANGE_LOW_BAT 0b11000000 // 7 6
|
||||
#define SX127X_DIO1_CONT_DCLK 0b00000000 // 5 4
|
||||
#define SX127X_DIO1_CONT_RSSI_PREAMBLE_DETECTED 0b00010000 // 5 4
|
||||
#define SX127X_DIO1_PACK_FIFO_LEVEL 0b00000000 // 5 4
|
||||
#define SX127X_DIO1_PACK_FIFO_EMPTY 0b00010000 // 5 4
|
||||
#define SX127X_DIO1_PACK_FIFO_FULL 0b00100000 // 5 4
|
||||
#define SX127X_DIO2_CONT_DATA 0b00000000 // 3 2
|
||||
|
||||
// SX1272_REG_PLL_HOP + SX1278_REG_PLL_HOP
|
||||
#define SX127X_FAST_HOP_OFF 0b00000000 // 7 7 carrier frequency validated when FRF registers are written
|
||||
|
@ -532,340 +532,309 @@ class SX127x: public PhysicalLayer {
|
|||
// introduce PhysicalLayer overloads
|
||||
using PhysicalLayer::transmit;
|
||||
using PhysicalLayer::receive;
|
||||
|
||||
using PhysicalLayer::startTransmit;
|
||||
using PhysicalLayer::readData;
|
||||
|
||||
// constructor
|
||||
|
||||
|
||||
/*!
|
||||
\brief Default constructor. Called internally when creating new LoRa instance.
|
||||
|
||||
|
||||
\param mod Instance of Module that will be used to communicate with the %LoRa chip.
|
||||
*/
|
||||
SX127x(Module* mod);
|
||||
|
||||
|
||||
// basic methods
|
||||
|
||||
|
||||
/*!
|
||||
\brief Initialization method. Will be called with appropriate parameters when calling initialization method from derived class.
|
||||
|
||||
|
||||
\param chipVersion Value in SPI version register. Used to verify the connection and hardware version.
|
||||
|
||||
|
||||
\param syncWord %LoRa sync word.
|
||||
|
||||
|
||||
\param currentLimit Trim value for OCP (over current protection) in mA.
|
||||
|
||||
|
||||
\param preambleLength Length of %LoRa transmission preamble in symbols.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t begin(uint8_t chipVersion, uint8_t syncWord, uint8_t currentLimit, uint16_t preambleLength);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Initialization method for FSK modem. Will be called with appropriate parameters when calling FSK initialization method from derived class.
|
||||
|
||||
|
||||
\param chipVersion Value in SPI version register. Used to verify the connection and hardware version.
|
||||
|
||||
|
||||
\param br Bit rate of the FSK transmission in kbps (kilobits per second).
|
||||
|
||||
|
||||
\param freqDev Frequency deviation of the FSK transmission in kHz.
|
||||
|
||||
|
||||
\param rxBw Receiver bandwidth in kHz.
|
||||
|
||||
|
||||
\param currentLimit Trim value for OCP (over current protection) in mA.
|
||||
|
||||
|
||||
\param enableOOK Flag to specify OOK mode. This modulation is similar to FSK.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t beginFSK(uint8_t chipVersion, float br, float freqDev, float rxBw, uint8_t currentLimit, bool enableOOK);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Binary transmit method. Will transmit arbitrary binary data up to 255 bytes long using %LoRa or up to 63 bytes using FSK modem.
|
||||
For overloads to transmit Arduino String or C-string, see PhysicalLayer::transmit.
|
||||
|
||||
|
||||
\param data Binary data that will be transmitted.
|
||||
|
||||
|
||||
\param len Length of binary data to transmit (in bytes).
|
||||
|
||||
|
||||
\param addr Node address to transmit the packet to. Only used in FSK mode.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Binary receive method. Will attempt to receive arbitrary binary data up to 255 bytes long using %LoRa or up to 63 bytes using FSK modem.
|
||||
For overloads to receive Arduino String, see PhysicalLayer::receive.
|
||||
|
||||
|
||||
\param data Pointer to array to save the received binary data.
|
||||
|
||||
|
||||
\param len Number of bytes that will be received. Must be known in advance for binary transmissions.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t receive(uint8_t* data, size_t len);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Performs scan for valid %LoRa preamble in the current channel.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t scanChannel();
|
||||
|
||||
|
||||
/*!
|
||||
\brief Sets the %LoRa 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 autmatically when methods like transmit or receive are called.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t sleep();
|
||||
|
||||
|
||||
/*!
|
||||
\brief Sets the %LoRa module to standby.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t standby();
|
||||
|
||||
|
||||
/*!
|
||||
\brief Enables direct transmission mode on pins DIO1 (clock) and DIO2 (data).
|
||||
\brief Enables direct transmission mode on pins DIO1 (clock) and DIO2 (data).
|
||||
While in direct mode, the module will not be able to transmit or receive packets. Can only be activated in FSK mode.
|
||||
|
||||
|
||||
\param FRF 24-bit raw frequency value to start transmitting at. Required for quick frequency shifts in RTTY.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t transmitDirect(uint32_t FRF = 0);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Enables direct reception mode on pins DIO1 (clock) and DIO2 (data).
|
||||
\brief Enables direct reception mode on pins DIO1 (clock) and DIO2 (data).
|
||||
While in direct mode, the module will not be able to transmit or receive packets. Can only be activated in FSK mode.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t receiveDirect();
|
||||
|
||||
|
||||
/*!
|
||||
\brief Disables direct mode and enables packet mode, allowing the module to receive packets. Can only be activated in FSK mode.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t packetMode();
|
||||
|
||||
|
||||
|
||||
|
||||
// interrupt methods
|
||||
|
||||
|
||||
/*!
|
||||
\brief Set interrupt service routine function to call when DIO0 activates.
|
||||
|
||||
|
||||
\param func Pointer to interrupt service routine.
|
||||
*/
|
||||
void setDio0Action(void (*func)(void));
|
||||
|
||||
|
||||
/*!
|
||||
\brief Set interrupt service routine function to call when DIO1 activates.
|
||||
|
||||
|
||||
\param func Pointer to interrupt service routine.
|
||||
*/
|
||||
void setDio1Action(void (*func)(void));
|
||||
|
||||
/*!
|
||||
\brief Interrupt-driven Arduino String transmit method. Will start transmitting Arduino String up to 255 characters long using %LoRa or up to 63 bytes using FSK modem.
|
||||
Unlike the standard transmit method, this one is non-blocking. DIO0 will be activated when transmission finishes.
|
||||
|
||||
\param str Address of Arduino String that will be transmitted.
|
||||
|
||||
\param addr Node address to transmit the packet to. Only used in FSK mode.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t startTransmit(String& str, uint8_t addr = 0);
|
||||
|
||||
/*!
|
||||
\brief Interrupt-driven Arduino String transmit method. Will start transmitting Arduino String up to 255 characters long using %LoRa or up to 63 bytes using FSK modem.
|
||||
Unlike the standard transmit method, this one is non-blocking. DIO0 will be activated when transmission finishes.
|
||||
|
||||
\param str C-string that will be transmitted.
|
||||
|
||||
\param addr Node address to transmit the packet to. Only used in FSK mode.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t startTransmit(const char* str, uint8_t addr = 0);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Interrupt-driven binary transmit method. Will start transmitting arbitrary binary data up to 255 bytes long using %LoRa or up to 63 bytes using FSK modem.
|
||||
|
||||
|
||||
\param data Binary data that will be transmitted.
|
||||
|
||||
|
||||
\param len Length of binary data to transmit (in bytes).
|
||||
|
||||
|
||||
\param addr Node address to transmit the packet to. Only used in FSK mode.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Interrupt-driven receive method. DIO0 will be activated when full valid packet is received.
|
||||
|
||||
|
||||
\param mode Receive mode to be used. Defaults to RxContinuous.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t startReceive();
|
||||
|
||||
int16_t startReceive(uint8_t mode = SX127X_RXCONTINUOUS);
|
||||
|
||||
/*!
|
||||
\brief Reads data that was received after calling startReceive method.
|
||||
|
||||
\param str Address of Arduino String to save the received data.
|
||||
|
||||
\param len Expected number of characters in the message. Must be known in advance for %LoRa spreading factor 6.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t readData(String& str, size_t len = 0);
|
||||
|
||||
/*!
|
||||
\brief Reads data that was received after calling startReceive method.
|
||||
|
||||
|
||||
\param data Pointer to array to save the received binary data.
|
||||
|
||||
|
||||
\param len Number of bytes that will be received. Must be known in advance for binary transmissions.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t readData(uint8_t* data, size_t len);
|
||||
|
||||
|
||||
|
||||
|
||||
// configuration methods
|
||||
|
||||
|
||||
/*!
|
||||
\brief Sets %LoRa sync word. Only available in %LoRa mode.
|
||||
|
||||
|
||||
\param syncWord Sync word to be set.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setSyncWord(uint8_t syncWord);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Sets current limit for over current protection at transmitter amplifier. Allowed values range from 45 to 120 mA in 5 mA steps and 120 to 240 mA in 10 mA steps.
|
||||
|
||||
|
||||
\param currentLimit Current limit to be set (in mA).
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setCurrentLimit(uint8_t currentLimit);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Sets %LoRa preamble length. Allowed values range from 6 to 65535. Only available in %LoRa mode.
|
||||
|
||||
|
||||
\param preambleLength Preamble length to be set (in symbols).
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setPreambleLength(uint16_t preambleLength);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Gets frequency error of the latest received packet.
|
||||
|
||||
|
||||
\param autoCorrect When set to true, frequency will be autmatically corrected.
|
||||
|
||||
|
||||
\returns Frequency error in Hz.
|
||||
*/
|
||||
float getFrequencyError(bool autoCorrect = false);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Gets signal-to-noise ratio of the latest received packet.
|
||||
|
||||
|
||||
\returns Last packet signal-to-noise ratio (SNR).
|
||||
*/
|
||||
float getSNR();
|
||||
|
||||
|
||||
/*!
|
||||
\brief Get data rate of the latest transmitted packet.
|
||||
|
||||
|
||||
\returns Last packet data rate in bps (bits per second).
|
||||
*/
|
||||
float getDataRate();
|
||||
|
||||
|
||||
/*!
|
||||
\brief Sets FSK bit rate. Allowed values range from 1.2 to 300 kbps. Only available in FSK mode.
|
||||
|
||||
|
||||
\param br Bit rate to be set (in kbps).
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setBitRate(float br);
|
||||
|
||||
|
||||
/*!
|
||||
\brief 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.
|
||||
|
||||
|
||||
\param freqDev Frequency deviation to be set (in kHz).
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setFrequencyDeviation(float freqDev);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Sets FSK receiver bandwidth. Allowed values range from 2.6 to 250 kHz. Only available in FSK mode.
|
||||
|
||||
|
||||
\param rxBw Receiver bandwidth to be set (in kHz).
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setRxBandwidth(float rxBw);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Sets FSK sync word. Allowed sync words are up to 8 bytes long and can not conatain null bytes. Only available in FSK mode.
|
||||
|
||||
|
||||
\param syncWord Sync word array.
|
||||
|
||||
|
||||
\param len Sync word length (in bytes).
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setSyncWord(uint8_t* syncWord, size_t len);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Sets FSK node address. Calling this method will enable address filtering. Only available in FSK mode.
|
||||
|
||||
|
||||
\param nodeAddr Node address to be set.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setNodeAddress(uint8_t nodeAddr);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Sets FSK broadcast address. Calling this method will enable address filtering. Only available in FSK mode.
|
||||
|
||||
|
||||
\param broadAddr Broadcast address to be set.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setBroadcastAddress(uint8_t broadAddr);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Disables FSK address filtering.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t disableAddressFiltering();
|
||||
|
||||
|
||||
/*!
|
||||
\brief Enables/disables OOK modulation instead of FSK.
|
||||
|
||||
|
||||
\param enableOOK Enable (true) or disable (false) OOK.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setOOK(bool enableOOK);
|
||||
|
||||
|
||||
#ifdef RADIOLIB_DEBUG
|
||||
void regDump();
|
||||
#endif
|
||||
|
||||
|
||||
protected:
|
||||
Module* _mod;
|
||||
|
||||
|
||||
float _freq;
|
||||
float _bw;
|
||||
uint8_t _sf;
|
||||
|
@ -873,16 +842,16 @@ class SX127x: public PhysicalLayer {
|
|||
float _br;
|
||||
float _rxBw;
|
||||
bool _ook;
|
||||
|
||||
|
||||
int16_t setFrequencyRaw(float newFreq);
|
||||
int16_t config();
|
||||
int16_t configFSK();
|
||||
int16_t getActiveModem();
|
||||
int16_t directMode();
|
||||
|
||||
|
||||
private:
|
||||
float _dataRate;
|
||||
|
||||
|
||||
bool findChip(uint8_t ver);
|
||||
int16_t setMode(uint8_t mode);
|
||||
int16_t setActiveModem(uint8_t modem);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "PhysicalLayer.h"
|
||||
|
||||
PhysicalLayer::PhysicalLayer(float crysFreq, uint8_t divExp) {
|
||||
PhysicalLayer::PhysicalLayer(float crysFreq, uint8_t divExp) {
|
||||
_crystalFreq = crysFreq;
|
||||
_divExponent = divExp;
|
||||
}
|
||||
|
@ -13,16 +13,38 @@ int16_t PhysicalLayer::transmit(const char* str, uint8_t addr) {
|
|||
return(transmit((uint8_t*)str, strlen(str), addr));
|
||||
}
|
||||
|
||||
int16_t PhysicalLayer::receive(String& str, size_t len) {
|
||||
int16_t PhysicalLayer::startTransmit(String& str, uint8_t addr) {
|
||||
return(startTransmit(str.c_str(), addr));
|
||||
}
|
||||
|
||||
int16_t PhysicalLayer::startTransmit(const char* str, uint8_t addr) {
|
||||
return(startTransmit((uint8_t*)str, strlen(str), addr));
|
||||
}
|
||||
|
||||
int16_t PhysicalLayer::readData(String& str, size_t len) {
|
||||
// create temporary array to store received data
|
||||
char* data = new char[len + 1];
|
||||
int16_t state = receive((uint8_t*)data, len);
|
||||
|
||||
int16_t state = readData((uint8_t*)data, len);
|
||||
|
||||
// if packet was received successfully, copy data into String
|
||||
if(state == ERR_NONE) {
|
||||
str = String(data);
|
||||
}
|
||||
|
||||
|
||||
delete[] data;
|
||||
return(state);
|
||||
}
|
||||
|
||||
int16_t PhysicalLayer::receive(String& str, size_t len) {
|
||||
// create temporary array to store received data
|
||||
char* data = new char[len + 1];
|
||||
int16_t state = receive((uint8_t*)data, len);
|
||||
|
||||
// if packet was received successfully, copy data into String
|
||||
if(state == ERR_NONE) {
|
||||
str = String(data);
|
||||
}
|
||||
|
||||
delete[] data;
|
||||
return(state);
|
||||
}
|
||||
|
|
|
@ -12,119 +12,178 @@
|
|||
*/
|
||||
class PhysicalLayer {
|
||||
public:
|
||||
|
||||
|
||||
// constructor
|
||||
|
||||
|
||||
/*!
|
||||
\brief Default constructor.
|
||||
|
||||
|
||||
\param crysFreq Frequency of crystal oscillator inside the module in MHz.
|
||||
|
||||
|
||||
\param divExp Exponent of module frequency divider.
|
||||
*/
|
||||
PhysicalLayer(float crysFreq, uint8_t divExp);
|
||||
|
||||
|
||||
// basic methods
|
||||
|
||||
|
||||
/*!
|
||||
\brief Arduino String transmit method. Will transmit Arduino String up to 255 characters long using %LoRa or up to 63 bytes using FSK modem.
|
||||
|
||||
|
||||
\param str Address of Arduino string that will be transmitted.
|
||||
|
||||
|
||||
\param addr Node address to transmit the packet to. Only used in FSK mode.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t transmit(String& str, uint8_t addr = 0);
|
||||
|
||||
|
||||
/*!
|
||||
\brief C-string transmit method. Will transmit C-string up to 255 characters long using %LoRa or up to 63 characters using FSK modem.
|
||||
|
||||
|
||||
\param str C-string that will be transmitted.
|
||||
|
||||
|
||||
\param addr Node address to transmit the packet to. Only used in FSK mode.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t transmit(const char* str, uint8_t addr = 0);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Binary transmit method. Will transmit arbitrary binary data up to 255 bytes long using %LoRa or up to 63 bytes using FSK modem.
|
||||
Must be implemented in module class.
|
||||
|
||||
|
||||
\param data Binary data that will be transmitted.
|
||||
|
||||
|
||||
\param len Length of binary data to transmit (in bytes).
|
||||
|
||||
|
||||
\param addr Node address to transmit the packet to. Only used in FSK mode.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
virtual int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0) = 0;
|
||||
|
||||
|
||||
/*!
|
||||
\brief Arduino String receive method. Will attempt to receive Arduino String up to 255 characters long using %LoRa or up to 63 characters using FSK modem.
|
||||
|
||||
|
||||
\param str Address of Arduino String to save the received data.
|
||||
|
||||
|
||||
\param len Expected number of characters in the message. Must be known in advance for %LoRa spreading factor 6.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t receive(String& str, size_t len = 0);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Binary receive method. Will attempt to receive arbitrary binary data up to 255 bytes long using %LoRa or up to 63 bytes using FSK modem.
|
||||
Must be implemented in module class.
|
||||
|
||||
|
||||
\param data Pointer to array to save the received binary data.
|
||||
|
||||
|
||||
\param len Number of bytes that will be received. Must be known in advance for binary transmissions.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
virtual int16_t receive(uint8_t* data, size_t len) = 0;
|
||||
|
||||
|
||||
/*!
|
||||
\brief Interrupt-driven Arduino String transmit method. Will start transmitting Arduino String up to 255 characters long using %LoRa or up to 63 bytes using FSK modem.
|
||||
Unlike the standard transmit method, this one is non-blocking. DIO0 will be activated when transmission finishes.
|
||||
|
||||
\param str Address of Arduino String that will be transmitted.
|
||||
|
||||
\param addr Node address to transmit the packet to. Only used in FSK mode.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t startTransmit(String& str, uint8_t addr = 0);
|
||||
|
||||
/*!
|
||||
\brief Interrupt-driven Arduino String transmit method. Will start transmitting Arduino String up to 255 characters long using %LoRa or up to 63 bytes using FSK modem.
|
||||
Unlike the standard transmit method, this one is non-blocking. DIO0 will be activated when transmission finishes.
|
||||
|
||||
\param str C-string that will be transmitted.
|
||||
|
||||
\param addr Node address to transmit the packet to. Only used in FSK mode.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t startTransmit(const char* str, uint8_t addr = 0);
|
||||
|
||||
/*!
|
||||
\brief Interrupt-driven binary transmit method. Will start transmitting arbitrary binary data up to 255 bytes long using %LoRa or up to 63 bytes using FSK modem.
|
||||
|
||||
\param data Binary data that will be transmitted.
|
||||
|
||||
\param len Length of binary data to transmit (in bytes).
|
||||
|
||||
\param addr Node address to transmit the packet to. Only used in FSK mode.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
virtual int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0) = 0;
|
||||
|
||||
/*!
|
||||
\brief Reads data that was received after calling startReceive method.
|
||||
|
||||
\param str Address of Arduino String to save the received data.
|
||||
|
||||
\param len Expected number of characters in the message. Must be known in advance for %LoRa spreading factor 6.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t readData(String& str, size_t len = 0);
|
||||
|
||||
/*!
|
||||
\brief Reads data that was received after calling startReceive method.
|
||||
|
||||
\param data Pointer to array to save the received binary data.
|
||||
|
||||
\param len Number of bytes that will be received. Must be known in advance for binary transmissions.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
virtual int16_t readData(uint8_t* data, size_t len) = 0;
|
||||
|
||||
/*!
|
||||
\brief 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.
|
||||
|
||||
|
||||
\param FRF 24-bit raw frequency value to start transmitting at. Required for quick frequency shifts in RTTY.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
virtual int16_t transmitDirect(uint32_t FRF = 0) = 0;
|
||||
|
||||
|
||||
/*!
|
||||
\brief 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.
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
virtual int16_t receiveDirect() = 0;
|
||||
|
||||
|
||||
// configuration methods
|
||||
|
||||
|
||||
/*!
|
||||
\brief Sets FSK frequency deviation from carrier frequency. Allowed values depend on bit rate setting and must be lower than 200 kHz.
|
||||
\brief 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.
|
||||
|
||||
|
||||
\param freqDev Frequency deviation to be set (in kHz).
|
||||
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
virtual int16_t setFrequencyDeviation(float freqDev) = 0;
|
||||
|
||||
|
||||
/*!
|
||||
\brief Gets the module crystal oscillator frequency that was set in constructor.
|
||||
|
||||
|
||||
\returns Crystal oscillator frequency in MHz.
|
||||
*/
|
||||
float getCrystalFreq();
|
||||
|
||||
|
||||
/*!
|
||||
\brief Gets the module frequency divider exponent that was set in constructor.
|
||||
|
||||
|
||||
\returns Frequency divider exponent.
|
||||
*/
|
||||
uint8_t getDivExponent();
|
||||
|
|
Loading…
Add table
Reference in a new issue