Skip to content

Commit 7c3953e

Browse files
committed
Updated radio drivers to report the received SNR in dB and rounded to the nearest integer instead of register raw value.
All SNR variables are now declared signed 8 bits integer. Issue(#475), Pull-Request(#584, #585, #524)
1 parent 1b82ffe commit 7c3953e

File tree

33 files changed

+53
-517
lines changed

33 files changed

+53
-517
lines changed

src/apps/LoRaMac/classA/B-L072Z-LRWAN1/main.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -809,18 +809,6 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
809809
TimerStart( &Led3Timer );
810810

811811
const char *slotStrings[] = { "1", "2", "C", "Ping-Slot", "Multicast Ping-Slot" };
812-
int32_t snr = 0;
813-
if( mcpsIndication->Snr & 0x80 ) // The SNR sign bit is 1
814-
{
815-
// Invert and divide by 4
816-
snr = ( ( ~mcpsIndication->Snr + 1 ) & 0xFF ) >> 2;
817-
snr = -snr;
818-
}
819-
else
820-
{
821-
// Divide by 4
822-
snr = ( mcpsIndication->Snr & 0xFF ) >> 2;
823-
}
824812

825813
printf( "\r\n###### ===== DOWNLINK FRAME %lu ==== ######\r\n", mcpsIndication->DownLinkCounter );
826814

@@ -837,7 +825,7 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
837825
printf( "\r\n" );
838826
printf( "DATA RATE : DR_%d\r\n", mcpsIndication->RxDatarate );
839827
printf( "RX RSSI : %d\r\n", mcpsIndication->Rssi );
840-
printf( "RX SNR : %ld\r\n", snr );
828+
printf( "RX SNR : %d\r\n", mcpsIndication->Snr );
841829

842830
printf( "\r\n" );
843831
}

src/apps/LoRaMac/classA/NAMote72/main.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -902,18 +902,6 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
902902
TimerStart( &Led2Timer );
903903

904904
const char *slotStrings[] = { "1", "2", "C", "Ping-Slot", "Multicast Ping-Slot" };
905-
int32_t snr = 0;
906-
if( mcpsIndication->Snr & 0x80 ) // The SNR sign bit is 1
907-
{
908-
// Invert and divide by 4
909-
snr = ( ( ~mcpsIndication->Snr + 1 ) & 0xFF ) >> 2;
910-
snr = -snr;
911-
}
912-
else
913-
{
914-
// Divide by 4
915-
snr = ( mcpsIndication->Snr & 0xFF ) >> 2;
916-
}
917905

918906
printf( "\r\n###### ===== DOWNLINK FRAME %lu ==== ######\r\n", mcpsIndication->DownLinkCounter );
919907

@@ -930,7 +918,7 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
930918
printf( "\r\n" );
931919
printf( "DATA RATE : DR_%d\r\n", mcpsIndication->RxDatarate );
932920
printf( "RX RSSI : %d\r\n", mcpsIndication->Rssi );
933-
printf( "RX SNR : %ld\r\n", snr );
921+
printf( "RX SNR : %d\r\n", mcpsIndication->Snr );
934922

935923
printf( "\r\n" );
936924
}

src/apps/LoRaMac/classA/NucleoL073/main.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -807,18 +807,6 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
807807
TimerStart( &Led2Timer );
808808

809809
const char *slotStrings[] = { "1", "2", "C", "Ping-Slot", "Multicast Ping-Slot" };
810-
int32_t snr = 0;
811-
if( mcpsIndication->Snr & 0x80 ) // The SNR sign bit is 1
812-
{
813-
// Invert and divide by 4
814-
snr = ( ( ~mcpsIndication->Snr + 1 ) & 0xFF ) >> 2;
815-
snr = -snr;
816-
}
817-
else
818-
{
819-
// Divide by 4
820-
snr = ( mcpsIndication->Snr & 0xFF ) >> 2;
821-
}
822810

823811
printf( "\r\n###### ===== DOWNLINK FRAME %lu ==== ######\r\n", mcpsIndication->DownLinkCounter );
824812

@@ -835,7 +823,7 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
835823
printf( "\r\n" );
836824
printf( "DATA RATE : DR_%d\r\n", mcpsIndication->RxDatarate );
837825
printf( "RX RSSI : %d\r\n", mcpsIndication->Rssi );
838-
printf( "RX SNR : %ld\r\n", snr );
826+
printf( "RX SNR : %d\r\n", mcpsIndication->Snr );
839827

840828
printf( "\r\n" );
841829
}

src/apps/LoRaMac/classA/NucleoL152/main.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -807,18 +807,6 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
807807
TimerStart( &Led2Timer );
808808

809809
const char *slotStrings[] = { "1", "2", "C", "Ping-Slot", "Multicast Ping-Slot" };
810-
int32_t snr = 0;
811-
if( mcpsIndication->Snr & 0x80 ) // The SNR sign bit is 1
812-
{
813-
// Invert and divide by 4
814-
snr = ( ( ~mcpsIndication->Snr + 1 ) & 0xFF ) >> 2;
815-
snr = -snr;
816-
}
817-
else
818-
{
819-
// Divide by 4
820-
snr = ( mcpsIndication->Snr & 0xFF ) >> 2;
821-
}
822810

823811
printf( "\r\n###### ===== DOWNLINK FRAME %lu ==== ######\r\n", mcpsIndication->DownLinkCounter );
824812

@@ -835,7 +823,7 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
835823
printf( "\r\n" );
836824
printf( "DATA RATE : DR_%d\r\n", mcpsIndication->RxDatarate );
837825
printf( "RX RSSI : %d\r\n", mcpsIndication->Rssi );
838-
printf( "RX SNR : %ld\r\n", snr );
826+
printf( "RX SNR : %d\r\n", mcpsIndication->Snr );
839827

840828
printf( "\r\n" );
841829
}

src/apps/LoRaMac/classA/NucleoL476/main.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -807,18 +807,6 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
807807
TimerStart( &Led2Timer );
808808

809809
const char *slotStrings[] = { "1", "2", "C", "Ping-Slot", "Multicast Ping-Slot" };
810-
int32_t snr = 0;
811-
if( mcpsIndication->Snr & 0x80 ) // The SNR sign bit is 1
812-
{
813-
// Invert and divide by 4
814-
snr = ( ( ~mcpsIndication->Snr + 1 ) & 0xFF ) >> 2;
815-
snr = -snr;
816-
}
817-
else
818-
{
819-
// Divide by 4
820-
snr = ( mcpsIndication->Snr & 0xFF ) >> 2;
821-
}
822810

823811
printf( "\r\n###### ===== DOWNLINK FRAME %lu ==== ######\r\n", mcpsIndication->DownLinkCounter );
824812

@@ -835,7 +823,7 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
835823
printf( "\r\n" );
836824
printf( "DATA RATE : DR_%d\r\n", mcpsIndication->RxDatarate );
837825
printf( "RX RSSI : %d\r\n", mcpsIndication->Rssi );
838-
printf( "RX SNR : %ld\r\n", snr );
826+
printf( "RX SNR : %d\r\n", mcpsIndication->Snr );
839827

840828
printf( "\r\n" );
841829
}

src/apps/LoRaMac/classA/SAML21/main.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -813,18 +813,6 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
813813
TimerStart( &Led2Timer );
814814

815815
const char *slotStrings[] = { "1", "2", "C", "Ping-Slot", "Multicast Ping-Slot" };
816-
int32_t snr = 0;
817-
if( mcpsIndication->Snr & 0x80 ) // The SNR sign bit is 1
818-
{
819-
// Invert and divide by 4
820-
snr = ( ( ~mcpsIndication->Snr + 1 ) & 0xFF ) >> 2;
821-
snr = -snr;
822-
}
823-
else
824-
{
825-
// Divide by 4
826-
snr = ( mcpsIndication->Snr & 0xFF ) >> 2;
827-
}
828816

829817
printf( "\r\n###### ===== DOWNLINK FRAME %lu ==== ######\r\n", mcpsIndication->DownLinkCounter );
830818

@@ -841,7 +829,7 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
841829
printf( "\r\n" );
842830
printf( "DATA RATE : DR_%d\r\n", mcpsIndication->RxDatarate );
843831
printf( "RX RSSI : %d\r\n", mcpsIndication->Rssi );
844-
printf( "RX SNR : %ld\r\n", snr );
832+
printf( "RX SNR : %d\r\n", mcpsIndication->Snr );
845833

846834
printf( "\r\n" );
847835
}

src/apps/LoRaMac/classA/SKiM880B/main.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -823,18 +823,6 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
823823
TimerStart( &Led2Timer );
824824

825825
const char *slotStrings[] = { "1", "2", "C", "Ping-Slot", "Multicast Ping-Slot" };
826-
int32_t snr = 0;
827-
if( mcpsIndication->Snr & 0x80 ) // The SNR sign bit is 1
828-
{
829-
// Invert and divide by 4
830-
snr = ( ( ~mcpsIndication->Snr + 1 ) & 0xFF ) >> 2;
831-
snr = -snr;
832-
}
833-
else
834-
{
835-
// Divide by 4
836-
snr = ( mcpsIndication->Snr & 0xFF ) >> 2;
837-
}
838826

839827
printf( "\r\n###### ===== DOWNLINK FRAME %lu ==== ######\r\n", mcpsIndication->DownLinkCounter );
840828

@@ -851,7 +839,7 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
851839
printf( "\r\n" );
852840
printf( "DATA RATE : DR_%d\r\n", mcpsIndication->RxDatarate );
853841
printf( "RX RSSI : %d\r\n", mcpsIndication->Rssi );
854-
printf( "RX SNR : %ld\r\n", snr );
842+
printf( "RX SNR : %d\r\n", mcpsIndication->Snr );
855843

856844
printf( "\r\n" );
857845
}

src/apps/LoRaMac/classA/SKiM881AXL/main.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -823,18 +823,6 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
823823
TimerStart( &Led2Timer );
824824

825825
const char *slotStrings[] = { "1", "2", "C", "Ping-Slot", "Multicast Ping-Slot" };
826-
int32_t snr = 0;
827-
if( mcpsIndication->Snr & 0x80 ) // The SNR sign bit is 1
828-
{
829-
// Invert and divide by 4
830-
snr = ( ( ~mcpsIndication->Snr + 1 ) & 0xFF ) >> 2;
831-
snr = -snr;
832-
}
833-
else
834-
{
835-
// Divide by 4
836-
snr = ( mcpsIndication->Snr & 0xFF ) >> 2;
837-
}
838826

839827
printf( "\r\n###### ===== DOWNLINK FRAME %lu ==== ######\r\n", mcpsIndication->DownLinkCounter );
840828

@@ -851,7 +839,7 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
851839
printf( "\r\n" );
852840
printf( "DATA RATE : DR_%d\r\n", mcpsIndication->RxDatarate );
853841
printf( "RX RSSI : %d\r\n", mcpsIndication->Rssi );
854-
printf( "RX SNR : %ld\r\n", snr );
842+
printf( "RX SNR : %d\r\n", mcpsIndication->Snr );
855843

856844
printf( "\r\n" );
857845
}

src/apps/LoRaMac/classA/SKiM980A/main.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -823,18 +823,6 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
823823
TimerStart( &Led2Timer );
824824

825825
const char *slotStrings[] = { "1", "2", "C", "Ping-Slot", "Multicast Ping-Slot" };
826-
int32_t snr = 0;
827-
if( mcpsIndication->Snr & 0x80 ) // The SNR sign bit is 1
828-
{
829-
// Invert and divide by 4
830-
snr = ( ( ~mcpsIndication->Snr + 1 ) & 0xFF ) >> 2;
831-
snr = -snr;
832-
}
833-
else
834-
{
835-
// Divide by 4
836-
snr = ( mcpsIndication->Snr & 0xFF ) >> 2;
837-
}
838826

839827
printf( "\r\n###### ===== DOWNLINK FRAME %lu ==== ######\r\n", mcpsIndication->DownLinkCounter );
840828

@@ -851,7 +839,7 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
851839
printf( "\r\n" );
852840
printf( "DATA RATE : DR_%d\r\n", mcpsIndication->RxDatarate );
853841
printf( "RX RSSI : %d\r\n", mcpsIndication->Rssi );
854-
printf( "RX SNR : %ld\r\n", snr );
842+
printf( "RX SNR : %d\r\n", mcpsIndication->Snr );
855843

856844
printf( "\r\n" );
857845
}

src/apps/LoRaMac/classB/B-L072Z-LRWAN1/main.c

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -906,18 +906,6 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
906906
TimerStart( &Led3Timer );
907907

908908
const char *slotStrings[] = { "1", "2", "C", "Ping-Slot", "Multicast Ping-Slot" };
909-
int32_t snr = 0;
910-
if( mcpsIndication->Snr & 0x80 ) // The SNR sign bit is 1
911-
{
912-
// Invert and divide by 4
913-
snr = ( ( ~mcpsIndication->Snr + 1 ) & 0xFF ) >> 2;
914-
snr = -snr;
915-
}
916-
else
917-
{
918-
// Divide by 4
919-
snr = ( mcpsIndication->Snr & 0xFF ) >> 2;
920-
}
921909

922910
printf( "\r\n###### ===== DOWNLINK FRAME %lu ==== ######\r\n", mcpsIndication->DownLinkCounter );
923911

@@ -934,7 +922,7 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
934922
printf( "\r\n" );
935923
printf( "DATA RATE : DR_%d\r\n", mcpsIndication->RxDatarate );
936924
printf( "RX RSSI : %d\r\n", mcpsIndication->Rssi );
937-
printf( "RX SNR : %ld\r\n", snr );
925+
printf( "RX SNR : %d\r\n", mcpsIndication->Snr );
938926

939927
printf( "\r\n" );
940928
}
@@ -1118,20 +1106,7 @@ static void MlmeIndication( MlmeIndication_t *mlmeIndication )
11181106
printf( "FREQ : %lu\r\n", mlmeIndication->BeaconInfo.Frequency );
11191107
printf( "DATA RATE : DR_%d\r\n", mlmeIndication->BeaconInfo.Datarate );
11201108
printf( "RX RSSI : %d\r\n", mlmeIndication->BeaconInfo.Rssi );
1121-
1122-
int32_t snr = 0;
1123-
if( mlmeIndication->BeaconInfo.Snr & 0x80 ) // The SNR sign bit is 1
1124-
{
1125-
// Invert and divide by 4
1126-
snr = ( ( ~mlmeIndication->BeaconInfo.Snr + 1 ) & 0xFF ) >> 2;
1127-
snr = -snr;
1128-
}
1129-
else
1130-
{
1131-
// Divide by 4
1132-
snr = ( mlmeIndication->BeaconInfo.Snr & 0xFF ) >> 2;
1133-
}
1134-
printf( "RX SNR : %ld\r\n", snr );
1109+
printf( "RX SNR : %d\r\n", mlmeIndication->BeaconInfo.Snr );
11351110
printf( "\r\n" );
11361111
}
11371112
else

0 commit comments

Comments
 (0)