Prepare for decoding/encoding records differently based on record number
In their infinite wisdom, the authors of the EIRENE FFFIS for GSM-R SIM
cards invented yet a new way of encoding data in SIM card files: The
first record of a file may be encoded differently than further records
of files.
Let's add the required infrastructure to pySim so that the encode and
decode methods for record-oriented files get passed in the current
record number.
Change-Id: I02d6942016dd0631b21d1fd301711c13cb27962b
Related: OS#5784
diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py
index 65a2afe..e68866c 100644
--- a/pySim/ts_31_102.py
+++ b/pySim/ts_31_102.py
@@ -515,14 +515,14 @@
desc='Language Indication'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, rec_len=rec_len)
- def _decode_record_bin(self, in_bin):
+ def _decode_record_bin(self, in_bin, **kwargs):
if in_bin == b'\xff\xff':
return None
else:
# officially this is 7-bit GSM alphabet with one padding bit in each byte
return in_bin.decode('ascii')
- def _encode_record_bin(self, in_json):
+ def _encode_record_bin(self, in_json, **kwargs):
if in_json == None:
return b'\xff\xff'
else:
@@ -604,7 +604,7 @@
desc='Emergency Call Codes'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=(4, 20))
- def _decode_record_bin(self, in_bin):
+ def _decode_record_bin(self, in_bin, **kwargs):
# mandatory parts
code = in_bin[:3]
if code == b'\xff\xff\xff':
@@ -618,7 +618,7 @@
ret['alpha_id'] = parse_construct(EF_ECC.alpha_construct, alpha_id)
return ret
- def _encode_record_bin(self, in_json):
+ def _encode_record_bin(self, in_json, **kwargs):
if in_json is None:
return b'\xff\xff\xff\xff'
code = EF_ECC.cc_construct.build(in_json['call_code'])
@@ -753,7 +753,7 @@
def __init__(self, fid='6f65', sfid=None, name='EF.RPLMNAcTD', size=(2, 4), rec_len=2,
desc='RPLMN Last used Access Technology', **kwargs):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, rec_len=rec_len, **kwargs)
- def _decode_record_hex(self, in_hex):
+ def _decode_record_hex(self, in_hex, **kwargs):
return dec_act(in_hex)
# TODO: Encode