Skip to content

Commit 11963e2

Browse files
Daniel Jaecklemluis1
authored andcommitted
Fix wrong beacon time-on-air calculation.
1 parent be160a0 commit 11963e2

File tree

11 files changed

+43
-3
lines changed

11 files changed

+43
-3
lines changed

src/mac/LoRaMacClassB.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,10 @@ bool LoRaMacClassBRxBeacon( uint8_t *payload, uint16_t size )
12831283
getPhy.Attribute = PHY_BEACON_CHANNEL_DR;
12841284
phyParam = RegionGetPhyParam( *Ctx.LoRaMacClassBParams.LoRaMacRegion, &getPhy );
12851285

1286+
getPhy.Attribute = PHY_SF_FROM_DR;
1287+
getPhy.Datarate = phyParam.Value;
1288+
phyParam = RegionGetPhyParam( *Ctx.LoRaMacClassBParams.LoRaMacRegion, &getPhy );
1289+
12861290
TimerTime_t time = Radio.TimeOnAir( MODEM_LORA, 0, phyParam.Value, 1, 8, false, size, true );
12871291
SysTime_t timeOnAir;
12881292
timeOnAir.Seconds = time / 1000;

src/mac/region/Region.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -813,9 +813,9 @@ typedef enum ePhyAttribute
813813
*/
814814
PHY_PING_SLOT_CHANNEL_DR,
815815
/*!
816-
* Duty cycle period.
816+
* The equivalent spreading factor value from datarate
817817
*/
818-
PHY_DUTY_CYCLE_PERIOD
818+
PHY_SF_FROM_DR
819819
}PhyAttribute_t;
820820

821821
/*!
@@ -916,7 +916,7 @@ typedef struct sGetPhyParams
916916
/*!
917917
* Datarate.
918918
* The parameter is needed for the following queries:
919-
* PHY_MAX_PAYLOAD, PHY_NEXT_LOWER_TX_DR.
919+
* PHY_MAX_PAYLOAD, PHY_NEXT_LOWER_TX_DR, PHY_SF_FROM_DR.
920920
*/
921921
int8_t Datarate;
922922
/*!

src/mac/region/RegionAS923.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,10 @@ PhyParam_t RegionAS923GetPhyParam( GetPhyParams_t* getPhy )
332332
phyParam.Value = AS923_PING_SLOT_CHANNEL_DR;
333333
break;
334334
}
335+
case PHY_SF_FROM_DR:
336+
{
337+
phyParam.Value = DataratesAS923[getPhy->Datarate];
338+
}
335339
default:
336340
{
337341
break;

src/mac/region/RegionAU915.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,10 @@ PhyParam_t RegionAU915GetPhyParam( GetPhyParams_t* getPhy )
354354
phyParam.Value = AU915_PING_SLOT_CHANNEL_DR;
355355
break;
356356
}
357+
case PHY_SF_FROM_DR:
358+
{
359+
phyParam.Value = DataratesAU915[getPhy->Datarate];
360+
}
357361
default:
358362
{
359363
break;

src/mac/region/RegionCN470.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,10 @@ PhyParam_t RegionCN470GetPhyParam( GetPhyParams_t* getPhy )
305305
phyParam.Value = CN470_PING_SLOT_CHANNEL_DR;
306306
break;
307307
}
308+
case PHY_SF_FROM_DR:
309+
{
310+
phyParam.Value = DataratesCN470[getPhy->Datarate];
311+
}
308312
default:
309313
{
310314
break;

src/mac/region/RegionCN779.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ PhyParam_t RegionCN779GetPhyParam( GetPhyParams_t* getPhy )
300300
phyParam.Value = CN779_PING_SLOT_CHANNEL_DR;
301301
break;
302302
}
303+
case PHY_SF_FROM_DR:
304+
{
305+
phyParam.Value = DataratesCN779[getPhy->Datarate];
306+
}
303307
default:
304308
{
305309
break;

src/mac/region/RegionEU433.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ PhyParam_t RegionEU433GetPhyParam( GetPhyParams_t* getPhy )
300300
phyParam.Value = EU433_PING_SLOT_CHANNEL_DR;
301301
break;
302302
}
303+
case PHY_SF_FROM_DR:
304+
{
305+
phyParam.Value = DataratesEU433[getPhy->Datarate];
306+
}
303307
default:
304308
{
305309
break;

src/mac/region/RegionEU868.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@ PhyParam_t RegionEU868GetPhyParam( GetPhyParams_t* getPhy )
325325
phyParam.Value = EU868_PING_SLOT_CHANNEL_DR;
326326
break;
327327
}
328+
case PHY_SF_FROM_DR:
329+
{
330+
phyParam.Value = DataratesEU868[getPhy->Datarate];
331+
}
328332
default:
329333
{
330334
break;

src/mac/region/RegionIN865.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,10 @@ PhyParam_t RegionIN865GetPhyParam( GetPhyParams_t* getPhy )
304304
phyParam.Value = IN865_PING_SLOT_CHANNEL_DR;
305305
break;
306306
}
307+
case PHY_SF_FROM_DR:
308+
{
309+
phyParam.Value = DataratesIN865[getPhy->Datarate];
310+
}
307311
default:
308312
{
309313
break;

src/mac/region/RegionKR920.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ PhyParam_t RegionKR920GetPhyParam( GetPhyParams_t* getPhy )
314314
phyParam.Value = KR920_PING_SLOT_CHANNEL_DR;
315315
break;
316316
}
317+
case PHY_SF_FROM_DR:
318+
{
319+
phyParam.Value = DataratesKR920[getPhy->Datarate];
320+
}
317321
default:
318322
{
319323
break;

0 commit comments

Comments
 (0)