Skip to content

Commit 0968361

Browse files
committed
Updated Radio.TimeOnAir API in order to be independent of the current hardware settings.
1 parent dfced18 commit 0968361

File tree

17 files changed

+491
-167
lines changed

17 files changed

+491
-167
lines changed

src/mac/LoRaMacClassB.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,10 @@ bool LoRaMacClassBRxBeacon( uint8_t *payload, uint16_t size )
12801280
// Reset beacon variables, if one of the crc is valid
12811281
if( beaconProcessed == true )
12821282
{
1283-
TimerTime_t time = Radio.TimeOnAir( MODEM_LORA, size );
1283+
getPhy.Attribute = PHY_BEACON_CHANNEL_DR;
1284+
phyParam = RegionGetPhyParam( *Ctx.LoRaMacClassBParams.LoRaMacRegion, &getPhy );
1285+
1286+
TimerTime_t time = Radio.TimeOnAir( MODEM_LORA, 0, phyParam.Value, 1, 8, false, size, true );
12841287
SysTime_t timeOnAir;
12851288
timeOnAir.Seconds = time / 1000;
12861289
timeOnAir.SubSeconds = time - timeOnAir.Seconds * 1000;

src/mac/region/RegionAS923.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,17 +600,17 @@ bool RegionAS923TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
600600
{ // High Speed FSK channel
601601
modem = MODEM_FSK;
602602
Radio.SetTxConfig( modem, phyTxPower, 25000, bandwidth, phyDr * 1000, 0, 5, false, true, 0, 0, false, 4000 );
603+
*txTimeOnAir = Radio.TimeOnAir( modem, bandwidth, phyDr * 1000, 0, 5, false, txConfig->PktLen, true );
603604
}
604605
else
605606
{
606607
modem = MODEM_LORA;
607608
Radio.SetTxConfig( modem, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 4000 );
609+
*txTimeOnAir = Radio.TimeOnAir( modem, bandwidth, phyDr, 1, 8, false, txConfig->PktLen, true );
608610
}
609611

610612
// Setup maximum payload lenght of the radio driver
611613
Radio.SetMaxPayloadLength( modem, txConfig->PktLen );
612-
// Get the time-on-air of the next tx frame
613-
*txTimeOnAir = Radio.TimeOnAir( modem, txConfig->PktLen );
614614

615615
*txPower = txPowerLimited;
616616
return true;

src/mac/region/RegionAU915.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,10 +603,10 @@ bool RegionAU915TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
603603

604604
// Setup maximum payload lenght of the radio driver
605605
Radio.SetMaxPayloadLength( MODEM_LORA, txConfig->PktLen );
606-
607-
*txTimeOnAir = Radio.TimeOnAir( MODEM_LORA, txConfig->PktLen );
606+
// Get the time-on-air of the next tx frame
607+
*txTimeOnAir = Radio.TimeOnAir( MODEM_LORA, bandwidth, phyDr, 1, 8, false, txConfig->PktLen, true );
608+
608609
*txPower = txPowerLimited;
609-
610610
return true;
611611
}
612612

src/mac/region/RegionCN470.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ bool RegionCN470TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
510510
// Setup maximum payload lenght of the radio driver
511511
Radio.SetMaxPayloadLength( MODEM_LORA, txConfig->PktLen );
512512
// Get the time-on-air of the next tx frame
513-
*txTimeOnAir = Radio.TimeOnAir( MODEM_LORA, txConfig->PktLen );
513+
*txTimeOnAir = Radio.TimeOnAir( MODEM_LORA, 0, phyDr, 1, 8, false, txConfig->PktLen, true );
514514
*txPower = txPowerLimited;
515515

516516
return true;

src/mac/region/RegionCN779.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,17 +556,19 @@ bool RegionCN779TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
556556
{ // High Speed FSK channel
557557
modem = MODEM_FSK;
558558
Radio.SetTxConfig( modem, phyTxPower, 25000, bandwidth, phyDr * 1000, 0, 5, false, true, 0, 0, false, 4000 );
559+
// Get the time-on-air of the next tx frame
560+
*txTimeOnAir = Radio.TimeOnAir( modem, bandwidth, phyDr * 1000, 0, 5, false, txConfig->PktLen, true );
559561
}
560562
else
561563
{
562564
modem = MODEM_LORA;
563565
Radio.SetTxConfig( modem, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 4000 );
566+
// Get the time-on-air of the next tx frame
567+
*txTimeOnAir = Radio.TimeOnAir( modem, bandwidth, phyDr, 1, 8, false, txConfig->PktLen, true );
564568
}
565569

566570
// Setup maximum payload lenght of the radio driver
567571
Radio.SetMaxPayloadLength( modem, txConfig->PktLen );
568-
// Get the time-on-air of the next tx frame
569-
*txTimeOnAir = Radio.TimeOnAir( modem, txConfig->PktLen );
570572

571573
*txPower = txPowerLimited;
572574
return true;

src/mac/region/RegionEU433.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,17 +556,19 @@ bool RegionEU433TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
556556
{ // High Speed FSK channel
557557
modem = MODEM_FSK;
558558
Radio.SetTxConfig( modem, phyTxPower, 25000, bandwidth, phyDr * 1000, 0, 5, false, true, 0, 0, false, 4000 );
559+
// Get the time-on-air of the next tx frame
560+
*txTimeOnAir = Radio.TimeOnAir( modem, bandwidth, phyDr * 1000, 0, 5, false, txConfig->PktLen, true );
559561
}
560562
else
561563
{
562564
modem = MODEM_LORA;
563565
Radio.SetTxConfig( modem, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 4000 );
566+
// Get the time-on-air of the next tx frame
567+
*txTimeOnAir = Radio.TimeOnAir( modem, bandwidth, phyDr, 1, 8, false, txConfig->PktLen, true );
564568
}
565569

566570
// Setup maximum payload lenght of the radio driver
567571
Radio.SetMaxPayloadLength( modem, txConfig->PktLen );
568-
// Get the time-on-air of the next tx frame
569-
*txTimeOnAir = Radio.TimeOnAir( modem, txConfig->PktLen );
570572

571573
*txPower = txPowerLimited;
572574
return true;

src/mac/region/RegionEU868.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,17 +587,17 @@ bool RegionEU868TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
587587
{ // High Speed FSK channel
588588
modem = MODEM_FSK;
589589
Radio.SetTxConfig( modem, phyTxPower, 25000, bandwidth, phyDr * 1000, 0, 5, false, true, 0, 0, false, 4000 );
590+
*txTimeOnAir = Radio.TimeOnAir( modem, bandwidth, phyDr * 1000, 0, 5, false, txConfig->PktLen, true );
590591
}
591592
else
592593
{
593594
modem = MODEM_LORA;
594595
Radio.SetTxConfig( modem, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 4000 );
596+
*txTimeOnAir = Radio.TimeOnAir( modem, bandwidth, phyDr, 1, 8, false, txConfig->PktLen, true );
595597
}
596598

597599
// Setup maximum payload lenght of the radio driver
598600
Radio.SetMaxPayloadLength( modem, txConfig->PktLen );
599-
// Get the time-on-air of the next tx frame
600-
*txTimeOnAir = Radio.TimeOnAir( modem, txConfig->PktLen );
601601

602602
*txPower = txPowerLimited;
603603
return true;

src/mac/region/RegionIN865.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,17 +573,19 @@ bool RegionIN865TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
573573
{ // High Speed FSK channel
574574
modem = MODEM_FSK;
575575
Radio.SetTxConfig( modem, phyTxPower, 25000, bandwidth, phyDr * 1000, 0, 5, false, true, 0, 0, false, 4000 );
576+
// Get the time-on-air of the next tx frame
577+
*txTimeOnAir = Radio.TimeOnAir( modem, bandwidth, phyDr * 1000, 0, 5, false, txConfig->PktLen, true );
576578
}
577579
else
578580
{
579581
modem = MODEM_LORA;
580582
Radio.SetTxConfig( modem, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 4000 );
583+
// Get the time-on-air of the next tx frame
584+
*txTimeOnAir = Radio.TimeOnAir( modem, bandwidth, phyDr, 1, 8, false, txConfig->PktLen, true );
581585
}
582586

583587
// Setup maximum payload lenght of the radio driver
584588
Radio.SetMaxPayloadLength( modem, txConfig->PktLen );
585-
// Get the time-on-air of the next tx frame
586-
*txTimeOnAir = Radio.TimeOnAir( modem, txConfig->PktLen );
587589

588590
*txPower = txPowerLimited;
589591
return true;

src/mac/region/RegionKR920.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ bool RegionKR920TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
566566
// Setup maximum payload lenght of the radio driver
567567
Radio.SetMaxPayloadLength( MODEM_LORA, txConfig->PktLen );
568568
// Get the time-on-air of the next tx frame
569-
*txTimeOnAir = Radio.TimeOnAir( MODEM_LORA, txConfig->PktLen );
569+
*txTimeOnAir = Radio.TimeOnAir( MODEM_LORA, bandwidth, phyDr, 1, 8, false, txConfig->PktLen, true );
570570

571571
*txPower = txPowerLimited;
572572
return true;

src/mac/region/RegionRU864.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,17 +549,19 @@ bool RegionRU864TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
549549
{ // High Speed FSK channel
550550
modem = MODEM_FSK;
551551
Radio.SetTxConfig( modem, phyTxPower, 25000, bandwidth, phyDr * 1000, 0, 5, false, true, 0, 0, false, 4000 );
552+
// Get the time-on-air of the next tx frame
553+
*txTimeOnAir = Radio.TimeOnAir( modem, bandwidth, phyDr * 1000, 0, 5, false, txConfig->PktLen, true );
552554
}
553555
else
554556
{
555557
modem = MODEM_LORA;
556558
Radio.SetTxConfig( modem, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 4000 );
559+
// Get the time-on-air of the next tx frame
560+
*txTimeOnAir = Radio.TimeOnAir( modem, bandwidth, phyDr, 1, 8, false, txConfig->PktLen, true );
557561
}
558562

559563
// Setup maximum payload lenght of the radio driver
560564
Radio.SetMaxPayloadLength( modem, txConfig->PktLen );
561-
// Get the time-on-air of the next tx frame
562-
*txTimeOnAir = Radio.TimeOnAir( modem, txConfig->PktLen );
563565

564566
*txPower = txPowerLimited;
565567
return true;

0 commit comments

Comments
 (0)