From 493ae2bd9101acd778799f41865dc672dc2e59d1 Mon Sep 17 00:00:00 2001 From: Hasnain Virk Date: Thu, 17 May 2018 12:38:27 +0300 Subject: [PATCH] dr_range bitfield should be unsigned integer If the value is an integer, the 4th bit is used for sign, so you can store values upto 7 only whereas the datarate values could go upto 15. That's why we need to turn this to an unsigned integer so that the last bit can also be used. --- features/lorawan/lorawan_types.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/features/lorawan/lorawan_types.h b/features/lorawan/lorawan_types.h index e6f09709c5..c6171d78ce 100644 --- a/features/lorawan/lorawan_types.h +++ b/features/lorawan/lorawan_types.h @@ -275,7 +275,7 @@ typedef union { /** * Byte-access to the bits. */ - int8_t value; + uint8_t value; /** * The structure to store the minimum and the maximum datarate. */ @@ -288,7 +288,7 @@ typedef union { * The allowed ranges are region-specific. * Please refer to \ref DR_0 to \ref DR_15 for details. */ - int8_t min : 4; + uint8_t min : 4; /** * The maximum data rate. * @@ -297,7 +297,7 @@ typedef union { * The allowed ranges are region-specific. * Please refer to \ref DR_0 to \ref DR_15 for details. */ - int8_t max : 4; + uint8_t max : 4; } fields; } dr_range_t;