jolly has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/34657?usp=email )


Change subject: Fix selection of correct ARFCN at arfcn_from_freq_index()
......................................................................

Fix selection of correct ARFCN at arfcn_from_freq_index()

The selection of ARFCN is described in TS 44.018 §10.5.2.20.

The frequencies found in SI5 and SI5bis are counted first, in the
following order: ARFCN 1..1023,0.

The frequencies found in SI5ter are counted afterwards, in the following
order: ARFCN 1..1023,0.

Related: OS#5782
Change-Id: I090d84a5550d89743e8f5a886f400df6483f50d7
---
M src/host/layer23/src/common/sysinfo.c
1 file changed, 28 insertions(+), 15 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/57/34657/1

diff --git a/src/host/layer23/src/common/sysinfo.c 
b/src/host/layer23/src/common/sysinfo.c
index 356f8eb..f541c85 100644
--- a/src/host/layer23/src/common/sysinfo.c
+++ b/src/host/layer23/src/common/sysinfo.c
@@ -1078,30 +1078,25 @@
        return 0;
 }

-static int16_t arfcn_from_freq_index(struct gsm48_sysinfo *s, uint16_t index)
+/* Get ARFCN from BCCH allocation found in SI5/SI5bis an SI5ter. See TS 44.018 
§10.5.2.20. */
+int16_t arfcn_from_freq_index(const struct gsm48_sysinfo *s, uint16_t index)
 {
        uint16_t arfcn, i = 0;

-       /* First, search for the P-GSM ARFCN. */
-       for (arfcn = 1; arfcn < 124; arfcn++) {
-               if (!(s->freq[arfcn].mask & FREQ_TYPE_REP))
+       /* Search for ARFCN found in SI5 or SI5bis. (first sub list) */
+       for (arfcn = 1; arfcn <= 1024; arfcn++) {
+               if (!(s->freq[arfcn & 1023].mask & (FREQ_TYPE_REP_5 | 
FREQ_TYPE_REP_5bis)))
                        continue;
                if (index == i++)
-                       return arfcn;
+                       return arfcn & 1023;
        }

-       /* Second, search for ARFCN 0. */
-       if ((s->freq[arfcn].mask & FREQ_TYPE_REP)) {
-               if (index == i++)
-                       return arfcn;
-       }
-
-       /* Third, search for all other ARFCN. */
-       for (arfcn = 125; arfcn < 1024; arfcn++) {
-               if (!(s->freq[arfcn].mask & FREQ_TYPE_REP))
+       /* Search for ARFCN found in SI5ter. (second sub list) */
+       for (arfcn = 1; arfcn <= 1024; arfcn++) {
+               if (!(s->freq[arfcn & 1023].mask & FREQ_TYPE_REP_5ter))
                        continue;
                if (index == i++)
-                       return arfcn;
+                       return arfcn & 1023;
        }

        /* If not found, return EOF (-1) as idicator. */

--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/34657?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I090d84a5550d89743e8f5a886f400df6483f50d7
Gerrit-Change-Number: 34657
Gerrit-PatchSet: 1
Gerrit-Owner: jolly <andr...@eversberg.eu>
Gerrit-MessageType: newchange

Reply via email to