Skip to content

Commit

Permalink
[PHY] Get/Set modem (#1294)
Browse files Browse the repository at this point in the history
* [PHY] Added set modem method

* Added new keyword

* [SX126x] Added setModem implementation

* [LoRaWAN] Use setModem

* [PHY] Added getModem

* [LoRaWAN] Use getModem instead of caching modulation

* [SX126x] Implement getModem

* Added new keywords

* [LR11x0] Added get/set modem

* [LLCC68] Added get/set modem

* [SX126x] Added missing default branch

* [SX127x] Added get/set modem

* [SX128x] Added get/set modem

* [CI] Drop Hellschreiber from AVR builds

* [CI] Drop Arduino Uno from CI
  • Loading branch information
jgromes authored Oct 26, 2024
1 parent 64253f6 commit e44e9b4
Show file tree
Hide file tree
Showing 36 changed files with 456 additions and 33 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ on:
id:
description: The ID of the platform on which the build is run
required: true
default: arduino:avr:uno
default: arduino:avr:mega
type: choice
options:
- all
- none
- arduino:avr:uno
- arduino:avr:mega
- arduino:mbed:nano33ble
- arduino:mbed:envie_m4
Expand Down Expand Up @@ -45,8 +44,6 @@ jobs:
matrix:
# platform-dependent settings - extra board options, board index URLs, skip patterns etc.
include:
- id: arduino:avr:uno
run: echo "skip-pattern=(STM32WL|SSTV|LoRaWAN|LR11x0_Firmware_Update|Pager|APRS|Morse|SX126x)" >> $GITHUB_OUTPUT
- id: arduino:avr:mega
run: |
echo "options=':cpu=atmega2560'" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -131,7 +128,7 @@ jobs:
runs-on: ubuntu-latest
name: ${{ matrix.id }}
env:
run-build: ${{ (inputs.id != 'none' && matrix.id == 'arduino:avr:uno') || contains(github.event.head_commit.message, 'CI_BUILD_ALL') || contains(github.event.head_commit.message, 'Bump version to') || contains(github.event.head_commit.message, format('{0}', matrix.id)) || inputs.id == 'all' || inputs.id == matrix.id }}
run-build: ${{ (inputs.id != 'none' && matrix.id == 'arduino:avr:mega') || contains(github.event.head_commit.message, 'CI_BUILD_ALL') || contains(github.event.head_commit.message, 'Bump version to') || contains(github.event.head_commit.message, format('{0}', matrix.id)) || inputs.id == 'all' || inputs.id == matrix.id }}

steps:
- name: Free Disk Space (Ubuntu)
Expand Down
12 changes: 10 additions & 2 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,15 @@ dropRepeaters KEYWORD2
sendTone KEYWORD2

# PhysicalLayer
RadioLibIrqType_t KEYWORD1
LoRaRate_t KEYWORD1
FSKRate_t KEYWORD1
LrFhssRate_t KEYWORD1
DataRate_t KEYWORD1
CADScanConfig_t KEYWORD1
RSSIScanConfig_t KEYWORD1
ChannelScanConfig_t KEYWORD1
ModemType_t KEYWORD1
dropSync KEYWORD2
setTimerFlag KEYWORD2
setInterruptSetup KEYWORD2
Expand All @@ -329,9 +338,8 @@ setPacketSentAction KEYWORD2
clearPacketSentAction KEYWORD2
setDataRate KEYWORD2
checkDataRate KEYWORD2

# BellModem
setModem KEYWORD2
getModem KEYWORD2

# LoRaWAN
getBufferNonces KEYWORD2
Expand Down
16 changes: 16 additions & 0 deletions src/modules/LLCC68/LLCC68.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,20 @@ int16_t LLCC68::checkDataRate(DataRate_t dr) {
return(state);
}

int16_t LLCC68::setModem(ModemType_t modem) {
switch(modem) {
case(ModemType_t::LoRa): {
return(this->begin());
} break;
case(ModemType_t::FSK): {
return(this->beginFSK());
} break;
case(ModemType_t::LRFHSS): {
return(this->beginLRFHSS());
} break;
default:
return(RADIOLIB_ERR_WRONG_MODEM);
}
}

#endif
8 changes: 8 additions & 0 deletions src/modules/LLCC68/LLCC68.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ class LLCC68: public SX1262 {
\returns \ref status_codes
*/
int16_t checkDataRate(DataRate_t dr) override;

/*!
\brief Set modem for the radio to use. Will perform full reset and reconfigure the radio
using its default parameters.
\param modem Modem type to set - FSK, LoRa or LR-FHSS.
\returns \ref status_codes
*/
int16_t setModem(ModemType_t modem) override;

#if !RADIOLIB_GODMODE
private:
Expand Down
15 changes: 15 additions & 0 deletions src/modules/LR11x0/LR1110.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,19 @@ int16_t LR1110::checkOutputPower(int8_t power, int8_t* clipped, bool forceHighPo
return(RADIOLIB_ERR_NONE);
}

int16_t LR1110::setModem(ModemType_t modem) {
switch(modem) {
case(ModemType_t::LoRa): {
return(this->begin());
} break;
case(ModemType_t::FSK): {
return(this->beginGFSK());
} break;
case(ModemType_t::LRFHSS): {
return(this->beginLRFHSS());
} break;
}
return(RADIOLIB_ERR_WRONG_MODEM);
}

#endif
8 changes: 8 additions & 0 deletions src/modules/LR11x0/LR1110.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ class LR1110: public LR11x0 {
*/
int16_t checkOutputPower(int8_t power, int8_t* clipped, bool forceHighPower);

/*!
\brief Set modem for the radio to use. Will perform full reset and reconfigure the radio
using its default parameters.
\param modem Modem type to set - FSK, LoRa or LR-FHSS.
\returns \ref status_codes
*/
int16_t setModem(ModemType_t modem) override;

#if !RADIOLIB_GODMODE
private:
#endif
Expand Down
15 changes: 15 additions & 0 deletions src/modules/LR11x0/LR1120.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,19 @@ int16_t LR1120::checkOutputPower(int8_t power, int8_t* clipped, bool forceHighPo
return(RADIOLIB_ERR_NONE);
}

int16_t LR1120::setModem(ModemType_t modem) {
switch(modem) {
case(ModemType_t::LoRa): {
return(this->begin());
} break;
case(ModemType_t::FSK): {
return(this->beginGFSK());
} break;
case(ModemType_t::LRFHSS): {
return(this->beginLRFHSS());
} break;
}
return(RADIOLIB_ERR_WRONG_MODEM);
}

#endif
8 changes: 8 additions & 0 deletions src/modules/LR11x0/LR1120.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ class LR1120: public LR11x0 {
*/
int16_t checkOutputPower(int8_t power, int8_t* clipped, bool forceHighPower);

/*!
\brief Set modem for the radio to use. Will perform full reset and reconfigure the radio
using its default parameters.
\param modem Modem type to set - FSK, LoRa or LR-FHSS.
\returns \ref status_codes
*/
int16_t setModem(ModemType_t modem) override;

#if !RADIOLIB_GODMODE
private:
#endif
Expand Down
24 changes: 24 additions & 0 deletions src/modules/LR11x0/LR11x0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2009,6 +2009,30 @@ int16_t LR11x0::getGnssSatellites(LR11x0GnssSatellite_t* sats, uint8_t numSats)
return(state);
}

int16_t LR11x0::getModem(ModemType_t* modem) {
if(!modem) {
return(RADIOLIB_ERR_MEMORY_ALLOCATION_FAILED);
}

uint8_t packetType = RADIOLIB_LR11X0_PACKET_TYPE_NONE;
int16_t state = getPacketType(&packetType);
RADIOLIB_ASSERT(state);

switch(packetType) {
case(RADIOLIB_LR11X0_PACKET_TYPE_LORA):
*modem = ModemType_t::LoRa;
return(RADIOLIB_ERR_NONE);
case(RADIOLIB_LR11X0_PACKET_TYPE_GFSK):
*modem = ModemType_t::FSK;
return(RADIOLIB_ERR_NONE);
case(RADIOLIB_LR11X0_PACKET_TYPE_LR_FHSS):
*modem = ModemType_t::LRFHSS;
return(RADIOLIB_ERR_NONE);
}

return(RADIOLIB_ERR_WRONG_MODEM);
}

int16_t LR11x0::modSetup(float tcxoVoltage, uint8_t modem) {
this->mod->init();
this->mod->hal->pinMode(this->mod->getIrq(), this->mod->hal->GpioModeInput);
Expand Down
7 changes: 7 additions & 0 deletions src/modules/LR11x0/LR11x0.h
Original file line number Diff line number Diff line change
Expand Up @@ -1602,6 +1602,13 @@ class LR11x0: public PhysicalLayer {
\returns \ref status_codes
*/
int16_t getGnssSatellites(LR11x0GnssSatellite_t* sats, uint8_t numSats);

/*!
\brief Get modem currently in use by the radio.
\param modem Pointer to a variable to save the retrieved configuration into.
\returns \ref status_codes
*/
int16_t getModem(ModemType_t* modem) override;

#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL
protected:
Expand Down
16 changes: 16 additions & 0 deletions src/modules/SX126x/SX1262.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,20 @@ int16_t SX1262::checkOutputPower(int8_t power, int8_t* clipped) {
return(RADIOLIB_ERR_NONE);
}

int16_t SX1262::setModem(ModemType_t modem) {
switch(modem) {
case(ModemType_t::LoRa): {
return(this->begin());
} break;
case(ModemType_t::FSK): {
return(this->beginFSK());
} break;
case(ModemType_t::LRFHSS): {
return(this->beginLRFHSS());
} break;
default:
return(RADIOLIB_ERR_WRONG_MODEM);
}
}

#endif
8 changes: 8 additions & 0 deletions src/modules/SX126x/SX1262.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ class SX1262: public SX126x {
\returns \ref status_codes
*/
int16_t checkOutputPower(int8_t power, int8_t* clipped) override;

/*!
\brief Set modem for the radio to use. Will perform full reset and reconfigure the radio
using its default parameters.
\param modem Modem type to set - FSK, LoRa or LR-FHSS.
\returns \ref status_codes
*/
int16_t setModem(ModemType_t modem) override;

#if !RADIOLIB_GODMODE
private:
Expand Down
16 changes: 16 additions & 0 deletions src/modules/SX126x/SX1268.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,20 @@ int16_t SX1268::checkOutputPower(int8_t power, int8_t* clipped) {
return(RADIOLIB_ERR_NONE);
}

int16_t SX1268::setModem(ModemType_t modem) {
switch(modem) {
case(ModemType_t::LoRa): {
return(this->begin());
} break;
case(ModemType_t::FSK): {
return(this->beginFSK());
} break;
case(ModemType_t::LRFHSS): {
return(this->beginLRFHSS());
} break;
default:
return(RADIOLIB_ERR_WRONG_MODEM);
}
}

#endif
8 changes: 8 additions & 0 deletions src/modules/SX126x/SX1268.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ class SX1268: public SX126x {
\returns \ref status_codes
*/
int16_t checkOutputPower(int8_t power, int8_t* clipped) override;

/*!
\brief Set modem for the radio to use. Will perform full reset and reconfigure the radio
using its default parameters.
\param modem Modem type to set - FSK, LoRa or LR-FHSS.
\returns \ref status_codes
*/
int16_t setModem(ModemType_t modem) override;

#if !RADIOLIB_GODMODE
private:
Expand Down
21 changes: 21 additions & 0 deletions src/modules/SX126x/SX126x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,27 @@ int16_t SX126x::invertIQ(bool enable) {
return(setPacketParams(this->preambleLengthLoRa, this->crcTypeLoRa, this->implicitLen, this->headerType, this->invertIQEnabled));
}

int16_t SX126x::getModem(ModemType_t* modem) {
if(!modem) {
return(RADIOLIB_ERR_MEMORY_ALLOCATION_FAILED);
}

uint8_t packetType = getPacketType();
switch(packetType) {
case(RADIOLIB_SX126X_PACKET_TYPE_LORA):
*modem = ModemType_t::LoRa;
return(RADIOLIB_ERR_NONE);
case(RADIOLIB_SX126X_PACKET_TYPE_GFSK):
*modem = ModemType_t::FSK;
return(RADIOLIB_ERR_NONE);
case(RADIOLIB_SX126X_PACKET_TYPE_LR_FHSS):
*modem = ModemType_t::LRFHSS;
return(RADIOLIB_ERR_NONE);
}

return(RADIOLIB_ERR_WRONG_MODEM);
}

#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
void SX126x::setDirectAction(void (*func)(void)) {
setDio1Action(func);
Expand Down
7 changes: 7 additions & 0 deletions src/modules/SX126x/SX126x.h
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,13 @@ class SX126x: public PhysicalLayer {
*/
int16_t invertIQ(bool enable) override;

/*!
\brief Get modem currently in use by the radio.
\param modem Pointer to a variable to save the retrieved configuration into.
\returns \ref status_codes
*/
int16_t getModem(ModemType_t* modem) override;

#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
/*!
\brief Set interrupt service routine function to call when data bit is received in direct mode.
Expand Down
13 changes: 13 additions & 0 deletions src/modules/SX127x/SX1272.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,4 +585,17 @@ void SX1272::errataFix(bool rx) {
mod->SPIsetRegValue(0x31, 0b10000000, 7, 7);
}

int16_t SX1272::setModem(ModemType_t modem) {
switch(modem) {
case(ModemType_t::LoRa): {
return(this->begin());
} break;
case(ModemType_t::FSK): {
return(this->beginFSK());
} break;
default:
return(RADIOLIB_ERR_WRONG_MODEM);
}
}

#endif
8 changes: 8 additions & 0 deletions src/modules/SX127x/SX1272.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,14 @@ class SX1272: public SX127x {
\returns \ref status_codes
*/
int16_t explicitHeader();

/*!
\brief Set modem for the radio to use. Will perform full reset and reconfigure the radio
using its default parameters.
\param modem Modem type to set - FSK or LoRa.
\returns \ref status_codes
*/
int16_t setModem(ModemType_t modem) override;

#if !RADIOLIB_GODMODE
protected:
Expand Down
13 changes: 13 additions & 0 deletions src/modules/SX127x/SX1273.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,17 @@ int16_t SX1273::checkDataRate(DataRate_t dr) {
return(state);
}

int16_t SX1273::setModem(ModemType_t modem) {
switch(modem) {
case(ModemType_t::LoRa): {
return(this->begin());
} break;
case(ModemType_t::FSK): {
return(this->beginFSK());
} break;
default:
return(RADIOLIB_ERR_WRONG_MODEM);
}
}

#endif
8 changes: 8 additions & 0 deletions src/modules/SX127x/SX1273.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ class SX1273: public SX1272 {
\returns \ref status_codes
*/
int16_t checkDataRate(DataRate_t dr) override;

/*!
\brief Set modem for the radio to use. Will perform full reset and reconfigure the radio
using its default parameters.
\param modem Modem type to set - FSK or LoRa.
\returns \ref status_codes
*/
int16_t setModem(ModemType_t modem) override;

#if !RADIOLIB_GODMODE
private:
Expand Down
Loading

0 comments on commit e44e9b4

Please sign in to comment.