test: Add send-ussd script
authorPhilippe Nunes <philippe.nunes@linux.intel.com>
Thu, 26 Jul 2012 15:57:54 +0000 (17:57 +0200)
committerDenis Kenzior <denkenz@gmail.com>
Fri, 27 Jul 2012 05:30:57 +0000 (00:30 -0500)
Simpler script that test-ussd that is still capable of replying to
network initiated USSD requests and USSD dialogs.

Makefile.am
test/send-ussd [new file with mode: 0755]

index e012d3f..b63bcb3 100644 (file)
@@ -584,6 +584,7 @@ test_scripts = test/backtrace \
                test/test-ss-control-cs \
                test/test-voicecall \
                test/test-ussd \
+               test/send-ussd \
                test/cancel-ussd \
                test/initiate-ussd \
                test/offline-modem \
diff --git a/test/send-ussd b/test/send-ussd
new file mode 100755 (executable)
index 0000000..fcabd21
--- /dev/null
@@ -0,0 +1,57 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+if (len(sys.argv) < 2):
+       print "Usage: %s [modem] <ussd-string>" % (sys.argv[0])
+       sys.exit(1)
+
+bus = dbus.SystemBus()
+
+manager = dbus.Interface(bus.get_object('org.ofono', '/'),
+                                               'org.ofono.Manager')
+
+modems = manager.GetModems()
+
+if (len(sys.argv) == 2):
+       path = modems[0][0]
+       ussdstring = sys.argv[1]
+else:
+       path = sys.argv[1]
+       ussdstring = sys.argv[2]
+
+ussd = dbus.Interface(bus.get_object('org.ofono', path),
+                                       'org.ofono.SupplementaryServices')
+
+properties = ussd.GetProperties()
+state = properties["State"]
+
+print "State: %s" % (state)
+
+if state == "idle":
+       result = ussd.Initiate(ussdstring, timeout=100)
+       print result[0] + ": " + result[1]
+elif state == "user-response":
+       print ussd.Respond(ussdstring, timeout=100)
+else:
+       sys.exit(1);
+
+properties = ussd.GetProperties()
+state = properties["State"]
+
+if state == "idle":
+       sys.exit(0)
+
+print "State: %s" % (state)
+
+while state == "user-response":
+       response = raw_input("Enter response: ")
+
+       print ussd.Respond(response, timeout=100)
+
+       properties = ussd.GetProperties()
+       state = properties["State"]
+
+       if state != "idle":
+               print "State: %s" % (state)