aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2022-02-13 11:32:50 +0100
committerHarald Welte <laforge@osmocom.org>2022-02-15 15:35:36 +0100
commit1e73d228f4b11b6202ad452f96d590bfb294a83e (patch)
treead99a679e7ae00563598abf819e5f5dd58701763
parentbc0e209a9fe72258e64e1984629d12deb8d127d7 (diff)
ts_51_011: Convert EF_ADN and EF_ACC to Construct
this has the benefit of providing encoding support for free. Change-Id: I31c118082e92892486c3688de2197c0c6dd2750e
-rw-r--r--pySim/ts_51_011.py20
1 files changed, 7 insertions, 13 deletions
diff --git a/pySim/ts_51_011.py b/pySim/ts_51_011.py
index c29b54c..890b85b 100644
--- a/pySim/ts_51_011.py
+++ b/pySim/ts_51_011.py
@@ -343,13 +343,12 @@ EF_SST_map = {
class EF_ADN(LinFixedEF):
def __init__(self, fid='6f3a', sfid=None, name='EF.ADN', desc='Abbreviated Dialing Numbers', **kwargs):
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len={14, 30}, **kwargs)
-
- def _decode_record_bin(self, raw_bin_data):
- alpha_id_len = len(raw_bin_data) - 14
- alpha_id = raw_bin_data[:alpha_id_len]
- u = unpack('!BB10sBB', raw_bin_data[-14:])
- return {'alpha_id': alpha_id, 'len_of_bcd': u[0], 'ton_npi': u[1],
- 'dialing_nr': u[2], 'cap_conf_id': u[3], 'ext1_record_id': u[4]}
+ self._construct = Struct('alpha_id'/COptional(GsmStringAdapter(Rpad(Bytes(this._.total_len-14)), codec='ascii')),
+ 'len_of_bcd'/Int8ub,
+ 'ton_npi'/TonNpi,
+ 'dialing_nr'/BcdAdapter(Rpad(Bytes(10))),
+ 'cap_conf_id'/Int8ub,
+ 'ext1_record_id'/Int8ub)
# TS 51.011 Section 10.5.5
class EF_SMS(LinFixedEF):
@@ -656,12 +655,7 @@ class EF_ACC(TransparentEF):
def __init__(self, fid='6f78', sfid=None, name='EF.ACC',
desc='Access Control Class', size={2, 2}, **kwargs):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, **kwargs)
-
- def _decode_bin(self, raw_bin):
- return {'acc': unpack('!H', raw_bin)[0]}
-
- def _encode_bin(self, abstract):
- return pack('!H', abstract['acc'])
+ self._construct = HexAdapter(Bytes(2))
# TS 51.011 Section 10.3.16
class EF_LOCI(TransparentEF):