Jan Hrach has uploaded this change for review. ( 
https://gerrit.osmocom.org/10270


Change subject: update scrambling only if we have good CRC
......................................................................

update scrambling only if we have good CRC

When a bad frame is received, the scrambling should not be updated,
because setting scrambling to wrong values will completely break further
decoding (until another SYNC frame is received).

Change-Id: I5e88b52fcbb98532d7ab6ca85e4f956589a595ab
---
M src/lower_mac/tetra_lower_mac.c
1 file changed, 10 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-tetra refs/changes/70/10270/1

diff --git a/src/lower_mac/tetra_lower_mac.c b/src/lower_mac/tetra_lower_mac.c
index 81832bc..d6f9e41 100644
--- a/src/lower_mac/tetra_lower_mac.c
+++ b/src/lower_mac/tetra_lower_mac.c
@@ -272,14 +272,16 @@
                printf("MCC %s(%u) ", osmo_ubit_dump(type2+31, 10), 
bits_to_uint(type2+31, 10));
                printf("MNC %s(%u)\n", osmo_ubit_dump(type2+41, 14), 
bits_to_uint(type2+41, 14));
                /* obtain information from SYNC PDU */
-               tcd->colour_code = bits_to_uint(type2+4, 6);
-               tcd->time.tn = bits_to_uint(type2+10, 2);
-               tcd->time.fn = bits_to_uint(type2+12, 5);
-               tcd->time.mn = bits_to_uint(type2+17, 6);
-               tcd->mcc = bits_to_uint(type2+31, 10);
-               tcd->mnc = bits_to_uint(type2+41, 14);
-               /* compute the scrambling code for the current cell */
-               tcd->scramb_init = tetra_scramb_get_init(tcd->mcc, tcd->mnc, 
tcd->colour_code);
+               if (tup->crc_ok) {
+                       tcd->colour_code = bits_to_uint(type2+4, 6);
+                       tcd->time.tn = bits_to_uint(type2+10, 2);
+                       tcd->time.fn = bits_to_uint(type2+12, 5);
+                       tcd->time.mn = bits_to_uint(type2+17, 6);
+                       tcd->mcc = bits_to_uint(type2+31, 10);
+                       tcd->mnc = bits_to_uint(type2+41, 14);
+                       /* compute the scrambling code for the current cell */
+                       tcd->scramb_init = tetra_scramb_get_init(tcd->mcc, 
tcd->mnc, tcd->colour_code);
+               }
                /* update the PHY layer time */
                memcpy(&t_phy_state.time, &tcd->time, sizeof(t_phy_state.time));
                tup->lchan = TETRA_LC_BSCH;

--
To view, visit https://gerrit.osmocom.org/10270
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-tetra
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5e88b52fcbb98532d7ab6ca85e4f956589a595ab
Gerrit-Change-Number: 10270
Gerrit-PatchSet: 1
Gerrit-Owner: Jan Hrach <[email protected]>

Reply via email to