diff --git a/src/STM32CubeWL/LICENSE.md b/src/STM32CubeWL/LICENSE.md index fb85584..21861a8 100644 --- a/src/STM32CubeWL/LICENSE.md +++ b/src/STM32CubeWL/LICENSE.md @@ -3,7 +3,7 @@ | CMSIS | ARM Limited | Apache-2.0 | | CMSIS Device | ARM Limited - STMicroelectronics | Apache-2.0 | | STM32WL HAL | STMicroelectronics | BSD-3-Clause | -| BSP NUCLEO-WL55JC | STMicroelectronics | BSD-3-Clause | +| STM32WLxx_Nucleo | STMicroelectronics | BSD-3-Clause | | B-WL5M-SUBG | STMicroelectronics | BSD-3-Clause | | BSP Components | STMicroelectronics | BSD-3-Clause | | FreeRTOS kernel | Amazon.com, Inc. or its affiliates | MIT | diff --git a/src/STM32CubeWL/LoRaWAN/CHANGELOG.md b/src/STM32CubeWL/LoRaWAN/CHANGELOG.md index d6c7c01..54b5a83 100644 --- a/src/STM32CubeWL/LoRaWAN/CHANGELOG.md +++ b/src/STM32CubeWL/LoRaWAN/CHANGELOG.md @@ -11,6 +11,68 @@ Please refer to [Releases pre-certification-results](https://github.com/Lora-net ## [Unreleased] +## [4.7.0] - 2022-12-09 + +### General + +- Release based on "LoRaWAN specification 1.0.4" and "LoRaWAN specification 1.1.0 + FCntDwn ERRATA" with "LoRaWAN Regional Parameters 2-1.0.3" +- GitHub reported issues corrections. + +### Known limitations + +- SAMR34 platform does not implement NVM storage functionality. This is a requirement for LoRaWAN versions greater or equal to 1.0.4. + No work on this subject is forseen by the maintainers. Implementation proposals are welcome. + +### Added + +- Trigger NVM update on `MacGroup2.DutyCycleOn` change +- Configure radio sync word upon state restoration from NVM +- Added missing return status initialization for Class A +- Added a check for `GroupId` in order to avoid out of bounds access +- Make LBT RSSI free channel threshold and carrier sense time (CST) parameters configurable +- Signal NVM data change in `LoRaMacMc*` functions +- Teach `LoRaMacIsBusy` return false if the MAC is stopped +- Added support for new release of ARIB STD-T108 Ver1.4 under AS923 region +- Support LoRaWAN 1.1 with ATECC608A/B secure element +- Added a function to reset the stack internal state machine +- Added an option for MAC commands to verify against an explicit confirmation +- Added a check to verify that `SystemMaxRxError` provided value is in the range 0..500 ms + +### Changed + +- Updated regions implementation to regional parameters RP2-1.0.3 +- Move AdrAckLimit and AdrAckDelay to NVM `MacGroup2` +- Refactored and improved the way the duty-cycle is managed + +### Fixed + +- Fixed class B multicast handling in `LoRaMacClassBProcessMulticastSlot()` +- Restore `RegionGroup2` in `RestoreNvmData` +- Fix a duty cycle related deadlock in `ScheduleTx` +- Fixed where `LastDownFCnt` update takes place for LoRaWAN 1.1.x +- Fixes for class C activation and deactivation +- Don't `memset` the TX/RX buffer when radio is set to receive mode +- Fixed usage of wrong API for general purpose keys +- Fixed and refactored JoinReq, `ReJoinType0Req`, `ReJoinType1Req`, `ReJoinType2Req` handling +- Fixed Rx windows timer handling +- Fixed FUOTA fragmentation implementation +- Fixed time credits check as proposed +- Fixed potential buffer overflow in `ProcessRadioRxDone` - [Security](###security) +- Applied the proposed fix for the CRC check of empty `struct` +- Fixed inconsistent handling of undefined callbacks +- Fixed `HardFault_Handler` for Cortex-M0 targets +- Fixed ABP join handling to be similar to OTAA join handling +- Fixed issue with RX2 data rate in case of 0x0F for `RxParamSetupReq` and `JoinAccept` + +### Removed + +- Removed useless `FOptsLen` filed check +- Removed unused `ACTIVE_REGION` pre-processing check + +### Security + +- Security breach found by Simon Worner(@SWW13) please refer to security advisory - [security advisory - CVE-2022-39274](https://github.com/Lora-net/LoRaMac-node/security/advisories/GHSA-7vv8-73pc-63c2) + ## [4.6.0] - 2022-01-11 ### General diff --git a/src/STM32CubeWL/LoRaWAN/Mac/LoRaMac.c b/src/STM32CubeWL/LoRaWAN/Mac/LoRaMac.c index 17fc628..f279972 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/LoRaMac.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/LoRaMac.c @@ -94,6 +94,11 @@ */ #define ADR_ACK_COUNTER_MAX 0xFFFFFFFF +/*! + * Delay required to simulate an ABP join like an OTAA join + */ +#define ABP_JOIN_PENDING_DELAY_MS 10 + #if defined(__ICCARM__) #ifndef __NO_INIT #define __NO_INIT __no_init @@ -119,14 +124,15 @@ static const uint8_t LoRaMacMaxEirpTable[] = { 8, 10, 12, 13, 14, 16, 18, 20, 21 */ enum eLoRaMacState { - LORAMAC_IDLE = 0x00000000, - LORAMAC_STOPPED = 0x00000001, - LORAMAC_TX_RUNNING = 0x00000002, - LORAMAC_RX = 0x00000004, - LORAMAC_ACK_RETRY = 0x00000010, - LORAMAC_TX_DELAYED = 0x00000020, - LORAMAC_TX_CONFIG = 0x00000040, - LORAMAC_RX_ABORT = 0x00000080, + LORAMAC_IDLE = 0x00000000, + LORAMAC_STOPPED = 0x00000001, + LORAMAC_TX_RUNNING = 0x00000002, + LORAMAC_RX = 0x00000004, + LORAMAC_ACK_RETRY = 0x00000010, + LORAMAC_TX_DELAYED = 0x00000020, + LORAMAC_TX_CONFIG = 0x00000040, + LORAMAC_RX_ABORT = 0x00000080, + LORAMAC_ABP_JOIN_PENDING = 0x00000100, }; /* @@ -314,6 +320,10 @@ typedef struct sLoRaMacCtx * Start time of the response timeout */ TimerTime_t ResponseTimeoutStartTime; + /* + * Timer required to simulate an ABP join like an OTAA join + */ + TimerEvent_t AbpJoinPendingTimer; #endif /* LORAMAC_VERSION */ /*! * Buffer containing the MAC layer commands @@ -1262,7 +1272,26 @@ static void ProcessRadioRxDone( void ) joinType = MLME_REJOIN_2; } #endif /* LORAMAC_VERSION */ +#if (defined( LORAMAC_VERSION ) && (( LORAMAC_VERSION == 0x01000400 ) || ( LORAMAC_VERSION == 0x01010100 ))) + if( LORAMAC_CRYPTO_SUCCESS == macCryptoStatus ) + { + VerifyParams_t verifyRxDr; + if( macMsgJoinAccept.DLSettings.Bits.RX2DataRate != 0x0F ) + { + verifyRxDr.DatarateParams.Datarate = macMsgJoinAccept.DLSettings.Bits.RX2DataRate; + verifyRxDr.DatarateParams.DownlinkDwellTime = Nvm.MacGroup2.MacParams.DownlinkDwellTime; + if( RegionVerify( Nvm.MacGroup2.Region, &verifyRxDr, PHY_RX_DR ) == false ) + { + // MLME handling + if( LoRaMacConfirmQueueIsCmdActive( MLME_JOIN ) == true ) + { + LoRaMacConfirmQueueSetStatus( LORAMAC_EVENT_INFO_STATUS_JOIN_FAIL, MLME_JOIN ); + } + break; + } + } +#else VerifyParams_t verifyRxDr; bool rxDrValid = false; verifyRxDr.DatarateParams.Datarate = macMsgJoinAccept.DLSettings.Bits.RX2DataRate; @@ -1271,6 +1300,8 @@ static void ProcessRadioRxDone( void ) if( ( LORAMAC_CRYPTO_SUCCESS == macCryptoStatus ) && ( rxDrValid == true ) ) { +#endif + // Network ID Nvm.MacGroup2.NetID = ( uint32_t ) macMsgJoinAccept.NetID[0]; Nvm.MacGroup2.NetID |= ( ( uint32_t ) macMsgJoinAccept.NetID[1] << 8 ); @@ -1283,8 +1314,18 @@ static void ProcessRadioRxDone( void ) // DLSettings Nvm.MacGroup2.MacParams.Rx1DrOffset = macMsgJoinAccept.DLSettings.Bits.RX1DRoffset; + +#if (defined( LORAMAC_VERSION ) && (( LORAMAC_VERSION == 0x01000400 ) || ( LORAMAC_VERSION == 0x01010100 ))) + // Verify if we shall assign the new datarate + if( macMsgJoinAccept.DLSettings.Bits.RX2DataRate != 0x0F ) + { +#endif + Nvm.MacGroup2.MacParams.Rx2Channel.Datarate = macMsgJoinAccept.DLSettings.Bits.RX2DataRate; Nvm.MacGroup2.MacParams.RxCChannel.Datarate = macMsgJoinAccept.DLSettings.Bits.RX2DataRate; +#if (defined( LORAMAC_VERSION ) && (( LORAMAC_VERSION == 0x01000400 ) || ( LORAMAC_VERSION == 0x01010100 ))) + } +#endif // RxDelay Nvm.MacGroup2.MacParams.ReceiveDelay1 = macMsgJoinAccept.RxDelay; @@ -1612,9 +1653,13 @@ static void ProcessRadioRxDone( void ) } // Set the pending status - /* if( ( ( ( Nvm.MacGroup1.SrvAckRequested == true ) || ( macMsgData.FHDR.FCtrl.Bits.FPending > 0 ) ) && ( Nvm.MacGroup2.DeviceClass == CLASS_A ) ) || - ( MacCtx.McpsIndication.ResponseTimeout > 0 ) ) */ - if( ( ( Nvm.MacGroup1.SrvAckRequested == true ) || ( macMsgData.FHDR.FCtrl.Bits.FPending > 0 ) ) && ( Nvm.MacGroup2.DeviceClass == CLASS_A ) ) + // Fix for Class C Certification test. Re-enabled part of if condition previously removed. + if( ( ( ( Nvm.MacGroup1.SrvAckRequested == true ) || ( macMsgData.FHDR.FCtrl.Bits.FPending > 0 ) ) && ( Nvm.MacGroup2.DeviceClass == CLASS_A ) ) +#if (defined( LORAMAC_VERSION ) && (( LORAMAC_VERSION == 0x01000400 ) || ( LORAMAC_VERSION == 0x01010100 ))) + || ( MacCtx.McpsIndication.ResponseTimeout > 0 ) +#endif /* LORAMAC_VERSION */ + ) + //if( ( ( Nvm.MacGroup1.SrvAckRequested == true ) || ( macMsgData.FHDR.FCtrl.Bits.FPending > 0 ) ) && ( Nvm.MacGroup2.DeviceClass == CLASS_A ) ) { MacCtx.McpsIndication.IsUplinkTxPending = 1; } @@ -2877,6 +2922,14 @@ static void ProcessMacCommands( uint8_t *payload, uint8_t macIndex, uint8_t comm rxParamSetupReq.Datarate = payload[macIndex] & 0x0F; macIndex++; +#if (defined( LORAMAC_VERSION ) && (( LORAMAC_VERSION == 0x01000400 ) || ( LORAMAC_VERSION == 0x01010100 ))) + if( rxParamSetupReq.Datarate == 0x0F ) + { + // Keep the current datarate + rxParamSetupReq.Datarate = Nvm.MacGroup2.MacParams.Rx2Channel.Datarate; + } +#endif + rxParamSetupReq.Frequency = ( uint32_t ) payload[macIndex++]; rxParamSetupReq.Frequency |= ( uint32_t ) payload[macIndex++] << 8; rxParamSetupReq.Frequency |= ( uint32_t ) payload[macIndex++] << 16; @@ -5734,7 +5787,18 @@ LoRaMacStatus_t LoRaMacMibSetRequestConfirm( MibRequestConfirm_t* mibSet ) } case MIB_SYSTEM_MAX_RX_ERROR: { +#if (defined( LORAMAC_VERSION ) && (( LORAMAC_VERSION == 0x01000400 ) || ( LORAMAC_VERSION == 0x01010100 ))) + if( mibSet->Param.SystemMaxRxError <= 500 ) + { // Only apply the new value if in range 0..500 ms else keep current value. + Nvm.MacGroup2.MacParams.SystemMaxRxError = Nvm.MacGroup2.MacParamsDefaults.SystemMaxRxError = mibSet->Param.SystemMaxRxError; + } + else + { + status = LORAMAC_STATUS_PARAMETER_INVALID; + } +#else Nvm.MacGroup2.MacParams.SystemMaxRxError = Nvm.MacGroup2.MacParamsDefaults.SystemMaxRxError = mibSet->Param.SystemMaxRxError; +#endif break; } case MIB_MIN_RX_SYMBOLS: @@ -6082,6 +6146,38 @@ LoRaMacStatus_t LoRaMacMcChannelSetupRxParams( AddressIdentifier_t groupID, McRx return LORAMAC_STATUS_OK; } +#if (defined( LORAMAC_VERSION ) && (( LORAMAC_VERSION == 0x01000400 ) || ( LORAMAC_VERSION == 0x01010100 ))) +/*! + * \brief Function executed on AbpJoinPendingTimer timer event + */ +static void OnAbpJoinPendingTimerEvent( void *context ) +{ + MacCtx.MacState &= ~LORAMAC_ABP_JOIN_PENDING; + MacCtx.MacFlags.Bits.MacDone = 1; + OnMacProcessNotify( ); +} + +/*! + * \brief Start ABP join simulation + */ +static void AbpJoinPendingStart( void ) +{ + static bool initialized = false; + + if( initialized == false ) + { + initialized = true; + TimerInit( &MacCtx.AbpJoinPendingTimer, OnAbpJoinPendingTimerEvent ); + } + + MacCtx.MacState |= LORAMAC_ABP_JOIN_PENDING; + + TimerStop( &MacCtx.AbpJoinPendingTimer ); + TimerSetValue( &MacCtx.AbpJoinPendingTimer, ABP_JOIN_PENDING_DELAY_MS ); + TimerStart( &MacCtx.AbpJoinPendingTimer ); +} +#endif /* LORAMAC_VERSION */ + LoRaMacStatus_t LoRaMacProcessMicForDatablock( uint8_t *buffer, uint32_t size, uint16_t sessionCnt, uint8_t fragIndex, uint32_t descriptor, uint32_t *mic ) { LoRaMacCryptoStatus_t macCryptoStatus = LORAMAC_CRYPTO_ERROR; @@ -6099,6 +6195,9 @@ LoRaMacStatus_t LoRaMacMlmeRequest( MlmeReq_t* mlmeRequest ) { LoRaMacStatus_t status = LORAMAC_STATUS_SERVICE_UNKNOWN; MlmeConfirmQueue_t queueElement; +#if (defined( LORAMAC_VERSION ) && (( LORAMAC_VERSION == 0x01000400 ) || ( LORAMAC_VERSION == 0x01010100 ))) + bool isAbpJoinPending = false; +#endif /* LORAMAC_VERSION */ uint8_t macCmdPayload[2] = { 0x00, 0x00 }; if( mlmeRequest == NULL ) @@ -6191,6 +6290,9 @@ LoRaMacStatus_t LoRaMacMlmeRequest( MlmeReq_t* mlmeRequest ) queueElement.ReadyToHandle = true; OnMacProcessNotify( ); MacCtx.MacFlags.Bits.MacDone = 1; +#if (defined( LORAMAC_VERSION ) && (( LORAMAC_VERSION == 0x01000400 ) || ( LORAMAC_VERSION == 0x01010100 ))) + isAbpJoinPending = true; +#endif status = LORAMAC_STATUS_OK; } #endif /* LORAMAC_VERSION */ @@ -6335,6 +6437,12 @@ LoRaMacStatus_t LoRaMacMlmeRequest( MlmeReq_t* mlmeRequest ) else { LoRaMacConfirmQueueAdd( &queueElement ); +#if (defined( LORAMAC_VERSION ) && (( LORAMAC_VERSION == 0x01000400 ) || ( LORAMAC_VERSION == 0x01010100 ))) + if( isAbpJoinPending == true ) + { + AbpJoinPendingStart( ); + } +#endif /* LORAMAC_VERSION */ } return status; } @@ -6681,4 +6789,22 @@ LoRaMacStatus_t LoRaMacDeInitialization( void ) } } +void LoRaMacReset( void ) +{ + // Reset state machine + MacCtx.MacState &= ~LORAMAC_TX_RUNNING; + MacCtx.MacFlags.Bits.MacDone = 1; + + // Stop Timers + TimerStop( &MacCtx.TxDelayedTimer ); + TimerStop( &MacCtx.RxWindowTimer1 ); + TimerStop( &MacCtx.RxWindowTimer2 ); + + // Stop retransmissions + MacCtx.ChannelsNbTransCounter = Nvm.MacGroup2.MacParams.ChannelsNbTrans; + + // Inform application layer + OnMacProcessNotify( ); +} + #pragma GCC diagnostic pop diff --git a/src/STM32CubeWL/LoRaWAN/Mac/LoRaMac.h b/src/STM32CubeWL/LoRaWAN/Mac/LoRaMac.h index 8b9f33f..27776d3 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/LoRaMac.h +++ b/src/STM32CubeWL/LoRaWAN/Mac/LoRaMac.h @@ -476,6 +476,14 @@ LoRaMacStatus_t LoRaMacDeInitialization( void ); LoRaMacStatus_t LoRaMacProcessMicForDatablock( uint8_t *buffer, uint32_t size, uint16_t sessionCnt, uint8_t fragIndex, uint32_t descriptor, uint32_t *mic ); + +/*! + * \brief Resets the internal state machine. + * + * \details Resets the internal state machine to force the MAC to finalize a procedure. + */ +void LoRaMacReset( void ); + /*! \} defgroup LORAMAC */ #ifdef __cplusplus diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/Region.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/Region.c index bc67f83..4d2177d 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/Region.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/Region.c @@ -34,7 +34,7 @@ #include "../LoRaMacInterfaces.h" #include "RegionVersion.h" -#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x01010003 ) || ( REGION_VERSION == 0x02010001 ))) +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x01010003 ) || ( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) #else #error REGION_VERSION not valid #endif /* REGION_VERSION */ diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/Region.h b/src/STM32CubeWL/LoRaWAN/Mac/Region/Region.h index 836cd27..829bf19 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/Region.h +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/Region.h @@ -169,7 +169,7 @@ typedef enum ePhyAttribute * Acknowledgement time out. */ PHY_ACK_TIMEOUT, -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) /*! * Acknowledgement time out. */ @@ -482,7 +482,7 @@ typedef struct sInitDefaultsParams * Pointer to region NVM group2. */ void* NvmGroup2; -#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) /*! * Pointer to common region band storage. */ @@ -536,7 +536,7 @@ typedef union uVerifyParams */ typedef struct sApplyCFListParams { -#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) uint8_t JoinChannel; #endif /* REGION_VERSION */ /*! @@ -613,7 +613,7 @@ typedef struct sRxConfigParams * Sets the RX window. */ LoRaMacRxSlot_t RxSlot; -#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) /*! * LoRaWAN Network End-Device Activation ( ACTIVATION_TYPE_NONE, ACTIVATION_TYPE_ABP * or ACTIVATION_TYPE_OTTA ) @@ -653,7 +653,7 @@ typedef struct sTxConfigParams * Frame length to setup. */ uint16_t PktLen; -#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) /*! * LoRaWAN Network End-Device Activation ( ACTIVATION_TYPE_NONE, ACTIVATION_TYPE_ABP * or ACTIVATION_TYPE_OTTA ) diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAS923.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAS923.c index 4a0313d..1792c19 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAS923.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAS923.c @@ -57,6 +57,12 @@ */ #define AS923_CARRIER_SENSE_TIME 5 +/*! + * Specifies the reception bandwidth to be used while executing the LBT + * Max channel bandwidth is 200 kHz + */ +#define AS923_LBT_RX_BANDWIDTH 200000 + #ifndef REGION_AS923_DEFAULT_CHANNEL_PLAN #define REGION_AS923_DEFAULT_CHANNEL_PLAN CHANNEL_PLAN_GROUP_AS923_1 #endif @@ -76,8 +82,13 @@ // -1.8MHz #define REGION_AS923_FREQ_OFFSET ( ( ~( 0xFFFFB9B0 ) + 1 ) * 100 ) +#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010003 )) +#define AS923_MIN_RF_FREQUENCY 920000000 +#define AS923_MAX_RF_FREQUENCY 923000000 +#else #define AS923_MIN_RF_FREQUENCY 915000000 #define AS923_MAX_RF_FREQUENCY 928000000 +#endif #elif ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_3 ) @@ -86,7 +97,11 @@ #define REGION_AS923_FREQ_OFFSET ( ( ~( 0xFFFEFE30 ) + 1 ) * 100 ) #define AS923_MIN_RF_FREQUENCY 915000000 +#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010003 )) +#define AS923_MAX_RF_FREQUENCY 921000000 +#else #define AS923_MAX_RF_FREQUENCY 928000000 +#endif #elif ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_4 ) @@ -97,7 +112,10 @@ #define AS923_MIN_RF_FREQUENCY 917000000 #define AS923_MAX_RF_FREQUENCY 920000000 -#elif ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP ) +#endif + +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x01010003 ) || ( REGION_VERSION == 0x02010001 ))) +#if ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP ) // Channel plan CHANNEL_PLAN_GROUP_AS923_1_JP @@ -128,7 +146,121 @@ #undef AS923_DEFAULT_DOWNLINK_DWELL_TIME #define AS923_DEFAULT_DOWNLINK_DWELL_TIME 0 -#endif /* REGION_AS923_DEFAULT_CHANNEL_PLAN */ +#endif //( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP ) + +#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010003 )) + +#if ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP_CH24_CH38_LBT ) + +// Channel plan CHANNEL_PLAN_GROUP_AS923_1_JP_CH24_CH38_LBT + +#define REGION_AS923_FREQ_OFFSET 0 + +/*! + * Restrict AS923 frequencies to channels 24 to 38 + * Center frequencies 920.6 MHz to 923.4 MHz @ 200 kHz max bandwidth + */ +#define AS923_MIN_RF_FREQUENCY 920600000 +#define AS923_MAX_RF_FREQUENCY 923400000 + +#undef AS923_TX_MAX_DATARATE +#define AS923_TX_MAX_DATARATE DR_5 + +#undef AS923_RX_MAX_DATARATE +#define AS923_RX_MAX_DATARATE DR_5 + +#undef AS923_DEFAULT_MAX_EIRP +#define AS923_DEFAULT_MAX_EIRP 13.0f + +/*! + * STD-T108 Ver1.4 does not require dwell-time enforcement when using LBT on channels 28 to 38 + */ +#undef AS923_DEFAULT_UPLINK_DWELL_TIME +#define AS923_DEFAULT_UPLINK_DWELL_TIME 0 + +#elif ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP_CH24_CH38_DC ) + +/* + * STD-T108 Ver1.4 allows the use of channels 24 to 38 without LBT. + * However a duty cycle enforcement must be in place + */ + +// Channel plan CHANNEL_PLAN_GROUP_AS923_1_JP_CH24_CH38_DC + +#define REGION_AS923_FREQ_OFFSET 0 + +/*! + * Restrict AS923 frequencies to channels 24 to 38 + * Center frequencies 920.6 MHz to 923.4 MHz @ 200 kHz max bandwidth + */ +#define AS923_MIN_RF_FREQUENCY 920600000 +#define AS923_MAX_RF_FREQUENCY 923400000 + +#undef AS923_TX_MAX_DATARATE +#define AS923_TX_MAX_DATARATE DR_5 + +#undef AS923_RX_MAX_DATARATE +#define AS923_RX_MAX_DATARATE DR_5 + +#undef AS923_DEFAULT_MAX_EIRP +#define AS923_DEFAULT_MAX_EIRP 13.0f + +/*! + * STD-T108 Ver1.4 does not require dwell-time enforcement when using DC on channels 28 to 38 + */ +#undef AS923_DEFAULT_UPLINK_DWELL_TIME +#define AS923_DEFAULT_UPLINK_DWELL_TIME 0 + +/*! + * Enable duty cycle enforcement + */ +#undef AS923_DUTY_CYCLE_ENABLED +#define AS923_DUTY_CYCLE_ENABLED 1 + +#elif ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP_CH37_CH61_LBT_DC ) + +/* + * STD-T108 Ver1.4 allows the use of channels 37 to 61 with LBT and DC. + * However dwell time enforcement must be enabled + */ + +// Channel plan CHANNEL_PLAN_GROUP_AS923_1_JP_CH37_CH61_LBT_DC + +#define REGION_AS923_FREQ_OFFSET 0 + +/*! + * Restrict AS923 frequencies to channels 37 to 61 + * Center frequencies 922.4 MHz to 928.0 MHz @ 200 kHz max bandwidth + */ +#define AS923_MIN_RF_FREQUENCY 922400000 +#define AS923_MAX_RF_FREQUENCY 928000000 + +#undef AS923_TX_MAX_DATARATE +#define AS923_TX_MAX_DATARATE DR_5 + +#undef AS923_RX_MAX_DATARATE +#define AS923_RX_MAX_DATARATE DR_5 + +#undef AS923_DEFAULT_MAX_EIRP +#define AS923_DEFAULT_MAX_EIRP 13.0f + +/*! + * Enable duty cycle enforcement + */ +#undef AS923_DUTY_CYCLE_ENABLED +#define AS923_DUTY_CYCLE_ENABLED 1 + +/*! + * STD-T108 Ver1.4 requires a carrier sense time of at least 128 us on channels 37 to 61 + */ +#undef AS923_CARRIER_SENSE_TIME +#define AS923_CARRIER_SENSE_TIME 1 + +#endif // REGION_AS923_DEFAULT_CHANNEL_PLAN +//#else +//#error "Wrong default channel plan selected. Please review compiler options." +//#endif +#endif //( REGION_VERSION == 0x02010003 )) #if defined( REGION_AS923 ) /* @@ -137,7 +269,7 @@ #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) static RegionNvmDataGroup1_t* RegionNvmGroup1; static RegionNvmDataGroup2_t* RegionNvmGroup2; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) // static RegionNvmDataGroup1_t* RegionNvmGroup1; /* Unused for this region */ static RegionNvmDataGroup2_t* RegionNvmGroup2; static Band_t* RegionBands; @@ -312,7 +444,7 @@ PhyParam_t RegionAS923GetPhyParam( GetPhyParams_t* getPhy ) phyParam.Value = ( REGION_COMMON_DEFAULT_ACK_TIMEOUT + randr( -REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND, REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND ) ); break; } -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) case PHY_RETRANSMIT_TIMEOUT: { phyParam.Value = ( REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT + randr( -REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT_RND, REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT_RND ) ); @@ -395,7 +527,7 @@ PhyParam_t RegionAS923GetPhyParam( GetPhyParams_t* getPhy ) { #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) phyParam.Value = AS923_PING_SLOT_CHANNEL_FREQ; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) phyParam.Value = AS923_PING_SLOT_CHANNEL_FREQ - REGION_AS923_FREQ_OFFSET; #endif /* REGION_VERSION */ break; @@ -431,7 +563,7 @@ void RegionAS923SetBandTxDone( SetBandTxDoneParams_t* txDone ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band], txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionCommonSetBandTxDone( &RegionBands[RegionNvmGroup2->Channels[txDone->Channel].Band], txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); #endif /* REGION_VERSION */ @@ -461,7 +593,7 @@ void RegionAS923InitDefaults( InitDefaultsParams_t* params ) // Default bands memcpy1( ( uint8_t* )RegionNvmGroup1->Bands, ( uint8_t* )bands, sizeof( Band_t ) * AS923_MAX_NB_BANDS ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionNvmGroup2 = (RegionNvmDataGroup2_t*) params->NvmGroup2; RegionBands = (Band_t*) params->Bands; @@ -483,7 +615,9 @@ void RegionAS923InitDefaults( InitDefaultsParams_t* params ) // Update the channels mask RegionCommonChanMaskCopy( RegionNvmGroup2->ChannelsMask, RegionNvmGroup2->ChannelsDefaultMask, CHANNELS_MASK_SIZE ); -#if ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP ) +#if ( ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP ) || \ + ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP_CH24_CH38_LBT ) || \ + ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP_CH37_CH61_LBT_DC ) ) RegionNvmGroup2->RssiFreeThreshold = AS923_RSSI_FREE_TH; RegionNvmGroup2->CarrierSenseTime = AS923_CARRIER_SENSE_TIME; #endif @@ -741,7 +875,7 @@ bool RegionAS923TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime int8_t phyDr = DataratesAS923[txConfig->Datarate]; #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) int8_t txPowerLimited = RegionCommonLimitTxPower( txConfig->TxPower, RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txConfig->Channel].Band].TxMaxPower ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) int8_t txPowerLimited = RegionCommonLimitTxPower( txConfig->TxPower, RegionBands[RegionNvmGroup2->Channels[txConfig->Channel].Band].TxMaxPower ); #endif /* REGION_VERSION */ uint32_t bandwidth = RegionCommonGetBandwidth( txConfig->Datarate, BandwidthsAS923 ); @@ -1036,7 +1170,7 @@ LoRaMacStatus_t RegionAS923NextChannel( NextChanParams_t* nextChanParams, uint8_ countChannelsParams.Channels = RegionNvmGroup2->Channels; #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) countChannelsParams.Bands = RegionNvmGroup1->Bands; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) countChannelsParams.Bands = RegionBands; #endif /* REGION_VERSION */ countChannelsParams.MaxNbChannels = AS923_MAX_NB_CHANNELS; @@ -1058,7 +1192,9 @@ LoRaMacStatus_t RegionAS923NextChannel( NextChanParams_t* nextChanParams, uint8_ if( status == LORAMAC_STATUS_OK ) { -#if ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP ) +#if (( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP ) || \ + ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP_CH24_CH38_LBT ) || \ + ( REGION_AS923_DEFAULT_CHANNEL_PLAN == CHANNEL_PLAN_GROUP_AS923_1_JP_CH37_CH61_LBT_DC ) ) // Executes the LBT algorithm when operating in Japan uint8_t channelNext = 0; @@ -1211,7 +1347,7 @@ uint8_t RegionAS923ApplyDrOffset( uint8_t downlinkDwellTime, int8_t dr, int8_t d #endif /* REGION_AS923 */ } -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) uint8_t RegionAS923ApplyDrOffset( uint8_t downlinkDwellTime, int8_t dr, int8_t drOffset ) { #if defined( REGION_AS923 ) diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAS923.h b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAS923.h index acc6a81..0cdaf86 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAS923.h +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAS923.h @@ -78,12 +78,33 @@ extern "C" */ #define CHANNEL_PLAN_GROUP_AS923_4 4 +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x01010003 ) || ( REGION_VERSION == 0x02010001 ))) /*! * Channel plan group AS923-1 for Japan * AS923_FREQ_OFFSET = 0 */ #define CHANNEL_PLAN_GROUP_AS923_1_JP 5 +#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010003 )) +/*! + * Channel plan group AS923-1 for Japan - channels 24 to 38 Listen Before Talk + * AS923_FREQ_OFFSET = 0 + */ +#define CHANNEL_PLAN_GROUP_AS923_1_JP_CH24_CH38_LBT 5 + +/*! + * Channel plan group AS923-1 for Japan - channels 24 to 38 Duty Cycle + * AS923_FREQ_OFFSET = 0 + */ +#define CHANNEL_PLAN_GROUP_AS923_1_JP_CH24_CH38_DC 6 + +/*! + * Channel plan group AS923-1 for Japan - channels 37 to 61 Listen Before Talk + Duty Cycle + * AS923_FREQ_OFFSET = 0 + */ +#define CHANNEL_PLAN_GROUP_AS923_1_JP_CH37_CH61_LBT_DC 7 +#endif + /*! * LoRaMac maximum number of channels */ @@ -165,7 +186,7 @@ extern "C" */ #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) #define AS923_DEFAULT_DOWNLINK_DWELL_TIME 1 -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) #define AS923_DEFAULT_DOWNLINK_DWELL_TIME REGION_COMMON_DEFAULT_DOWNLINK_DWELL_TIME #endif /* REGION_VERSION */ @@ -226,7 +247,7 @@ extern "C" */ #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) #define AS923_RFU1_SIZE 2 -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) #define AS923_RFU1_SIZE 1 #endif /* REGION_VERSION */ @@ -294,7 +315,7 @@ static const uint32_t BandwidthsAS923[] = { 125000, 125000, 125000, 125000, 1250 */ #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) static const uint8_t MaxPayloadOfDatarateDwell0AS923[] = { 51, 51, 51, 115, 242, 242, 242, 242 }; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) static const uint8_t MaxPayloadOfDatarateDwell0AS923[] = { 51, 51, 115, 115, 242, 242, 242, 242 }; #endif /* REGION_VERSION */ @@ -304,7 +325,7 @@ static const uint8_t MaxPayloadOfDatarateDwell0AS923[] = { 51, 51, 115, 115, 242 */ #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) static const uint8_t MaxPayloadOfDatarateRepeaterDwell0AS923[] = { 51, 51, 51, 115, 222, 222, 222, 222 }; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) static const uint8_t MaxPayloadOfDatarateRepeaterDwell0AS923[] = { 51, 51, 115, 115, 222, 222, 222, 222 }; #endif /* REGION_VERSION */ @@ -319,7 +340,7 @@ static const uint8_t MaxPayloadOfDatarateDwell1AS923[] = { 0, 0, 11, 53, 125, 24 * Effective datarate offsets for receive window 1. */ static const int8_t EffectiveRx1DrOffsetAS923[] = { 0, 1, 2, 3, 4, 5, -1, -2 }; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) /*! * Effective datarate offsets for receive window 1 when downlink dwell time is zero. */ diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAU915.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAU915.c index 34274f0..e569fd4 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAU915.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAU915.c @@ -75,7 +75,7 @@ */ static RegionNvmDataGroup1_t* RegionNvmGroup1; static RegionNvmDataGroup2_t* RegionNvmGroup2; -#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) static Band_t* RegionBands; #endif /* REGION_VERSION */ @@ -248,7 +248,7 @@ PhyParam_t RegionAU915GetPhyParam( GetPhyParams_t* getPhy ) phyParam.Value = ( REGION_COMMON_DEFAULT_ACK_TIMEOUT + randr( -REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND, REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND ) ); break; } -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) case PHY_RETRANSMIT_TIMEOUT: { phyParam.Value = ( REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT + randr( -REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT_RND, REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT_RND ) ); @@ -377,7 +377,7 @@ void RegionAU915SetBandTxDone( SetBandTxDoneParams_t* txDone ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band], txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionCommonSetBandTxDone( &RegionBands[RegionNvmGroup2->Channels[txDone->Channel].Band], txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); #endif /* REGION_VERSION */ @@ -403,7 +403,7 @@ void RegionAU915InitDefaults( InitDefaultsParams_t* params ) RegionNvmGroup1 = (RegionNvmDataGroup1_t*) params->NvmGroup1; RegionNvmGroup2 = (RegionNvmDataGroup2_t*) params->NvmGroup2; -#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionBands = (Band_t*) params->Bands; #endif /* REGION_VERSION */ @@ -416,7 +416,7 @@ void RegionAU915InitDefaults( InitDefaultsParams_t* params ) // Default bands #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) memcpy1( ( uint8_t* )RegionNvmGroup1->Bands, ( uint8_t* )bands, sizeof( Band_t ) * AU915_MAX_NB_BANDS ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) memcpy1( ( uint8_t* )RegionBands, ( uint8_t* )bands, sizeof( Band_t ) * AU915_MAX_NB_BANDS ); #endif /* REGION_VERSION */ @@ -662,7 +662,7 @@ bool RegionAU915TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime int8_t phyDr = DataratesAU915[txConfig->Datarate]; #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) int8_t txPowerLimited = RegionCommonLimitTxPower( txConfig->TxPower, RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txConfig->Channel].Band].TxMaxPower ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) int8_t txPowerLimited = RegionCommonLimitTxPower( txConfig->TxPower, RegionBands[RegionNvmGroup2->Channels[txConfig->Channel].Band].TxMaxPower ); #endif /* REGION_VERSION */ uint32_t bandwidth = RegionCommonGetBandwidth( txConfig->Datarate, BandwidthsAU915 ); @@ -965,7 +965,7 @@ LoRaMacStatus_t RegionAU915NextChannel( NextChanParams_t* nextChanParams, uint8_ countChannelsParams.Channels = RegionNvmGroup2->Channels; #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) countChannelsParams.Bands = RegionNvmGroup1->Bands; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) countChannelsParams.Bands = RegionBands; #endif /* REGION_VERSION */ countChannelsParams.MaxNbChannels = AU915_MAX_NB_CHANNELS; diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAU915.h b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAU915.h index f2f429e..aa4a67c 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAU915.h +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionAU915.h @@ -69,7 +69,7 @@ extern "C" * Maximal datarate that can be used by the node */ #define AU915_TX_MAX_DATARATE DR_6 -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) /*! * Maximal datarate that can be used by the node */ @@ -198,7 +198,7 @@ extern "C" */ #define AU915_RFU2_SIZE 1 /* #define AU915_RFU2_SIZE 3 */ -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) /*! * Payload size of a beacon frame */ @@ -305,7 +305,7 @@ static const uint8_t MaxPayloadOfDatarateDwell1AU915[] = { 0, 0, 11, 53, 125, 24 */ #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) static const uint8_t MaxPayloadOfDatarateRepeaterDwell1AU915[] = { 0, 0, 11, 53, 125, 242, 242, 0, 33, 109, 222, 222, 222, 222 }; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) static const uint8_t MaxPayloadOfDatarateRepeaterDwell1AU915[] = { 0, 0, 11, 53, 125, 222, 222, 0, 33, 109, 222, 222, 222, 222 }; #endif /* REGION_VERSION */ diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN470.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN470.c index a6a82e3..caf1cc1 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN470.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN470.c @@ -45,7 +45,7 @@ #include "RegionCN470.h" #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) #include "RegionBaseUS.h" -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) #include "RegionCN470A20.h" #include "RegionCN470B20.h" #include "RegionCN470A26.h" @@ -76,7 +76,7 @@ #define HYBRID_DEFAULT_MASK5 0x0000 #endif -#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) #ifndef REGION_CN470_DEFAULT_CHANNEL_PLAN #define REGION_CN470_DEFAULT_CHANNEL_PLAN CHANNEL_PLAN_20MHZ_TYPE_A #endif @@ -191,7 +191,7 @@ typedef struct sRegionCN470ChannelPlanCtx */ static RegionNvmDataGroup1_t* RegionNvmGroup1; static RegionNvmDataGroup2_t* RegionNvmGroup2; -#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) static Band_t* RegionBands; /* @@ -336,7 +336,7 @@ static bool VerifyRfFreq( uint32_t freq ) } return true; } -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) static bool VerifyRfFreq( uint32_t frequency ) { // Check radio driver support @@ -465,7 +465,7 @@ PhyParam_t RegionCN470GetPhyParam( GetPhyParams_t* getPhy ) phyParam.Value = ( REGION_COMMON_DEFAULT_ACK_TIMEOUT + randr( -REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND, REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND ) ); break; } -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) case PHY_RETRANSMIT_TIMEOUT: { phyParam.Value = ( REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT + randr( -REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT_RND, REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT_RND ) ); @@ -481,7 +481,7 @@ PhyParam_t RegionCN470GetPhyParam( GetPhyParams_t* getPhy ) { #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) phyParam.Value = CN470_RX_WND_2_FREQ; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) phyParam.Value = REGION_CN470_DEFAULT_RX_WND_2_FREQ; if( RegionNvmGroup2->ChannelPlan != CHANNEL_PLAN_UNKNOWN ) @@ -542,7 +542,7 @@ PhyParam_t RegionCN470GetPhyParam( GetPhyParams_t* getPhy ) phyParam.Value = RegionBaseUSCalcDownlinkFrequency( getPhy->Channel, CN470_BEACON_CHANNEL_FREQ, CN470_BEACON_CHANNEL_STEPWIDTH ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) phyParam.Value = REGION_CN470_DEFAULT_RX_WND_2_FREQ; // Implementation depending on the join channel @@ -590,7 +590,7 @@ PhyParam_t RegionCN470GetPhyParam( GetPhyParams_t* getPhy ) phyParam.Value = CN470_BEACON_NB_CHANNELS; break; } -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) case PHY_BEACON_NB_CHANNELS: { // Implementation depending on the join channel @@ -664,7 +664,7 @@ void RegionCN470SetBandTxDone( SetBandTxDoneParams_t* txDone ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band], txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionCommonSetBandTxDone( &RegionBands[RegionNvmGroup2->Channels[txDone->Channel].Band], txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); #endif /* REGION_VERSION */ @@ -723,7 +723,7 @@ void RegionCN470InitDefaults( InitDefaultsParams_t* params ) // Copy channels default mask RegionCommonChanMaskCopy( RegionNvmGroup2->ChannelsMask, RegionNvmGroup2->ChannelsDefaultMask, CHANNELS_MASK_SIZE ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionBands = (Band_t*) params->Bands; // Default bands @@ -760,7 +760,7 @@ void RegionCN470InitDefaults( InitDefaultsParams_t* params ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) // Copy channels default mask RegionCommonChanMaskCopy( RegionNvmGroup2->ChannelsMask, RegionNvmGroup2->ChannelsDefaultMask, CHANNELS_MASK_SIZE ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) // Restore channels default mask RegionCommonChanMaskCopy( RegionNvmGroup2->ChannelsMask, RegionNvmGroup2->ChannelsDefaultMask, CHANNELS_MASK_SIZE ); @@ -818,7 +818,7 @@ bool RegionCN470Verify( VerifyParams_t* verify, PhyAttribute_t phyAttribute ) void RegionCN470ApplyCFList( ApplyCFListParams_t* applyCFList ) { #if defined( REGION_CN470 ) -#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) // Setup the channel plan based on the join channel RegionNvmGroup2->CommonJoinChannelIndex = applyCFList->JoinChannel; RegionNvmGroup2->IsOtaaDevice = true; @@ -852,7 +852,7 @@ void RegionCN470ApplyCFList( ApplyCFListParams_t* applyCFList ) RegionNvmGroup2->ChannelsMask[chMaskItr] = (uint16_t) (0x00FF & applyCFList->Payload[cntPayload]); RegionNvmGroup2->ChannelsMask[chMaskItr] |= (uint16_t) (applyCFList->Payload[cntPayload+1] << 8); } -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) for( uint8_t chMaskItr = 0, cntPayload = 0; chMaskItr < ChannelPlanCtx.JoinAcceptListSize; chMaskItr++, cntPayload+=2 ) { RegionNvmGroup2->ChannelsMask[chMaskItr] = (uint16_t) (0x00FF & applyCFList->Payload[cntPayload]); @@ -874,7 +874,7 @@ bool RegionCN470ChanMaskSet( ChanMaskSetParams_t* chanMaskSet ) { RegionCommonChanMaskCopy( RegionNvmGroup2->ChannelsMask, chanMaskSet->ChannelsMaskIn, CHANNELS_MASK_SIZE ); -#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) for( uint8_t i = 0; i < CHANNELS_MASK_SIZE; i++ ) { // Copy-And the channels mask RegionNvmGroup1->ChannelsMaskRemaining[i] &= RegionNvmGroup2->ChannelsMask[i]; @@ -930,7 +930,7 @@ bool RegionCN470RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate ) // Apply window 1 frequency frequency = CN470_FIRST_RX1_CHANNEL + ( rxConfig->Channel % 48 ) * CN470_STEPWIDTH_RX1_CHANNEL; } -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) // The RX configuration depends on whether the device has joined or not. if( rxConfig->NetworkActivation != ACTIVATION_TYPE_NONE ) { @@ -1001,7 +1001,7 @@ bool RegionCN470TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime // Setup maximum payload length of the radio driver Radio.SetMaxPayloadLength( MODEM_LORA, txConfig->PktLen ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RadioModems_t modem; uint32_t frequency; uint8_t band; @@ -1112,7 +1112,7 @@ uint8_t RegionCN470LinkAdrReq( LinkAdrReqParams_t* linkAdrReq, int8_t* drOut, in channelsMask[linkAdrParams.ChMaskCtrl] = linkAdrParams.ChMask; } } -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) while( bytesProcessed < linkAdrReq->PayloadSize ) { // Get ADR request parameters @@ -1274,7 +1274,7 @@ LoRaMacStatus_t RegionCN470NextChannel( NextChanParams_t* nextChanParams, uint8_ countChannelsParams.Bands = RegionNvmGroup1->Bands; countChannelsParams.MaxNbChannels = CN470_MAX_NB_CHANNELS; countChannelsParams.JoinChannels = NULL; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) uint8_t nbEnabledChannels = 0; uint8_t nbRestrictedChannels = 0; uint8_t enabledChannels[CN470_MAX_NB_CHANNELS] = { 0 }; @@ -1335,7 +1335,7 @@ LoRaMacStatus_t RegionCN470NextChannel( NextChanParams_t* nextChanParams, uint8_ // We found a valid channel. Selection is random. *channel = enabledChannels[randr( 0, nbEnabledChannels - 1 )]; -#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) // Disable the channel in the mask RegionCommonChanDisable( RegionNvmGroup1->ChannelsMaskRemaining, *channel, ChannelPlanCtx.ChannelsMaskSize ); #endif /* REGION_VERSION */ @@ -1377,7 +1377,7 @@ uint8_t RegionCN470ApplyDrOffset( uint8_t downlinkDwellTime, int8_t dr, int8_t d #if defined( REGION_CN470 ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) int8_t datarate = dr - drOffset; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) int8_t datarate = DatarateOffsetsCN470[dr][drOffset]; #endif /* REGION_VERSION */ if( datarate < 0 ) diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN470.h b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN470.h index 124895e..0e270ea 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN470.h +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN470.h @@ -84,7 +84,7 @@ extern "C" * Default datarate used by the node */ #define CN470_DEFAULT_DATARATE DR_0 -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) /*! * Minimal datarate that can be used by the node */ @@ -166,7 +166,7 @@ extern "C" * Second reception window channel datarate definition. */ #define CN470_RX_WND_2_DR DR_0 -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) /*! * Second reception window channel datarate definition. */ @@ -211,7 +211,7 @@ extern "C" * Size of RFU 1 field */ #define CN470_RFU1_SIZE 3 -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) /*! * Payload size of a beacon frame */ @@ -269,7 +269,7 @@ extern "C" */ #define CN470_STEPWIDTH_RX1_CHANNEL ( (uint32_t) 200000 ) -#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) #define CN470_DEFAULT_DR_RANGE { .Value = ( CN470_TX_MAX_DATARATE << 4 ) | CN470_TX_MIN_DATARATE } #define CN470_COMMON_JOIN_CHANNELS \ @@ -328,7 +328,7 @@ static const uint8_t MaxPayloadOfDatarateCN470[] = { 51, 51, 51, 115, 242, 242 } * Maximum payload with respect to the datarate index. Can operate with repeater. */ static const uint8_t MaxPayloadOfDatarateRepeaterCN470[] = { 51, 51, 51, 115, 222, 222 }; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) /*! * Data rates table definition */ diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN779.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN779.c index 00a642a..ffc32b4 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN779.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN779.c @@ -54,7 +54,7 @@ #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) static RegionNvmDataGroup1_t* RegionNvmGroup1; static RegionNvmDataGroup2_t* RegionNvmGroup2; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) // static RegionNvmDataGroup1_t* RegionNvmGroup1; /* Unused for this region */ static RegionNvmDataGroup2_t* RegionNvmGroup2; static Band_t* RegionBands; @@ -201,7 +201,7 @@ PhyParam_t RegionCN779GetPhyParam( GetPhyParams_t* getPhy ) phyParam.Value = ( REGION_COMMON_DEFAULT_ACK_TIMEOUT + randr( -REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND, REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND ) ); break; } -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) case PHY_RETRANSMIT_TIMEOUT: { phyParam.Value = ( REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT + randr( -REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT_RND, REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT_RND ) ); @@ -316,7 +316,7 @@ void RegionCN779SetBandTxDone( SetBandTxDoneParams_t* txDone ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band], txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionCommonSetBandTxDone( &RegionBands[RegionNvmGroup2->Channels[txDone->Channel].Band], txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); #endif /* REGION_VERSION */ @@ -346,7 +346,7 @@ void RegionCN779InitDefaults( InitDefaultsParams_t* params ) // Default bands memcpy1( ( uint8_t* )RegionNvmGroup1->Bands, ( uint8_t* )bands, sizeof( Band_t ) * CN779_MAX_NB_BANDS ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionNvmGroup2 = (RegionNvmDataGroup2_t*) params->NvmGroup2; RegionBands = (Band_t*) params->Bands; @@ -604,7 +604,7 @@ bool RegionCN779TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime int8_t phyDr = DataratesCN779[txConfig->Datarate]; #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) int8_t txPowerLimited = RegionCommonLimitTxPower( txConfig->TxPower, RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txConfig->Channel].Band].TxMaxPower ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) int8_t txPowerLimited = RegionCommonLimitTxPower( txConfig->TxPower, RegionBands[RegionNvmGroup2->Channels[txConfig->Channel].Band].TxMaxPower ); #endif /* REGION_VERSION */ uint32_t bandwidth = RegionCommonGetBandwidth( txConfig->Datarate, BandwidthsCN779 ); @@ -894,7 +894,7 @@ LoRaMacStatus_t RegionCN779NextChannel( NextChanParams_t* nextChanParams, uint8_ countChannelsParams.Channels = RegionNvmGroup2->Channels; #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) countChannelsParams.Bands = RegionNvmGroup1->Bands; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) countChannelsParams.Bands = RegionBands; #endif /* REGION_VERSION */ countChannelsParams.MaxNbChannels = CN779_MAX_NB_CHANNELS; diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN779.h b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN779.h index 4850c6d..e804009 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN779.h +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCN779.h @@ -184,7 +184,7 @@ extern "C" */ #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) #define CN779_RFU1_SIZE 2 -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) #define CN779_RFU1_SIZE 1 #endif /* REGION_VERSION */ diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCommon.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCommon.c index 826a25e..93f76ef 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCommon.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCommon.c @@ -65,8 +65,19 @@ * defined duty-cycle restrictions. In order to ensure that these restrictions never get violated we changed the * default duty cycle observation time period to 1/2 hour (1800000 ms). */ +#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010003 )) +#define DUTY_CYCLE_TIME_PERIOD 3600000 +#else #define DUTY_CYCLE_TIME_PERIOD 1800000 #endif +#endif + +#ifndef DUTY_CYCLE_TIME_PERIOD_JOIN_BACKOFF_24H +/*! + * Time credits for the join backoff algorithm for the 24H period. + */ +#define DUTY_CYCLE_TIME_PERIOD_JOIN_BACKOFF_24H 870000 +#endif /*! * \brief Returns `N / D` rounded to the smallest integer value greater than or equal to `N / D` @@ -96,6 +107,9 @@ static uint16_t GetDutyCycle( Band_t* band, bool joined, SysTime_t elapsedTimeSi if( joined == false ) { +#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010003 )) + uint16_t joinDutyCycle = BACKOFF_DC_1_HOUR; +#else uint16_t joinDutyCycle = BACKOFF_DC_24_HOURS; if( elapsedTimeSinceStartup.Seconds < BACKOFF_DUTY_CYCLE_1_HOUR_IN_S ) @@ -110,6 +124,7 @@ static uint16_t GetDutyCycle( Band_t* band, bool joined, SysTime_t elapsedTimeSi { joinDutyCycle = BACKOFF_DC_24_HOURS; } +#endif // Take the most restrictive duty cycle dutyCycle = MAX( dutyCycle, joinDutyCycle ); } @@ -128,8 +143,6 @@ static uint16_t SetMaxTimeCredits( Band_t* band, bool joined, SysTime_t elapsedT { uint16_t dutyCycle = band->DCycle; TimerTime_t maxCredits = DUTY_CYCLE_TIME_PERIOD; - TimerTime_t elapsedTime = SysTimeToMs( elapsedTimeSinceStartup ); - SysTime_t timeDiff = { 0 }; // Get the band duty cycle. If not joined, the function either returns the join duty cycle // or the band duty cycle, whichever is more restrictive. @@ -137,6 +150,22 @@ static uint16_t SetMaxTimeCredits( Band_t* band, bool joined, SysTime_t elapsedT if( joined == false ) { +#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010003 )) + if( elapsedTimeSinceStartup.Seconds < BACKOFF_DUTY_CYCLE_1_HOUR_IN_S ) + { + maxCredits = DUTY_CYCLE_TIME_PERIOD; + } + else if( elapsedTimeSinceStartup.Seconds < BACKOFF_DUTY_CYCLE_10_HOURS_IN_S ) + { + maxCredits = DUTY_CYCLE_TIME_PERIOD; + } + else + { + maxCredits = DUTY_CYCLE_TIME_PERIOD_JOIN_BACKOFF_24H; + } +#else + TimerTime_t elapsedTime = SysTimeToMs( elapsedTimeSinceStartup ); + SysTime_t timeDiff = { 0 }; if( dutyCycle == BACKOFF_DC_1_HOUR ) { maxCredits = DUTY_CYCLE_TIME_PERIOD; @@ -171,6 +200,8 @@ static uint16_t SetMaxTimeCredits( Band_t* band, bool joined, SysTime_t elapsedT band->LastMaxCreditAssignTime = SysTimeToMs( timeDiff ); } } +#endif + } else { @@ -181,11 +212,13 @@ static uint16_t SetMaxTimeCredits( Band_t* band, bool joined, SysTime_t elapsedT } } +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x01010003 ) || ( REGION_VERSION == 0x02010001 ))) // Assign the max credits if its the first time if( band->LastBandUpdateTime == 0 ) { band->TimeCredits = maxCredits; } +#endif // Setup the maximum allowed credits. We can assign them // safely all the time. @@ -194,6 +227,44 @@ static uint16_t SetMaxTimeCredits( Band_t* band, bool joined, SysTime_t elapsedT return dutyCycle; } + +#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010003 )) +static uint16_t UpdateTimeCredits( Band_t* band, bool joined, bool dutyCycleEnabled, + bool lastTxIsJoinRequest, SysTime_t elapsedTimeSinceStartup, + TimerTime_t currentTime, TimerTime_t lastBandUpdateTime ) +{ + uint16_t dutyCycle = SetMaxTimeCredits( band, joined, elapsedTimeSinceStartup, + dutyCycleEnabled, lastTxIsJoinRequest ); + TimerTime_t observation = DUTY_CYCLE_TIME_PERIOD; + + if( joined == false ) + { + if( elapsedTimeSinceStartup.Seconds < BACKOFF_DUTY_CYCLE_1_HOUR_IN_S ) + { + observation = BACKOFF_DUTY_CYCLE_1_HOUR_IN_S * 1000; + } + else if( elapsedTimeSinceStartup.Seconds < BACKOFF_DUTY_CYCLE_10_HOURS_IN_S ) + { + observation = ( BACKOFF_DUTY_CYCLE_10_HOURS_IN_S * 1000 ); + } + else + { + observation = ( BACKOFF_DUTY_CYCLE_24_HOURS_IN_S * 1000 ); + } + } + + // Apply new credits only if the observation period has been elapsed. + if( ( observation <= lastBandUpdateTime ) || + ( band->LastMaxCreditAssignTime != observation ) || + ( band->LastBandUpdateTime == 0 ) ) + { + band->TimeCredits = band->MaxTimeCredits; + band->LastBandUpdateTime = currentTime; + band->LastMaxCreditAssignTime = observation; + } + return dutyCycle; +} +#else static uint16_t UpdateTimeCredits( Band_t* band, bool joined, bool dutyCycleEnabled, bool lastTxIsJoinRequest, SysTime_t elapsedTimeSinceStartup, TimerTime_t currentTime ) @@ -219,6 +290,7 @@ static uint16_t UpdateTimeCredits( Band_t* band, bool joined, bool dutyCycleEnab return dutyCycle; } +#endif static uint8_t CountChannels( uint16_t mask, uint8_t nbBits ) { @@ -342,10 +414,19 @@ TimerTime_t RegionCommonUpdateBandTimeOff( bool joined, Band_t* bands, for( uint8_t i = 0; i < nbBands; i++ ) { +#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010003 )) + TimerTime_t elapsedTime = TimerGetElapsedTime( bands[i].LastBandUpdateTime ); + + // Synchronization of bands and credits + dutyCycle = UpdateTimeCredits( &bands[i], joined, dutyCycleEnabled, + lastTxIsJoinRequest, elapsedTimeSinceStartup, + currentTime, elapsedTime ); +#else // Synchronization of bands and credits dutyCycle = UpdateTimeCredits( &bands[i], joined, dutyCycleEnabled, lastTxIsJoinRequest, elapsedTimeSinceStartup, currentTime ); +#endif // Calculate the credit costs for the next transmission // with the duty cycle and the expected time on air @@ -354,7 +435,7 @@ TimerTime_t RegionCommonUpdateBandTimeOff( bool joined, Band_t* bands, // Check if the band is ready for transmission. Its ready, // when the duty cycle is off, or the TimeCredits of the band // is higher than the credit costs for the transmission. - if( ( bands[i].TimeCredits >= creditCosts ) || + if( ( bands[i].TimeCredits > creditCosts ) || ( ( dutyCycleEnabled == false ) && ( joined == true ) ) ) { bands[i].ReadyForTransmission = true; @@ -368,20 +449,31 @@ TimerTime_t RegionCommonUpdateBandTimeOff( bool joined, Band_t* bands, // for the next transmission. bands[i].ReadyForTransmission = false; - if( bands[i].MaxTimeCredits >= creditCosts ) + if( bands[i].MaxTimeCredits > creditCosts ) { // The band can only be taken into account, if the maximum credits // of the band are higher than the credit costs. // We calculate the minTimeToWait among the bands which are not // ready for transmission and which are potentially available // for a transmission in the future. +#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010003 )) + TimerTime_t observationTimeDiff = 0; + if( bands[i].LastMaxCreditAssignTime >= elapsedTime ) + { + observationTimeDiff = bands[i].LastMaxCreditAssignTime - elapsedTime; + } + minTimeToWait = MIN( minTimeToWait, observationTimeDiff ); +#else minTimeToWait = MIN( minTimeToWait, ( creditCosts - bands[i].TimeCredits ) ); +#endif + // This band is a potential candidate for an // upcoming transmission (even if its time credits are not enough // at the moment), so increase the counter. validBands++; } +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x01010003 ) || ( REGION_VERSION == 0x02010001 ))) // Apply a special calculation if the device is not joined. if( joined == false ) { @@ -411,6 +503,8 @@ TimerTime_t RegionCommonUpdateBandTimeOff( bool joined, Band_t* bands, backoffTimeRange = SysTimeSub( backoffTimeRange, elapsedTimeSinceStartup ); minTimeToWait = SysTimeToMs( backoffTimeRange ); } +#endif + } } diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCommon.h b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCommon.h index 162c136..2cb7ad0 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCommon.h +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionCommon.h @@ -105,7 +105,7 @@ extern "C" * In milliseconds. */ #define REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND 1000 -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) /*! * Retransmission timeout for ACK in milliseconds. */ diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU433.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU433.c index a390e65..30e26ce 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU433.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU433.c @@ -54,7 +54,7 @@ #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) static RegionNvmDataGroup1_t* RegionNvmGroup1; static RegionNvmDataGroup2_t* RegionNvmGroup2; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) // static RegionNvmDataGroup1_t* RegionNvmGroup1; /* Unused for this region */ static RegionNvmDataGroup2_t* RegionNvmGroup2; static Band_t* RegionBands; @@ -201,7 +201,7 @@ PhyParam_t RegionEU433GetPhyParam( GetPhyParams_t* getPhy ) phyParam.Value = ( REGION_COMMON_DEFAULT_ACK_TIMEOUT + randr( -REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND, REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND ) ); break; } -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) case PHY_RETRANSMIT_TIMEOUT: { phyParam.Value = ( REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT + randr( -REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT_RND, REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT_RND ) ); @@ -316,7 +316,7 @@ void RegionEU433SetBandTxDone( SetBandTxDoneParams_t* txDone ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band], txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionCommonSetBandTxDone( &RegionBands[RegionNvmGroup2->Channels[txDone->Channel].Band], txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); #endif /* REGION_VERSION */ @@ -346,7 +346,7 @@ void RegionEU433InitDefaults( InitDefaultsParams_t* params ) // Default bands memcpy1( ( uint8_t* )RegionNvmGroup1->Bands, ( uint8_t* )bands, sizeof( Band_t ) * EU433_MAX_NB_BANDS ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionNvmGroup2 = (RegionNvmDataGroup2_t*) params->NvmGroup2; RegionBands = (Band_t*) params->Bands; @@ -604,7 +604,7 @@ bool RegionEU433TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime int8_t phyDr = DataratesEU433[txConfig->Datarate]; #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) int8_t txPowerLimited = RegionCommonLimitTxPower( txConfig->TxPower, RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txConfig->Channel].Band].TxMaxPower ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) int8_t txPowerLimited = RegionCommonLimitTxPower( txConfig->TxPower, RegionBands[RegionNvmGroup2->Channels[txConfig->Channel].Band].TxMaxPower ); #endif /* REGION_VERSION */ uint32_t bandwidth = RegionCommonGetBandwidth( txConfig->Datarate, BandwidthsEU433 ); @@ -898,7 +898,7 @@ LoRaMacStatus_t RegionEU433NextChannel( NextChanParams_t* nextChanParams, uint8_ countChannelsParams.Channels = RegionNvmGroup2->Channels; #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) countChannelsParams.Bands = RegionNvmGroup1->Bands; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) countChannelsParams.Bands = RegionBands; #endif /* REGION_VERSION */ countChannelsParams.MaxNbChannels = EU433_MAX_NB_CHANNELS; diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU433.h b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU433.h index 3490e1c..013e7a4 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU433.h +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU433.h @@ -189,7 +189,7 @@ extern "C" */ #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) #define EU433_RFU1_SIZE 2 -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) #define EU433_RFU1_SIZE 1 #endif /* REGION_VERSION */ diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU868.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU868.c index 6bdd88f..6528cb8 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU868.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU868.c @@ -54,7 +54,7 @@ #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) static RegionNvmDataGroup1_t* RegionNvmGroup1; static RegionNvmDataGroup2_t* RegionNvmGroup2; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) // static RegionNvmDataGroup1_t* RegionNvmGroup1; /* Unused for this region */ static RegionNvmDataGroup2_t* RegionNvmGroup2; static Band_t* RegionBands; @@ -226,7 +226,7 @@ PhyParam_t RegionEU868GetPhyParam( GetPhyParams_t* getPhy ) phyParam.Value = ( REGION_COMMON_DEFAULT_ACK_TIMEOUT + randr( -REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND, REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND ) ); break; } -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) case PHY_RETRANSMIT_TIMEOUT: { @@ -342,7 +342,7 @@ void RegionEU868SetBandTxDone( SetBandTxDoneParams_t* txDone ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band], txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionCommonSetBandTxDone( &RegionBands[RegionNvmGroup2->Channels[txDone->Channel].Band], txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); #endif /* REGION_VERSION */ @@ -377,7 +377,7 @@ void RegionEU868InitDefaults( InitDefaultsParams_t* params ) // Default bands memcpy1( ( uint8_t* )RegionNvmGroup1->Bands, ( uint8_t* )bands, sizeof( Band_t ) * EU868_MAX_NB_BANDS ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionNvmGroup2 = (RegionNvmDataGroup2_t*) params->NvmGroup2; RegionBands = (Band_t*) params->Bands; @@ -637,7 +637,7 @@ bool RegionEU868TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime int8_t phyDr = DataratesEU868[txConfig->Datarate]; #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) int8_t txPowerLimited = RegionCommonLimitTxPower( txConfig->TxPower, RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txConfig->Channel].Band].TxMaxPower ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) int8_t txPowerLimited = RegionCommonLimitTxPower( txConfig->TxPower, RegionBands[RegionNvmGroup2->Channels[txConfig->Channel].Band].TxMaxPower ); #endif /* REGION_VERSION */ uint32_t bandwidth = RegionCommonGetBandwidth( txConfig->Datarate, BandwidthsEU868 ); @@ -934,7 +934,7 @@ LoRaMacStatus_t RegionEU868NextChannel( NextChanParams_t* nextChanParams, uint8_ countChannelsParams.Channels = RegionNvmGroup2->Channels; #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) countChannelsParams.Bands = RegionNvmGroup1->Bands; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) countChannelsParams.Bands = RegionBands; #endif /* REGION_VERSION */ countChannelsParams.MaxNbChannels = EU868_MAX_NB_CHANNELS; diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU868.h b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU868.h index db8ddc6..4459879 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU868.h +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionEU868.h @@ -189,7 +189,7 @@ extern "C" */ #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) #define EU868_RFU1_SIZE 2 -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) #define EU868_RFU1_SIZE 1 #endif /* REGION_VERSION */ diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionIN865.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionIN865.c index 9b8437d..f313302 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionIN865.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionIN865.c @@ -54,7 +54,7 @@ #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) static RegionNvmDataGroup1_t* RegionNvmGroup1; static RegionNvmDataGroup2_t* RegionNvmGroup2; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) // static RegionNvmDataGroup1_t* RegionNvmGroup1; /* Unused for this region */ static RegionNvmDataGroup2_t* RegionNvmGroup2; static Band_t* RegionBands; @@ -200,7 +200,7 @@ PhyParam_t RegionIN865GetPhyParam( GetPhyParams_t* getPhy ) phyParam.Value = ( REGION_COMMON_DEFAULT_ACK_TIMEOUT + randr( -REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND, REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND ) ); break; } -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) case PHY_RETRANSMIT_TIMEOUT: { phyParam.Value = ( REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT + randr( -REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT_RND, REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT_RND ) ); @@ -315,7 +315,7 @@ void RegionIN865SetBandTxDone( SetBandTxDoneParams_t* txDone ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band], txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionCommonSetBandTxDone( &RegionBands[RegionNvmGroup2->Channels[txDone->Channel].Band], txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); #endif /* REGION_VERSION */ @@ -345,7 +345,7 @@ void RegionIN865InitDefaults( InitDefaultsParams_t* params ) // Initialize bands memcpy1( ( uint8_t* )RegionNvmGroup1->Bands, ( uint8_t* )bands, sizeof( Band_t ) * IN865_MAX_NB_BANDS ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionNvmGroup2 = (RegionNvmDataGroup2_t*) params->NvmGroup2; RegionBands = (Band_t*) params->Bands; @@ -617,7 +617,7 @@ bool RegionIN865TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime int8_t phyDr = DataratesIN865[txConfig->Datarate]; #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) int8_t txPowerLimited = RegionCommonLimitTxPower( txConfig->TxPower, RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txConfig->Channel].Band].TxMaxPower ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) int8_t txPowerLimited = RegionCommonLimitTxPower( txConfig->TxPower, RegionBands[RegionNvmGroup2->Channels[txConfig->Channel].Band].TxMaxPower ); #endif /* REGION_VERSION */ uint32_t bandwidth = RegionCommonGetBandwidth( txConfig->Datarate, BandwidthsIN865 ); @@ -920,7 +920,7 @@ LoRaMacStatus_t RegionIN865NextChannel( NextChanParams_t* nextChanParams, uint8_ countChannelsParams.Channels = RegionNvmGroup2->Channels; #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) countChannelsParams.Bands = RegionNvmGroup1->Bands; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) countChannelsParams.Bands = RegionBands; #endif /* REGION_VERSION */ countChannelsParams.MaxNbChannels = IN865_MAX_NB_CHANNELS; @@ -1062,7 +1062,7 @@ uint8_t RegionIN865ApplyDrOffset( uint8_t downlinkDwellTime, int8_t dr, int8_t d return 0; #endif /* REGION_IN865 */ } -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) uint8_t RegionIN865ApplyDrOffset( uint8_t downlinkDwellTime, int8_t dr, int8_t drOffset ) { #if defined( REGION_IN865 ) diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionIN865.h b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionIN865.h index 0353b69..44c3a08 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionIN865.h +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionIN865.h @@ -181,7 +181,7 @@ extern "C" */ #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) #define IN865_RFU1_SIZE 1 -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) #define IN865_RFU1_SIZE 0 #endif /* REGION_VERSION */ @@ -239,7 +239,7 @@ extern "C" */ #define IN865_JOIN_CHANNELS ( uint16_t )( LC( 1 ) | LC( 2 ) | LC( 3 ) ) -#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) /*! * RFU value */ @@ -271,7 +271,7 @@ static const uint8_t MaxPayloadOfDatarateRepeaterIN865[] = { 51, 51, 51, 115, 22 */ #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) static const int8_t EffectiveRx1DrOffsetIN865[] = { 0, 1, 2, 3, 4, 5, -1, -2 }; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) static const int8_t EffectiveRx1DrOffsetIN865[8][8] = { { DR_0 , DR_0 , DR_0 , DR_0 , DR_0 , DR_0 , DR_1 , DR_2 }, // DR_0 diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionKR920.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionKR920.c index 38b0c0d..5aba9a9 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionKR920.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionKR920.c @@ -70,7 +70,7 @@ #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) static RegionNvmDataGroup1_t* RegionNvmGroup1; static RegionNvmDataGroup2_t* RegionNvmGroup2; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) // static RegionNvmDataGroup1_t* RegionNvmGroup1; /* Unused for this region */ static RegionNvmDataGroup2_t* RegionNvmGroup2; static Band_t* RegionBands; @@ -227,7 +227,7 @@ PhyParam_t RegionKR920GetPhyParam( GetPhyParams_t* getPhy ) phyParam.Value = ( REGION_COMMON_DEFAULT_ACK_TIMEOUT + randr( -REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND, REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND ) ); break; } -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) case PHY_RETRANSMIT_TIMEOUT: { phyParam.Value = ( REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT + randr( -REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT_RND, REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT_RND ) ); @@ -346,7 +346,7 @@ void RegionKR920SetBandTxDone( SetBandTxDoneParams_t* txDone ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band], txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionCommonSetBandTxDone( &RegionBands[RegionNvmGroup2->Channels[txDone->Channel].Band], txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); #endif /* REGION_VERSION */ @@ -376,7 +376,7 @@ void RegionKR920InitDefaults( InitDefaultsParams_t* params ) // Initialize bands memcpy1( ( uint8_t* )RegionNvmGroup1->Bands, ( uint8_t* )bands, sizeof( Band_t ) * KR920_MAX_NB_BANDS ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionNvmGroup2 = (RegionNvmDataGroup2_t*) params->NvmGroup2; RegionBands = (Band_t*) params->Bands; @@ -620,7 +620,7 @@ bool RegionKR920TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime int8_t phyDr = DataratesKR920[txConfig->Datarate]; #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) int8_t txPowerLimited = RegionCommonLimitTxPower( txConfig->TxPower, RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txConfig->Channel].Band].TxMaxPower ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) int8_t txPowerLimited = RegionCommonLimitTxPower( txConfig->TxPower, RegionBands[RegionNvmGroup2->Channels[txConfig->Channel].Band].TxMaxPower ); #endif /* REGION_VERSION */ uint32_t bandwidth = RegionCommonGetBandwidth( txConfig->Datarate, BandwidthsKR920 ); @@ -910,7 +910,7 @@ LoRaMacStatus_t RegionKR920NextChannel( NextChanParams_t* nextChanParams, uint8_ countChannelsParams.Channels = RegionNvmGroup2->Channels; #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) countChannelsParams.Bands = RegionNvmGroup1->Bands; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) countChannelsParams.Bands = RegionBands; #endif /* REGION_VERSION */ countChannelsParams.MaxNbChannels = KR920_MAX_NB_CHANNELS; diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionKR920.h b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionKR920.h index 3231027..f003545 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionKR920.h +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionKR920.h @@ -186,7 +186,7 @@ extern "C" */ #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) #define KR920_RFU1_SIZE 2 -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) #define KR920_RFU1_SIZE 1 #endif /* REGION_VERSION */ diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionNvm.h b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionNvm.h index 1ec0d49..1a01f7e 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionNvm.h +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionNvm.h @@ -42,7 +42,7 @@ extern "C" #include "../LoRaMacTypes.h" #include "RegionVersion.h" -#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) /*! * Channel plan for region CN470 */ @@ -122,7 +122,7 @@ typedef struct sRegionNvmDataGroup2 * LoRaMac channels default mask */ uint16_t ChannelsDefaultMask[ REGION_NVM_CHANNELS_MASK_SIZE ]; -#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) #if defined( REGION_CN470 ) /*! * Holds the channel plan. diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionRU864.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionRU864.c index bb9d9c5..e99cc3f 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionRU864.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionRU864.c @@ -54,7 +54,7 @@ #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) static RegionNvmDataGroup1_t* RegionNvmGroup1; static RegionNvmDataGroup2_t* RegionNvmGroup2; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) // static RegionNvmDataGroup1_t* RegionNvmGroup1; /* Unused for this region */ static RegionNvmDataGroup2_t* RegionNvmGroup2; static Band_t* RegionBands; @@ -202,7 +202,7 @@ PhyParam_t RegionRU864GetPhyParam( GetPhyParams_t* getPhy ) phyParam.Value = ( REGION_COMMON_DEFAULT_ACK_TIMEOUT + randr( -REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND, REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND ) ); break; } -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) case PHY_RETRANSMIT_TIMEOUT: { phyParam.Value = ( REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT + randr( -REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT_RND, REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT_RND ) ); @@ -318,7 +318,7 @@ void RegionRU864SetBandTxDone( SetBandTxDoneParams_t* txDone ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band], txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionCommonSetBandTxDone( &RegionBands[RegionNvmGroup2->Channels[txDone->Channel].Band], txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); #endif /* REGION_VERSION */ @@ -349,7 +349,7 @@ void RegionRU864InitDefaults( InitDefaultsParams_t* params ) // Default bands memcpy1( ( uint8_t* )RegionNvmGroup1->Bands, ( uint8_t* )bands, sizeof( Band_t ) * RU864_MAX_NB_BANDS ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionNvmGroup2 = (RegionNvmDataGroup2_t*) params->NvmGroup2; RegionBands = (Band_t*) params->Bands; @@ -606,7 +606,7 @@ bool RegionRU864TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime int8_t phyDr = DataratesRU864[txConfig->Datarate]; #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) int8_t txPowerLimited = RegionCommonLimitTxPower( txConfig->TxPower, RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txConfig->Channel].Band].TxMaxPower ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) int8_t txPowerLimited = RegionCommonLimitTxPower( txConfig->TxPower, RegionBands[RegionNvmGroup2->Channels[txConfig->Channel].Band].TxMaxPower ); #endif /* REGION_VERSION */ uint32_t bandwidth = RegionCommonGetBandwidth( txConfig->Datarate, BandwidthsRU864 ); @@ -900,7 +900,7 @@ LoRaMacStatus_t RegionRU864NextChannel( NextChanParams_t* nextChanParams, uint8_ countChannelsParams.Channels = RegionNvmGroup2->Channels; #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) countChannelsParams.Bands = RegionNvmGroup1->Bands; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) countChannelsParams.Bands = RegionBands; #endif /* REGION_VERSION */ countChannelsParams.MaxNbChannels = RU864_MAX_NB_CHANNELS; diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionRU864.h b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionRU864.h index a2198ef..2884130 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionRU864.h +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionRU864.h @@ -179,7 +179,7 @@ extern "C" */ #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) #define RU864_RFU1_SIZE 2 -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) #define RU864_RFU1_SIZE 1 #endif /* REGION_VERSION */ diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionUS915.c b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionUS915.c index 552027b..ac05226 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionUS915.c +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionUS915.c @@ -75,7 +75,7 @@ */ static RegionNvmDataGroup1_t* RegionNvmGroup1; static RegionNvmDataGroup2_t* RegionNvmGroup2; -#if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#if (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) static Band_t* RegionBands; #endif /* REGION_VERSION */ @@ -240,7 +240,7 @@ PhyParam_t RegionUS915GetPhyParam( GetPhyParams_t* getPhy ) phyParam.Value = ( REGION_COMMON_DEFAULT_ACK_TIMEOUT + randr( -REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND, REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND ) ); break; } -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) case PHY_RETRANSMIT_TIMEOUT: { phyParam.Value = ( REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT + randr( -REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT_RND, REGION_COMMON_DEFAULT_RETRANSMIT_TIMEOUT_RND ) ); @@ -369,7 +369,7 @@ void RegionUS915SetBandTxDone( SetBandTxDoneParams_t* txDone ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band], txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionCommonSetBandTxDone( &RegionBands[RegionNvmGroup2->Channels[txDone->Channel].Band], txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp ); #endif /* REGION_VERSION */ @@ -405,7 +405,7 @@ void RegionUS915InitDefaults( InitDefaultsParams_t* params ) // Default bands memcpy1( ( uint8_t* )RegionNvmGroup1->Bands, ( uint8_t* )bands, sizeof( Band_t ) * US915_MAX_NB_BANDS ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) RegionBands = (Band_t*) params->Bands; // Initialize 8 bit channel groups index @@ -469,7 +469,7 @@ void RegionUS915InitDefaults( InitDefaultsParams_t* params ) #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) for( uint8_t i = 0; i < CHANNELS_MASK_SIZE; i++ ) -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) for( uint8_t i = 0; i < 6; i++ ) #endif /* REGION_VERSION */ { // Copy-And the channels mask @@ -500,7 +500,7 @@ bool RegionUS915Verify( VerifyParams_t* verify, PhyAttribute_t phyAttribute ) { return RegionCommonValueInRange( verify->DatarateParams.Datarate, US915_TX_MIN_DATARATE, US915_TX_MAX_DATARATE ); } -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) case PHY_TX_DR: { return RegionCommonValueInRange( verify->DatarateParams.Datarate, US915_TX_MIN_DATARATE, US915_TX_MAX_DATARATE ); @@ -671,7 +671,7 @@ bool RegionUS915TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime int8_t phyDr = DataratesUS915[txConfig->Datarate]; #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txConfig->Channel].Band].TxMaxPower, txConfig->Datarate, RegionNvmGroup2->ChannelsMask ); -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, RegionBands[RegionNvmGroup2->Channels[txConfig->Channel].Band].TxMaxPower, txConfig->Datarate, RegionNvmGroup2->ChannelsMask ); #endif /* REGION_VERSION */ @@ -709,7 +709,7 @@ uint8_t RegionUS915LinkAdrReq( LinkAdrReqParams_t* linkAdrReq, int8_t* drOut, in uint8_t bytesProcessed = 0; #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) uint16_t channelsMask[CHANNELS_MASK_SIZE] = { 0, 0, 0, 0, 0, 0 }; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) uint16_t channelsMask[6] = { 0, 0, 0, 0, 0, 0 }; #endif /* REGION_VERSION */ GetPhyParams_t getPhy; @@ -979,7 +979,7 @@ LoRaMacStatus_t RegionUS915NextChannel( NextChanParams_t* nextChanParams, uint8_ countChannelsParams.Channels = RegionNvmGroup2->Channels; #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) countChannelsParams.Bands = RegionNvmGroup1->Bands; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) countChannelsParams.Bands = RegionBands; #endif /* REGION_VERSION */ countChannelsParams.MaxNbChannels = US915_MAX_NB_CHANNELS; @@ -996,7 +996,7 @@ LoRaMacStatus_t RegionUS915NextChannel( NextChanParams_t* nextChanParams, uint8_ identifyChannelsParam.ExpectedTimeOnAir = GetTimeOnAir( nextChanParams->Datarate, nextChanParams->PktLen ); identifyChannelsParam.CountNbOfEnabledChannelsParam = &countChannelsParams; -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) identifyChannelsParam.CountNbOfEnabledChannelsParam = &countChannelsParams; identifyChannelsParam.ElapsedTimeSinceStartUp = nextChanParams->ElapsedTimeSinceStartUp; diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionUS915.h b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionUS915.h index 8f2582e..478dd12 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionUS915.h +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionUS915.h @@ -176,7 +176,7 @@ extern "C" */ #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) #define US915_RFU1_SIZE 5 -#elif (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) +#elif (defined( REGION_VERSION ) && (( REGION_VERSION == 0x02010001 ) || ( REGION_VERSION == 0x02010003 ))) #define US915_RFU1_SIZE 4 #endif /* REGION_VERSION */ diff --git a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionVersion.h b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionVersion.h index af5d36f..b7fbe17 100644 --- a/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionVersion.h +++ b/src/STM32CubeWL/LoRaWAN/Mac/Region/RegionVersion.h @@ -37,7 +37,12 @@ extern "C" * @brief Regional parameters version definition. * @note RP002-1.0.1 : https://lora-alliance.org/resource_hub/rp2-101-lorawan-regional-parameters-2/ */ -#define REGION_VERSION 0x02010001 +//#define REGION_VERSION 0x02010001 +/*! + * Regional parameters version definition. + * RP002-1.0.3 + */ +#define REGION_VERSION 0x02010003 #endif /* LORAMAC_VERSION */ #endif /* REGION_VERSION */ diff --git a/src/STM32CubeWL/LoRaWAN/Release_Notes.html b/src/STM32CubeWL/LoRaWAN/Release_Notes.html index e6cf83b..0eda896 100644 --- a/src/STM32CubeWL/LoRaWAN/Release_Notes.html +++ b/src/STM32CubeWL/LoRaWAN/Release_Notes.html @@ -49,6 +49,46 @@
None
+