Skip to contentSkip to conversation

Added test script to enter pin to sim card.

PATCH In review Ryan M. Raasch 2 participants 3 messages Nov 24, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Added test script to enter pin to sim card.

---
 test/enter-pin.py |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
 create mode 100755 test/enter-pin.py
test/enter-pin.py new file +28 -0
new file mode 100755
index 0000000..77de93a
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+import dbus
+import sys
+
+bus = dbus.SystemBus()
+
+manager = dbus.Interface(bus.get_object('org.ofono', '/'),
+                         'org.ofono.Manager')
+
+properties = manager.GetProperties()
+
+path = properties["Modems"][0]
+
+if len(path)==0:
+    print "No modems found"
+    exit
+
+modem = dbus.Interface(bus.get_object('org.ofono', path),
+                       'org.ofono.SimManager')
+properties = modem.GetProperties()
+if properties.has_key('PinRequired') and properties['PinRequired'] == sys.argv[1] :
+    modem.EnterPin(sys.argv[1], sys.argv[2])
+elif properties.has_key('PinRequired') and properties['PinRequired'] == 'none' :
+    print "Pin not needed"
+elif properties.has_key('PinRequired'):
+    print "Error: Pin type not supported (%s != %s)" % (sys.argv[1],properties['PinRequired'])
+
+
Signature · 1 line
1.6.4.GIT
#1 lore raw

Hi Ryan,

Quoted 4 lines
---
 test/enter-pin.py |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
 create mode 100755 test/enter-pin.py

don't forget to modify EXTRA_DIST of Makefile.am and please remove the .py suffix. We don't do that with our test scripts.

Quoted 22 lines
test/enter-pin.py new file +16 -0
new file mode 100755
index 0000000..77de93a
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+import dbus
+import sys
+
+bus = dbus.SystemBus()
+
+manager = dbus.Interface(bus.get_object('org.ofono', '/'),
+                         'org.ofono.Manager')
+
+properties = manager.GetProperties()
+
+path = properties["Modems"][0]
+
+if len(path)==0:
+    print "No modems found"
+    exit

test/enter-pin.py line 26

Quoted 10 lines
test/enter-pin.py new file +10 -0
+
+modem = dbus.Interface(bus.get_object('org.ofono', path),
+                       'org.ofono.SimManager')
+properties = modem.GetProperties()
+if properties.has_key('PinRequired') and properties['PinRequired'] == sys.argv[1] :
+    modem.EnterPin(sys.argv[1], sys.argv[2])
+elif properties.has_key('PinRequired') and properties['PinRequired'] == 'none' :
+    print "Pin not needed"
+elif properties.has_key('PinRequired'):
+    print "Error: Pin type not supported (%s != %s)" % (sys.argv[1],properties['PinRequired'])

can we do something like if no argument has been provided, then check for the current required PIN. So that you can get an easy way to tell what is needed.

And then supplying the PIN type is pointless, isn't it. Just take the first argument and set it as PIN. The type comes via PinRequired anyway.

Regards

Marcel

#2 lore raw

PATCH 1/1 Added test script to unlock sim card (revised).

---
 Makefile.am     |    3 ++-
 test/unlock-sim |   25 +++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletions(-)
 create mode 100755 test/unlock-sim
Makefile.am +2 -1
index 4b0d7e8..2420c2c 100644
@@ -242,7 +242,8 @@ test_files = test/test-manager test/test-modem test/test-voicecall \
 		test/receive-sms test/send-sms \
 		test/list-contexts test/create-context \
 		test/activate-context test/deactivate-context \
-		test/process-context-settings
+		test/process-context-settings \
+		test/unlock-sim
 
 conf_files = src/ofono.conf plugins/modem.conf
 
test/unlock-sim new file +25 -0
new file mode 100755
index 0000000..38ae38d
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+import dbus
+import sys
+
+bus = dbus.SystemBus()
+
+manager = dbus.Interface(bus.get_object('org.ofono', '/'),
+                         'org.ofono.Manager')
+
+properties = manager.GetProperties()
+
+try:
+    path = properties["Modems"][0]
+except:
+    print "No modems found "
+    sys.exit(2)
+
+modem = dbus.Interface(bus.get_object('org.ofono', path),
+                    'org.ofono.SimManager')
+properties = modem.GetProperties()
+
+try:
+    modem.EnterPin(properties['PinRequired'], sys.argv[1])
+except:
+    print "PinRequried = %s " % properties['PinRequired']
Signature · 1 line
1.6.4.GIT