Revert "utils.py: Fix for parsing MNC"
This reverts commit bdf3d3597b5d8e4260f80a00ada78e9ad612b00b, which
broke pySim.utils.dec_mnc_from_plmn(). According to 3GPP TS 31.102,
which points to TS 24.008, the three-digit EHPLMN shall be encoded
as shown below (ASCII-art interpretation):
0 1 2 3 4 5 6 7
+---+---+---+---+---+---+---+---+
| MCC Digit 2 | MCC Digit 1 |
+---+---+---+---+---+---+---+---+
| MNC Digit 3 | MCC Digit 3 |
+---+---+---+---+---+---+---+---+
| MNC Digit 2 | MNC Digit 1 |
+---+---+---+---+---+---+---+---+
So the original implementation was correct, and we even had a unit
test for it. Most likely, the SIM card itself was programmed
incorrectly?
Makes 'testDecMNCfromPLMN_threeDigitMNC' pass again.
Change-Id: If6bf5383988ad442e275efc7c5a159327d104879
diff --git a/pySim/utils.py b/pySim/utils.py
index 6dbd980..b49a437 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -140,9 +140,9 @@
def dec_mnc_from_plmn(plmn):
ia = h2i(plmn)
- digit1 = (ia[1] & 0xF0) >>4 # 2nd byte, MSB
- digit2 = ia[2] & 0x0F # 3rd byte, LSB
- digit3 = (ia[2] & 0xF0) >> 4 # 3nd byte, MSB
+ digit1 = ia[2] & 0x0F # 3rd byte, LSB
+ digit2 = (ia[2] & 0xF0) >> 4 # 3rd byte, MSB
+ digit3 = (ia[1] & 0xF0) >> 4 # 2nd byte, MSB
if digit3 == 0xF and digit2 == 0xF and digit1 == 0xF:
return 0xFFF # 4095
return derive_mnc(digit1, digit2, digit3)