aboutsummaryrefslogtreecommitdiffstats
path: root/src/encoding.cpp
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-07-07 17:20:59 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2020-07-09 13:36:47 +0200
commit732373d7b442568620261f2930d07d535b7155ba (patch)
tree98292602b6e713ce560ca167999f8e6fc96e5947 /src/encoding.cpp
parent26743ac4f94437f383fb4082976235149c8b2d96 (diff)
encoding: Encode TA as unsigned and check validty against GSM48_TA_INVALID
According to 3GPP TS 44.018 sec 10.5.2.40, Timing Advance value is 8 bit and range is 0-63 (0-219 on GSM400). Unsigned value (uint8_t) is used everywhere else, so avoid using a signed one here, and simply check for GSM48_TA_INVALID here, which we use everywhere else to initialize when the value is not known. Ideally we should check for value based on band, but it makes more sense to check that when receiving the data and storing in in set_ta(). Change-Id: I82b13561d0fe5ebafb5c3a8b9a501045c29809bc
Diffstat (limited to 'src/encoding.cpp')
-rw-r--r--src/encoding.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/encoding.cpp b/src/encoding.cpp
index 89cc5f21..32358c33 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -142,9 +142,9 @@ static inline bool write_tai(bitvec *dest, unsigned& wp, int8_t tai)
}
/* { 0 | 1 < TIMING_ADVANCE_VALUE : bit (6) > } */
-static inline void write_ta(bitvec *dest, unsigned& wp, int8_t ta)
+static inline void write_ta(bitvec *dest, unsigned& wp, uint8_t ta)
{
- if (ta < 0) /* No TIMING_ADVANCE_VALUE: */
+ if (ta >= GSM48_TA_INVALID) /* No TIMING_ADVANCE_VALUE: */
bitvec_write_field(dest, &wp, 0, 1);
else { /* TIMING_ADVANCE_VALUE: */
bitvec_write_field(dest, &wp, 1, 1);
@@ -174,7 +174,7 @@ static inline void write_ws(bitvec *dest, unsigned int *write_index, uint16_t ws
< TIMING_ADVANCE_TIMESLOT_NUMBER : bit (3) > }
*/
static inline void write_ta_ie(bitvec *dest, unsigned& wp,
- int8_t ta, int8_t tai, uint8_t ts)
+ uint8_t ta, int8_t tai, uint8_t ts)
{
write_ta(dest, wp, ta);
if (write_tai(dest, wp, tai)) /* TIMING_ADVANCE_TIMESLOT_NUMBER: */