Porównaj commity

...

15 Commity

Autor SHA1 Wiadomość Data
Matthias Prinke fbee7471c7
[LoRaWAN] Added pin maps (#1047)
* Added pin maps

* Modified pin map for ARDUINO_TTGO_LORA32_V2 (DIO1 not connected & not needed)
2024-04-01 21:03:38 +02:00
jgromes e7ee407b0d [Doc] Additional doxygen fixes 2024-04-01 12:11:13 +02:00
Jan Gromeš e57c9b08ea
[Doxygen] Warnings fixes (#1046)
* [APRS] Fix Doxygen warnings

* [Print] Fix Doxygen warnings

* [CC1101] Fixed doxygen warnings

* [nRF24] Fixed doxygen warnings

* [RF69] Fixed doxygen warnings

* [SX126x] Fixed doxygen warnings

* [SX127x] Fixed doxygen warnings

* [AFSK] Fixed doxygen warnings

* [APRS] Fixed doxygen warnings

* [Bell] Fixed doxygen warnings

* [Ext] Fixed doxygen warnings

* [LoRaWAN] Fixed doxygen warnings

* [PHY] Fixed doxygen warnings

* [Print] Fixed doxygen warnings

* [Mod] Fixed doxygen warnings
2024-04-01 11:11:24 +02:00
Jonathan Bennett e5493618a4
Update ArduinoHal.h to make spi and friends protected (#1044)
Most of the "override" functions here can't actually be overridden in a useful way when spi, spiSettings, and everything else is marked private. If everything is override, then nothing should be private.
2024-03-31 21:43:30 +02:00
Jan Gromeš 9daf4c4f26
[CI] Minor fixes (#1045)
* [CI] Add Teensy back in

* [CI] Add Arduino 101 back to build matrix

* [CI] Try different path to libs

* [CI] Skip LoRaWAN on Teensy
2024-03-31 21:41:12 +02:00
StevenCellist b2c7e98d6c
Update examples/LoRaWAN/README 2024-03-30 09:33:30 +01:00
jgromes 721a44c6e4 [RF69] Fix copy-pate error (#1013) 2024-03-29 08:40:25 +01:00
jgromes 88f26c4aab [SX126x] Use millis for timeouts (#1013) 2024-03-29 08:36:51 +01:00
jgromes fb7d698007 [SX127x] Use millis for timeouts 2024-03-29 08:36:05 +01:00
jgromes 8098bea254 [SX128x] Use millis for timeouts 2024-03-29 08:35:29 +01:00
jgromes eba32d7dcd [Si443x] Use millis for timeouts 2024-03-29 08:35:08 +01:00
jgromes 5980e0fb00 [RF69] Use millis for timeouts 2024-03-29 08:34:56 +01:00
jgromes aafe96faf8 [nRF24] Use millis for timeouts 2024-03-29 08:34:48 +01:00
jgromes 936a39ad98 [CC1101] Use millis for timeouts 2024-03-29 08:34:35 +01:00
Crsarmv7l 1fb5100413
[CC1101] 3 New CC1101 Functions (#1038)
* getFrequency implementation

* getFrequency Method

* Get bitrate method

* getBitRate

* CalcRxBandwidth() method

* CalcRxBandwidth();

* Fix Notes

* Changes for pull

* Changes for pull 2

* Update keywords.txt

* Revert to hopefully bring in current

* Fix ()

* Re add
2024-03-28 18:44:10 +01:00
31 zmienionych plików z 321 dodań i 193 usunięć

Wyświetl plik

@ -104,6 +104,10 @@ jobs:
run: echo "index-url=--additional-urls https://resource.heltec.cn/download/package_CubeCell_index.json" >> $GITHUB_OUTPUT
- id: MegaCore:avr:1281
run: echo "index-url=--additional-urls https://mcudude.github.io/MegaCore/package_MCUdude_MegaCore_index.json" >> $GITHUB_OUTPUT
- id: teensy:avr:teensy41
run: |
echo "skip-pattern=(STM32WL|LoRaWAN)" >> $GITHUB_OUTPUT
echo "index-url=--additional-urls https://www.pjrc.com/teensy/package_teensy_index.json" >> $GITHUB_OUTPUT
- id: arduino:renesas_uno:minima
run: |
echo "skip-pattern=(STM32WL|LoRaWAN)" >> $GITHUB_OUTPUT

Wyświetl plik

@ -53,7 +53,8 @@ const uint8_t subBand = 0; // For US915, change this to 2, otherwise leave on 0
SX1276 radio = new Module(18, 26, 14, 33);
#elif defined(ARDUINO_TTGO_LORA32_V2)
#pragma error ("ARDUINO_TTGO_LORA32_V2 awaiting pin map")
#pragma message ("ARDUINO_TTGO_LORA32_V2 + Display")
SX1276 radio = new Module(18, 26, 12, RADIOLIB_NC);
#elif defined(ARDUINO_TTGO_LoRa32_v21new) // T3_V1.6.1
#pragma message ("Using TTGO LoRa32 v2.1 marked T3_V1.6.1 + Display")
@ -71,6 +72,14 @@ const uint8_t subBand = 0; // For US915, change this to 2, otherwise leave on 0
#elif defined(ARDUINO_HELTEC_WIFI_LORA_32)
#pragma error ("ARDUINO_HELTEC_WIFI_LORA_32 awaiting pin map")
#elif defined (ARDUINO_heltec_wireless_stick)
#pragma message ("Using Heltec Wireless Stick")
SX1278 radio = new Module(14, 4, 12, 16);
#elif defined(ARDUINO_heltec_wifi_lora_32_V2)
#pragma message ("Using Heltec WiFi LoRa32 v2")
SX1278 radio = new Module(14, 4, 12, 16);
#elif defined(ARDUINO_heltec_wifi_kit_32_V2)
#pragma message ("ARDUINO_heltec_wifi_kit_32_V2 awaiting pin map")
SX1276 radio = new Module(18, 26, 14, 35);

Wyświetl plik

@ -48,7 +48,8 @@ const uint8_t subBand = 0; // For US915, change this to 2, otherwise leave on 0
SX1276 radio = new Module(18, 26, 14, 33);
#elif defined(ARDUINO_TTGO_LORA32_V2)
#pragma error ("ARDUINO_TTGO_LORA32_V2 awaiting pin map")
#pragma message ("ARDUINO_TTGO_LORA32_V2 + Display")
SX1276 radio = new Module(18, 26, 12, RADIOLIB_NC);
#elif defined(ARDUINO_TTGO_LoRa32_v21new) // T3_V1.6.1
#pragma message ("Using TTGO LoRa32 v2.1 marked T3_V1.6.1 + Display")
@ -66,6 +67,14 @@ const uint8_t subBand = 0; // For US915, change this to 2, otherwise leave on 0
#elif defined(ARDUINO_HELTEC_WIFI_LORA_32)
#pragma error ("ARDUINO_HELTEC_WIFI_LORA_32 awaiting pin map")
#elif defined (ARDUINO_heltec_wireless_stick)
#pragma message ("Using Heltec Wireless Stick")
SX1278 radio = new Module(14, 4, 12, 16);
#elif defined(ARDUINO_heltec_wifi_lora_32_V2)
#pragma message ("Using Heltec WiFi LoRa32 v2")
SX1278 radio = new Module(14, 4, 12, 16);
#elif defined(ARDUINO_heltec_wifi_kit_32_V2)
#pragma message ("ARDUINO_heltec_wifi_kit_32_V2 awaiting pin map")
SX1276 radio = new Module(18, 26, 14, 35);

Wyświetl plik

@ -48,7 +48,8 @@ const uint8_t subBand = 0; // For US915, change this to 2, otherwise leave on 0
SX1276 radio = new Module(18, 26, 14, 33);
#elif defined(ARDUINO_TTGO_LORA32_V2)
#pragma error ("ARDUINO_TTGO_LORA32_V2 awaiting pin map")
#pragma message ("ARDUINO_TTGO_LORA32_V2 + Display")
SX1276 radio = new Module(18, 26, 12, RADIOLIB_NC);
#elif defined(ARDUINO_TTGO_LoRa32_v21new) // T3_V1.6.1
#pragma message ("Using TTGO LoRa32 v2.1 marked T3_V1.6.1 + Display")
@ -66,6 +67,14 @@ const uint8_t subBand = 0; // For US915, change this to 2, otherwise leave on 0
#elif defined(ARDUINO_HELTEC_WIFI_LORA_32)
#pragma error ("ARDUINO_HELTEC_WIFI_LORA_32 awaiting pin map")
#elif defined (ARDUINO_heltec_wireless_stick)
#pragma message ("Using Heltec Wireless Stick")
SX1278 radio = new Module(14, 4, 12, 16);
#elif defined(ARDUINO_heltec_wifi_lora_32_V2)
#pragma message ("Using Heltec WiFi LoRa32 v2")
SX1278 radio = new Module(14, 4, 12, 16);
#elif defined(ARDUINO_heltec_wifi_kit_32_V2)
#pragma message ("ARDUINO_heltec_wifi_kit_32_V2 awaiting pin map")
SX1276 radio = new Module(18, 26, 14, 35);

Wyświetl plik

@ -1,18 +1,20 @@
# LoRaWAN examples
RadioLib LoRaWAN v1.1 examples.
* [LoRaWAN_Starter](https://github.com/jgromes/RadioLib/tree/master/examples/LoRaWAN/LoRaWAN_Starter): this is the recommended entry point for new users. Please read the `notes` that come with this example to learn more about LoRaWAN and how to use it in RadioLib!
* [LoRaWAN_Reference](https://github.com/jgromes/RadioLib/tree/master/examples/LoRaWAN/LoRaWAN_Reference): this sketch showcases most of the available API for LoRaWAN in RadioLib. Be frightened by the possibilities! It is recommended you have read all the `notes` for the Starter sketch first, as well as the [Learn section on The Things Network](https://www.thethingsnetwork.org/docs/lorawan/)!
* [LoRaWAN_Starter](https://github.com/jgromes/RadioLib/tree/master/examples/LoRaWAN/LoRaWAN_Starter): this is the recommended entry point for new users. Please read the [`notes`](https://github.com/jgromes/RadioLib/blob/master/examples/LoRaWAN/LoRaWAN_Starter/notes.md) that come with this example to learn more about LoRaWAN and how to use it in RadioLib!
* [LoRaWAN_Reference](https://github.com/jgromes/RadioLib/tree/master/examples/LoRaWAN/LoRaWAN_Reference): this sketch showcases most of the available API for LoRaWAN in RadioLib. Be frightened by the possibilities! It is recommended you have read all the [`notes`](https://github.com/jgromes/RadioLib/blob/master/examples/LoRaWAN/LoRaWAN_Starter/notes.md) for the Starter sketch first, as well as the [Learn section on The Things Network](https://www.thethingsnetwork.org/docs/lorawan/)!
* [LoRaWAN_ABP](https://github.com/jgromes/RadioLib/tree/master/examples/LoRaWAN/LoRaWAN_ABP): if you wish to use ABP instead of OTAA (but why?), this example shows how you can do this using RadioLib.
---
All three of these examples do not fully comply with LoRaWAN v1.1: for that, persistent storage is necessary. As the implementation of persistent storage differs between different platforms, these are not given here, but in a separate repository, see below:
> [!WARNING]
> These examples do not fully comply with LoRaWAN v1.1: for that, persistent storage is necessary. As the implementation of persistent storage differs between different platforms, these are not given here, but in a separate repository, see below:
## RadioLib persistence
In [this repository](https://github.com/radiolib-org/radiolib-persistence), examples are provided that do comply with the required persistence of certain parameters for LoRaWAN v1.1. Examples are (or will become) available for some of the most popular platforms. **These examples assume you have successfully used the Starter sketch and understood (most of) the accompanying notes!**
Currently, examples are available for the following platforms:
* [LoRaWAN for ESP32](https://github.com/radiolib-org/radiolib-persistence/tree/main/examples/LoRaWAN_ESP32)
* [LoRaWAN for ESP8266](https://github.com/radiolib-org/radiolib-persistence/tree/main/examples/LoRaWAN_ESP8266)
_This list is last updated for RadioLib 6.5.0_
_This list is last updated at 30/03/2024._

Wyświetl plik

@ -134,6 +134,7 @@ getSNR KEYWORD2
getDataRate KEYWORD2
setBitRate KEYWORD2
setRxBandwidth KEYWORD2
autoSetRxBandwidth KEYWORD2
setAFCBandwidth KEYWORD2
setAFC KEYWORD2
setAFCAGCTrigger KEYWORD2

Wyświetl plik

@ -60,7 +60,7 @@ class ArduinoHal : public RadioLibHal {
uint32_t pinToInterrupt(uint32_t pin) override;
#if !RADIOLIB_GODMODE
private:
protected:
#endif
SPIClass* spi = NULL;
SPISettings spiSettings = RADIOLIB_DEFAULT_SPI_SETTINGS;

Wyświetl plik

@ -13,10 +13,9 @@
#endif
/*!
* Value to use as the last element in a mode table to indicate the
* end of the table.
*
* See setRfSwitchTable() for details.
\def Value to use as the last element in a mode table to indicate the
end of the table.
See \ref setRfSwitchTable for details.
*/
#define END_OF_MODE_TABLE { Module::MODE_END_OF_TABLE, {} }
@ -31,43 +30,49 @@
class Module {
public:
/*!
* \brief The maximum number of pins supported by the RF switch
* code.
*
* Note: It is not recommended to use this constant in your sketch
* when defining a rfswitch pins array, to prevent issues when this
* value is ever increased and such an array gets extra zero
* elements (that will be interpreted as pin 0).
*/
\brief The maximum number of pins supported by the RF switch code.
Note: It is not recommended to use this constant in your sketch
when defining a rfswitch pins array, to prevent issues when this
value is ever increased and such an array gets extra zero
elements (that will be interpreted as pin 0).
*/
static const size_t RFSWITCH_MAX_PINS = 3;
/*!
* Description of RF switch pin states for a single mode.
*
* See setRfSwitchTable() for details.
*/
\struct RfSwitchMode_t
\brief Description of RF switch pin states for a single mode.
See \ref setRfSwitchTable for details.
*/
struct RfSwitchMode_t {
/*! \brief RF switching mode, one of \ref OpMode_t or a custom radio-defined value. */
uint8_t mode;
/*! \brief Output pin values */
uint32_t values[RFSWITCH_MAX_PINS];
};
/*!
* Constants to use in a mode table set be setRfSwitchTable. These
* constants work for most radios, but some radios define their own
* constants to be used instead.
*
* See setRfSwitchTable() for details.
*/
\enum OpMode_t
\brief Constants to use in a mode table set be setRfSwitchTable. These
constants work for most radios, but some radios define their own
constants to be used instead.
See \ref setRfSwitchTable for details.
*/
enum OpMode_t {
/*! End of table marker, use \ref END_OF_MODE_TABLE constant
* instead. Value is zero to ensure zero-initialized mode ends the
* table */
/*!
\brief End of table marker, use \ref END_OF_MODE_TABLE constant instead.
Value is zero to ensure zero-initialized mode ends the table.
*/
MODE_END_OF_TABLE = 0,
/*! Idle mode */
/*! \brief Idle mode */
MODE_IDLE,
/*! Receive mode */
/*! \brief Receive mode */
MODE_RX,
/*! Transmission mode */
/*! \brief Transmission mode */
MODE_TX,
};
@ -111,7 +116,7 @@ class Module {
/*!
\brief Overload for assignment operator.
\param frame rvalue Module.
\param mod rvalue Module.
*/
Module& operator=(const Module& mod);
@ -438,7 +443,7 @@ class Module {
/*!
\brief Find a mode in the RfSwitchTable.
\param The mode to find.
\param mode The mode to find.
\returns A pointer to the RfSwitchMode_t struct in the table that
matches the passed mode. Returns nullptr if no rfswitch pins are
configured, or the passed mode is not listed in the table.

Wyświetl plik

@ -100,29 +100,29 @@ void CC1101::reset() {
int16_t CC1101::transmit(uint8_t* data, size_t len, uint8_t addr) {
// calculate timeout (5ms + 500 % of expected time-on-air)
uint32_t timeout = 5000000 + (uint32_t)((((float)(len * 8)) / (this->bitRate * 1000.0)) * 5000000.0);
uint32_t timeout = 5 + (uint32_t)((((float)(len * 8)) / this->bitRate) * 5);
// start transmission
int16_t state = startTransmit(data, len, addr);
RADIOLIB_ASSERT(state);
// wait for transmission start or timeout
uint32_t start = this->mod->hal->micros();
uint32_t start = this->mod->hal->millis();
while(!this->mod->hal->digitalRead(this->mod->getGpio())) {
this->mod->hal->yield();
if(this->mod->hal->micros() - start > timeout) {
if(this->mod->hal->millis() - start > timeout) {
finishTransmit();
return(RADIOLIB_ERR_TX_TIMEOUT);
}
}
// wait for transmission end or timeout
start = this->mod->hal->micros();
start = this->mod->hal->millis();
while(this->mod->hal->digitalRead(this->mod->getGpio())) {
this->mod->hal->yield();
if(this->mod->hal->micros() - start > timeout) {
if(this->mod->hal->millis() - start > timeout) {
finishTransmit();
return(RADIOLIB_ERR_TX_TIMEOUT);
}
@ -133,18 +133,18 @@ int16_t CC1101::transmit(uint8_t* data, size_t len, uint8_t addr) {
int16_t CC1101::receive(uint8_t* data, size_t len) {
// calculate timeout (500 ms + 400 full max-length packets at current bit rate)
uint32_t timeout = 500000 + (1.0/(this->bitRate*1000.0))*(RADIOLIB_CC1101_MAX_PACKET_LENGTH*400.0);
uint32_t timeout = 500 + (1.0/(this->bitRate))*(RADIOLIB_CC1101_MAX_PACKET_LENGTH*400.0);
// start reception
int16_t state = startReceive();
RADIOLIB_ASSERT(state);
// wait for packet start or timeout
uint32_t start = this->mod->hal->micros();
uint32_t start = this->mod->hal->millis();
while(this->mod->hal->digitalRead(this->mod->getIrq())) {
this->mod->hal->yield();
if(this->mod->hal->micros() - start > timeout) {
if(this->mod->hal->millis() - start > timeout) {
standby();
SPIsendCommand(RADIOLIB_CC1101_CMD_FLUSH_RX);
return(RADIOLIB_ERR_RX_TIMEOUT);
@ -152,11 +152,11 @@ int16_t CC1101::receive(uint8_t* data, size_t len) {
}
// wait for packet end or timeout
start = this->mod->hal->micros();
start = this->mod->hal->millis();
while(!this->mod->hal->digitalRead(this->mod->getIrq())) {
this->mod->hal->yield();
if(this->mod->hal->micros() - start > timeout) {
if(this->mod->hal->millis() - start > timeout) {
standby();
SPIsendCommand(RADIOLIB_CC1101_CMD_FLUSH_RX);
return(RADIOLIB_ERR_RX_TIMEOUT);
@ -489,6 +489,24 @@ int16_t CC1101::setRxBandwidth(float rxBw) {
return(RADIOLIB_ERR_INVALID_RX_BANDWIDTH);
}
int16_t CC1101::autoSetRxBandwidth() {
// Uncertainty ~ +/- 40ppm for a cheap CC1101
// Uncertainty * 2 for both transmitter and receiver
float uncertainty = ((this->frequency) * 40 * 2);
uncertainty = (uncertainty/1000); //Since bitrate is in kBit
float minbw = ((this->bitRate) + uncertainty);
int possibles[16] = {58, 68, 81, 102, 116, 135, 162, 203, 232, 270, 325, 406, 464, 541, 650, 812};
for (int i = 0; i < 16; i++) {
if (possibles[i] > minbw) {
int16_t state = setRxBandwidth(possibles[i]);
return(state);
}
}
return(RADIOLIB_ERR_UNKNOWN);
}
int16_t CC1101::setFrequencyDeviation(float freqDev) {
// set frequency deviation to lowest available setting (required for digimodes)
float newFreqDev = freqDev;

Wyświetl plik

@ -537,7 +537,7 @@ class CC1101: public PhysicalLayer {
/*!
\brief Default constructor.
\param mod Instance of Module that will be used to communicate with the radio.
\param module Instance of Module that will be used to communicate with the radio.
*/
CC1101(Module* module);
@ -745,6 +745,14 @@ class CC1101: public PhysicalLayer {
*/
int16_t setRxBandwidth(float rxBw);
/*!
\brief calculates and sets Rx bandwidth based on the freq, baud and freq uncertainty.
Reimplement of atlas0fd00m's (RfCat) CalculatePktChanBw function.
Modified for worse ppm with the CC1101, and adjusted for the supportted CC1101 bw.
\returns \ref status_codes
*/
int16_t autoSetRxBandwidth();
/*!
\brief Sets frequency deviation. Allowed values range from 1.587 to 380.8 kHz.
\param freqDev Frequency deviation to be set in kHz.
@ -789,6 +797,7 @@ class CC1101: public PhysicalLayer {
/*!
\brief Sets preamble length.
\param preambleLength Preamble length to be set (in bits), allowed values: 16, 24, 32, 48, 64, 96, 128 and 192.
\param qualityThreshold Preamble quality threshold (PQT) to set.
\returns \ref status_codes
*/
int16_t setPreambleLength(uint8_t preambleLength, uint8_t qualityThreshold);
@ -826,52 +835,52 @@ class CC1101: public PhysicalLayer {
\brief Gets LQI (Link Quality Indicator) of the last received packet.
\returns Last packet LQI (lower is better).
*/
uint8_t getLQI() const;
uint8_t getLQI() const;
/*!
/*!
\brief Query modem for the packet length of received payload.
\param update Update received packet length. Will return cached value when set to false.
\returns Length of last received packet in bytes.
*/
size_t getPacketLength(bool update = true) override;
/*!
/*!
\brief Set modem in fixed packet length mode.
\param len Packet length.
\returns \ref status_codes
*/
int16_t fixedPacketLengthMode(uint8_t len = RADIOLIB_CC1101_MAX_PACKET_LENGTH);
/*!
/*!
\brief Set modem in variable packet length mode.
\param len Maximum packet length.
\param maxLen Maximum packet length.
\returns \ref status_codes
*/
int16_t variablePacketLengthMode(uint8_t maxLen = RADIOLIB_CC1101_MAX_PACKET_LENGTH);
/*!
/*!
\brief Enable sync word filtering and generation.
\param numBits Sync word length in bits.
\param maxErrBits Maximum number of allowed error bits in sync word.
\param requireCarrierSense Require carrier sense above threshold in addition to sync word.
\returns \ref status_codes
*/
int16_t enableSyncWordFiltering(uint8_t maxErrBits = 0, bool requireCarrierSense = false);
/*!
/*!
\brief Disable preamble and sync word filtering and generation.
\param requireCarrierSense Require carrier sense above threshold.
\returns \ref status_codes
*/
int16_t disableSyncWordFiltering(bool requireCarrierSense = false);
/*!
/*!
\brief Enable CRC filtering and generation.
\param enable Set or unset CRC generation and filtering.
\returns \ref status_codes
*/
int16_t setCrcFiltering(bool enable = true);
/*!
/*!
\brief Set modem in "sniff" mode: no packet filtering (e.g., no preamble, sync word, address, CRC).
\param enable Set or unset promiscuous mode.
\param requireCarrierSense Set carriersense required above threshold, defaults to false.
@ -879,7 +888,7 @@ class CC1101: public PhysicalLayer {
*/
int16_t setPromiscuousMode(bool enable = true, bool requireCarrierSense = false);
/*!
/*!
\brief Get whether the modem is in promiscuous mode: no packet filtering
(e.g., no preamble, sync word, address, CRC).
\returns Whether the modem is in promiscuous mode.
@ -909,16 +918,16 @@ class CC1101: public PhysicalLayer {
void setRfSwitchTable(const uint32_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]);
/*!
\brief Get one truly random byte from RSSI noise.
\returns TRNG byte.
*/
\brief Get one truly random byte from RSSI noise.
\returns TRNG byte.
*/
uint8_t randomByte();
/*!
\brief Read version SPI register. Should return CC1101_VERSION_LEGACY (0x04) or
CC1101_VERSION_CURRENT (0x14) if CC1101 is connected and working.
\returns Version register contents or \ref status_codes
*/
\brief Read version SPI register. Should return CC1101_VERSION_LEGACY (0x04) or
CC1101_VERSION_CURRENT (0x14) if CC1101 is connected and working.
\returns Version register contents or \ref status_codes
*/
int16_t getChipVersion();
#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE

Wyświetl plik

@ -100,18 +100,18 @@ void RF69::reset() {
int16_t RF69::transmit(uint8_t* data, size_t len, uint8_t addr) {
// calculate timeout (5ms + 500 % of expected time-on-air)
uint32_t timeout = 5000000 + (uint32_t)((((float)(len * 8)) / (this->bitRate * 1000.0)) * 5000000.0);
uint32_t timeout = 5 + (uint32_t)((((float)(len * 8)) / this->bitRate) * 5);
// start transmission
int16_t state = startTransmit(data, len, addr);
RADIOLIB_ASSERT(state);
// wait for transmission end or timeout
uint32_t start = this->mod->hal->micros();
uint32_t start = this->mod->hal->millis();
while(!this->mod->hal->digitalRead(this->mod->getIrq())) {
this->mod->hal->yield();
if(this->mod->hal->micros() - start > timeout) {
if(this->mod->hal->millis() - start > timeout) {
finishTransmit();
return(RADIOLIB_ERR_TX_TIMEOUT);
}
@ -122,18 +122,18 @@ int16_t RF69::transmit(uint8_t* data, size_t len, uint8_t addr) {
int16_t RF69::receive(uint8_t* data, size_t len) {
// calculate timeout (500 ms + 400 full 64-byte packets at current bit rate)
uint32_t timeout = 500000 + (1.0/(this->bitRate*1000.0))*(RADIOLIB_RF69_MAX_PACKET_LENGTH*400.0);
uint32_t timeout = 500 + (1.0/(this->bitRate))*(RADIOLIB_RF69_MAX_PACKET_LENGTH*400.0);
// start reception
int16_t state = startReceive();
RADIOLIB_ASSERT(state);
// wait for packet reception or timeout
uint32_t start = this->mod->hal->micros();
uint32_t start = this->mod->hal->millis();
while(!this->mod->hal->digitalRead(this->mod->getIrq())) {
this->mod->hal->yield();
if(this->mod->hal->micros() - start > timeout) {
if(this->mod->hal->millis() - start > timeout) {
standby();
clearIRQFlags();
return(RADIOLIB_ERR_RX_TIMEOUT);

Wyświetl plik

@ -486,7 +486,7 @@ class RF69: public PhysicalLayer {
/*!
\brief Default constructor.
\param mod Instance of Module that will be used to communicate with the radio.
\param module Instance of Module that will be used to communicate with the radio.
*/
RF69(Module* module);
@ -575,7 +575,7 @@ class RF69: public PhysicalLayer {
/*!
\brief Sets AES key.
\param Key to be used for AES encryption. Must be exactly 16 bytes long.
\param key Key to be used for AES encryption. Must be exactly 16 bytes long.
*/
void setAESKey(uint8_t* key);
@ -872,14 +872,14 @@ class RF69: public PhysicalLayer {
/*!
\brief Set modem in variable packet length mode.
\param len Maximum packet length.
\param maxLen Maximum packet length.
\returns \ref status_codes
*/
int16_t variablePacketLengthMode(uint8_t maxLen = RADIOLIB_RF69_MAX_PACKET_LENGTH);
/*!
\brief Enable sync word filtering and generation.
\param numBits Sync word length in bits.
\param maxErrBits Maximum allowed number of error bits in sync word.
\returns \ref status_codes
*/
int16_t enableSyncWordFiltering(uint8_t maxErrBits = 0);

Wyświetl plik

@ -22,10 +22,19 @@ enum {
RADIOLIB_STM32WLx_VIRTUAL_PIN_RESET,
};
/*!
\class Stm32wlxHal
\brief Hardware Abstraction Layer for STM32WL.
*/
class Stm32wlxHal : public ArduinoHal {
public:
Stm32wlxHal(): ArduinoHal(SubGhz.SPI, SubGhz.spi_settings) {}
/*!
\brief Pin mode override to handle STM32WL virtual pins.
\param dwPin Pin to set.
\param dwMode Mode to set.
*/
void pinMode(uint32_t dwPin, uint32_t dwMode) {
switch(dwPin) {
case RADIOLIB_STM32WLx_VIRTUAL_PIN_NSS:
@ -40,6 +49,11 @@ class Stm32wlxHal : public ArduinoHal {
}
}
/*!
\brief Digital write override to handle STM32WL virtual pins.
\param dwPin Pin to set.
\param dwVal Value to set.
*/
void digitalWrite(uint32_t dwPin, uint32_t dwVal) {
switch (dwPin) {
case RADIOLIB_STM32WLx_VIRTUAL_PIN_NSS:
@ -61,6 +75,11 @@ class Stm32wlxHal : public ArduinoHal {
}
}
/*!
\brief Digital read override to handle STM32WL virtual pins.
\param ulPin Pin to read.
\returns Value read on the pin.
*/
uint32_t digitalRead(uint32_t ulPin) {
switch (ulPin) {
case RADIOLIB_STM32WLx_VIRTUAL_PIN_BUSY:

Wyświetl plik

@ -231,41 +231,27 @@ int16_t SX126x::transmit(uint8_t* data, size_t len, uint8_t addr) {
return(RADIOLIB_ERR_PACKET_TOO_LONG);
}
uint32_t timeout = 0;
// get currently active modem
uint8_t modem = getPacketType();
if(modem == RADIOLIB_SX126X_PACKET_TYPE_LORA) {
// calculate timeout (150% of expected time-on-air)
timeout = (getTimeOnAir(len) * 3) / 2;
} else if(modem == RADIOLIB_SX126X_PACKET_TYPE_GFSK) {
// calculate timeout (500% of expected time-on-air)
timeout = getTimeOnAir(len) * 5;
} else {
return(RADIOLIB_ERR_UNKNOWN);
}
RADIOLIB_DEBUG_BASIC_PRINTLN("Timeout in %lu us", timeout);
// calculate timeout in ms (500% of expected time-on-air)
uint32_t timeout = (getTimeOnAir(len) * 5) / 1000;
RADIOLIB_DEBUG_BASIC_PRINTLN("Timeout in %lu ms", timeout);
// start transmission
state = startTransmit(data, len, addr);
RADIOLIB_ASSERT(state);
// wait for packet transmission or timeout
uint32_t start = this->mod->hal->micros();
uint32_t start = this->mod->hal->millis();
while(!this->mod->hal->digitalRead(this->mod->getIrq())) {
this->mod->hal->yield();
if(this->mod->hal->micros() - start > timeout) {
if(this->mod->hal->millis() - start > timeout) {
finishTransmit();
return(RADIOLIB_ERR_TX_TIMEOUT);
}
}
uint32_t elapsed = this->mod->hal->micros() - start;
// update data rate
this->dataRateMeasured = (len*8.0)/((float)elapsed/1000000.0);
uint32_t elapsed = this->mod->hal->millis() - start;
this->dataRateMeasured = (len*8.0)/((float)elapsed/1000.0);
return(finishTransmit());
}
@ -282,7 +268,8 @@ int16_t SX126x::receive(uint8_t* data, size_t len) {
if(modem == RADIOLIB_SX126X_PACKET_TYPE_LORA) {
// calculate timeout (100 LoRa symbols, the default for SX127x series)
float symbolLength = (float)(uint32_t(1) << this->spreadingFactor) / (float)this->bandwidthKhz;
timeout = (uint32_t)(symbolLength * 100.0 * 1000.0);
timeout = (uint32_t)(symbolLength * 100.0);
} else if(modem == RADIOLIB_SX126X_PACKET_TYPE_GFSK) {
// calculate timeout (500 % of expected time-one-air)
size_t maxLen = len;
@ -290,26 +277,27 @@ int16_t SX126x::receive(uint8_t* data, size_t len) {
maxLen = 0xFF;
}
float brBps = ((float)(RADIOLIB_SX126X_CRYSTAL_FREQ) * 1000000.0 * 32.0) / (float)this->bitRate;
timeout = (uint32_t)(((maxLen * 8.0) / brBps) * 1000000.0 * 5.0);
timeout = (uint32_t)(((maxLen * 8.0) / brBps) * 1000.0 * 5.0);
} else {
return(RADIOLIB_ERR_UNKNOWN);
}
RADIOLIB_DEBUG_BASIC_PRINTLN("Timeout in %lu us", timeout);
RADIOLIB_DEBUG_BASIC_PRINTLN("Timeout in %lu ms", timeout);
// start reception
uint32_t timeoutValue = (uint32_t)((float)timeout / 15.625);
uint32_t timeoutValue = (uint32_t)(((float)timeout * 1000.0) / 15.625);
state = startReceive(timeoutValue);
RADIOLIB_ASSERT(state);
// wait for packet reception or timeout
bool softTimeout = false;
uint32_t start = this->mod->hal->micros();
uint32_t start = this->mod->hal->millis();
while(!this->mod->hal->digitalRead(this->mod->getIrq())) {
this->mod->hal->yield();
// safety check, the timeout should be done by the radio
if(this->mod->hal->micros() - start > timeout) {
if(this->mod->hal->millis() - start > timeout) {
softTimeout = true;
break;
}

Wyświetl plik

@ -935,7 +935,7 @@ class SX126x: public PhysicalLayer {
/*!
\brief Set modem in variable packet length mode. Available in FSK mode only.
\param len Maximum packet length.
\param maxLen Maximum packet length.
\returns \ref status_codes
*/
int16_t variablePacketLengthMode(uint8_t maxLen = RADIOLIB_SX126X_MAX_PACKET_LENGTH);
@ -964,7 +964,7 @@ class SX126x: public PhysicalLayer {
/*!
\brief Check whether the IRQ bit for RxTimeout is set
\returns \ref RxTimeout IRQ is set
\returns Whether RxTimeout IRQ is set
*/
bool isRxTimeout();

Wyświetl plik

@ -111,8 +111,7 @@ class SX1272: public SX127x {
\param sf %LoRa link spreading factor. Allowed values range from 6 to 12.
\param cr %LoRa link coding rate denominator. Allowed values range from 5 to 8.
\param syncWord %LoRa sync word. Can be used to distinguish different networks. Note that value 0x34 is reserved for LoRaWAN networks.
\param currentLimit Trim value for OCP (over current protection) in mA. Can be set to multiplies of 5 in range 45 to 120 mA and to multiples of 10 in range 120 to 240 mA.
Set to 0 to disable OCP (not recommended).
\param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm.
\param preambleLength Length of %LoRa transmission preamble in symbols. The actual preamble length is 4.25 symbols longer than the set number.
Allowed values range from 6 to 65535.
\param gain Gain of receiver LNA (low-noise amplifier). Can be set to any integer in range 1 to 6 where 1 is the highest gain.

Wyświetl plik

@ -149,13 +149,14 @@ int16_t SX127x::transmit(uint8_t* data, size_t len, uint8_t addr) {
int16_t modem = getActiveModem();
uint32_t start = 0;
uint32_t timeout = 0;
uint32_t toa = getTimeOnAir(len);
if(modem == RADIOLIB_SX127X_LORA) {
// calculate timeout (150 % of expected time-on-air)
timeout = getTimeOnAir(len) * 1.5;
// calculate timeout in ms (150 % of expected time-on-air)
timeout = (toa * 1.5) / 1000;
} else if(modem == RADIOLIB_SX127X_FSK_OOK) {
// calculate timeout (5ms + 500 % of expected time-on-air)
timeout = 5000 + getTimeOnAir(len) * 5;
// calculate timeout in ms (5ms + 500 % of expected time-on-air)
timeout = 5 + (toa * 5) / 1000;
} else {
return(RADIOLIB_ERR_UNKNOWN);
@ -163,22 +164,23 @@ int16_t SX127x::transmit(uint8_t* data, size_t len, uint8_t addr) {
}
// start transmission
RADIOLIB_DEBUG_BASIC_PRINTLN("Timeout in %lu ms", timeout);
state = startTransmit(data, len, addr);
RADIOLIB_ASSERT(state);
// wait for packet transmission or timeout
start = this->mod->hal->micros();
start = this->mod->hal->millis();
while(!this->mod->hal->digitalRead(this->mod->getIrq())) {
this->mod->hal->yield();
if(this->mod->hal->micros() - start > timeout) {
if(this->mod->hal->millis() - start > timeout) {
finishTransmit();
return(RADIOLIB_ERR_TX_TIMEOUT);
}
}
// update data rate
uint32_t elapsed = this->mod->hal->micros() - start;
this->dataRate = (len*8.0)/((float)elapsed/1000000.0);
uint32_t elapsed = this->mod->hal->millis() - start;
this->dataRate = (len*8.0)/((float)elapsed/1000.0);
return(finishTransmit());
}
@ -198,17 +200,17 @@ int16_t SX127x::receive(uint8_t* data, size_t len) {
uint32_t timeout = 0;
if(this->mod->getGpio() == RADIOLIB_NC) {
float symbolLength = (float) (uint32_t(1) << this->spreadingFactor) / (float) this->bandwidth;
timeout = (uint32_t)(symbolLength * 100.0 * 1000.0);
timeout = (uint32_t)(symbolLength * 100.0);
}
// wait for packet reception or timeout
uint32_t start = this->mod->hal->micros();
uint32_t start = this->mod->hal->millis();
while(!this->mod->hal->digitalRead(this->mod->getIrq())) {
this->mod->hal->yield();
if(this->mod->getGpio() == RADIOLIB_NC) {
// no GPIO pin provided, use software timeout
if(this->mod->hal->micros() - start > timeout) {
if(this->mod->hal->millis() - start > timeout) {
clearIRQFlags();
return(RADIOLIB_ERR_RX_TIMEOUT);
}
@ -223,18 +225,18 @@ int16_t SX127x::receive(uint8_t* data, size_t len) {
}
} else if(modem == RADIOLIB_SX127X_FSK_OOK) {
// calculate timeout (500 % of expected time-on-air)
uint32_t timeout = getTimeOnAir(len) * 5;
// calculate timeout in ms (500 % of expected time-on-air)
uint32_t timeout = (getTimeOnAir(len) * 5) / 1000;
// set mode to receive
state = startReceive(len, RADIOLIB_SX127X_RX);
RADIOLIB_ASSERT(state);
// wait for packet reception or timeout
uint32_t start = this->mod->hal->micros();
uint32_t start = this->mod->hal->millis();
while(!this->mod->hal->digitalRead(this->mod->getIrq())) {
this->mod->hal->yield();
if(this->mod->hal->micros() - start > timeout) {
if(this->mod->hal->millis() - start > timeout) {
clearIRQFlags();
return(RADIOLIB_ERR_RX_TIMEOUT);
}
@ -1252,31 +1254,30 @@ uint32_t SX127x::getTimeOnAir(size_t len) {
// get number of symbols
float n_sym = getNumSymbols(len);
// Get time-on-air in us
// get time-on-air in us
return ceil((double)symbolLength * (double)n_sym) * 1000;
} else if(modem == RADIOLIB_SX127X_FSK_OOK) {
// Get number of bits preamble
// get number of bits preamble
float n_pre = (float) ((this->mod->SPIgetRegValue(RADIOLIB_SX127X_REG_PREAMBLE_MSB_FSK) << 8) | this->mod->SPIgetRegValue(RADIOLIB_SX127X_REG_PREAMBLE_LSB_FSK)) * 8;
//Get the number of bits of the sync word
// get the number of bits of the sync word
float n_syncWord = (float) (this->mod->SPIgetRegValue(RADIOLIB_SX127X_REG_SYNC_CONFIG, 2, 0) + 1) * 8;
//Get CRC bits
// get CRC bits
float crc = (this->mod->SPIgetRegValue(RADIOLIB_SX127X_REG_PACKET_CONFIG_1, 4, 4) == RADIOLIB_SX127X_CRC_ON) * 16;
if (this->packetLengthConfig == RADIOLIB_SX127X_PACKET_FIXED) {
//If Packet size fixed -> len = fixed packet length
// if packet size fixed -> len = fixed packet length
len = this->mod->SPIgetRegValue(RADIOLIB_SX127X_REG_PAYLOAD_LENGTH_FSK);
} else {
//if packet variable -> Add 1 extra byte for payload length
// if packet variable -> Add 1 extra byte for payload length
len += 1;
}
// Calculate time-on-air in us {[(length in bytes) * (8 bits / 1 byte)] / [(Bit Rate in kbps) * (1000 bps / 1 kbps)]} * (1000000 us in 1 sec)
return (uint32_t) (((crc + n_syncWord + n_pre + (float) (len * 8)) / (this->bitRate * 1000.0)) * 1000000.0);
} else {
return(RADIOLIB_ERR_UNKNOWN);
// calculate time-on-air in us {[(length in bytes) * (8 bits / 1 byte)] / [(Bit Rate in kbps) * (1000 bps / 1 kbps)]} * (1000000 us in 1 sec)
return((uint32_t) (((crc + n_syncWord + n_pre + (float) (len * 8)) / (this->bitRate * 1000.0)) * 1000000.0));
}
return(RADIOLIB_ERR_UNKNOWN);
}
uint32_t SX127x::calculateRxTimeout(uint32_t timeoutUs) {

Wyświetl plik

@ -600,7 +600,7 @@ class SX127x: public PhysicalLayer {
/*!
\brief Initialization method. Will be called with appropriate parameters when calling initialization method from derived class.
\param chipVersion Array of possible values in SPI version register. Used to verify the connection and hardware version.
\param chipVersions Array of possible values in SPI version register. Used to verify the connection and hardware version.
\param numVersions Number of possible chip versions.
\param syncWord %LoRa sync word.
\param preambleLength Length of %LoRa transmission preamble in symbols.
@ -615,7 +615,7 @@ class SX127x: public PhysicalLayer {
/*!
\brief Initialization method for FSK modem. Will be called with appropriate parameters when calling FSK initialization method from derived class.
\param chipVersion Array of possible values in SPI version register. Used to verify the connection and hardware version.
\param chipVersions Array of possible values in SPI version register. Used to verify the connection and hardware version.
\param numVersions Number of possible chip versions.
\param freqDev Frequency deviation of the FSK transmission in kHz.
\param rxBw Receiver bandwidth in kHz.
@ -928,7 +928,7 @@ class SX127x: public PhysicalLayer {
/*!
\brief Sets FSK automatic frequency correction bandwidth. Allowed values range from 2.6 to 250 kHz. Only available in FSK mode.
\param rxBw Receiver AFC bandwidth to be set (in kHz).
\param afcBw Receiver AFC bandwidth to be set (in kHz).
\returns \ref status_codes
*/
int16_t setAFCBandwidth(float afcBw);
@ -1038,7 +1038,7 @@ class SX127x: public PhysicalLayer {
/*!
\brief Set modem in variable packet length mode. Available in FSK mode only.
\param len Maximum packet length.
\param maxLen Maximum packet length.
\returns \ref status_codes
*/
int16_t variablePacketLengthMode(uint8_t maxLen = RADIOLIB_SX127X_MAX_PACKET_LENGTH_FSK);
@ -1074,7 +1074,7 @@ class SX127x: public PhysicalLayer {
/*!
\brief Check whether the IRQ bit for RxTimeout is set
\returns \ref RxTimeout IRQ is set
\returns Whether RxTimeout IRQ is set
*/
bool isRxTimeout();
@ -1201,14 +1201,6 @@ class SX127x: public PhysicalLayer {
*/
int16_t setDIOPreambleDetect(bool usePreambleDetect);
/*!
\brief Gets recorded signal strength indicator.
\param packet Whether to read last packet RSSI, or the current value. LoRa mode only, ignored for FSK.
\param skipReceive Set to true to skip putting radio in receive mode for the RSSI measurement in FSK/OOK mode.
\returns RSSI value in dBm.
*/
float getRSSI(bool packet, bool skipReceive, int16_t offset);
/*!
\brief Sets the RSSI value above which the RSSI interrupt is signaled
\param dbm A dBm value between -127.5 and 0 inclusive
@ -1246,6 +1238,7 @@ class SX127x: public PhysicalLayer {
int16_t getActiveModem();
int16_t setFrequencyRaw(float newFreq);
int16_t setBitRateCommon(float br, uint8_t fracRegAddr);
float getRSSI(bool packet, bool skipReceive, int16_t offset);
#if !RADIOLIB_GODMODE
private:

Wyświetl plik

@ -305,20 +305,19 @@ int16_t SX128x::transmit(uint8_t* data, size_t len, uint8_t addr) {
int16_t state = standby();
RADIOLIB_ASSERT(state);
// calculate timeout (500% of expected time-on-air)
uint32_t timeout = getTimeOnAir(len) * 5;
RADIOLIB_DEBUG_BASIC_PRINTLN("Timeout in %lu us", timeout);
// calculate timeout in ms (500% of expected time-on-air)
uint32_t timeout = (getTimeOnAir(len) * 5) / 1000;
RADIOLIB_DEBUG_BASIC_PRINTLN("Timeout in %lu ms", timeout);
// start transmission
state = startTransmit(data, len, addr);
RADIOLIB_ASSERT(state);
// wait for packet transmission or timeout
uint32_t start = this->mod->hal->micros();
uint32_t start = this->mod->hal->millis();
while(!this->mod->hal->digitalRead(this->mod->getIrq())) {
this->mod->hal->yield();
if(this->mod->hal->micros() - start > timeout) {
if(this->mod->hal->millis() - start > timeout) {
finishTransmit();
return(RADIOLIB_ERR_TX_TIMEOUT);
}
@ -340,8 +339,7 @@ int16_t SX128x::receive(uint8_t* data, size_t len) {
// calculate timeout (1000% of expected time-on-air)
uint32_t timeout = getTimeOnAir(len) * 10;
RADIOLIB_DEBUG_BASIC_PRINTLN("Timeout in %lu us", timeout);
RADIOLIB_DEBUG_BASIC_PRINTLN("Timeout in %lu ms", timeout);
// start reception
uint32_t timeoutValue = (uint32_t)((float)timeout / 15.625);
@ -350,11 +348,11 @@ int16_t SX128x::receive(uint8_t* data, size_t len) {
// wait for packet reception or timeout
bool softTimeout = false;
uint32_t start = this->mod->hal->micros();
uint32_t start = this->mod->hal->millis();
while(!this->mod->hal->digitalRead(this->mod->getIrq())) {
this->mod->hal->yield();
// safety check, the timeout should be done by the radio
if(this->mod->hal->micros() - start > timeout) {
if(this->mod->hal->millis() - start > timeout) {
softTimeout = true;
break;
}

Wyświetl plik

@ -73,17 +73,17 @@ void Si443x::reset() {
int16_t Si443x::transmit(uint8_t* data, size_t len, uint8_t addr) {
// calculate timeout (5ms + 500 % of expected time-on-air)
uint32_t timeout = 5000000 + (uint32_t)((((float)(len * 8)) / (this->bitRate * 1000.0)) * 5000000.0);
uint32_t timeout = 5 + (uint32_t)((((float)(len * 8)) / this->bitRate) * 5);
// start transmission
int16_t state = startTransmit(data, len, addr);
RADIOLIB_ASSERT(state);
// wait for transmission end or timeout
uint32_t start = this->mod->hal->micros();
uint32_t start = this->mod->hal->millis();
while(this->mod->hal->digitalRead(this->mod->getIrq())) {
this->mod->hal->yield();
if(this->mod->hal->micros() - start > timeout) {
if(this->mod->hal->millis() - start > timeout) {
finishTransmit();
return(RADIOLIB_ERR_TX_TIMEOUT);
}
@ -94,16 +94,16 @@ int16_t Si443x::transmit(uint8_t* data, size_t len, uint8_t addr) {
int16_t Si443x::receive(uint8_t* data, size_t len) {
// calculate timeout (500 ms + 400 full 64-byte packets at current bit rate)
uint32_t timeout = 500000 + (1.0/(this->bitRate*1000.0))*(RADIOLIB_SI443X_MAX_PACKET_LENGTH*400.0);
uint32_t timeout = 500 + (1.0/(this->bitRate))*(RADIOLIB_SI443X_MAX_PACKET_LENGTH*400.0);
// start reception
int16_t state = startReceive();
RADIOLIB_ASSERT(state);
// wait for packet reception or timeout
uint32_t start = this->mod->hal->micros();
uint32_t start = this->mod->hal->millis();
while(this->mod->hal->digitalRead(this->mod->getIrq())) {
if(this->mod->hal->micros() - start > timeout) {
if(this->mod->hal->millis() - start > timeout) {
standby();
clearIRQFlags();
return(RADIOLIB_ERR_RX_TIMEOUT);

Wyświetl plik

@ -88,7 +88,7 @@ int16_t nRF24::transmit(uint8_t* data, size_t len, uint8_t addr) {
RADIOLIB_ASSERT(state);
// wait until transmission is finished
uint32_t start = this->mod->hal->micros();
uint32_t start = this->mod->hal->millis();
while(this->mod->hal->digitalRead(this->mod->getIrq())) {
this->mod->hal->yield();
@ -98,8 +98,8 @@ int16_t nRF24::transmit(uint8_t* data, size_t len, uint8_t addr) {
return(RADIOLIB_ERR_ACK_NOT_RECEIVED);
}
// check timeout: 15 retries * 4ms (max Tx time as per datasheet)
if(this->mod->hal->micros() - start >= 60000) {
// check timeout: 15 retries * 4ms (max Tx time as per datasheet) + 10 ms
if(this->mod->hal->millis() - start >= ((15 * 4) + 10)) {
finishTransmit();
return(RADIOLIB_ERR_TX_TIMEOUT);
}
@ -114,12 +114,12 @@ int16_t nRF24::receive(uint8_t* data, size_t len) {
RADIOLIB_ASSERT(state);
// wait for Rx_DataReady or timeout
uint32_t start = this->mod->hal->micros();
uint32_t start = this->mod->hal->millis();
while(this->mod->hal->digitalRead(this->mod->getIrq())) {
this->mod->hal->yield();
// check timeout: 15 retries * 4ms (max Tx time as per datasheet)
if(this->mod->hal->micros() - start >= 60000) {
// check timeout: 15 retries * 4ms (max Tx time as per datasheet) + 10 ms
if(this->mod->hal->millis() - start >= ((15 * 4) + 10)) {
standby();
clearIRQ();
return(RADIOLIB_ERR_RX_TIMEOUT);

Wyświetl plik

@ -460,7 +460,7 @@ class nRF24: public PhysicalLayer {
/*!
\brief Dummy encoding configuration method, to ensure PhysicalLayer compatibility.
\param sh Ignored.
\param encoding Ignored.
\returns \ref status_codes
*/
int16_t setEncoding(uint8_t encoding) override;

Wyświetl plik

@ -44,7 +44,7 @@ class AFSKClient {
/*!
\brief Stops transmitting audio tone.
\param freq Keep transmitter on - this may limit noise when switching transmitter on or off.
\param keepOn Keep transmitter on - this may limit noise when switching transmitter on or off.
\returns \ref status_codes
*/
int16_t noTone(bool keepOn = false);

Wyświetl plik

@ -29,17 +29,33 @@
/*!
\defgroup mic_e_message_types Mic-E message types.
\{
*/
/*! \brief Mic-E "Off duty" message. */
#define RADIOLIB_APRS_MIC_E_TYPE_OFF_DUTY 0b00000111
/*! \brief Mic-E "En route" message. */
#define RADIOLIB_APRS_MIC_E_TYPE_EN_ROUTE 0b00000110
/*! \brief Mic-E "In service" message. */
#define RADIOLIB_APRS_MIC_E_TYPE_IN_SERVICE 0b00000101
/*! \brief Mic-E "Returning" message. */
#define RADIOLIB_APRS_MIC_E_TYPE_RETURNING 0b00000100
/*! \brief Mic-E "Commited" message. */
#define RADIOLIB_APRS_MIC_E_TYPE_COMMITTED 0b00000011
/*! \brief Mic-E special message. */
#define RADIOLIB_APRS_MIC_E_TYPE_SPECIAL 0b00000010
/*! \brief Mic-E priority message. */
#define RADIOLIB_APRS_MIC_E_TYPE_PRIORITY 0b00000001
/*! \brief Mic-E emergency message. */
#define RADIOLIB_APRS_MIC_E_TYPE_EMERGENCY 0b00000000
/*!
\}
*/
@ -97,9 +113,9 @@ class APRSClient {
\param destCallsign Destination station callsign.
\param destSSID Destination station SSID.
\param lat Latitude as a null-terminated string.
\param long Longitude as a null-terminated string.
\param lon Longitude as a null-terminated string.
\param msg Message to be transmitted. Defaults to NULL (no message).
\param msg Position timestamp. Defaults to NULL (no timestamp).
\param time Position timestamp. Defaults to NULL (no timestamp).
\returns \ref status_codes
*/
int16_t sendPosition(char* destCallsign, uint8_t destSSID, char* lat, char* lon, char* msg = NULL, char* time = NULL);

Wyświetl plik

@ -1,7 +1,7 @@
#include "BellModem.h"
#if !RADIOLIB_EXCLUDE_BELL
const struct BellModem_t Bell101 {
const BellModem_t Bell101 = {
.freqMark = 1270,
.freqSpace = 1070,
.baudRate = 110,
@ -9,7 +9,7 @@ const struct BellModem_t Bell101 {
.freqSpaceReply = 2025,
};
const struct BellModem_t Bell103 {
const BellModem_t Bell103 = {
.freqMark = 1270,
.freqSpace = 1070,
.baudRate = 300,
@ -17,7 +17,7 @@ const struct BellModem_t Bell103 {
.freqSpaceReply = 2025,
};
const struct BellModem_t Bell202 {
const BellModem_t Bell202 = {
.freqMark = 1200,
.freqSpace = 2200,
.baudRate = 1200,

Wyświetl plik

@ -93,7 +93,7 @@ class BellClient: public AFSKClient, public RadioLibPrint {
/*!
\brief Set correction coefficient for tone length.
\param correction Timing correction factor, used to adjust the length of tones.
\param corr Timing correction factor, used to adjust the length of tones.
Less than 1.0 leads to shorter tones, defaults to 1.0 (no correction).
\returns \ref status_codes
*/

Wyświetl plik

@ -9,6 +9,10 @@
#include "../PhysicalLayer/PhysicalLayer.h"
/*!
\class ExternalRadio
\brief Class to interface with external radio hardware.
*/
class ExternalRadio: public PhysicalLayer {
public:
#if defined(RADIOLIB_BUILD_ARDUINO)

Wyświetl plik

@ -199,11 +199,22 @@
#define RADIOLIB_LORAWAN_MAX_MAC_COMMAND_LEN_UP (2)
#define RADIOLIB_LORAWAN_MAX_NUM_ADR_COMMANDS (8)
/*!
\struct LoRaWANMacSpec_t
\brief MAC command specification structure.
*/
struct LoRaWANMacSpec_t {
/*! \brief Command ID */
const uint8_t cid;
/*! \brief Uplink message length */
const uint8_t lenDn;
/*! \brief Downlink message length */
const uint8_t lenUp;
const bool user; // whether this MAC command can be issued by a user or not
/*! \brief Whether this MAC command can be issued by the user or not */
const bool user;
};
const LoRaWANMacSpec_t MacTable[RADIOLIB_LORAWAN_NUM_MAC_COMMANDS + 1] = {
@ -277,7 +288,7 @@ enum LoRaWANSchemeSession_t {
};
/*!
\struct LoRaWANChannelSpan_t
\struct LoRaWANChannel_t
\brief Structure to save information about LoRaWAN channels.
To save space, adjacent channels are saved in "spans".
*/
@ -352,8 +363,10 @@ struct LoRaWANBand_t {
/*! \brief Number of milliseconds per hour of allowed Time-on-Air */
uint32_t dutyCycle;
/*! \brief Maximum dwell time per message in milliseconds */
/*! \brief Maximum dwell time per uplink message in milliseconds */
uint32_t dwellTimeUp;
/*! \brief Maximum dwell time per downlink message in milliseconds */
uint32_t dwellTimeDn;
/*! \brief A set of default uplink (TX) channels for frequency-type bands */
@ -432,10 +445,18 @@ struct LoRaWANMacCommand_t {
/*! \brief Repetition counter (the command will be uplinked repeat + 1 times) */
uint8_t repeat;
};
/*!
\struct LoRaWANMacCommandQueue_t
\brief Structure to hold information about a queue of MAC commands
*/
struct LoRaWANMacCommandQueue_t {
/*! \brief Number of commands in the queue */
uint8_t numCommands;
/*! \brief Total length of the queue */
uint8_t len;
/*! \brief MAC command buffer */
LoRaWANMacCommand_t commands[RADIOLIB_LORAWAN_MAC_COMMAND_QUEUE_SIZE];
};
@ -477,10 +498,10 @@ struct LoRaWANEvent_t {
class LoRaWANNode {
public:
// Offset between TX and RX1 (such that RX1 has equal or lower DR)
/*! \brief Offset between TX and RX1 (such that RX1 has equal or lower DR) */
uint8_t rx1DrOffset = 0;
// RX2 channel properties - may be changed by MAC command
/*! \brief RX2 channel properties - may be changed by MAC command */
LoRaWANChannel_t rx2;
/*!
@ -734,7 +755,7 @@ class LoRaWANNode {
/*!
\brief Set uplink datarate. This should not be used when ADR is enabled.
\param dr Datarate to use for uplinks.
\param drUp Datarate to use for uplinks.
\returns \ref status_codes
*/
int16_t setDatarate(uint8_t drUp);
@ -768,7 +789,7 @@ class LoRaWANNode {
/*!
\brief Toggle adherence to dwellTime limits to on or off.
\param enable Whether to adhere to dwellTime limits or not (default true).
\param msPerHour The maximum allowed Time-on-Air per uplink in milliseconds
\param msPerUplink The maximum allowed Time-on-Air per uplink in milliseconds
(default 0 = maximum allowed for configured band).
*/
void setDwellTime(bool enable, uint32_t msPerUplink = 0);

Wyświetl plik

@ -4,22 +4,42 @@
#include "../../TypeDef.h"
#include "../../Module.h"
// data rate structure interpretation in case LoRa is used
/*!
\struct LoRaRate_t
\brief Data rate structure interpretation in case LoRa is used
*/
struct LoRaRate_t {
/*! \brief LoRa spreading factor */
uint8_t spreadingFactor;
/*! \brief LoRa bandwidth in kHz */
float bandwidth;
/*! \brief LoRa coding rate */
uint8_t codingRate;
};
// data rate structure interpretation in case FSK is used
/*!
\struct FSKRate_t
\brief Data rate structure interpretation in case FSK is used
*/
struct FSKRate_t {
/*! \brief FSK bit rate in kbps */
float bitRate;
/*! \brief FS frequency deviation in kHz*/
float freqDev;
};
// common data rate
/*!
\union DataRate_t
\brief Common data rate structure
*/
union DataRate_t {
/*! \brief Interpretation for LoRa modems */
LoRaRate_t lora;
/*! \brief Interpretation for FSK modems */
FSKRate_t fsk;
};
@ -237,7 +257,7 @@ class PhysicalLayer {
/*!
\brief Sets FSK data encoding. Only available in FSK mode. Must be implemented in module class.
\param enc Encoding to be used. See \ref config_encoding for possible values.
\param encoding Encoding to be used. See \ref config_encoding for possible values.
\returns \ref status_codes
*/
virtual int16_t setEncoding(uint8_t encoding);
@ -334,7 +354,7 @@ class PhysicalLayer {
/*!
\brief Check whether the IRQ bit for RxTimeout is set
\returns \ref RxTimeout IRQ is set
\returns Whether RxTimeout IRQ is set
*/
virtual bool isRxTimeout();

Wyświetl plik

@ -152,7 +152,7 @@ size_t RadioLibPrint::print(double n, int digits) {
return(RadioLibPrint::printFloat(n, digits));
}
size_t RadioLibPrint::println(const char* str) {
size_t RadioLibPrint::println(const char str[]) {
size_t n = RadioLibPrint::print(str);
n += RadioLibPrint::println();
return(n);

Wyświetl plik

@ -10,7 +10,10 @@
#define RADIOLIB_ASCII_EXTENDED 1
#define RADIOLIB_ITA2 2
// based on Arduino Print class
/*!
\class RadioLibPrint
\brief Printing class, based on Arduino Print class with additional encodings.
*/
class RadioLibPrint {
public:
virtual size_t write(uint8_t) = 0;