Skip to content

Commit 9dcb489

Browse files
author
Daniel Jäckle
committed
Introduce individual MIN and MAX datarates for RX and TX.
1 parent 4e5a890 commit 9dcb489

File tree

4 files changed

+100
-30
lines changed

4 files changed

+100
-30
lines changed

src/boards/LoRaMote/LoRaMac-board.h

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,22 @@ Maintainer: Miguel Luis and Gregory Cristian
3333
/*!
3434
* Minimal datarate that can be used by the node
3535
*/
36-
#define LORAMAC_MIN_DATARATE DR_0
36+
#define LORAMAC_TX_MIN_DATARATE DR_0
3737

3838
/*!
3939
* Minimal datarate that can be used by the node
4040
*/
41-
#define LORAMAC_MAX_DATARATE DR_7
41+
#define LORAMAC_TX_MAX_DATARATE DR_7
42+
43+
/*!
44+
* Minimal datarate that can be used by the node
45+
*/
46+
#define LORAMAC_RX_MIN_DATARATE DR_0
47+
48+
/*!
49+
* Minimal datarate that can be used by the node
50+
*/
51+
#define LORAMAC_RX_MAX_DATARATE DR_7
4252

4353
/*!
4454
* Default datarate used by the node
@@ -150,12 +160,22 @@ typedef enum
150160
/*!
151161
* Minimal datarate that can be used by the node
152162
*/
153-
#define LORAMAC_MIN_DATARATE DR_0
163+
#define LORAMAC_TX_MIN_DATARATE DR_0
164+
165+
/*!
166+
* Minimal datarate that can be used by the node
167+
*/
168+
#define LORAMAC_TX_MAX_DATARATE DR_4
169+
170+
/*!
171+
* Minimal datarate that can be used by the node
172+
*/
173+
#define LORAMAC_RX_MIN_DATARATE DR_8
154174

155175
/*!
156176
* Minimal datarate that can be used by the node
157177
*/
158-
#define LORAMAC_MAX_DATARATE DR_4
178+
#define LORAMAC_RX_MAX_DATARATE DR_13
159179

160180
/*!
161181
* Default datarate used by the node

src/boards/SK-iM880A/LoRaMac-board.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,22 @@ Maintainer: Miguel Luis and Gregory Cristian
3333
/*!
3434
* Minimal datarate that can be used by the node
3535
*/
36-
#define LORAMAC_MIN_DATARATE DR_0
36+
#define LORAMAC_TX_MIN_DATARATE DR_0
3737

3838
/*!
3939
* Minimal datarate that can be used by the node
4040
*/
41-
#define LORAMAC_MAX_DATARATE DR_7
41+
#define LORAMAC_TX_MAX_DATARATE DR_7
42+
43+
/*!
44+
* Minimal datarate that can be used by the node
45+
*/
46+
#define LORAMAC_RX_MIN_DATARATE DR_0
47+
48+
/*!
49+
* Minimal datarate that can be used by the node
50+
*/
51+
#define LORAMAC_RX_MAX_DATARATE DR_7
4252

4353
/*!
4454
* Default datarate used by the node

src/boards/SensorNode/LoRaMac-board.h

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,22 @@ Maintainer: Miguel Luis and Gregory Cristian
3333
/*!
3434
* Minimal datarate that can be used by the node
3535
*/
36-
#define LORAMAC_MIN_DATARATE DR_0
36+
#define LORAMAC_TX_MIN_DATARATE DR_0
3737

3838
/*!
3939
* Minimal datarate that can be used by the node
4040
*/
41-
#define LORAMAC_MAX_DATARATE DR_7
41+
#define LORAMAC_TX_MAX_DATARATE DR_7
42+
43+
/*!
44+
* Minimal datarate that can be used by the node
45+
*/
46+
#define LORAMAC_RX_MIN_DATARATE DR_0
47+
48+
/*!
49+
* Minimal datarate that can be used by the node
50+
*/
51+
#define LORAMAC_RX_MAX_DATARATE DR_7
4252

4353
/*!
4454
* Default datarate used by the node
@@ -134,12 +144,22 @@ Maintainer: Miguel Luis and Gregory Cristian
134144
/*!
135145
* Minimal datarate that can be used by the node
136146
*/
137-
#define LORAMAC_MIN_DATARATE DR_0
147+
#define LORAMAC_TX_MIN_DATARATE DR_0
148+
149+
/*!
150+
* Minimal datarate that can be used by the node
151+
*/
152+
#define LORAMAC_TX_MAX_DATARATE DR_7
153+
154+
/*!
155+
* Minimal datarate that can be used by the node
156+
*/
157+
#define LORAMAC_RX_MIN_DATARATE DR_0
138158

139159
/*!
140160
* Minimal datarate that can be used by the node
141161
*/
142-
#define LORAMAC_MAX_DATARATE DR_7
162+
#define LORAMAC_RX_MAX_DATARATE DR_7
143163

144164
/*!
145165
* Default datarate used by the node
@@ -235,12 +255,22 @@ Maintainer: Miguel Luis and Gregory Cristian
235255
/*!
236256
* Minimal datarate that can be used by the node
237257
*/
238-
#define LORAMAC_MIN_DATARATE DR_0
258+
#define LORAMAC_TX_MIN_DATARATE DR_0
239259

240260
/*!
241261
* Minimal datarate that can be used by the node
242262
*/
243-
#define LORAMAC_MAX_DATARATE DR_7
263+
#define LORAMAC_TX_MAX_DATARATE DR_7
264+
265+
/*!
266+
* Minimal datarate that can be used by the node
267+
*/
268+
#define LORAMAC_RX_MIN_DATARATE DR_0
269+
270+
/*!
271+
* Minimal datarate that can be used by the node
272+
*/
273+
#define LORAMAC_RX_MAX_DATARATE DR_7
244274

245275
/*!
246276
* Default datarate used by the node
@@ -352,12 +382,22 @@ typedef enum
352382
/*!
353383
* Minimal datarate that can be used by the node
354384
*/
355-
#define LORAMAC_MIN_DATARATE DR_0
385+
#define LORAMAC_TX_MIN_DATARATE DR_0
386+
387+
/*!
388+
* Minimal datarate that can be used by the node
389+
*/
390+
#define LORAMAC_TX_MAX_DATARATE DR_4
391+
392+
/*!
393+
* Minimal datarate that can be used by the node
394+
*/
395+
#define LORAMAC_RX_MIN_DATARATE DR_8
356396

357397
/*!
358398
* Minimal datarate that can be used by the node
359399
*/
360-
#define LORAMAC_MAX_DATARATE DR_4
400+
#define LORAMAC_RX_MAX_DATARATE DR_13
361401

362402
/*!
363403
* Default datarate used by the node

src/mac/LoRaMac.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,7 @@ static void OnMacStateCheckTimerEvent( void )
13971397

13981398
if( ( AckTimeoutRetriesCounter % 2 ) == 1 )
13991399
{
1400-
ChannelsDatarate = MAX( ChannelsDatarate - 1, LORAMAC_MIN_DATARATE );
1400+
ChannelsDatarate = MAX( ChannelsDatarate - 1, LORAMAC_TX_MIN_DATARATE );
14011401
}
14021402
LoRaMacFlags.Bits.MacDone = 0;
14031403
// Sends the same frame again
@@ -1944,7 +1944,7 @@ static bool AdrNextDr( bool adrEnabled, bool updateChannelMask, int8_t* datarate
19441944

19451945
if( adrEnabled == true )
19461946
{
1947-
if( datarate == LORAMAC_MIN_DATARATE )
1947+
if( datarate == LORAMAC_TX_MIN_DATARATE )
19481948
{
19491949
AdrAckCounter = 0;
19501950
adrAckReq = false;
@@ -1964,11 +1964,11 @@ static bool AdrNextDr( bool adrEnabled, bool updateChannelMask, int8_t* datarate
19641964
if( ( ( AdrAckCounter - ADR_ACK_DELAY ) % ADR_ACK_LIMIT ) == 0 )
19651965
{
19661966
#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 )
1967-
if( datarate > LORAMAC_MIN_DATARATE )
1967+
if( datarate > LORAMAC_TX_MIN_DATARATE )
19681968
{
19691969
datarate--;
19701970
}
1971-
if( datarate == LORAMAC_MIN_DATARATE )
1971+
if( datarate == LORAMAC_TX_MIN_DATARATE )
19721972
{
19731973
if( updateChannelMask == true )
19741974
{
@@ -1978,15 +1978,15 @@ static bool AdrNextDr( bool adrEnabled, bool updateChannelMask, int8_t* datarate
19781978
}
19791979
}
19801980
#elif defined( USE_BAND_915 ) || defined( USE_BAND_915_HYBRID )
1981-
if( ( datarate > LORAMAC_MIN_DATARATE ) && ( datarate == DR_8 ) )
1981+
if( ( datarate > LORAMAC_TX_MIN_DATARATE ) && ( datarate == DR_8 ) )
19821982
{
19831983
datarate = DR_4;
19841984
}
1985-
else if( datarate > LORAMAC_MIN_DATARATE )
1985+
else if( datarate > LORAMAC_TX_MIN_DATARATE )
19861986
{
19871987
datarate--;
19881988
}
1989-
if( datarate == LORAMAC_MIN_DATARATE )
1989+
if( datarate == LORAMAC_TX_MIN_DATARATE )
19901990
{
19911991
if( updateChannelMask == true )
19921992
{
@@ -2236,7 +2236,7 @@ static void ProcessMacCommands( uint8_t *payload, uint8_t macIndex, uint8_t comm
22362236
#else
22372237
#error "Please define a frequency band in the compiler options."
22382238
#endif
2239-
if( ValueInRange( datarate, LORAMAC_MIN_DATARATE, LORAMAC_MAX_DATARATE ) == false )
2239+
if( ValueInRange( datarate, LORAMAC_TX_MIN_DATARATE, LORAMAC_TX_MAX_DATARATE ) == false )
22402240
{
22412241
status &= 0xFD; // Datarate KO
22422242
}
@@ -2291,7 +2291,7 @@ static void ProcessMacCommands( uint8_t *payload, uint8_t macIndex, uint8_t comm
22912291
status &= 0xFE; // Channel frequency KO
22922292
}
22932293

2294-
if( ValueInRange( datarate, LORAMAC_MIN_DATARATE, LORAMAC_MAX_DATARATE ) == false )
2294+
if( ValueInRange( datarate, LORAMAC_RX_MIN_DATARATE, LORAMAC_RX_MAX_DATARATE ) == false )
22952295
{
22962296
status &= 0xFD; // Datarate KO
22972297
}
@@ -3222,7 +3222,7 @@ LoRaMacStatus_t LoRaMacMibSetRequestConfirm( MibRequestConfirm_t *mibSet )
32223222
case MIB_CHANNELS_DATARATE:
32233223
{
32243224
if( ValueInRange( mibSet->Param.ChannelsDatarate,
3225-
LORAMAC_MIN_DATARATE, LORAMAC_MAX_DATARATE ) )
3225+
LORAMAC_TX_MIN_DATARATE, LORAMAC_TX_MAX_DATARATE ) )
32263226
{
32273227
ChannelsDatarate = mibSet->Param.ChannelsDatarate;
32283228
}
@@ -3289,10 +3289,10 @@ LoRaMacStatus_t LoRaMacChannelAdd( uint8_t id, ChannelParams_t params )
32893289
}
32903290
// Validate the datarate
32913291
if( ( params.DrRange.Fields.Min > params.DrRange.Fields.Max ) ||
3292-
( ValueInRange( params.DrRange.Fields.Min, LORAMAC_MIN_DATARATE,
3293-
LORAMAC_MAX_DATARATE ) == false ) ||
3294-
( ValueInRange( params.DrRange.Fields.Max, LORAMAC_MIN_DATARATE,
3295-
LORAMAC_MAX_DATARATE ) == false ) )
3292+
( ValueInRange( params.DrRange.Fields.Min, LORAMAC_TX_MIN_DATARATE,
3293+
LORAMAC_TX_MAX_DATARATE ) == false ) ||
3294+
( ValueInRange( params.DrRange.Fields.Max, LORAMAC_TX_MIN_DATARATE,
3295+
LORAMAC_TX_MAX_DATARATE ) == false ) )
32963296
{
32973297
datarateInvalid = true;
32983298
}
@@ -3309,7 +3309,7 @@ LoRaMacStatus_t LoRaMacChannelAdd( uint8_t id, ChannelParams_t params )
33093309
{
33103310
datarateInvalid = true;
33113311
}
3312-
if( ValueInRange( params.DrRange.Fields.Max, DR_5, LORAMAC_MAX_DATARATE ) == false )
3312+
if( ValueInRange( params.DrRange.Fields.Max, DR_5, LORAMAC_TX_MAX_DATARATE ) == false )
33133313
{
33143314
datarateInvalid = true;
33153315
}
@@ -3642,7 +3642,7 @@ LoRaMacStatus_t LoRaMacMcpsRequest( McpsReq_t *mcpsRequest )
36423642
{
36433643
if( AdrCtrlOn == false )
36443644
{
3645-
if( ValueInRange( datarate, LORAMAC_MIN_DATARATE, LORAMAC_MAX_DATARATE ) == true )
3645+
if( ValueInRange( datarate, LORAMAC_TX_MIN_DATARATE, LORAMAC_TX_MAX_DATARATE ) == true )
36463646
{
36473647
ChannelsDatarate = datarate;
36483648
}

0 commit comments

Comments
 (0)