diff --git a/sysdrv/tools/board/lorawan-bridge/LoraMac/LoRaMac.c b/sysdrv/tools/board/lorawan-bridge/LoraMac/LoRaMac.c index 0b68920946..ac790e1b6f 100644 --- a/sysdrv/tools/board/lorawan-bridge/LoraMac/LoRaMac.c +++ b/sysdrv/tools/board/lorawan-bridge/LoraMac/LoRaMac.c @@ -45,6 +45,7 @@ #include "LoRaMacAdr.h" #include "LoRaMacSerializer.h" #include "radio.h" +#include #include "LoRaMac.h" @@ -3758,6 +3759,7 @@ LoRaMacStatus_t LoRaMacInitialization( LoRaMacPrimitives_t* primitives, LoRaMacC if( ( primitives == NULL ) || ( callbacks == NULL ) ) { + printf("primitives or callbacks null"); return LORAMAC_STATUS_PARAMETER_INVALID; } @@ -3766,11 +3768,13 @@ LoRaMacStatus_t LoRaMacInitialization( LoRaMacPrimitives_t* primitives, LoRaMacC ( primitives->MacMlmeConfirm == NULL ) || ( primitives->MacMlmeIndication == NULL ) ) { + printf("primitives null"); return LORAMAC_STATUS_PARAMETER_INVALID; } // Verify if the region is supported if( RegionIsActive( region ) == false ) { + printf("region problem: %d", region); return LORAMAC_STATUS_REGION_NOT_SUPPORTED; } @@ -3922,24 +3926,28 @@ LoRaMacStatus_t LoRaMacInitialization( LoRaMacPrimitives_t* primitives, LoRaMacC // Initialize the Secure Element driver if( SecureElementInit( &Nvm.SecureElement ) != SECURE_ELEMENT_SUCCESS ) { + printf("Secure Element Driver failed"); return LORAMAC_STATUS_CRYPTO_ERROR; } // Initialize Crypto module if( LoRaMacCryptoInit( &Nvm.Crypto ) != LORAMAC_CRYPTO_SUCCESS ) { + printf("Crypto Driver failed"); return LORAMAC_STATUS_CRYPTO_ERROR; } // Initialize MAC commands module if( LoRaMacCommandsInit( ) != LORAMAC_COMMANDS_SUCCESS ) { + printf("MAC Driver failed"); return LORAMAC_STATUS_MAC_COMMAD_ERROR; } // Set multicast downlink counter reference if( LoRaMacCryptoSetMulticastReference( Nvm.MacGroup2.MulticastChannelList ) != LORAMAC_CRYPTO_SUCCESS ) { + printf("Multicast Downlink Driver failed"); return LORAMAC_STATUS_CRYPTO_ERROR; } diff --git a/sysdrv/tools/board/lorawan-bridge/LoraMac/common/LmHandler/LmHandler.c b/sysdrv/tools/board/lorawan-bridge/LoraMac/common/LmHandler/LmHandler.c index ebe59fefe1..527b6a5ab0 100644 --- a/sysdrv/tools/board/lorawan-bridge/LoraMac/common/LmHandler/LmHandler.c +++ b/sysdrv/tools/board/lorawan-bridge/LoraMac/common/LmHandler/LmHandler.c @@ -22,6 +22,7 @@ * * \author Miguel Luis ( Semtech ) */ +#include #include #include #include @@ -263,6 +264,7 @@ LmHandlerErrorStatus_t LmHandlerInit( LmHandlerCallbacks_t *handlerCallbacks, if( LoRaMacInitialization( &LoRaMacPrimitives, &LoRaMacCallbacks, LmHandlerParams->Region ) != LORAMAC_STATUS_OK ) { + printf("IT FAILDED HERE"); return LORAMAC_HANDLER_ERROR; } @@ -335,11 +337,14 @@ LmHandlerErrorStatus_t LmHandlerInit( LmHandlerCallbacks_t *handlerCallbacks, LoRaMacTestSetDutyCycleOn( LmHandlerParams->DutyCycleEnabled ); + printf("HERE1"); LoRaMacStart( ); + printf("HERE2"); mibReq.Type = MIB_NETWORK_ACTIVATION; if( LoRaMacMibGetRequestConfirm( &mibReq ) == LORAMAC_STATUS_OK ) { + printf("HERE3"); if( mibReq.Param.NetworkActivation == ACTIVATION_TYPE_NONE ) { if( LmHandlerCallbacks->OnNetworkParametersChange != NULL ) @@ -348,6 +353,7 @@ LmHandlerErrorStatus_t LmHandlerInit( LmHandlerCallbacks_t *handlerCallbacks, } } } + printf("HERE4"); return LORAMAC_HANDLER_SUCCESS; } diff --git a/sysdrv/tools/board/lorawan-bridge/LoraMac/main.c b/sysdrv/tools/board/lorawan-bridge/LoraMac/main.c index aa11acfe41..2f28281d08 100644 --- a/sysdrv/tools/board/lorawan-bridge/LoraMac/main.c +++ b/sysdrv/tools/board/lorawan-bridge/LoraMac/main.c @@ -24,6 +24,7 @@ /*! \file periodic-uplink/B-L072Z-LRWAN1/main.c */ #include +#include #include "utilities.h" #include "board.h" #include "RegionCommon.h" @@ -274,20 +275,21 @@ int main( void ) // Fatal error, endless loop. while ( 1 ) { + exit(-1); // This is linux now :) } } // Set system maximum tolerated rx error in milliseconds LmHandlerSetSystemMaxRxError( 20 ); - + printf("HERE5"); // The LoRa-Alliance Compliance protocol package should always be // initialized and activated. LmHandlerPackageRegister( PACKAGE_ID_COMPLIANCE, &LmhpComplianceParams ); - + printf("HERE6"); LmHandlerJoin( ); - + printf("HERE7"); StartTxProcess( LORAMAC_HANDLER_TX_ON_TIMER ); - + printf("HERE8"); // while( 1 ) // { // // Process characters sent over the command line interface diff --git a/sysdrv/tools/board/lorawan-bridge/LoraMac/region/Region.c b/sysdrv/tools/board/lorawan-bridge/LoraMac/region/Region.c index 83c380e0dc..01024bf12a 100644 --- a/sysdrv/tools/board/lorawan-bridge/LoraMac/region/Region.c +++ b/sysdrv/tools/board/lorawan-bridge/LoraMac/region/Region.c @@ -32,513 +32,565 @@ #include "Region.h" // Setup regions -#ifdef REGION_AS923 +//#ifdef REGION_AS923 #include "RegionAS923.h" -#define AS923_CASE case LORAMAC_REGION_AS923: -#define AS923_IS_ACTIVE( ) AS923_CASE { return true; } -#define AS923_GET_PHY_PARAM( ) AS923_CASE { return RegionAS923GetPhyParam( getPhy ); } -#define AS923_SET_BAND_TX_DONE( ) AS923_CASE { RegionAS923SetBandTxDone( txDone ); break; } -#define AS923_INIT_DEFAULTS( ) AS923_CASE { RegionAS923InitDefaults( params ); break; } -#define AS923_VERIFY( ) AS923_CASE { return RegionAS923Verify( verify, phyAttribute ); } -#define AS923_APPLY_CF_LIST( ) AS923_CASE { RegionAS923ApplyCFList( applyCFList ); break; } -#define AS923_CHAN_MASK_SET( ) AS923_CASE { return RegionAS923ChanMaskSet( chanMaskSet ); } -#define AS923_COMPUTE_RX_WINDOW_PARAMETERS( ) AS923_CASE { RegionAS923ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } -#define AS923_RX_CONFIG( ) AS923_CASE { return RegionAS923RxConfig( rxConfig, datarate ); } -#define AS923_TX_CONFIG( ) AS923_CASE { return RegionAS923TxConfig( txConfig, txPower, txTimeOnAir ); } -#define AS923_LINK_ADR_REQ( ) AS923_CASE { return RegionAS923LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } -#define AS923_RX_PARAM_SETUP_REQ( ) AS923_CASE { return RegionAS923RxParamSetupReq( rxParamSetupReq ); } -#define AS923_NEW_CHANNEL_REQ( ) AS923_CASE { return RegionAS923NewChannelReq( newChannelReq ); } -#define AS923_TX_PARAM_SETUP_REQ( ) AS923_CASE { return RegionAS923TxParamSetupReq( txParamSetupReq ); } -#define AS923_DL_CHANNEL_REQ( ) AS923_CASE { return RegionAS923DlChannelReq( dlChannelReq ); } -#define AS923_ALTERNATE_DR( ) AS923_CASE { return RegionAS923AlternateDr( currentDr, type ); } -#define AS923_NEXT_CHANNEL( ) AS923_CASE { return RegionAS923NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } -#define AS923_CHANNEL_ADD( ) AS923_CASE { return RegionAS923ChannelAdd( channelAdd ); } -#define AS923_CHANNEL_REMOVE( ) AS923_CASE { return RegionAS923ChannelsRemove( channelRemove ); } -#define AS923_APPLY_DR_OFFSET( ) AS923_CASE { return RegionAS923ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } -#define AS923_RX_BEACON_SETUP( ) AS923_CASE { RegionAS923RxBeaconSetup( rxBeaconSetup, outDr ); break; } -#else -#define AS923_IS_ACTIVE( ) -#define AS923_GET_PHY_PARAM( ) -#define AS923_SET_BAND_TX_DONE( ) -#define AS923_INIT_DEFAULTS( ) -#define AS923_GET_NVM_CTX( ) -#define AS923_VERIFY( ) -#define AS923_APPLY_CF_LIST( ) -#define AS923_CHAN_MASK_SET( ) -#define AS923_COMPUTE_RX_WINDOW_PARAMETERS( ) -#define AS923_RX_CONFIG( ) -#define AS923_TX_CONFIG( ) -#define AS923_LINK_ADR_REQ( ) -#define AS923_RX_PARAM_SETUP_REQ( ) -#define AS923_NEW_CHANNEL_REQ( ) -#define AS923_TX_PARAM_SETUP_REQ( ) -#define AS923_DL_CHANNEL_REQ( ) -#define AS923_ALTERNATE_DR( ) -#define AS923_NEXT_CHANNEL( ) -#define AS923_CHANNEL_ADD( ) -#define AS923_CHANNEL_REMOVE( ) -#define AS923_APPLY_DR_OFFSET( ) -#define AS923_RX_BEACON_SETUP( ) -#endif - -#ifdef REGION_AU915 +//#define AS923_CASE case LORAMAC_REGION_AS923: +#define AS923_IS_ACTIVE( ) { return true; } +#define AS923_GET_PHY_PARAM( ) { return RegionAS923GetPhyParam( getPhy ); } +#define AS923_SET_BAND_TX_DONE( ) { RegionAS923SetBandTxDone( txDone ); break; } +#define AS923_INIT_DEFAULTS( ) { RegionAS923InitDefaults( params ); break; } +#define AS923_VERIFY( ) { return RegionAS923Verify( verify, phyAttribute ); } +#define AS923_APPLY_CF_LIST( ) { RegionAS923ApplyCFList( applyCFList ); break; } +#define AS923_CHAN_MASK_SET( ) { return RegionAS923ChanMaskSet( chanMaskSet ); } +#define AS923_COMPUTE_RX_WINDOW_PARAMETERS( ) { RegionAS923ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } +#define AS923_RX_CONFIG( ) { return RegionAS923RxConfig( rxConfig, datarate ); } +#define AS923_TX_CONFIG( ) { return RegionAS923TxConfig( txConfig, txPower, txTimeOnAir ); } +#define AS923_LINK_ADR_REQ( ) { return RegionAS923LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } +#define AS923_RX_PARAM_SETUP_REQ( ) { return RegionAS923RxParamSetupReq( rxParamSetupReq ); } +#define AS923_NEW_CHANNEL_REQ( ) { return RegionAS923NewChannelReq( newChannelReq ); } +#define AS923_TX_PARAM_SETUP_REQ( ) { return RegionAS923TxParamSetupReq( txParamSetupReq ); } +#define AS923_DL_CHANNEL_REQ( ) { return RegionAS923DlChannelReq( dlChannelReq ); } +#define AS923_ALTERNATE_DR( ) { return RegionAS923AlternateDr( currentDr, type ); } +#define AS923_NEXT_CHANNEL( ) { return RegionAS923NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } +#define AS923_CHANNEL_ADD( ) { return RegionAS923ChannelAdd( channelAdd ); } +#define AS923_CHANNEL_REMOVE( ) { return RegionAS923ChannelsRemove( channelRemove ); } +#define AS923_APPLY_DR_OFFSET( ) { return RegionAS923ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } +#define AS923_RX_BEACON_SETUP( ) { RegionAS923RxBeaconSetup( rxBeaconSetup, outDr ); break; } +// #else +// #define AS923_IS_ACTIVE( ) +// #define AS923_GET_PHY_PARAM( ) +// #define AS923_SET_BAND_TX_DONE( ) +// #define AS923_INIT_DEFAULTS( ) +// #define AS923_GET_NVM_CTX( ) +// #define AS923_VERIFY( ) +// #define AS923_APPLY_CF_LIST( ) +// #define AS923_CHAN_MASK_SET( ) +// #define AS923_COMPUTE_RX_WINDOW_PARAMETERS( ) +// #define AS923_RX_CONFIG( ) +// #define AS923_TX_CONFIG( ) +// #define AS923_LINK_ADR_REQ( ) +// #define AS923_RX_PARAM_SETUP_REQ( ) +// #define AS923_NEW_CHANNEL_REQ( ) +// #define AS923_TX_PARAM_SETUP_REQ( ) +// #define AS923_DL_CHANNEL_REQ( ) +// #define AS923_ALTERNATE_DR( ) +// #define AS923_NEXT_CHANNEL( ) +// #define AS923_CHANNEL_ADD( ) +// #define AS923_CHANNEL_REMOVE( ) +// #define AS923_APPLY_DR_OFFSET( ) +// #define AS923_RX_BEACON_SETUP( ) +// #endif + +//#ifdef REGION_AU915 #include "RegionAU915.h" -#define AU915_CASE case LORAMAC_REGION_AU915: -#define AU915_IS_ACTIVE( ) AU915_CASE { return true; } -#define AU915_GET_PHY_PARAM( ) AU915_CASE { return RegionAU915GetPhyParam( getPhy ); } -#define AU915_SET_BAND_TX_DONE( ) AU915_CASE { RegionAU915SetBandTxDone( txDone ); break; } -#define AU915_INIT_DEFAULTS( ) AU915_CASE { RegionAU915InitDefaults( params ); break; } -#define AU915_VERIFY( ) AU915_CASE { return RegionAU915Verify( verify, phyAttribute ); } -#define AU915_APPLY_CF_LIST( ) AU915_CASE { RegionAU915ApplyCFList( applyCFList ); break; } -#define AU915_CHAN_MASK_SET( ) AU915_CASE { return RegionAU915ChanMaskSet( chanMaskSet ); } -#define AU915_COMPUTE_RX_WINDOW_PARAMETERS( ) AU915_CASE { RegionAU915ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } -#define AU915_RX_CONFIG( ) AU915_CASE { return RegionAU915RxConfig( rxConfig, datarate ); } -#define AU915_TX_CONFIG( ) AU915_CASE { return RegionAU915TxConfig( txConfig, txPower, txTimeOnAir ); } -#define AU915_LINK_ADR_REQ( ) AU915_CASE { return RegionAU915LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } -#define AU915_RX_PARAM_SETUP_REQ( ) AU915_CASE { return RegionAU915RxParamSetupReq( rxParamSetupReq ); } -#define AU915_NEW_CHANNEL_REQ( ) AU915_CASE { return RegionAU915NewChannelReq( newChannelReq ); } -#define AU915_TX_PARAM_SETUP_REQ( ) AU915_CASE { return RegionAU915TxParamSetupReq( txParamSetupReq ); } -#define AU915_DL_CHANNEL_REQ( ) AU915_CASE { return RegionAU915DlChannelReq( dlChannelReq ); } -#define AU915_ALTERNATE_DR( ) AU915_CASE { return RegionAU915AlternateDr( currentDr, type ); } -#define AU915_NEXT_CHANNEL( ) AU915_CASE { return RegionAU915NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } -#define AU915_CHANNEL_ADD( ) AU915_CASE { return RegionAU915ChannelAdd( channelAdd ); } -#define AU915_CHANNEL_REMOVE( ) AU915_CASE { return RegionAU915ChannelsRemove( channelRemove ); } -#define AU915_APPLY_DR_OFFSET( ) AU915_CASE { return RegionAU915ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } -#define AU915_RX_BEACON_SETUP( ) AU915_CASE { RegionAU915RxBeaconSetup( rxBeaconSetup, outDr ); break; } -#else -#define AU915_IS_ACTIVE( ) -#define AU915_GET_PHY_PARAM( ) -#define AU915_SET_BAND_TX_DONE( ) -#define AU915_INIT_DEFAULTS( ) -#define AU915_GET_NVM_CTX( ) -#define AU915_VERIFY( ) -#define AU915_APPLY_CF_LIST( ) -#define AU915_CHAN_MASK_SET( ) -#define AU915_COMPUTE_RX_WINDOW_PARAMETERS( ) -#define AU915_RX_CONFIG( ) -#define AU915_TX_CONFIG( ) -#define AU915_LINK_ADR_REQ( ) -#define AU915_RX_PARAM_SETUP_REQ( ) -#define AU915_NEW_CHANNEL_REQ( ) -#define AU915_TX_PARAM_SETUP_REQ( ) -#define AU915_DL_CHANNEL_REQ( ) -#define AU915_ALTERNATE_DR( ) -#define AU915_NEXT_CHANNEL( ) -#define AU915_CHANNEL_ADD( ) -#define AU915_CHANNEL_REMOVE( ) -#define AU915_APPLY_DR_OFFSET( ) -#define AU915_RX_BEACON_SETUP( ) -#endif - -#ifdef REGION_CN470 +//#define AU915_CASE case LORAMAC_REGION_AU915: +#define AU915_IS_ACTIVE( ) { return true; } +#define AU915_GET_PHY_PARAM( ) { return RegionAU915GetPhyParam( getPhy ); } +#define AU915_SET_BAND_TX_DONE( ) { RegionAU915SetBandTxDone( txDone ); break; } +#define AU915_INIT_DEFAULTS( ) { RegionAU915InitDefaults( params ); break; } +#define AU915_VERIFY( ) { return RegionAU915Verify( verify, phyAttribute ); } +#define AU915_APPLY_CF_LIST( ) { RegionAU915ApplyCFList( applyCFList ); break; } +#define AU915_CHAN_MASK_SET( ) { return RegionAU915ChanMaskSet( chanMaskSet ); } +#define AU915_COMPUTE_RX_WINDOW_PARAMETERS( ) { RegionAU915ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } +#define AU915_RX_CONFIG( ) { return RegionAU915RxConfig( rxConfig, datarate ); } +#define AU915_TX_CONFIG( ) { return RegionAU915TxConfig( txConfig, txPower, txTimeOnAir ); } +#define AU915_LINK_ADR_REQ( ) { return RegionAU915LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } +#define AU915_RX_PARAM_SETUP_REQ( ) { return RegionAU915RxParamSetupReq( rxParamSetupReq ); } +#define AU915_NEW_CHANNEL_REQ( ) { return RegionAU915NewChannelReq( newChannelReq ); } +#define AU915_TX_PARAM_SETUP_REQ( ) { return RegionAU915TxParamSetupReq( txParamSetupReq ); } +#define AU915_DL_CHANNEL_REQ( ) { return RegionAU915DlChannelReq( dlChannelReq ); } +#define AU915_ALTERNATE_DR( ) { return RegionAU915AlternateDr( currentDr, type ); } +#define AU915_NEXT_CHANNEL( ) { return RegionAU915NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } +#define AU915_CHANNEL_ADD( ) { return RegionAU915ChannelAdd( channelAdd ); } +#define AU915_CHANNEL_REMOVE( ) { return RegionAU915ChannelsRemove( channelRemove ); } +#define AU915_APPLY_DR_OFFSET( ) { return RegionAU915ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } +#define AU915_RX_BEACON_SETUP( ) { RegionAU915RxBeaconSetup( rxBeaconSetup, outDr ); break; } +// #else +// #define AU915_IS_ACTIVE( ) +// #define AU915_GET_PHY_PARAM( ) +// #define AU915_SET_BAND_TX_DONE( ) +// #define AU915_INIT_DEFAULTS( ) +// #define AU915_GET_NVM_CTX( ) +// #define AU915_VERIFY( ) +// #define AU915_APPLY_CF_LIST( ) +// #define AU915_CHAN_MASK_SET( ) +// #define AU915_COMPUTE_RX_WINDOW_PARAMETERS( ) +// #define AU915_RX_CONFIG( ) +// #define AU915_TX_CONFIG( ) +// #define AU915_LINK_ADR_REQ( ) +// #define AU915_RX_PARAM_SETUP_REQ( ) +// #define AU915_NEW_CHANNEL_REQ( ) +// #define AU915_TX_PARAM_SETUP_REQ( ) +// #define AU915_DL_CHANNEL_REQ( ) +// #define AU915_ALTERNATE_DR( ) +// #define AU915_NEXT_CHANNEL( ) +// #define AU915_CHANNEL_ADD( ) +// #define AU915_CHANNEL_REMOVE( ) +// #define AU915_APPLY_DR_OFFSET( ) +// #define AU915_RX_BEACON_SETUP( ) +// #endif + +// #ifdef REGION_CN470 #include "RegionCN470.h" -#define CN470_CASE case LORAMAC_REGION_CN470: -#define CN470_IS_ACTIVE( ) CN470_CASE { return true; } -#define CN470_GET_PHY_PARAM( ) CN470_CASE { return RegionCN470GetPhyParam( getPhy ); } -#define CN470_SET_BAND_TX_DONE( ) CN470_CASE { RegionCN470SetBandTxDone( txDone ); break; } -#define CN470_INIT_DEFAULTS( ) CN470_CASE { RegionCN470InitDefaults( params ); break; } -#define CN470_VERIFY( ) CN470_CASE { return RegionCN470Verify( verify, phyAttribute ); } -#define CN470_APPLY_CF_LIST( ) CN470_CASE { RegionCN470ApplyCFList( applyCFList ); break; } -#define CN470_CHAN_MASK_SET( ) CN470_CASE { return RegionCN470ChanMaskSet( chanMaskSet ); } -#define CN470_COMPUTE_RX_WINDOW_PARAMETERS( ) CN470_CASE { RegionCN470ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } -#define CN470_RX_CONFIG( ) CN470_CASE { return RegionCN470RxConfig( rxConfig, datarate ); } -#define CN470_TX_CONFIG( ) CN470_CASE { return RegionCN470TxConfig( txConfig, txPower, txTimeOnAir ); } -#define CN470_LINK_ADR_REQ( ) CN470_CASE { return RegionCN470LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } -#define CN470_RX_PARAM_SETUP_REQ( ) CN470_CASE { return RegionCN470RxParamSetupReq( rxParamSetupReq ); } -#define CN470_NEW_CHANNEL_REQ( ) CN470_CASE { return RegionCN470NewChannelReq( newChannelReq ); } -#define CN470_TX_PARAM_SETUP_REQ( ) CN470_CASE { return RegionCN470TxParamSetupReq( txParamSetupReq ); } -#define CN470_DL_CHANNEL_REQ( ) CN470_CASE { return RegionCN470DlChannelReq( dlChannelReq ); } -#define CN470_ALTERNATE_DR( ) CN470_CASE { return RegionCN470AlternateDr( currentDr, type ); } -#define CN470_NEXT_CHANNEL( ) CN470_CASE { return RegionCN470NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } -#define CN470_CHANNEL_ADD( ) CN470_CASE { return RegionCN470ChannelAdd( channelAdd ); } -#define CN470_CHANNEL_REMOVE( ) CN470_CASE { return RegionCN470ChannelsRemove( channelRemove ); } -#define CN470_APPLY_DR_OFFSET( ) CN470_CASE { return RegionCN470ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } -#define CN470_RX_BEACON_SETUP( ) CN470_CASE { RegionCN470RxBeaconSetup( rxBeaconSetup, outDr ); break; } -#else -#define CN470_IS_ACTIVE( ) -#define CN470_GET_PHY_PARAM( ) -#define CN470_SET_BAND_TX_DONE( ) -#define CN470_INIT_DEFAULTS( ) -#define CN470_GET_NVM_CTX( ) -#define CN470_VERIFY( ) -#define CN470_APPLY_CF_LIST( ) -#define CN470_CHAN_MASK_SET( ) -#define CN470_COMPUTE_RX_WINDOW_PARAMETERS( ) -#define CN470_RX_CONFIG( ) -#define CN470_TX_CONFIG( ) -#define CN470_LINK_ADR_REQ( ) -#define CN470_RX_PARAM_SETUP_REQ( ) -#define CN470_NEW_CHANNEL_REQ( ) -#define CN470_TX_PARAM_SETUP_REQ( ) -#define CN470_DL_CHANNEL_REQ( ) -#define CN470_ALTERNATE_DR( ) -#define CN470_NEXT_CHANNEL( ) -#define CN470_CHANNEL_ADD( ) -#define CN470_CHANNEL_REMOVE( ) -#define CN470_APPLY_DR_OFFSET( ) -#define CN470_RX_BEACON_SETUP( ) -#endif - -#ifdef REGION_CN779 +//#define CN470_CASE case LORAMAC_REGION_CN470: +#define CN470_IS_ACTIVE( ) { return true; } +#define CN470_GET_PHY_PARAM( ) { return RegionCN470GetPhyParam( getPhy ); } +#define CN470_SET_BAND_TX_DONE( ) { RegionCN470SetBandTxDone( txDone ); break; } +#define CN470_INIT_DEFAULTS( ) { RegionCN470InitDefaults( params ); break; } +#define CN470_VERIFY( ) { return RegionCN470Verify( verify, phyAttribute ); } +#define CN470_APPLY_CF_LIST( ) { RegionCN470ApplyCFList( applyCFList ); break; } +#define CN470_CHAN_MASK_SET( ) { return RegionCN470ChanMaskSet( chanMaskSet ); } +#define CN470_COMPUTE_RX_WINDOW_PARAMETERS( ) { RegionCN470ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } +#define CN470_RX_CONFIG( ) { return RegionCN470RxConfig( rxConfig, datarate ); } +#define CN470_TX_CONFIG( ) { return RegionCN470TxConfig( txConfig, txPower, txTimeOnAir ); } +#define CN470_LINK_ADR_REQ( ) { return RegionCN470LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } +#define CN470_RX_PARAM_SETUP_REQ( ) { return RegionCN470RxParamSetupReq( rxParamSetupReq ); } +#define CN470_NEW_CHANNEL_REQ( ) { return RegionCN470NewChannelReq( newChannelReq ); } +#define CN470_TX_PARAM_SETUP_REQ( ) { return RegionCN470TxParamSetupReq( txParamSetupReq ); } +#define CN470_DL_CHANNEL_REQ( ) { return RegionCN470DlChannelReq( dlChannelReq ); } +#define CN470_ALTERNATE_DR( ) { return RegionCN470AlternateDr( currentDr, type ); } +#define CN470_NEXT_CHANNEL( ) { return RegionCN470NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } +#define CN470_CHANNEL_ADD( ) { return RegionCN470ChannelAdd( channelAdd ); } +#define CN470_CHANNEL_REMOVE( ) { return RegionCN470ChannelsRemove( channelRemove ); } +#define CN470_APPLY_DR_OFFSET( ) { return RegionCN470ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } +#define CN470_RX_BEACON_SETUP( ) { RegionCN470RxBeaconSetup( rxBeaconSetup, outDr ); break; } +// #else +// #define CN470_IS_ACTIVE( ) +// #define CN470_GET_PHY_PARAM( ) +// #define CN470_SET_BAND_TX_DONE( ) +// #define CN470_INIT_DEFAULTS( ) +// #define CN470_GET_NVM_CTX( ) +// #define CN470_VERIFY( ) +// #define CN470_APPLY_CF_LIST( ) +// #define CN470_CHAN_MASK_SET( ) +// #define CN470_COMPUTE_RX_WINDOW_PARAMETERS( ) +// #define CN470_RX_CONFIG( ) +// #define CN470_TX_CONFIG( ) +// #define CN470_LINK_ADR_REQ( ) +// #define CN470_RX_PARAM_SETUP_REQ( ) +// #define CN470_NEW_CHANNEL_REQ( ) +// #define CN470_TX_PARAM_SETUP_REQ( ) +// #define CN470_DL_CHANNEL_REQ( ) +// #define CN470_ALTERNATE_DR( ) +// #define CN470_NEXT_CHANNEL( ) +// #define CN470_CHANNEL_ADD( ) +// #define CN470_CHANNEL_REMOVE( ) +// #define CN470_APPLY_DR_OFFSET( ) +// #define CN470_RX_BEACON_SETUP( ) +// #endif + +// #ifdef REGION_CN779 #include "RegionCN779.h" -#define CN779_CASE case LORAMAC_REGION_CN779: -#define CN779_IS_ACTIVE( ) CN779_CASE { return true; } -#define CN779_GET_PHY_PARAM( ) CN779_CASE { return RegionCN779GetPhyParam( getPhy ); } -#define CN779_SET_BAND_TX_DONE( ) CN779_CASE { RegionCN779SetBandTxDone( txDone ); break; } -#define CN779_INIT_DEFAULTS( ) CN779_CASE { RegionCN779InitDefaults( params ); break; } -#define CN779_VERIFY( ) CN779_CASE { return RegionCN779Verify( verify, phyAttribute ); } -#define CN779_APPLY_CF_LIST( ) CN779_CASE { RegionCN779ApplyCFList( applyCFList ); break; } -#define CN779_CHAN_MASK_SET( ) CN779_CASE { return RegionCN779ChanMaskSet( chanMaskSet ); } -#define CN779_COMPUTE_RX_WINDOW_PARAMETERS( ) CN779_CASE { RegionCN779ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } -#define CN779_RX_CONFIG( ) CN779_CASE { return RegionCN779RxConfig( rxConfig, datarate ); } -#define CN779_TX_CONFIG( ) CN779_CASE { return RegionCN779TxConfig( txConfig, txPower, txTimeOnAir ); } -#define CN779_LINK_ADR_REQ( ) CN779_CASE { return RegionCN779LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } -#define CN779_RX_PARAM_SETUP_REQ( ) CN779_CASE { return RegionCN779RxParamSetupReq( rxParamSetupReq ); } -#define CN779_NEW_CHANNEL_REQ( ) CN779_CASE { return RegionCN779NewChannelReq( newChannelReq ); } -#define CN779_TX_PARAM_SETUP_REQ( ) CN779_CASE { return RegionCN779TxParamSetupReq( txParamSetupReq ); } -#define CN779_DL_CHANNEL_REQ( ) CN779_CASE { return RegionCN779DlChannelReq( dlChannelReq ); } -#define CN779_ALTERNATE_DR( ) CN779_CASE { return RegionCN779AlternateDr( currentDr, type ); } -#define CN779_NEXT_CHANNEL( ) CN779_CASE { return RegionCN779NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } -#define CN779_CHANNEL_ADD( ) CN779_CASE { return RegionCN779ChannelAdd( channelAdd ); } -#define CN779_CHANNEL_REMOVE( ) CN779_CASE { return RegionCN779ChannelsRemove( channelRemove ); } -#define CN779_APPLY_DR_OFFSET( ) CN779_CASE { return RegionCN779ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } -#define CN779_RX_BEACON_SETUP( ) CN779_CASE { RegionCN779RxBeaconSetup( rxBeaconSetup, outDr ); break; } -#else -#define CN779_IS_ACTIVE( ) -#define CN779_GET_PHY_PARAM( ) -#define CN779_SET_BAND_TX_DONE( ) -#define CN779_INIT_DEFAULTS( ) -#define CN779_GET_NVM_CTX( ) -#define CN779_VERIFY( ) -#define CN779_APPLY_CF_LIST( ) -#define CN779_CHAN_MASK_SET( ) -#define CN779_COMPUTE_RX_WINDOW_PARAMETERS( ) -#define CN779_RX_CONFIG( ) -#define CN779_TX_CONFIG( ) -#define CN779_LINK_ADR_REQ( ) -#define CN779_RX_PARAM_SETUP_REQ( ) -#define CN779_NEW_CHANNEL_REQ( ) -#define CN779_TX_PARAM_SETUP_REQ( ) -#define CN779_DL_CHANNEL_REQ( ) -#define CN779_ALTERNATE_DR( ) -#define CN779_NEXT_CHANNEL( ) -#define CN779_CHANNEL_ADD( ) -#define CN779_CHANNEL_REMOVE( ) -#define CN779_APPLY_DR_OFFSET( ) -#define CN779_RX_BEACON_SETUP( ) -#endif - -#ifdef REGION_EU433 +//#define CN779_CASE case LORAMAC_REGION_CN779: +#define CN779_IS_ACTIVE( ) { return true; } +#define CN779_GET_PHY_PARAM( ) { return RegionCN779GetPhyParam( getPhy ); } +#define CN779_SET_BAND_TX_DONE( ) { RegionCN779SetBandTxDone( txDone ); break; } +#define CN779_INIT_DEFAULTS( ) { RegionCN779InitDefaults( params ); break; } +#define CN779_VERIFY( ) { return RegionCN779Verify( verify, phyAttribute ); } +#define CN779_APPLY_CF_LIST( ) { RegionCN779ApplyCFList( applyCFList ); break; } +#define CN779_CHAN_MASK_SET( ) { return RegionCN779ChanMaskSet( chanMaskSet ); } +#define CN779_COMPUTE_RX_WINDOW_PARAMETERS( ) { RegionCN779ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } +#define CN779_RX_CONFIG( ) { return RegionCN779RxConfig( rxConfig, datarate ); } +#define CN779_TX_CONFIG( ) { return RegionCN779TxConfig( txConfig, txPower, txTimeOnAir ); } +#define CN779_LINK_ADR_REQ( ) { return RegionCN779LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } +#define CN779_RX_PARAM_SETUP_REQ( ) { return RegionCN779RxParamSetupReq( rxParamSetupReq ); } +#define CN779_NEW_CHANNEL_REQ( ) { return RegionCN779NewChannelReq( newChannelReq ); } +#define CN779_TX_PARAM_SETUP_REQ( ) { return RegionCN779TxParamSetupReq( txParamSetupReq ); } +#define CN779_DL_CHANNEL_REQ( ) { return RegionCN779DlChannelReq( dlChannelReq ); } +#define CN779_ALTERNATE_DR( ) { return RegionCN779AlternateDr( currentDr, type ); } +#define CN779_NEXT_CHANNEL( ) { return RegionCN779NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } +#define CN779_CHANNEL_ADD( ) { return RegionCN779ChannelAdd( channelAdd ); } +#define CN779_CHANNEL_REMOVE( ) { return RegionCN779ChannelsRemove( channelRemove ); } +#define CN779_APPLY_DR_OFFSET( ) { return RegionCN779ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } +#define CN779_RX_BEACON_SETUP( ) { RegionCN779RxBeaconSetup( rxBeaconSetup, outDr ); break; } +// #else +// #define CN779_IS_ACTIVE( ) +// #define CN779_GET_PHY_PARAM( ) +// #define CN779_SET_BAND_TX_DONE( ) +// #define CN779_INIT_DEFAULTS( ) +// #define CN779_GET_NVM_CTX( ) +// #define CN779_VERIFY( ) +// #define CN779_APPLY_CF_LIST( ) +// #define CN779_CHAN_MASK_SET( ) +// #define CN779_COMPUTE_RX_WINDOW_PARAMETERS( ) +// #define CN779_RX_CONFIG( ) +// #define CN779_TX_CONFIG( ) +// #define CN779_LINK_ADR_REQ( ) +// #define CN779_RX_PARAM_SETUP_REQ( ) +// #define CN779_NEW_CHANNEL_REQ( ) +// #define CN779_TX_PARAM_SETUP_REQ( ) +// #define CN779_DL_CHANNEL_REQ( ) +// #define CN779_ALTERNATE_DR( ) +// #define CN779_NEXT_CHANNEL( ) +// #define CN779_CHANNEL_ADD( ) +// #define CN779_CHANNEL_REMOVE( ) +// #define CN779_APPLY_DR_OFFSET( ) +// #define CN779_RX_BEACON_SETUP( ) +// #endif + +// #ifdef REGION_EU433 #include "RegionEU433.h" -#define EU433_CASE case LORAMAC_REGION_EU433: -#define EU433_IS_ACTIVE( ) EU433_CASE { return true; } -#define EU433_GET_PHY_PARAM( ) EU433_CASE { return RegionEU433GetPhyParam( getPhy ); } -#define EU433_SET_BAND_TX_DONE( ) EU433_CASE { RegionEU433SetBandTxDone( txDone ); break; } -#define EU433_INIT_DEFAULTS( ) EU433_CASE { RegionEU433InitDefaults( params ); break; } -#define EU433_VERIFY( ) EU433_CASE { return RegionEU433Verify( verify, phyAttribute ); } -#define EU433_APPLY_CF_LIST( ) EU433_CASE { RegionEU433ApplyCFList( applyCFList ); break; } -#define EU433_CHAN_MASK_SET( ) EU433_CASE { return RegionEU433ChanMaskSet( chanMaskSet ); } -#define EU433_COMPUTE_RX_WINDOW_PARAMETERS( ) EU433_CASE { RegionEU433ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } -#define EU433_RX_CONFIG( ) EU433_CASE { return RegionEU433RxConfig( rxConfig, datarate ); } -#define EU433_TX_CONFIG( ) EU433_CASE { return RegionEU433TxConfig( txConfig, txPower, txTimeOnAir ); } -#define EU433_LINK_ADR_REQ( ) EU433_CASE { return RegionEU433LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } -#define EU433_RX_PARAM_SETUP_REQ( ) EU433_CASE { return RegionEU433RxParamSetupReq( rxParamSetupReq ); } -#define EU433_NEW_CHANNEL_REQ( ) EU433_CASE { return RegionEU433NewChannelReq( newChannelReq ); } -#define EU433_TX_PARAM_SETUP_REQ( ) EU433_CASE { return RegionEU433TxParamSetupReq( txParamSetupReq ); } -#define EU433_DL_CHANNEL_REQ( ) EU433_CASE { return RegionEU433DlChannelReq( dlChannelReq ); } -#define EU433_ALTERNATE_DR( ) EU433_CASE { return RegionEU433AlternateDr( currentDr, type ); } -#define EU433_NEXT_CHANNEL( ) EU433_CASE { return RegionEU433NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } -#define EU433_CHANNEL_ADD( ) EU433_CASE { return RegionEU433ChannelAdd( channelAdd ); } -#define EU433_CHANNEL_REMOVE( ) EU433_CASE { return RegionEU433ChannelsRemove( channelRemove ); } -#define EU433_APPLY_DR_OFFSET( ) EU433_CASE { return RegionEU433ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } -#define EU433_RX_BEACON_SETUP( ) EU433_CASE { RegionEU433RxBeaconSetup( rxBeaconSetup, outDr ); break; } -#else -#define EU433_IS_ACTIVE( ) -#define EU433_GET_PHY_PARAM( ) -#define EU433_SET_BAND_TX_DONE( ) -#define EU433_INIT_DEFAULTS( ) -#define EU433_GET_NVM_CTX( ) -#define EU433_VERIFY( ) -#define EU433_APPLY_CF_LIST( ) -#define EU433_CHAN_MASK_SET( ) -#define EU433_COMPUTE_RX_WINDOW_PARAMETERS( ) -#define EU433_RX_CONFIG( ) -#define EU433_TX_CONFIG( ) -#define EU433_LINK_ADR_REQ( ) -#define EU433_RX_PARAM_SETUP_REQ( ) -#define EU433_NEW_CHANNEL_REQ( ) -#define EU433_TX_PARAM_SETUP_REQ( ) -#define EU433_DL_CHANNEL_REQ( ) -#define EU433_ALTERNATE_DR( ) -#define EU433_NEXT_CHANNEL( ) -#define EU433_CHANNEL_ADD( ) -#define EU433_CHANNEL_REMOVE( ) -#define EU433_APPLY_DR_OFFSET( ) -#define EU433_RX_BEACON_SETUP( ) -#endif - -#ifdef REGION_EU868 +//#define EU433_CASE case LORAMAC_REGION_EU433: +#define EU433_IS_ACTIVE( ) { return true; } +#define EU433_GET_PHY_PARAM( ) { return RegionEU433GetPhyParam( getPhy ); } +#define EU433_SET_BAND_TX_DONE( ) { RegionEU433SetBandTxDone( txDone ); break; } +#define EU433_INIT_DEFAULTS( ) { RegionEU433InitDefaults( params ); break; } +#define EU433_VERIFY( ) { return RegionEU433Verify( verify, phyAttribute ); } +#define EU433_APPLY_CF_LIST( ) { RegionEU433ApplyCFList( applyCFList ); break; } +#define EU433_CHAN_MASK_SET( ) { return RegionEU433ChanMaskSet( chanMaskSet ); } +#define EU433_COMPUTE_RX_WINDOW_PARAMETERS( ) { RegionEU433ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } +#define EU433_RX_CONFIG( ) { return RegionEU433RxConfig( rxConfig, datarate ); } +#define EU433_TX_CONFIG( ) { return RegionEU433TxConfig( txConfig, txPower, txTimeOnAir ); } +#define EU433_LINK_ADR_REQ( ) { return RegionEU433LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } +#define EU433_RX_PARAM_SETUP_REQ( ) { return RegionEU433RxParamSetupReq( rxParamSetupReq ); } +#define EU433_NEW_CHANNEL_REQ( ) { return RegionEU433NewChannelReq( newChannelReq ); } +#define EU433_TX_PARAM_SETUP_REQ( ) { return RegionEU433TxParamSetupReq( txParamSetupReq ); } +#define EU433_DL_CHANNEL_REQ( ) { return RegionEU433DlChannelReq( dlChannelReq ); } +#define EU433_ALTERNATE_DR( ) { return RegionEU433AlternateDr( currentDr, type ); } +#define EU433_NEXT_CHANNEL( ) { return RegionEU433NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } +#define EU433_CHANNEL_ADD( ) { return RegionEU433ChannelAdd( channelAdd ); } +#define EU433_CHANNEL_REMOVE( ) { return RegionEU433ChannelsRemove( channelRemove ); } +#define EU433_APPLY_DR_OFFSET( ) { return RegionEU433ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } +#define EU433_RX_BEACON_SETUP( ) { RegionEU433RxBeaconSetup( rxBeaconSetup, outDr ); break; } +// #else +// #define EU433_IS_ACTIVE( ) +// #define EU433_GET_PHY_PARAM( ) +// #define EU433_SET_BAND_TX_DONE( ) +// #define EU433_INIT_DEFAULTS( ) +// #define EU433_GET_NVM_CTX( ) +// #define EU433_VERIFY( ) +// #define EU433_APPLY_CF_LIST( ) +// #define EU433_CHAN_MASK_SET( ) +// #define EU433_COMPUTE_RX_WINDOW_PARAMETERS( ) +// #define EU433_RX_CONFIG( ) +// #define EU433_TX_CONFIG( ) +// #define EU433_LINK_ADR_REQ( ) +// #define EU433_RX_PARAM_SETUP_REQ( ) +// #define EU433_NEW_CHANNEL_REQ( ) +// #define EU433_TX_PARAM_SETUP_REQ( ) +// #define EU433_DL_CHANNEL_REQ( ) +// #define EU433_ALTERNATE_DR( ) +// #define EU433_NEXT_CHANNEL( ) +// #define EU433_CHANNEL_ADD( ) +// #define EU433_CHANNEL_REMOVE( ) +// #define EU433_APPLY_DR_OFFSET( ) +// #define EU433_RX_BEACON_SETUP( ) +// #endif + +// #ifdef REGION_EU868 #include "RegionEU868.h" -#define EU868_CASE case LORAMAC_REGION_EU868: -#define EU868_IS_ACTIVE( ) EU868_CASE { return true; } -#define EU868_GET_PHY_PARAM( ) EU868_CASE { return RegionEU868GetPhyParam( getPhy ); } -#define EU868_SET_BAND_TX_DONE( ) EU868_CASE { RegionEU868SetBandTxDone( txDone ); break; } -#define EU868_INIT_DEFAULTS( ) EU868_CASE { RegionEU868InitDefaults( params ); break; } -#define EU868_VERIFY( ) EU868_CASE { return RegionEU868Verify( verify, phyAttribute ); } -#define EU868_APPLY_CF_LIST( ) EU868_CASE { RegionEU868ApplyCFList( applyCFList ); break; } -#define EU868_CHAN_MASK_SET( ) EU868_CASE { return RegionEU868ChanMaskSet( chanMaskSet ); } -#define EU868_COMPUTE_RX_WINDOW_PARAMETERS( ) EU868_CASE { RegionEU868ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } -#define EU868_RX_CONFIG( ) EU868_CASE { return RegionEU868RxConfig( rxConfig, datarate ); } -#define EU868_TX_CONFIG( ) EU868_CASE { return RegionEU868TxConfig( txConfig, txPower, txTimeOnAir ); } -#define EU868_LINK_ADR_REQ( ) EU868_CASE { return RegionEU868LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } -#define EU868_RX_PARAM_SETUP_REQ( ) EU868_CASE { return RegionEU868RxParamSetupReq( rxParamSetupReq ); } -#define EU868_NEW_CHANNEL_REQ( ) EU868_CASE { return RegionEU868NewChannelReq( newChannelReq ); } -#define EU868_TX_PARAM_SETUP_REQ( ) EU868_CASE { return RegionEU868TxParamSetupReq( txParamSetupReq ); } -#define EU868_DL_CHANNEL_REQ( ) EU868_CASE { return RegionEU868DlChannelReq( dlChannelReq ); } -#define EU868_ALTERNATE_DR( ) EU868_CASE { return RegionEU868AlternateDr( currentDr, type ); } -#define EU868_NEXT_CHANNEL( ) EU868_CASE { return RegionEU868NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } -#define EU868_CHANNEL_ADD( ) EU868_CASE { return RegionEU868ChannelAdd( channelAdd ); } -#define EU868_CHANNEL_REMOVE( ) EU868_CASE { return RegionEU868ChannelsRemove( channelRemove ); } -#define EU868_APPLY_DR_OFFSET( ) EU868_CASE { return RegionEU868ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } -#define EU868_RX_BEACON_SETUP( ) EU868_CASE { RegionEU868RxBeaconSetup( rxBeaconSetup, outDr ); break; } -#else -#define EU868_IS_ACTIVE( ) -#define EU868_GET_PHY_PARAM( ) -#define EU868_SET_BAND_TX_DONE( ) -#define EU868_INIT_DEFAULTS( ) -#define EU868_GET_NVM_CTX( ) -#define EU868_VERIFY( ) -#define EU868_APPLY_CF_LIST( ) -#define EU868_CHAN_MASK_SET( ) -#define EU868_COMPUTE_RX_WINDOW_PARAMETERS( ) -#define EU868_RX_CONFIG( ) -#define EU868_TX_CONFIG( ) -#define EU868_LINK_ADR_REQ( ) -#define EU868_RX_PARAM_SETUP_REQ( ) -#define EU868_NEW_CHANNEL_REQ( ) -#define EU868_TX_PARAM_SETUP_REQ( ) -#define EU868_DL_CHANNEL_REQ( ) -#define EU868_ALTERNATE_DR( ) -#define EU868_NEXT_CHANNEL( ) -#define EU868_CHANNEL_ADD( ) -#define EU868_CHANNEL_REMOVE( ) -#define EU868_APPLY_DR_OFFSET( ) -#define EU868_RX_BEACON_SETUP( ) -#endif - -#ifdef REGION_KR920 +//#define EU868_CASE case LORAMAC_REGION_EU868: +#define EU868_IS_ACTIVE( ) { return true; } +#define EU868_GET_PHY_PARAM( ) { return RegionEU868GetPhyParam( getPhy ); } +#define EU868_SET_BAND_TX_DONE( ) { RegionEU868SetBandTxDone( txDone ); break; } +#define EU868_INIT_DEFAULTS( ) { RegionEU868InitDefaults( params ); break; } +#define EU868_VERIFY( ) { return RegionEU868Verify( verify, phyAttribute ); } +#define EU868_APPLY_CF_LIST( ) { RegionEU868ApplyCFList( applyCFList ); break; } +#define EU868_CHAN_MASK_SET( ) { return RegionEU868ChanMaskSet( chanMaskSet ); } +#define EU868_COMPUTE_RX_WINDOW_PARAMETERS( ) { RegionEU868ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } +#define EU868_RX_CONFIG( ) { return RegionEU868RxConfig( rxConfig, datarate ); } +#define EU868_TX_CONFIG( ) { return RegionEU868TxConfig( txConfig, txPower, txTimeOnAir ); } +#define EU868_LINK_ADR_REQ( ) { return RegionEU868LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } +#define EU868_RX_PARAM_SETUP_REQ( ) { return RegionEU868RxParamSetupReq( rxParamSetupReq ); } +#define EU868_NEW_CHANNEL_REQ( ) { return RegionEU868NewChannelReq( newChannelReq ); } +#define EU868_TX_PARAM_SETUP_REQ( ) { return RegionEU868TxParamSetupReq( txParamSetupReq ); } +#define EU868_DL_CHANNEL_REQ( ) { return RegionEU868DlChannelReq( dlChannelReq ); } +#define EU868_ALTERNATE_DR( ) { return RegionEU868AlternateDr( currentDr, type ); } +#define EU868_NEXT_CHANNEL( ) { return RegionEU868NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } +#define EU868_CHANNEL_ADD( ) { return RegionEU868ChannelAdd( channelAdd ); } +#define EU868_CHANNEL_REMOVE( ) { return RegionEU868ChannelsRemove( channelRemove ); } +#define EU868_APPLY_DR_OFFSET( ) { return RegionEU868ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } +#define EU868_RX_BEACON_SETUP( ) { RegionEU868RxBeaconSetup( rxBeaconSetup, outDr ); break; } +// #else +// #define EU868_IS_ACTIVE( ) +// #define EU868_GET_PHY_PARAM( ) +// #define EU868_SET_BAND_TX_DONE( ) +// #define EU868_INIT_DEFAULTS( ) +// #define EU868_GET_NVM_CTX( ) +// #define EU868_VERIFY( ) +// #define EU868_APPLY_CF_LIST( ) +// #define EU868_CHAN_MASK_SET( ) +// #define EU868_COMPUTE_RX_WINDOW_PARAMETERS( ) +// #define EU868_RX_CONFIG( ) +// #define EU868_TX_CONFIG( ) +// #define EU868_LINK_ADR_REQ( ) +// #define EU868_RX_PARAM_SETUP_REQ( ) +// #define EU868_NEW_CHANNEL_REQ( ) +// #define EU868_TX_PARAM_SETUP_REQ( ) +// #define EU868_DL_CHANNEL_REQ( ) +// #define EU868_ALTERNATE_DR( ) +// #define EU868_NEXT_CHANNEL( ) +// #define EU868_CHANNEL_ADD( ) +// #define EU868_CHANNEL_REMOVE( ) +// #define EU868_APPLY_DR_OFFSET( ) +// #define EU868_RX_BEACON_SETUP( ) +// #endif + +// #ifdef REGION_KR920 #include "RegionKR920.h" -#define KR920_CASE case LORAMAC_REGION_KR920: -#define KR920_IS_ACTIVE( ) KR920_CASE { return true; } -#define KR920_GET_PHY_PARAM( ) KR920_CASE { return RegionKR920GetPhyParam( getPhy ); } -#define KR920_SET_BAND_TX_DONE( ) KR920_CASE { RegionKR920SetBandTxDone( txDone ); break; } -#define KR920_INIT_DEFAULTS( ) KR920_CASE { RegionKR920InitDefaults( params ); break; } -#define KR920_VERIFY( ) KR920_CASE { return RegionKR920Verify( verify, phyAttribute ); } -#define KR920_APPLY_CF_LIST( ) KR920_CASE { RegionKR920ApplyCFList( applyCFList ); break; } -#define KR920_CHAN_MASK_SET( ) KR920_CASE { return RegionKR920ChanMaskSet( chanMaskSet ); } -#define KR920_COMPUTE_RX_WINDOW_PARAMETERS( ) KR920_CASE { RegionKR920ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } -#define KR920_RX_CONFIG( ) KR920_CASE { return RegionKR920RxConfig( rxConfig, datarate ); } -#define KR920_TX_CONFIG( ) KR920_CASE { return RegionKR920TxConfig( txConfig, txPower, txTimeOnAir ); } -#define KR920_LINK_ADR_REQ( ) KR920_CASE { return RegionKR920LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } -#define KR920_RX_PARAM_SETUP_REQ( ) KR920_CASE { return RegionKR920RxParamSetupReq( rxParamSetupReq ); } -#define KR920_NEW_CHANNEL_REQ( ) KR920_CASE { return RegionKR920NewChannelReq( newChannelReq ); } -#define KR920_TX_PARAM_SETUP_REQ( ) KR920_CASE { return RegionKR920TxParamSetupReq( txParamSetupReq ); } -#define KR920_DL_CHANNEL_REQ( ) KR920_CASE { return RegionKR920DlChannelReq( dlChannelReq ); } -#define KR920_ALTERNATE_DR( ) KR920_CASE { return RegionKR920AlternateDr( currentDr, type ); } -#define KR920_NEXT_CHANNEL( ) KR920_CASE { return RegionKR920NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } -#define KR920_CHANNEL_ADD( ) KR920_CASE { return RegionKR920ChannelAdd( channelAdd ); } -#define KR920_CHANNEL_REMOVE( ) KR920_CASE { return RegionKR920ChannelsRemove( channelRemove ); } -#define KR920_APPLY_DR_OFFSET( ) KR920_CASE { return RegionKR920ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } -#define KR920_RX_BEACON_SETUP( ) KR920_CASE { RegionKR920RxBeaconSetup( rxBeaconSetup, outDr ); break; } -#else -#define KR920_IS_ACTIVE( ) -#define KR920_GET_PHY_PARAM( ) -#define KR920_SET_BAND_TX_DONE( ) -#define KR920_INIT_DEFAULTS( ) -#define KR920_GET_NVM_CTX( ) -#define KR920_VERIFY( ) -#define KR920_APPLY_CF_LIST( ) -#define KR920_CHAN_MASK_SET( ) -#define KR920_COMPUTE_RX_WINDOW_PARAMETERS( ) -#define KR920_RX_CONFIG( ) -#define KR920_TX_CONFIG( ) -#define KR920_LINK_ADR_REQ( ) -#define KR920_RX_PARAM_SETUP_REQ( ) -#define KR920_NEW_CHANNEL_REQ( ) -#define KR920_TX_PARAM_SETUP_REQ( ) -#define KR920_DL_CHANNEL_REQ( ) -#define KR920_ALTERNATE_DR( ) -#define KR920_NEXT_CHANNEL( ) -#define KR920_CHANNEL_ADD( ) -#define KR920_CHANNEL_REMOVE( ) -#define KR920_APPLY_DR_OFFSET( ) -#define KR920_RX_BEACON_SETUP( ) -#endif - -#ifdef REGION_IN865 +//#define KR920_CASE case LORAMAC_REGION_KR920: +#define KR920_IS_ACTIVE( ) { return true; } +#define KR920_GET_PHY_PARAM( ) { return RegionKR920GetPhyParam( getPhy ); } +#define KR920_SET_BAND_TX_DONE( ) { RegionKR920SetBandTxDone( txDone ); break; } +#define KR920_INIT_DEFAULTS( ) { RegionKR920InitDefaults( params ); break; } +#define KR920_VERIFY( ) { return RegionKR920Verify( verify, phyAttribute ); } +#define KR920_APPLY_CF_LIST( ) { RegionKR920ApplyCFList( applyCFList ); break; } +#define KR920_CHAN_MASK_SET( ) { return RegionKR920ChanMaskSet( chanMaskSet ); } +#define KR920_COMPUTE_RX_WINDOW_PARAMETERS( ) { RegionKR920ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } +#define KR920_RX_CONFIG( ) { return RegionKR920RxConfig( rxConfig, datarate ); } +#define KR920_TX_CONFIG( ) { return RegionKR920TxConfig( txConfig, txPower, txTimeOnAir ); } +#define KR920_LINK_ADR_REQ( ) { return RegionKR920LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } +#define KR920_RX_PARAM_SETUP_REQ( ) { return RegionKR920RxParamSetupReq( rxParamSetupReq ); } +#define KR920_NEW_CHANNEL_REQ( ) { return RegionKR920NewChannelReq( newChannelReq ); } +#define KR920_TX_PARAM_SETUP_REQ( ) { return RegionKR920TxParamSetupReq( txParamSetupReq ); } +#define KR920_DL_CHANNEL_REQ( ) { return RegionKR920DlChannelReq( dlChannelReq ); } +#define KR920_ALTERNATE_DR( ) { return RegionKR920AlternateDr( currentDr, type ); } +#define KR920_NEXT_CHANNEL( ) { return RegionKR920NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } +#define KR920_CHANNEL_ADD( ) { return RegionKR920ChannelAdd( channelAdd ); } +#define KR920_CHANNEL_REMOVE( ) { return RegionKR920ChannelsRemove( channelRemove ); } +#define KR920_APPLY_DR_OFFSET( ) { return RegionKR920ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } +#define KR920_RX_BEACON_SETUP( ) { RegionKR920RxBeaconSetup( rxBeaconSetup, outDr ); break; } +// #else +// #define KR920_IS_ACTIVE( ) +// #define KR920_GET_PHY_PARAM( ) +// #define KR920_SET_BAND_TX_DONE( ) +// #define KR920_INIT_DEFAULTS( ) +// #define KR920_GET_NVM_CTX( ) +// #define KR920_VERIFY( ) +// #define KR920_APPLY_CF_LIST( ) +// #define KR920_CHAN_MASK_SET( ) +// #define KR920_COMPUTE_RX_WINDOW_PARAMETERS( ) +// #define KR920_RX_CONFIG( ) +// #define KR920_TX_CONFIG( ) +// #define KR920_LINK_ADR_REQ( ) +// #define KR920_RX_PARAM_SETUP_REQ( ) +// #define KR920_NEW_CHANNEL_REQ( ) +// #define KR920_TX_PARAM_SETUP_REQ( ) +// #define KR920_DL_CHANNEL_REQ( ) +// #define KR920_ALTERNATE_DR( ) +// #define KR920_NEXT_CHANNEL( ) +// #define KR920_CHANNEL_ADD( ) +// #define KR920_CHANNEL_REMOVE( ) +// #define KR920_APPLY_DR_OFFSET( ) +// #define KR920_RX_BEACON_SETUP( ) +// #endif + +// #ifdef REGION_IN865 #include "RegionIN865.h" -#define IN865_CASE case LORAMAC_REGION_IN865: -#define IN865_IS_ACTIVE( ) IN865_CASE { return true; } -#define IN865_GET_PHY_PARAM( ) IN865_CASE { return RegionIN865GetPhyParam( getPhy ); } -#define IN865_SET_BAND_TX_DONE( ) IN865_CASE { RegionIN865SetBandTxDone( txDone ); break; } -#define IN865_INIT_DEFAULTS( ) IN865_CASE { RegionIN865InitDefaults( params ); break; } -#define IN865_VERIFY( ) IN865_CASE { return RegionIN865Verify( verify, phyAttribute ); } -#define IN865_APPLY_CF_LIST( ) IN865_CASE { RegionIN865ApplyCFList( applyCFList ); break; } -#define IN865_CHAN_MASK_SET( ) IN865_CASE { return RegionIN865ChanMaskSet( chanMaskSet ); } -#define IN865_COMPUTE_RX_WINDOW_PARAMETERS( ) IN865_CASE { RegionIN865ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } -#define IN865_RX_CONFIG( ) IN865_CASE { return RegionIN865RxConfig( rxConfig, datarate ); } -#define IN865_TX_CONFIG( ) IN865_CASE { return RegionIN865TxConfig( txConfig, txPower, txTimeOnAir ); } -#define IN865_LINK_ADR_REQ( ) IN865_CASE { return RegionIN865LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } -#define IN865_RX_PARAM_SETUP_REQ( ) IN865_CASE { return RegionIN865RxParamSetupReq( rxParamSetupReq ); } -#define IN865_NEW_CHANNEL_REQ( ) IN865_CASE { return RegionIN865NewChannelReq( newChannelReq ); } -#define IN865_TX_PARAM_SETUP_REQ( ) IN865_CASE { return RegionIN865TxParamSetupReq( txParamSetupReq ); } -#define IN865_DL_CHANNEL_REQ( ) IN865_CASE { return RegionIN865DlChannelReq( dlChannelReq ); } -#define IN865_ALTERNATE_DR( ) IN865_CASE { return RegionIN865AlternateDr( currentDr, type ); } -#define IN865_NEXT_CHANNEL( ) IN865_CASE { return RegionIN865NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } -#define IN865_CHANNEL_ADD( ) IN865_CASE { return RegionIN865ChannelAdd( channelAdd ); } -#define IN865_CHANNEL_REMOVE( ) IN865_CASE { return RegionIN865ChannelsRemove( channelRemove ); } -#define IN865_APPLY_DR_OFFSET( ) IN865_CASE { return RegionIN865ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } -#define IN865_RX_BEACON_SETUP( ) IN865_CASE { RegionIN865RxBeaconSetup( rxBeaconSetup, outDr ); break; } -#else -#define IN865_IS_ACTIVE( ) -#define IN865_GET_PHY_PARAM( ) -#define IN865_SET_BAND_TX_DONE( ) -#define IN865_INIT_DEFAULTS( ) -#define IN865_GET_NVM_CTX( ) -#define IN865_VERIFY( ) -#define IN865_APPLY_CF_LIST( ) -#define IN865_CHAN_MASK_SET( ) -#define IN865_COMPUTE_RX_WINDOW_PARAMETERS( ) -#define IN865_RX_CONFIG( ) -#define IN865_TX_CONFIG( ) -#define IN865_LINK_ADR_REQ( ) -#define IN865_RX_PARAM_SETUP_REQ( ) -#define IN865_NEW_CHANNEL_REQ( ) -#define IN865_TX_PARAM_SETUP_REQ( ) -#define IN865_DL_CHANNEL_REQ( ) -#define IN865_ALTERNATE_DR( ) -#define IN865_NEXT_CHANNEL( ) -#define IN865_CHANNEL_ADD( ) -#define IN865_CHANNEL_REMOVE( ) -#define IN865_APPLY_DR_OFFSET( ) -#define IN865_RX_BEACON_SETUP( ) -#endif - -#ifdef REGION_US915 +//#define IN865_CASE case LORAMAC_REGION_IN865: +#define IN865_IS_ACTIVE( ) { return true; } +#define IN865_GET_PHY_PARAM( ) { return RegionIN865GetPhyParam( getPhy ); } +#define IN865_SET_BAND_TX_DONE( ) { RegionIN865SetBandTxDone( txDone ); break; } +#define IN865_INIT_DEFAULTS( ) { RegionIN865InitDefaults( params ); break; } +#define IN865_VERIFY( ) { return RegionIN865Verify( verify, phyAttribute ); } +#define IN865_APPLY_CF_LIST( ) { RegionIN865ApplyCFList( applyCFList ); break; } +#define IN865_CHAN_MASK_SET( ) { return RegionIN865ChanMaskSet( chanMaskSet ); } +#define IN865_COMPUTE_RX_WINDOW_PARAMETERS( ) { RegionIN865ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } +#define IN865_RX_CONFIG( ) { return RegionIN865RxConfig( rxConfig, datarate ); } +#define IN865_TX_CONFIG( ) { return RegionIN865TxConfig( txConfig, txPower, txTimeOnAir ); } +#define IN865_LINK_ADR_REQ( ) { return RegionIN865LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } +#define IN865_RX_PARAM_SETUP_REQ( ) { return RegionIN865RxParamSetupReq( rxParamSetupReq ); } +#define IN865_NEW_CHANNEL_REQ( ) { return RegionIN865NewChannelReq( newChannelReq ); } +#define IN865_TX_PARAM_SETUP_REQ( ) { return RegionIN865TxParamSetupReq( txParamSetupReq ); } +#define IN865_DL_CHANNEL_REQ( ) { return RegionIN865DlChannelReq( dlChannelReq ); } +#define IN865_ALTERNATE_DR( ) { return RegionIN865AlternateDr( currentDr, type ); } +#define IN865_NEXT_CHANNEL( ) { return RegionIN865NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } +#define IN865_CHANNEL_ADD( ) { return RegionIN865ChannelAdd( channelAdd ); } +#define IN865_CHANNEL_REMOVE( ) { return RegionIN865ChannelsRemove( channelRemove ); } +#define IN865_APPLY_DR_OFFSET( ) { return RegionIN865ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } +#define IN865_RX_BEACON_SETUP( ) { RegionIN865RxBeaconSetup( rxBeaconSetup, outDr ); break; } +// #else +// #define IN865_IS_ACTIVE( ) +// #define IN865_GET_PHY_PARAM( ) +// #define IN865_SET_BAND_TX_DONE( ) +// #define IN865_INIT_DEFAULTS( ) +// #define IN865_GET_NVM_CTX( ) +// #define IN865_VERIFY( ) +// #define IN865_APPLY_CF_LIST( ) +// #define IN865_CHAN_MASK_SET( ) +// #define IN865_COMPUTE_RX_WINDOW_PARAMETERS( ) +// #define IN865_RX_CONFIG( ) +// #define IN865_TX_CONFIG( ) +// #define IN865_LINK_ADR_REQ( ) +// #define IN865_RX_PARAM_SETUP_REQ( ) +// #define IN865_NEW_CHANNEL_REQ( ) +// #define IN865_TX_PARAM_SETUP_REQ( ) +// #define IN865_DL_CHANNEL_REQ( ) +// #define IN865_ALTERNATE_DR( ) +// #define IN865_NEXT_CHANNEL( ) +// #define IN865_CHANNEL_ADD( ) +// #define IN865_CHANNEL_REMOVE( ) +// #define IN865_APPLY_DR_OFFSET( ) +// #define IN865_RX_BEACON_SETUP( ) +// #endif + +// #ifdef REGION_US915 #include "RegionUS915.h" -#define US915_CASE case LORAMAC_REGION_US915: -#define US915_IS_ACTIVE( ) US915_CASE { return true; } -#define US915_GET_PHY_PARAM( ) US915_CASE { return RegionUS915GetPhyParam( getPhy ); } -#define US915_SET_BAND_TX_DONE( ) US915_CASE { RegionUS915SetBandTxDone( txDone ); break; } -#define US915_INIT_DEFAULTS( ) US915_CASE { RegionUS915InitDefaults( params ); break; } -#define US915_VERIFY( ) US915_CASE { return RegionUS915Verify( verify, phyAttribute ); } -#define US915_APPLY_CF_LIST( ) US915_CASE { RegionUS915ApplyCFList( applyCFList ); break; } -#define US915_CHAN_MASK_SET( ) US915_CASE { return RegionUS915ChanMaskSet( chanMaskSet ); } -#define US915_COMPUTE_RX_WINDOW_PARAMETERS( ) US915_CASE { RegionUS915ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } -#define US915_RX_CONFIG( ) US915_CASE { return RegionUS915RxConfig( rxConfig, datarate ); } -#define US915_TX_CONFIG( ) US915_CASE { return RegionUS915TxConfig( txConfig, txPower, txTimeOnAir ); } -#define US915_LINK_ADR_REQ( ) US915_CASE { return RegionUS915LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } -#define US915_RX_PARAM_SETUP_REQ( ) US915_CASE { return RegionUS915RxParamSetupReq( rxParamSetupReq ); } -#define US915_NEW_CHANNEL_REQ( ) US915_CASE { return RegionUS915NewChannelReq( newChannelReq ); } -#define US915_TX_PARAM_SETUP_REQ( ) US915_CASE { return RegionUS915TxParamSetupReq( txParamSetupReq ); } -#define US915_DL_CHANNEL_REQ( ) US915_CASE { return RegionUS915DlChannelReq( dlChannelReq ); } -#define US915_ALTERNATE_DR( ) US915_CASE { return RegionUS915AlternateDr( currentDr, type ); } -#define US915_NEXT_CHANNEL( ) US915_CASE { return RegionUS915NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } -#define US915_CHANNEL_ADD( ) US915_CASE { return RegionUS915ChannelAdd( channelAdd ); } -#define US915_CHANNEL_REMOVE( ) US915_CASE { return RegionUS915ChannelsRemove( channelRemove ); } -#define US915_APPLY_DR_OFFSET( ) US915_CASE { return RegionUS915ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } -#define US915_RX_BEACON_SETUP( ) US915_CASE { RegionUS915RxBeaconSetup( rxBeaconSetup, outDr ); break; } -#else -#define US915_IS_ACTIVE( ) -#define US915_GET_PHY_PARAM( ) -#define US915_SET_BAND_TX_DONE( ) -#define US915_INIT_DEFAULTS( ) -#define US915_GET_NVM_CTX( ) -#define US915_VERIFY( ) -#define US915_APPLY_CF_LIST( ) -#define US915_CHAN_MASK_SET( ) -#define US915_COMPUTE_RX_WINDOW_PARAMETERS( ) -#define US915_RX_CONFIG( ) -#define US915_TX_CONFIG( ) -#define US915_LINK_ADR_REQ( ) -#define US915_RX_PARAM_SETUP_REQ( ) -#define US915_NEW_CHANNEL_REQ( ) -#define US915_TX_PARAM_SETUP_REQ( ) -#define US915_DL_CHANNEL_REQ( ) -#define US915_ALTERNATE_DR( ) -#define US915_NEXT_CHANNEL( ) -#define US915_CHANNEL_ADD( ) -#define US915_CHANNEL_REMOVE( ) -#define US915_APPLY_DR_OFFSET( ) -#define US915_RX_BEACON_SETUP( ) -#endif - -#ifdef REGION_RU864 +//#define US915_CASE case LORAMAC_REGION_US915: +#define US915_IS_ACTIVE( ) { return true; } +#define US915_GET_PHY_PARAM( ) { return RegionUS915GetPhyParam( getPhy ); } +#define US915_SET_BAND_TX_DONE( ) { RegionUS915SetBandTxDone( txDone ); break; } +#define US915_INIT_DEFAULTS( ) { RegionUS915InitDefaults( params ); break; } +#define US915_VERIFY( ) { return RegionUS915Verify( verify, phyAttribute ); } +#define US915_APPLY_CF_LIST( ) { RegionUS915ApplyCFList( applyCFList ); break; } +#define US915_CHAN_MASK_SET( ) { return RegionUS915ChanMaskSet( chanMaskSet ); } +#define US915_COMPUTE_RX_WINDOW_PARAMETERS( ) { RegionUS915ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } +#define US915_RX_CONFIG( ) { return RegionUS915RxConfig( rxConfig, datarate ); } +#define US915_TX_CONFIG( ) { return RegionUS915TxConfig( txConfig, txPower, txTimeOnAir ); } +#define US915_LINK_ADR_REQ( ) { return RegionUS915LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } +#define US915_RX_PARAM_SETUP_REQ( ) { return RegionUS915RxParamSetupReq( rxParamSetupReq ); } +#define US915_NEW_CHANNEL_REQ( ) { return RegionUS915NewChannelReq( newChannelReq ); } +#define US915_TX_PARAM_SETUP_REQ( ) { return RegionUS915TxParamSetupReq( txParamSetupReq ); } +#define US915_DL_CHANNEL_REQ( ) { return RegionUS915DlChannelReq( dlChannelReq ); } +#define US915_ALTERNATE_DR( ) { return RegionUS915AlternateDr( currentDr, type ); } +#define US915_NEXT_CHANNEL( ) { return RegionUS915NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } +#define US915_CHANNEL_ADD( ) { return RegionUS915ChannelAdd( channelAdd ); } +#define US915_CHANNEL_REMOVE( ) { return RegionUS915ChannelsRemove( channelRemove ); } +#define US915_APPLY_DR_OFFSET( ) { return RegionUS915ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } +#define US915_RX_BEACON_SETUP( ) { RegionUS915RxBeaconSetup( rxBeaconSetup, outDr ); break; } +// #else +// #define US915_IS_ACTIVE( ) +// #define US915_GET_PHY_PARAM( ) +// #define US915_SET_BAND_TX_DONE( ) +// #define US915_INIT_DEFAULTS( ) +// #define US915_GET_NVM_CTX( ) +// #define US915_VERIFY( ) +// #define US915_APPLY_CF_LIST( ) +// #define US915_CHAN_MASK_SET( ) +// #define US915_COMPUTE_RX_WINDOW_PARAMETERS( ) +// #define US915_RX_CONFIG( ) +// #define US915_TX_CONFIG( ) +// #define US915_LINK_ADR_REQ( ) +// #define US915_RX_PARAM_SETUP_REQ( ) +// #define US915_NEW_CHANNEL_REQ( ) +// #define US915_TX_PARAM_SETUP_REQ( ) +// #define US915_DL_CHANNEL_REQ( ) +// #define US915_ALTERNATE_DR( ) +// #define US915_NEXT_CHANNEL( ) +// #define US915_CHANNEL_ADD( ) +// #define US915_CHANNEL_REMOVE( ) +// #define US915_APPLY_DR_OFFSET( ) +// #define US915_RX_BEACON_SETUP( ) +// #endif + +// #ifdef REGION_RU864 #include "RegionRU864.h" -#define RU864_CASE case LORAMAC_REGION_RU864: -#define RU864_IS_ACTIVE( ) RU864_CASE { return true; } -#define RU864_GET_PHY_PARAM( ) RU864_CASE { return RegionRU864GetPhyParam( getPhy ); } -#define RU864_SET_BAND_TX_DONE( ) RU864_CASE { RegionRU864SetBandTxDone( txDone ); break; } -#define RU864_INIT_DEFAULTS( ) RU864_CASE { RegionRU864InitDefaults( params ); break; } -#define RU864_VERIFY( ) RU864_CASE { return RegionRU864Verify( verify, phyAttribute ); } -#define RU864_APPLY_CF_LIST( ) RU864_CASE { RegionRU864ApplyCFList( applyCFList ); break; } -#define RU864_CHAN_MASK_SET( ) RU864_CASE { return RegionRU864ChanMaskSet( chanMaskSet ); } -#define RU864_COMPUTE_RX_WINDOW_PARAMETERS( ) RU864_CASE { RegionRU864ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } -#define RU864_RX_CONFIG( ) RU864_CASE { return RegionRU864RxConfig( rxConfig, datarate ); } -#define RU864_TX_CONFIG( ) RU864_CASE { return RegionRU864TxConfig( txConfig, txPower, txTimeOnAir ); } -#define RU864_LINK_ADR_REQ( ) RU864_CASE { return RegionRU864LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } -#define RU864_RX_PARAM_SETUP_REQ( ) RU864_CASE { return RegionRU864RxParamSetupReq( rxParamSetupReq ); } -#define RU864_NEW_CHANNEL_REQ( ) RU864_CASE { return RegionRU864NewChannelReq( newChannelReq ); } -#define RU864_TX_PARAM_SETUP_REQ( ) RU864_CASE { return RegionRU864TxParamSetupReq( txParamSetupReq ); } -#define RU864_DL_CHANNEL_REQ( ) RU864_CASE { return RegionRU864DlChannelReq( dlChannelReq ); } -#define RU864_ALTERNATE_DR( ) RU864_CASE { return RegionRU864AlternateDr( currentDr, type ); } -#define RU864_NEXT_CHANNEL( ) RU864_CASE { return RegionRU864NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } -#define RU864_CHANNEL_ADD( ) RU864_CASE { return RegionRU864ChannelAdd( channelAdd ); } -#define RU864_CHANNEL_REMOVE( ) RU864_CASE { return RegionRU864ChannelsRemove( channelRemove ); } -#define RU864_APPLY_DR_OFFSET( ) RU864_CASE { return RegionRU864ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } -#define RU864_RX_BEACON_SETUP( ) RU864_CASE { RegionRU864RxBeaconSetup( rxBeaconSetup, outDr ); break; } -#else -#define RU864_IS_ACTIVE( ) -#define RU864_GET_PHY_PARAM( ) -#define RU864_SET_BAND_TX_DONE( ) -#define RU864_INIT_DEFAULTS( ) -#define RU864_GET_NVM_CTX( ) -#define RU864_VERIFY( ) -#define RU864_APPLY_CF_LIST( ) -#define RU864_CHAN_MASK_SET( ) -#define RU864_COMPUTE_RX_WINDOW_PARAMETERS( ) -#define RU864_RX_CONFIG( ) -#define RU864_TX_CONFIG( ) -#define RU864_LINK_ADR_REQ( ) -#define RU864_RX_PARAM_SETUP_REQ( ) -#define RU864_NEW_CHANNEL_REQ( ) -#define RU864_TX_PARAM_SETUP_REQ( ) -#define RU864_DL_CHANNEL_REQ( ) -#define RU864_ALTERNATE_DR( ) -#define RU864_NEXT_CHANNEL( ) -#define RU864_CHANNEL_ADD( ) -#define RU864_CHANNEL_REMOVE( ) -#define RU864_APPLY_DR_OFFSET( ) -#define RU864_RX_BEACON_SETUP( ) -#endif +//#define RU864_CASE case LORAMAC_REGION_RU864: +#define RU864_IS_ACTIVE( ) { return true; } +#define RU864_GET_PHY_PARAM( ) { return RegionRU864GetPhyParam( getPhy ); } +#define RU864_SET_BAND_TX_DONE( ) { RegionRU864SetBandTxDone( txDone ); break; } +#define RU864_INIT_DEFAULTS( ) { RegionRU864InitDefaults( params ); break; } +#define RU864_VERIFY( ) { return RegionRU864Verify( verify, phyAttribute ); } +#define RU864_APPLY_CF_LIST( ) { RegionRU864ApplyCFList( applyCFList ); break; } +#define RU864_CHAN_MASK_SET( ) { return RegionRU864ChanMaskSet( chanMaskSet ); } +#define RU864_COMPUTE_RX_WINDOW_PARAMETERS( ) { RegionRU864ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } +#define RU864_RX_CONFIG( ) { return RegionRU864RxConfig( rxConfig, datarate ); } +#define RU864_TX_CONFIG( ) { return RegionRU864TxConfig( txConfig, txPower, txTimeOnAir ); } +#define RU864_LINK_ADR_REQ( ) { return RegionRU864LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } +#define RU864_RX_PARAM_SETUP_REQ( ) { return RegionRU864RxParamSetupReq( rxParamSetupReq ); } +#define RU864_NEW_CHANNEL_REQ( ) { return RegionRU864NewChannelReq( newChannelReq ); } +#define RU864_TX_PARAM_SETUP_REQ( ) { return RegionRU864TxParamSetupReq( txParamSetupReq ); } +#define RU864_DL_CHANNEL_REQ( ) { return RegionRU864DlChannelReq( dlChannelReq ); } +#define RU864_ALTERNATE_DR( ) { return RegionRU864AlternateDr( currentDr, type ); } +#define RU864_NEXT_CHANNEL( ) { return RegionRU864NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } +#define RU864_CHANNEL_ADD( ) { return RegionRU864ChannelAdd( channelAdd ); } +#define RU864_CHANNEL_REMOVE( ) { return RegionRU864ChannelsRemove( channelRemove ); } +#define RU864_APPLY_DR_OFFSET( ) { return RegionRU864ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } +#define RU864_RX_BEACON_SETUP( ) { RegionRU864RxBeaconSetup( rxBeaconSetup, outDr ); break; } +// #else +// #define RU864_IS_ACTIVE( ) +// #define RU864_GET_PHY_PARAM( ) +// #define RU864_SET_BAND_TX_DONE( ) +// #define RU864_INIT_DEFAULTS( ) +// #define RU864_GET_NVM_CTX( ) +// #define RU864_VERIFY( ) +// #define RU864_APPLY_CF_LIST( ) +// #define RU864_CHAN_MASK_SET( ) +// #define RU864_COMPUTE_RX_WINDOW_PARAMETERS( ) +// #define RU864_RX_CONFIG( ) +// #define RU864_TX_CONFIG( ) +// #define RU864_LINK_ADR_REQ( ) +// #define RU864_RX_PARAM_SETUP_REQ( ) +// #define RU864_NEW_CHANNEL_REQ( ) +// #define RU864_TX_PARAM_SETUP_REQ( ) +// #define RU864_DL_CHANNEL_REQ( ) +// #define RU864_ALTERNATE_DR( ) +// #define RU864_NEXT_CHANNEL( ) +// #define RU864_CHANNEL_ADD( ) +// #define RU864_CHANNEL_REMOVE( ) +// #define RU864_APPLY_DR_OFFSET( ) +// #define RU864_RX_BEACON_SETUP( ) +// #endif bool RegionIsActive( LoRaMacRegion_t region ) { switch( region ) { - AS923_IS_ACTIVE( ); - AU915_IS_ACTIVE( ); - CN470_IS_ACTIVE( ); - CN779_IS_ACTIVE( ); - EU433_IS_ACTIVE( ); - EU868_IS_ACTIVE( ); - KR920_IS_ACTIVE( ); - IN865_IS_ACTIVE( ); - US915_IS_ACTIVE( ); - RU864_IS_ACTIVE( ); + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_IS_ACTIVE( ); + break; + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_IS_ACTIVE( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_IS_ACTIVE( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_IS_ACTIVE( ); + break; + /*! + * European band on 433MHz + */ + case LORAMAC_REGION_EU433: + EU433_IS_ACTIVE( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_IS_ACTIVE( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_IS_ACTIVE( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_IS_ACTIVE( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_IS_ACTIVE( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_IS_ACTIVE( ); + break; + + default: { - return false; + return true; // FIX THIS NOW } } } @@ -548,16 +600,69 @@ PhyParam_t RegionGetPhyParam( LoRaMacRegion_t region, GetPhyParams_t* getPhy ) PhyParam_t phyParam = { 0 }; switch( region ) { - AS923_GET_PHY_PARAM( ); - AU915_GET_PHY_PARAM( ); - CN470_GET_PHY_PARAM( ); - CN779_GET_PHY_PARAM( ); - EU433_GET_PHY_PARAM( ); - EU868_GET_PHY_PARAM( ); - KR920_GET_PHY_PARAM( ); - IN865_GET_PHY_PARAM( ); - US915_GET_PHY_PARAM( ); - RU864_GET_PHY_PARAM( ); + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_GET_PHY_PARAM( ); + break; + + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_GET_PHY_PARAM( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_GET_PHY_PARAM( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_GET_PHY_PARAM( ); + break; + /*! + * European band on 433MHz + */ + case LORAMAC_REGION_EU433: + EU433_GET_PHY_PARAM( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_GET_PHY_PARAM( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_GET_PHY_PARAM( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_GET_PHY_PARAM( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_GET_PHY_PARAM( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_GET_PHY_PARAM( ); + break; + + default: { return phyParam; @@ -569,16 +674,67 @@ void RegionSetBandTxDone( LoRaMacRegion_t region, SetBandTxDoneParams_t* txDone { switch( region ) { - AS923_SET_BAND_TX_DONE( ); - AU915_SET_BAND_TX_DONE( ); - CN470_SET_BAND_TX_DONE( ); - CN779_SET_BAND_TX_DONE( ); - EU433_SET_BAND_TX_DONE( ); - EU868_SET_BAND_TX_DONE( ); - KR920_SET_BAND_TX_DONE( ); - IN865_SET_BAND_TX_DONE( ); - US915_SET_BAND_TX_DONE( ); - RU864_SET_BAND_TX_DONE( ); + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_SET_BAND_TX_DONE( ); + break; + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_SET_BAND_TX_DONE( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_SET_BAND_TX_DONE( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_SET_BAND_TX_DONE( ); + break; + /*! + * European band on 433MHz + */ + case LORAMAC_REGION_EU433: + EU433_SET_BAND_TX_DONE( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_SET_BAND_TX_DONE( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_SET_BAND_TX_DONE( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_SET_BAND_TX_DONE( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_SET_BAND_TX_DONE( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_SET_BAND_TX_DONE( ); + break; + default: { return; @@ -590,16 +746,68 @@ void RegionInitDefaults( LoRaMacRegion_t region, InitDefaultsParams_t* params ) { switch( region ) { - AS923_INIT_DEFAULTS( ); - AU915_INIT_DEFAULTS( ); - CN470_INIT_DEFAULTS( ); - CN779_INIT_DEFAULTS( ); - EU433_INIT_DEFAULTS( ); - EU868_INIT_DEFAULTS( ); - KR920_INIT_DEFAULTS( ); - IN865_INIT_DEFAULTS( ); - US915_INIT_DEFAULTS( ); - RU864_INIT_DEFAULTS( ); + + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_INIT_DEFAULTS( ); + break; + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_INIT_DEFAULTS( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_INIT_DEFAULTS( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_INIT_DEFAULTS( ); + break; + /*! + * European band on 433MHz + */ + case LORAMAC_REGION_EU433: + EU433_INIT_DEFAULTS( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_INIT_DEFAULTS( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_INIT_DEFAULTS( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_INIT_DEFAULTS( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_INIT_DEFAULTS( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_INIT_DEFAULTS( ); + break; + default: { break; @@ -611,16 +819,67 @@ bool RegionVerify( LoRaMacRegion_t region, VerifyParams_t* verify, PhyAttribute_ { switch( region ) { - AS923_VERIFY( ); - AU915_VERIFY( ); - CN470_VERIFY( ); - CN779_VERIFY( ); - EU433_VERIFY( ); - EU868_VERIFY( ); - KR920_VERIFY( ); - IN865_VERIFY( ); - US915_VERIFY( ); - RU864_VERIFY( ); + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_VERIFY( ); + break; + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_VERIFY( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_VERIFY( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_VERIFY( ); + break; + /*! + * European band on 433MHz + */ + case LORAMAC_REGION_EU433: + EU433_VERIFY( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_VERIFY( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_VERIFY( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_VERIFY( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_VERIFY( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_VERIFY( ); + break; + default: { return false; @@ -632,16 +891,67 @@ void RegionApplyCFList( LoRaMacRegion_t region, ApplyCFListParams_t* applyCFList { switch( region ) { - AS923_APPLY_CF_LIST( ); - AU915_APPLY_CF_LIST( ); - CN470_APPLY_CF_LIST( ); - CN779_APPLY_CF_LIST( ); - EU433_APPLY_CF_LIST( ); - EU868_APPLY_CF_LIST( ); - KR920_APPLY_CF_LIST( ); - IN865_APPLY_CF_LIST( ); - US915_APPLY_CF_LIST( ); - RU864_APPLY_CF_LIST( ); + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_APPLY_CF_LIST( ); + break; + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_APPLY_CF_LIST( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_APPLY_CF_LIST( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_APPLY_CF_LIST( ); + break; + /*! + * European band on 433MHz + */ + case LORAMAC_REGION_EU433: + EU433_APPLY_CF_LIST( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_APPLY_CF_LIST( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_APPLY_CF_LIST( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_APPLY_CF_LIST( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_APPLY_CF_LIST( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_APPLY_CF_LIST( ); + break; + default: { break; @@ -653,16 +963,67 @@ bool RegionChanMaskSet( LoRaMacRegion_t region, ChanMaskSetParams_t* chanMaskSet { switch( region ) { - AS923_CHAN_MASK_SET( ); - AU915_CHAN_MASK_SET( ); - CN470_CHAN_MASK_SET( ); - CN779_CHAN_MASK_SET( ); - EU433_CHAN_MASK_SET( ); - EU868_CHAN_MASK_SET( ); - KR920_CHAN_MASK_SET( ); - IN865_CHAN_MASK_SET( ); - US915_CHAN_MASK_SET( ); - RU864_CHAN_MASK_SET( ); + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_CHAN_MASK_SET( ); + break; + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_CHAN_MASK_SET( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_CHAN_MASK_SET( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_CHAN_MASK_SET( ); + break; + /*! + * European band on 433MHz + */ + case LORAMAC_REGION_EU433: + EU433_CHAN_MASK_SET( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_CHAN_MASK_SET( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_CHAN_MASK_SET( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_CHAN_MASK_SET( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_CHAN_MASK_SET( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_CHAN_MASK_SET( ); + break; + default: { return false; @@ -674,16 +1035,67 @@ void RegionComputeRxWindowParameters( LoRaMacRegion_t region, int8_t datarate, u { switch( region ) { - AS923_COMPUTE_RX_WINDOW_PARAMETERS( ); - AU915_COMPUTE_RX_WINDOW_PARAMETERS( ); - CN470_COMPUTE_RX_WINDOW_PARAMETERS( ); - CN779_COMPUTE_RX_WINDOW_PARAMETERS( ); - EU433_COMPUTE_RX_WINDOW_PARAMETERS( ); - EU868_COMPUTE_RX_WINDOW_PARAMETERS( ); - KR920_COMPUTE_RX_WINDOW_PARAMETERS( ); - IN865_COMPUTE_RX_WINDOW_PARAMETERS( ); - US915_COMPUTE_RX_WINDOW_PARAMETERS( ); - RU864_COMPUTE_RX_WINDOW_PARAMETERS( ); + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_COMPUTE_RX_WINDOW_PARAMETERS( ); + break; + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_COMPUTE_RX_WINDOW_PARAMETERS( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_COMPUTE_RX_WINDOW_PARAMETERS( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_COMPUTE_RX_WINDOW_PARAMETERS( ); + break; + /*! + * European band on 433MHz + */ + LORAMAC_REGION_EU433: + EU433_COMPUTE_RX_WINDOW_PARAMETERS( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_COMPUTE_RX_WINDOW_PARAMETERS( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_COMPUTE_RX_WINDOW_PARAMETERS( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_COMPUTE_RX_WINDOW_PARAMETERS( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_COMPUTE_RX_WINDOW_PARAMETERS( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_COMPUTE_RX_WINDOW_PARAMETERS( ); + break; + default: { break; @@ -695,16 +1107,67 @@ bool RegionRxConfig( LoRaMacRegion_t region, RxConfigParams_t* rxConfig, int8_t* { switch( region ) { - AS923_RX_CONFIG( ); - AU915_RX_CONFIG( ); - CN470_RX_CONFIG( ); - CN779_RX_CONFIG( ); - EU433_RX_CONFIG( ); - EU868_RX_CONFIG( ); - KR920_RX_CONFIG( ); - IN865_RX_CONFIG( ); - US915_RX_CONFIG( ); - RU864_RX_CONFIG( ); + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_RX_CONFIG( ); + break; + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_RX_CONFIG( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_RX_CONFIG( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_RX_CONFIG( ); + break; + /*! + * European band on 433MHz + */ + case LORAMAC_REGION_EU433: + EU433_RX_CONFIG( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_RX_CONFIG( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_RX_CONFIG( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_RX_CONFIG( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_RX_CONFIG( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_RX_CONFIG( ); + break; + default: { return false; @@ -716,16 +1179,67 @@ bool RegionTxConfig( LoRaMacRegion_t region, TxConfigParams_t* txConfig, int8_t* { switch( region ) { - AS923_TX_CONFIG( ); - AU915_TX_CONFIG( ); - CN470_TX_CONFIG( ); - CN779_TX_CONFIG( ); - EU433_TX_CONFIG( ); - EU868_TX_CONFIG( ); - KR920_TX_CONFIG( ); - IN865_TX_CONFIG( ); - US915_TX_CONFIG( ); - RU864_TX_CONFIG( ); + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_TX_CONFIG( ); + break; + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_TX_CONFIG( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_TX_CONFIG( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_TX_CONFIG( ); + break; + /*! + * European band on 433MHz + */ + case LORAMAC_REGION_EU433: + EU433_TX_CONFIG( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_TX_CONFIG( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_TX_CONFIG( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_TX_CONFIG( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_TX_CONFIG( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_TX_CONFIG( ); + break; + default: { return false; @@ -737,16 +1251,67 @@ uint8_t RegionLinkAdrReq( LoRaMacRegion_t region, LinkAdrReqParams_t* linkAdrReq { switch( region ) { - AS923_LINK_ADR_REQ( ); - AU915_LINK_ADR_REQ( ); - CN470_LINK_ADR_REQ( ); - CN779_LINK_ADR_REQ( ); - EU433_LINK_ADR_REQ( ); - EU868_LINK_ADR_REQ( ); - KR920_LINK_ADR_REQ( ); - IN865_LINK_ADR_REQ( ); - US915_LINK_ADR_REQ( ); - RU864_LINK_ADR_REQ( ); + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_LINK_ADR_REQ( ); + break; + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_LINK_ADR_REQ( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_LINK_ADR_REQ( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_LINK_ADR_REQ( ); + break; + /*! + * European band on 433MHz + */ + case LORAMAC_REGION_EU433: + EU433_LINK_ADR_REQ( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_LINK_ADR_REQ( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_LINK_ADR_REQ( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_LINK_ADR_REQ( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_LINK_ADR_REQ( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_LINK_ADR_REQ( ); + break; + default: { return 0; @@ -758,16 +1323,67 @@ uint8_t RegionRxParamSetupReq( LoRaMacRegion_t region, RxParamSetupReqParams_t* { switch( region ) { - AS923_RX_PARAM_SETUP_REQ( ); - AU915_RX_PARAM_SETUP_REQ( ); - CN470_RX_PARAM_SETUP_REQ( ); - CN779_RX_PARAM_SETUP_REQ( ); - EU433_RX_PARAM_SETUP_REQ( ); - EU868_RX_PARAM_SETUP_REQ( ); - KR920_RX_PARAM_SETUP_REQ( ); - IN865_RX_PARAM_SETUP_REQ( ); - US915_RX_PARAM_SETUP_REQ( ); - RU864_RX_PARAM_SETUP_REQ( ); + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_RX_PARAM_SETUP_REQ( ); + break; + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_RX_PARAM_SETUP_REQ( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_RX_PARAM_SETUP_REQ( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_RX_PARAM_SETUP_REQ( ); + break; + /*! + * European band on 433MHz + */ + case LORAMAC_REGION_EU433: + EU433_RX_PARAM_SETUP_REQ( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_RX_PARAM_SETUP_REQ( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_RX_PARAM_SETUP_REQ( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_RX_PARAM_SETUP_REQ( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_RX_PARAM_SETUP_REQ( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_RX_PARAM_SETUP_REQ( ); + break; + default: { return 0; @@ -779,16 +1395,67 @@ int8_t RegionNewChannelReq( LoRaMacRegion_t region, NewChannelReqParams_t* newCh { switch( region ) { - AS923_NEW_CHANNEL_REQ( ); - AU915_NEW_CHANNEL_REQ( ); - CN470_NEW_CHANNEL_REQ( ); - CN779_NEW_CHANNEL_REQ( ); - EU433_NEW_CHANNEL_REQ( ); - EU868_NEW_CHANNEL_REQ( ); - KR920_NEW_CHANNEL_REQ( ); - IN865_NEW_CHANNEL_REQ( ); - US915_NEW_CHANNEL_REQ( ); - RU864_NEW_CHANNEL_REQ( ); + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_NEW_CHANNEL_REQ( ); + break; + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_NEW_CHANNEL_REQ( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_NEW_CHANNEL_REQ( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_NEW_CHANNEL_REQ( ); + break; + /*! + * European band on 433MHz + */ + case LORAMAC_REGION_EU433: + EU433_NEW_CHANNEL_REQ( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_NEW_CHANNEL_REQ( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_NEW_CHANNEL_REQ( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_NEW_CHANNEL_REQ( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_NEW_CHANNEL_REQ( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_NEW_CHANNEL_REQ( ); + break; + default: { return 0; @@ -800,16 +1467,67 @@ int8_t RegionTxParamSetupReq( LoRaMacRegion_t region, TxParamSetupReqParams_t* t { switch( region ) { - AS923_TX_PARAM_SETUP_REQ( ); - AU915_TX_PARAM_SETUP_REQ( ); - CN470_TX_PARAM_SETUP_REQ( ); - CN779_TX_PARAM_SETUP_REQ( ); - EU433_TX_PARAM_SETUP_REQ( ); - EU868_TX_PARAM_SETUP_REQ( ); - KR920_TX_PARAM_SETUP_REQ( ); - IN865_TX_PARAM_SETUP_REQ( ); - US915_TX_PARAM_SETUP_REQ( ); - RU864_TX_PARAM_SETUP_REQ( ); + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_TX_PARAM_SETUP_REQ( ); + break; + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_TX_PARAM_SETUP_REQ( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_TX_PARAM_SETUP_REQ( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_TX_PARAM_SETUP_REQ( ); + break; + /*! + * European band on 433MHz + */ + case LORAMAC_REGION_EU433: + EU433_TX_PARAM_SETUP_REQ( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_TX_PARAM_SETUP_REQ( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_TX_PARAM_SETUP_REQ( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_TX_PARAM_SETUP_REQ( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_TX_PARAM_SETUP_REQ( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_TX_PARAM_SETUP_REQ( ); + break; + default: { return 0; @@ -821,16 +1539,67 @@ int8_t RegionDlChannelReq( LoRaMacRegion_t region, DlChannelReqParams_t* dlChann { switch( region ) { - AS923_DL_CHANNEL_REQ( ); - AU915_DL_CHANNEL_REQ( ); - CN470_DL_CHANNEL_REQ( ); - CN779_DL_CHANNEL_REQ( ); - EU433_DL_CHANNEL_REQ( ); - EU868_DL_CHANNEL_REQ( ); - KR920_DL_CHANNEL_REQ( ); - IN865_DL_CHANNEL_REQ( ); - US915_DL_CHANNEL_REQ( ); - RU864_DL_CHANNEL_REQ( ); + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_DL_CHANNEL_REQ( ); + break; + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_DL_CHANNEL_REQ( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_DL_CHANNEL_REQ( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_DL_CHANNEL_REQ( ); + break; + /*! + * European band on 433MHz + */ + case LORAMAC_REGION_EU433: + EU433_DL_CHANNEL_REQ( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_DL_CHANNEL_REQ( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_DL_CHANNEL_REQ( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_DL_CHANNEL_REQ( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_DL_CHANNEL_REQ( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_DL_CHANNEL_REQ( ); + break; + default: { return 0; @@ -842,16 +1611,67 @@ int8_t RegionAlternateDr( LoRaMacRegion_t region, int8_t currentDr, AlternateDrT { switch( region ) { - AS923_ALTERNATE_DR( ); - AU915_ALTERNATE_DR( ); - CN470_ALTERNATE_DR( ); - CN779_ALTERNATE_DR( ); - EU433_ALTERNATE_DR( ); - EU868_ALTERNATE_DR( ); - KR920_ALTERNATE_DR( ); - IN865_ALTERNATE_DR( ); - US915_ALTERNATE_DR( ); - RU864_ALTERNATE_DR( ); + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_ALTERNATE_DR( ); + break; + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_ALTERNATE_DR( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_ALTERNATE_DR( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_ALTERNATE_DR( ); + break; + /*! + * European band on 433MHz + */ + case LORAMAC_REGION_EU433: + EU433_ALTERNATE_DR( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_ALTERNATE_DR( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_ALTERNATE_DR( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_ALTERNATE_DR( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_ALTERNATE_DR( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_ALTERNATE_DR( ); + break; + default: { return 0; @@ -863,16 +1683,67 @@ LoRaMacStatus_t RegionNextChannel( LoRaMacRegion_t region, NextChanParams_t* nex { switch( region ) { - AS923_NEXT_CHANNEL( ); - AU915_NEXT_CHANNEL( ); - CN470_NEXT_CHANNEL( ); - CN779_NEXT_CHANNEL( ); - EU433_NEXT_CHANNEL( ); - EU868_NEXT_CHANNEL( ); - KR920_NEXT_CHANNEL( ); - IN865_NEXT_CHANNEL( ); - US915_NEXT_CHANNEL( ); - RU864_NEXT_CHANNEL( ); + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_NEXT_CHANNEL( ); + break; + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_NEXT_CHANNEL( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_NEXT_CHANNEL( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_NEXT_CHANNEL( ); + break; + /*! + * European band on 433MHz + */ + case LORAMAC_REGION_EU433: + EU433_NEXT_CHANNEL( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_NEXT_CHANNEL( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_NEXT_CHANNEL( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_NEXT_CHANNEL( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_NEXT_CHANNEL( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_NEXT_CHANNEL( ); + break; + default: { return LORAMAC_STATUS_REGION_NOT_SUPPORTED; @@ -884,16 +1755,67 @@ LoRaMacStatus_t RegionChannelAdd( LoRaMacRegion_t region, ChannelAddParams_t* ch { switch( region ) { - AS923_CHANNEL_ADD( ); - AU915_CHANNEL_ADD( ); - CN470_CHANNEL_ADD( ); - CN779_CHANNEL_ADD( ); - EU433_CHANNEL_ADD( ); - EU868_CHANNEL_ADD( ); - KR920_CHANNEL_ADD( ); - IN865_CHANNEL_ADD( ); - US915_CHANNEL_ADD( ); - RU864_CHANNEL_ADD( ); + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_CHANNEL_ADD( ); + break; + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_CHANNEL_ADD( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_CHANNEL_ADD( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_CHANNEL_ADD( ); + break; + /*! + * European band on 433MHz + */ + case LORAMAC_REGION_EU433: + EU433_CHANNEL_ADD( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_CHANNEL_ADD( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_CHANNEL_ADD( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_CHANNEL_ADD( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_CHANNEL_ADD( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_CHANNEL_ADD( ); + break; + default: { return LORAMAC_STATUS_PARAMETER_INVALID; @@ -905,16 +1827,67 @@ bool RegionChannelsRemove( LoRaMacRegion_t region, ChannelRemoveParams_t* channe { switch( region ) { - AS923_CHANNEL_REMOVE( ); - AU915_CHANNEL_REMOVE( ); - CN470_CHANNEL_REMOVE( ); - CN779_CHANNEL_REMOVE( ); - EU433_CHANNEL_REMOVE( ); - EU868_CHANNEL_REMOVE( ); - KR920_CHANNEL_REMOVE( ); - IN865_CHANNEL_REMOVE( ); - US915_CHANNEL_REMOVE( ); - RU864_CHANNEL_REMOVE( ); + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_CHANNEL_REMOVE( ); + break; + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_CHANNEL_REMOVE( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_CHANNEL_REMOVE( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_CHANNEL_REMOVE( ); + break; + /*! + * European band on 433MHz + */ + case LORAMAC_REGION_EU433: + EU433_CHANNEL_REMOVE( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_CHANNEL_REMOVE( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_CHANNEL_REMOVE( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_CHANNEL_REMOVE( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_CHANNEL_REMOVE( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_CHANNEL_REMOVE( ); + break; + default: { return false; @@ -926,16 +1899,67 @@ uint8_t RegionApplyDrOffset( LoRaMacRegion_t region, uint8_t downlinkDwellTime, { switch( region ) { - AS923_APPLY_DR_OFFSET( ); - AU915_APPLY_DR_OFFSET( ); - CN470_APPLY_DR_OFFSET( ); - CN779_APPLY_DR_OFFSET( ); - EU433_APPLY_DR_OFFSET( ); - EU868_APPLY_DR_OFFSET( ); - KR920_APPLY_DR_OFFSET( ); - IN865_APPLY_DR_OFFSET( ); - US915_APPLY_DR_OFFSET( ); - RU864_APPLY_DR_OFFSET( ); + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_APPLY_DR_OFFSET( ); + break; + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_APPLY_DR_OFFSET( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_APPLY_DR_OFFSET( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_APPLY_DR_OFFSET( ); + break; + /*! + * European band on 433MHz + */ + case LORAMAC_REGION_EU433: + EU433_APPLY_DR_OFFSET( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_APPLY_DR_OFFSET( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_APPLY_DR_OFFSET( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_APPLY_DR_OFFSET( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_APPLY_DR_OFFSET( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_APPLY_DR_OFFSET( ); + break; + default: { return dr; @@ -947,16 +1971,67 @@ void RegionRxBeaconSetup( LoRaMacRegion_t region, RxBeaconSetup_t* rxBeaconSetup { switch( region ) { - AS923_RX_BEACON_SETUP( ); - AU915_RX_BEACON_SETUP( ); - CN470_RX_BEACON_SETUP( ); - CN779_RX_BEACON_SETUP( ); - EU433_RX_BEACON_SETUP( ); - EU868_RX_BEACON_SETUP( ); - KR920_RX_BEACON_SETUP( ); - IN865_RX_BEACON_SETUP( ); - US915_RX_BEACON_SETUP( ); - RU864_RX_BEACON_SETUP( ); + /*! + * AS band on 923MHz + */ + case LORAMAC_REGION_AS923: + AS923_RX_BEACON_SETUP( ); + break; + /*! + * Australian band on 915MHz + */ + case LORAMAC_REGION_AU915: + AU915_RX_BEACON_SETUP( ); + break; + /*! + * Chinese band on 470MHz + */ + case LORAMAC_REGION_CN470: + CN470_RX_BEACON_SETUP( ); + break; + /*! + * Chinese band on 779MHz + */ + case LORAMAC_REGION_CN779: + CN779_RX_BEACON_SETUP( ); + break; + /*! + * European band on 433MHz + */ + case LORAMAC_REGION_EU433: + EU433_RX_BEACON_SETUP( ); + break; + /*! + * European band on 868MHz + */ + case LORAMAC_REGION_EU868: + EU868_RX_BEACON_SETUP( ); + break; + /*! + * South korean band on 920MHz + */ + case LORAMAC_REGION_KR920: + KR920_RX_BEACON_SETUP( ); + break; + /*! + * India band on 865MHz + */ + case LORAMAC_REGION_IN865: + IN865_RX_BEACON_SETUP( ); + break; + /*! + * North american band on 915MHz + */ + case LORAMAC_REGION_US915: + US915_RX_BEACON_SETUP( ); + break; + /*! + * Russia band on 864MHz + */ + case LORAMAC_REGION_RU864: + RU864_RX_BEACON_SETUP( ); + break; + default: { break; diff --git a/sysdrv/tools/board/lorawan-bridge/LoraMac/rtc-board.c b/sysdrv/tools/board/lorawan-bridge/LoraMac/rtc-board.c new file mode 100644 index 0000000000..df550a2ccc --- /dev/null +++ b/sysdrv/tools/board/lorawan-bridge/LoraMac/rtc-board.c @@ -0,0 +1,58 @@ +#include "timer.h" +#include "rtc-board.h" + +void RtcProcess( void ) +{ + // Not used on this platform. +} + + +uint32_t GettimeToTicks(struct timespec *ts) { + uint32_t time; + time += ts->tv_sec * 1000000000; + time += ts->tv_nsec; + return time; +} + +struct timespec TicksToGettime(uint32_t time) { + struct timespec ts; + ts.tv_sec += time / 1000000000; + ts.tv_nsec += time % 1000000000; + return ts; +} + +TimerTime_t RtcTempCompensation( TimerTime_t period, float temperature ) +{ + //aka, not implemented on this board. + TimerTime_t time = 0; + return time; +} + +uint32_t RtcGetMinimumTimeout( void ) +{ + return 0; //( MIN_ALARM_DELAY ); +} + +uint32_t RtcGetTimerValue(void) { + uint32_t time; + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + time = GettimeToTicks(&ts); +} + +uint32_t RtcTick2Ms(uint32_t clock) { + return clock / 1000000; +} + +uint32_t RtcMs2Tick(uint32_t clock) { + return clock * 1000000; +} + +void RtcSetAlarm( uint32_t timeout ) { + struct timespec ts = TicksToGettime(timeout); + nanosleep(&ts, NULL); +} + +void RtcStopAlarm(void) { + //not needed; +} \ No newline at end of file diff --git a/sysdrv/tools/board/lorawan-bridge/LoraMac/rtc-board.h b/sysdrv/tools/board/lorawan-bridge/LoraMac/rtc-board.h index 8fa38a692b..b6eead485a 100644 --- a/sysdrv/tools/board/lorawan-bridge/LoraMac/rtc-board.h +++ b/sysdrv/tools/board/lorawan-bridge/LoraMac/rtc-board.h @@ -185,6 +185,8 @@ TimerTime_t RtcTempCompensation( TimerTime_t period, float temperature ); */ void RtcProcess( void ); +uint32_t GettimeToTicks(struct timespec *ts); + #ifdef __cplusplus } #endif diff --git a/sysdrv/tools/board/lorawan-bridge/LoraMac/timer.c b/sysdrv/tools/board/lorawan-bridge/LoraMac/timer.c index a2fb516c84..599c33dfa4 100644 --- a/sysdrv/tools/board/lorawan-bridge/LoraMac/timer.c +++ b/sysdrv/tools/board/lorawan-bridge/LoraMac/timer.c @@ -23,6 +23,7 @@ #include "utilities.h" #include "board.h" #include "timer.h" +#include "rtc-board.h" /*! * Safely execute call back @@ -84,8 +85,9 @@ static bool TimerExists( TimerEvent_t *obj ); void TimerInit( TimerEvent_t *obj, void ( *callback )( void *context ) ) { + uint32_t time = RtcGetTimerValue(); + obj->ReloadValue = time; obj->Timestamp = 0; - obj->ReloadValue = 0; obj->IsStarted = false; obj->IsNext2Expire = false; obj->Callback = callback; @@ -100,7 +102,10 @@ void TimerSetContext( TimerEvent_t *obj, void* context ) void TimerStart( TimerEvent_t *obj ) { - uint32_t elapsedTime = 0; + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + uint32_t time = GettimeToTicks(&ts); + uint32_t elapsedTime = time; CRITICAL_SECTION_BEGIN( ); @@ -116,13 +121,13 @@ void TimerStart( TimerEvent_t *obj ) if( TimerListHead == NULL ) { - RtcSetTimerContext( ); + //RtcSetTimerContext( ); // Inserts a timer at time now + obj->Timestamp TimerInsertNewHeadTimer( obj ); } else { - elapsedTime = RtcGetTimerElapsedTime( ); + elapsedTime = RtcGetTimerValue( ); obj->Timestamp += elapsedTime; if( obj->Timestamp < TimerListHead->Timestamp ) @@ -184,8 +189,8 @@ void TimerIrqHandler( void ) TimerEvent_t* cur; TimerEvent_t* next; - uint32_t old = RtcGetTimerContext( ); - uint32_t now = RtcSetTimerContext( ); + uint32_t old = RtcGetTimerValue( ); + uint32_t now = RtcGetTimerValue( ); uint32_t deltaContext = now - old; // intentional wrap around // Update timeStamp based upon new Time Reference @@ -216,7 +221,7 @@ void TimerIrqHandler( void ) } // Remove all the expired object from the list - while( ( TimerListHead != NULL ) && ( TimerListHead->Timestamp < RtcGetTimerElapsedTime( ) ) ) + while( ( TimerListHead != NULL ) && ( TimerListHead->Timestamp < RtcGetTimerValue( ) ) ) { cur = TimerListHead; TimerListHead = TimerListHead->Next; @@ -366,11 +371,11 @@ static void TimerSetTimeout( TimerEvent_t *obj ) int32_t minTicks= RtcGetMinimumTimeout( ); obj->IsNext2Expire = true; - // In case deadline too soon - if( obj->Timestamp < ( RtcGetTimerElapsedTime( ) + minTicks ) ) - { - obj->Timestamp = RtcGetTimerElapsedTime( ) + minTicks; - } + // // In case deadline too soon + // if( obj->Timestamp < ( RtcGetTimerElapsedTime( ) + minTicks ) ) + // { + // obj->Timestamp = RtcGetTimerElapsedTime( ) + minTicks; + // } RtcSetAlarm( obj->Timestamp ); } diff --git a/sysdrv/tools/board/lorawan-bridge/Makefile b/sysdrv/tools/board/lorawan-bridge/Makefile index 9425aaa057..0f413a17f4 100644 --- a/sysdrv/tools/board/lorawan-bridge/Makefile +++ b/sysdrv/tools/board/lorawan-bridge/Makefile @@ -5,11 +5,15 @@ # #This makefile is used to test the other Makefiles +ifeq ($(SYSDRV_PARAM), ) + SYSDRV_PARAM:=../../../Makefile.param + include $(SYSDRV_PARAM) +endif PROG = rest_server SRC = rest.c cJSON/cJSON.c cJSON/cJSON_Utils.c send_json.c lorawan_send.c b64.c/encode.c b64.c/decode.c b64.c/buffer.c -LORAWAN_SRC = LoraMac/spidev_lib/spidev_lib.c LoraMac/board.c LoraMac/main.c LoraMac/spi-board.c LoraMac/delay.c LoraMac/sx1276.c LoraMac/sx1276-board.c LoraMac/LoRaMac.c LoraMac/LoRaMacAdr.c LoraMac/LoRaMacClassB.c LoraMac/LoRaMacCommands.c LoraMac/LoRaMacConfirmQueue.c LoraMac/LoRaMacCrypto.c LoraMac/LoRaMacParser.c LoraMac/LoRaMacSerializer.c LoraMac/timer.c LoraMac/utilities.c LoraMac/systime.c +LORAWAN_SRC = LoraMac/spidev_lib/spidev_lib.c LoraMac/board.c LoraMac/main.c LoraMac/spi-board.c LoraMac/delay.c LoraMac/sx1276.c LoraMac/sx1276-board.c LoraMac/LoRaMac.c LoraMac/LoRaMacAdr.c LoraMac/LoRaMacClassB.c LoraMac/LoRaMacCommands.c LoraMac/LoRaMacConfirmQueue.c LoraMac/LoRaMacCrypto.c LoraMac/LoRaMacParser.c LoraMac/LoRaMacSerializer.c LoraMac/timer.c LoraMac/utilities.c LoraMac/systime.c LoraMac/rtc-board.c LORAMAC_COMMON_SRC = LoraMac/common/LmHandler/LmHandler.c LoraMac/common/LmHandler/packages/FragDecoder.c LoraMac/common/LmHandler/packages/LmhpClockSync.c LoraMac/common/LmHandler/packages/LmhpCompliance.c LoraMac/common/LmHandler/packages/LmhpFragmentation.c LoraMac/common/LmHandler/packages/LmhpRemoteMcastSetup.c LORAMAC_COMMON_SRC += LoraMac/common/CayenneLpp.c LoraMac/common/LmHandlerMsgDisplay.c LORAMAC_SOFT_SE_SRC += LoraMac/soft-se/aes.c LoraMac/soft-se/cmac.c LoraMac/soft-se/soft-se-hal.c LoraMac/soft-se/soft-se.c @@ -23,6 +27,13 @@ INCLUDE = -ILoraMac -ILoraMac/region -ILoraMac/common -ILoraMac/common/LmHandler include $(TOP)/resources/Makefile.in-os +export LC_ALL=C +SHELL:=/bin/bash +# arch=arm default use thumb-2 compile +ifeq ($(SYSDRV_ARCH_TYPE),arm) +PKG_USE_THUMB2 ?= YES +endif + ifeq ($(TARGET_OS),LINUX) LIBS += -ldl LIBS += -lm @@ -31,11 +42,13 @@ endif all: $(PROG) $(PROG): $(CIVETWEB_LIB) $(LORAWAN_SRC) $(LORAMAC_COMMON_SRC) $(LORAMAC_REGION_SRC) $(LORAMAC_SOFT_SE_SRC) - $(CC) -o $@ $(CFLAGS) $(INCLUDE) $(LDFLAGS) $(LORAWAN_SRC) $(LORAMAC_COMMON_SRC) $(LORAMAC_REGION_SRC) $(LORAMAC_SOFT_SE_SRC) $(CIVETWEB_LIB) $(LIBS) + $(SYSDRV_CROSS)-$(CC) -o $@ $(CFLAGS) $(INCLUDE) $(LDFLAGS) $(LORAWAN_SRC) $(LORAMAC_COMMON_SRC) $(LORAMAC_REGION_SRC) $(LORAMAC_SOFT_SE_SRC) $(CIVETWEB_LIB) $(LIBS) + $(call MAROC_COPY_PKG_TO_SYSDRV_OUTPUT, $(SYSDRV_DIR_OUT_ROOTFS), $(PKG_BIN)) $(CIVETWEB_LIB): $(MAKE) -C $(TOP) WITH_IPV6=1 WITH_WEBSOCKET=1 COPT='-DNO_SSL -DMG_EXPERIMENTAL_INTERFACES' clean lib cp $(TOP)/$(CIVETWEB_LIB) . + $(call MAROC_COPY_PKG_TO_SYSDRV_OUTPUT, $(SYSDRV_DIR_OUT_ROOTFS), $(PKG_BIN)) clean: rm -f $(CIVETWEB_LIB) $(PROG) diff --git a/sysdrv/tools/board/lorawan-bridge/libcivetweb.a b/sysdrv/tools/board/lorawan-bridge/libcivetweb.a index 96148345fb..63a984ee59 100644 Binary files a/sysdrv/tools/board/lorawan-bridge/libcivetweb.a and b/sysdrv/tools/board/lorawan-bridge/libcivetweb.a differ diff --git a/sysdrv/tools/board/lorawan-bridge/rest_server b/sysdrv/tools/board/lorawan-bridge/rest_server new file mode 100755 index 0000000000..8fe2539b5c Binary files /dev/null and b/sysdrv/tools/board/lorawan-bridge/rest_server differ