diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-05-26 09:50:51 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-05-26 09:50:51 -0500 |
commit | 48a4f59bdd341c524ec2de656fc98f1be1067574 (patch) | |
tree | a1ba2b0e66d04e74867d37d3324d1a2217cc276e /src/simutil.c | |
parent | 795f0f340672582696711929ca416c0839cc77e2 (diff) | |
download | ofono-48a4f59bdd341c524ec2de656fc98f1be1067574.tar.bz2 |
simutil: add sim_extract_bcd_number
Diffstat (limited to 'src/simutil.c')
-rw-r--r-- | src/simutil.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/simutil.c b/src/simutil.c index a86b404e..ccf5fb30 100644 --- a/src/simutil.c +++ b/src/simutil.c @@ -1103,6 +1103,37 @@ const struct sim_eons_operator_info *sim_eons_lookup_with_lac( return sim_eons_lookup_common(eons, mcc, mnc, TRUE, lac); } +/* + * Extract extended BCD format defined in 3GPP 11.11, 31.102. The format + * is different from what is defined in 3GPP 24.008 and 23.040 (sms). + * + * Here the digits with values 'C', 'D' and 'E' are treated differently, + * for more details see 31.102 Table 4.4 + * + * 'C' - DTMF Control Digit Separator, represented as 'c' by this function + * 'D' - Wild Value, represented as a '?' by this function + * 'E' - RFU, used to be used as a Shift Operator in 11.11 + * 'F' - Endmark + * + * Note that a second or subsequent 'C' BCD value will be interpreted as a + * 3 second pause. + */ +void sim_extract_bcd_number(const unsigned char *buf, int len, char *out) +{ + static const char digit_lut[] = "0123456789*#c?e\0"; + unsigned char oct; + int i; + + for (i = 0; i < len; i++) { + oct = buf[i]; + + out[i*2] = digit_lut[oct & 0x0f]; + out[i*2+1] = digit_lut[(oct & 0xf0) >> 4]; + } + + out[i*2] = '\0'; +} + gboolean sim_adn_parse(const unsigned char *data, int length, struct ofono_phone_number *ph, char **identifier) { |