From 4051c9f76a26ae691307666e1c2de1f9fdd881e7 Mon Sep 17 00:00:00 2001 From: Miguel Luis Date: Mon, 17 Jun 2019 10:04:51 +0200 Subject: [PATCH] Issue #723 - Move Tx power control after `if( adrNext->AdrAckCounter >= ( adrNext->AdrAckLimit + adrNext->AdrAckDelay ) )` The Tx power control is not specified into LoRaWAN specifications 1.0.3 and below. Although its control is advisable in order to avoid loosing connection in some conditions. This addition shouldn't have any impact on ADR algorithms nor on the certification process. --- src/mac/LoRaMacAdr.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mac/LoRaMacAdr.c b/src/mac/LoRaMacAdr.c index d7bcc52ef..732bc8e54 100644 --- a/src/mac/LoRaMacAdr.c +++ b/src/mac/LoRaMacAdr.c @@ -65,10 +65,6 @@ static bool CalcNextV10X( CalcNextAdrParams_t* adrNext, int8_t* drOut, int8_t* t if( adrNext->AdrAckCounter >= adrNext->AdrAckLimit ) { adrAckReq = true; - // Set TX Power to maximum - getPhy.Attribute = PHY_MAX_TX_POWER; - phyParam = RegionGetPhyParam( adrNext->Region, &getPhy ); - txPower = phyParam.Value; } else { @@ -76,6 +72,11 @@ static bool CalcNextV10X( CalcNextAdrParams_t* adrNext, int8_t* drOut, int8_t* t } if( adrNext->AdrAckCounter >= ( adrNext->AdrAckLimit + adrNext->AdrAckDelay ) ) { + // Set TX Power to maximum + getPhy.Attribute = PHY_MAX_TX_POWER; + phyParam = RegionGetPhyParam( adrNext->Region, &getPhy ); + txPower = phyParam.Value; + if( ( adrNext->AdrAckCounter % adrNext->AdrAckDelay ) == 1 ) { // Decrease the datarate