aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuncan Smith <Duncan@xrtc.net>2014-07-05 17:54:40 -0700
committerDuncan Smith <Duncan@xrtc.net>2014-07-05 17:54:40 -0700
commitc73e85aedb4b4367af5c51ae0232605ce19515a4 (patch)
tree3bfad851775f992d0b69f12f4e0f95b6a0edc966
parent470aa07fad4c2d84af30ceace8a54b2709bdbdd8 (diff)
Get and record the name of the subscriber
-rwxr-xr-xshadysim/toorsimtool-2014.py36
1 files changed, 23 insertions, 13 deletions
diff --git a/shadysim/toorsimtool-2014.py b/shadysim/toorsimtool-2014.py
index 49c3cf3..367fb76 100755
--- a/shadysim/toorsimtool-2014.py
+++ b/shadysim/toorsimtool-2014.py
@@ -50,7 +50,10 @@ def hex_ber_length(data):
return ('%02x' % (0x80 + (lenDataLen / 2))) + dataLen
def clear_phonebook():
-
+ for record_num in range(1, sc.record_count(['3f00', '7f10', '6f3a'])):
+ sc.update_record(['3f00', '7f10', '6f3a'],
+ record_num,
+ 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff')
def set_phonebook(slot, name, number, capability='ff'):
num_records = sc.record_count(['3f00','7f10','6f3a'])
@@ -58,14 +61,14 @@ def set_phonebook(slot, name, number, capability='ff'):
record_num = int(slot)
if (record_num < 1) or (record_num > num_records):
raise RuntimeError("Invalid phonebook record number")
- encoded_name = rpad(b2h(name), (record_size - 14) * 2)
- if len(encoded_name) > ((record_size - 14) * 2):
- raise RuntimeError("Name is too long")
- if len(number) > 20:
- raise RuntimeError("Number is too long")
- encoded_number = swap_nibbles(rpad(args.set_phonebook_entry[2], 20))
- record = encoded_name + ('%02x' % len(number)) + capability + encoded_number + 'ffff'
- sc.update_record(['3f00','7f10','6f3a'], record_num, record)
+ encoded_name = rpad(b2h(name), (record_size - 14) * 2)
+ if len(encoded_name) > ((record_size - 14) * 2):
+ raise RuntimeError("Name is longer than %s bytes" % ((record_size-14)))
+ if len(number) > 20:
+ raise RuntimeError("Number is too long")
+ encoded_number = swap_nibbles(rpad(number, 20))
+ record = encoded_name + ('%02x' % len(number)) + capability + encoded_number + 'ffff'
+ sc.update_record(['3f00','7f10','6f3a'], record_num, record)
def get_imsi():
imsi_raw = (sc.read_binary(['3f00', '7f20', '6f07'])[0])
@@ -74,6 +77,10 @@ def get_imsi():
print ("IMSI: %s" % imsi)
return imsi
+# Ask the user for the name of the customer
+def get_name():
+ return raw_input("Enter subscriber name: ")
+
def get_next_extension(db):
cur = db.cursor()
last_extn = cur.execute("select extension from subscriber where extension like '22____' order by extension desc limit 1;").fetchone()[0]
@@ -158,16 +165,19 @@ CREATE TABLE Subscriber (
"""
#
if args.record:
+ name = get_name()
imsi = get_imsi()
- set_phonebook(1, "Shadytel Service", "3000")
- set_phonebook(2, "Camp Registration", "3001")
- set_phonebook(3, "Camp Administration", "3002")
+ # takes a minute or two
+ clear_phonebook()
+ set_phonebook(1, "Shadytel", "3000")
+ set_phonebook(2, "Toorcamp Reg", "3001")
+ set_phonebook(3, "Toorcamp Admin", "3002")
set_phonebook(4, "Tone test", "720")
set_phonebook(5, "Echo test", "722")
extn = get_next_extension(dbh)
print("Extension: %s" % extn)
- dbh.cursor().execute("insert into subscriber (imsi, extension, authorized, created, updated) values (?, ?, 1, datetime('now'), datetime('now') );", (imsi, extn))
+ dbh.cursor().execute("insert into subscriber (name, imsi, extension, authorized, created, updated) values (?, ?, ?, 1, datetime('now'), datetime('now') );", (name, imsi, extn))
dbh.commit()