From 631f5480b607cfc019cabf4dabd42b8b35f0ecf6 Mon Sep 17 00:00:00 2001 From: Austin Promenschenkel Date: Tue, 22 Jul 2025 23:38:20 -0600 Subject: [PATCH] fix the encoding format for UMTS Cell ID Previously, the broadcast value was ~16 times smaller than it should have been. The 28-bit Cell ID is stored in a 32-bit variable, and the 0 padding needs to be at the LSB end rather than the MSB end. --- UMTS/UMTSConfig.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/UMTS/UMTSConfig.cpp b/UMTS/UMTSConfig.cpp index 7ca6723..b716803 100644 --- a/UMTS/UMTSConfig.cpp +++ b/UMTS/UMTSConfig.cpp @@ -1025,9 +1025,11 @@ void BeaconConfig::regenerate() // UC-Id or C-Id is used to identify a cell in UTRAN Iub and Iur interfaces or Iur-g interface: UC-Id = RNC-Id + C-Id. // (pat) This last does not apply to us because we dont use the Iub/Iur interfaces. uint32_t *cellID = RN_CALLOC(uint32_t); - // (pat) TODO: Is this right? network order is high byte first. - // Luckily, hardly matters. - *cellID = htonl(gConfig.getNum("UMTS.Identity.CI")); + *cellID = gConfig.getNum("UMTS.Identity.CI"); + // UMTS protocol specifies that the cell ID is a 28 bit number, but it is represented as a 32 bit value in memory. + // The value that is broadcast is the first 28 bits, not the last 28, so the data must be shifted. + *cellID = *cellID << 4; + *cellID = htonl(*cellID); // cellID is a 28-bit BIT_STRING setAsnBIT_STRING(&mSIB3.cellIdentity,(uint8_t*)cellID,28); // ASN CellSelectReselectInfoSIB_3_4 cellSelectReselectInfo, 10.3.2.3