aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am7
-rw-r--r--test/Makefile.in9
-rwxr-xr-xtest/disable.py5
-rwxr-xr-xtest/enable.py5
-rwxr-xr-xtest/info.py6
-rwxr-xr-xtest/location.py5
-rwxr-xr-xtest/mm-send-sms.py52
-rwxr-xr-xtest/scan.py89
-rwxr-xr-xtest/send-pin.py6
-rwxr-xr-xtest/sms-get.py80
-rwxr-xr-xtest/sms-send.py89
-rwxr-xr-xtest/ussd.py48
12 files changed, 338 insertions, 63 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 8249131..ccec30a 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -25,6 +25,9 @@ EXTRA_DIST = \
info.py \
list-modems.py \
location.py \
- mm-send-sms.py \
- send-pin.py
+ sms-send.py \
+ sms-get.py \
+ send-pin.py \
+ ussd.py \
+ scan.py
diff --git a/test/Makefile.in b/test/Makefile.in
index c27c0ce..3df9166 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -43,7 +43,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \
$(top_srcdir)/m4/intltool.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
- $(top_srcdir)/configure.ac
+ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
@@ -293,8 +293,11 @@ EXTRA_DIST = \
info.py \
list-modems.py \
location.py \
- mm-send-sms.py \
- send-pin.py
+ sms-send.py \
+ sms-get.py \
+ send-pin.py \
+ ussd.py \
+ scan.py
all: all-am
diff --git a/test/disable.py b/test/disable.py
index 5b8c14a..4e52cf1 100755
--- a/test/disable.py
+++ b/test/disable.py
@@ -21,7 +21,10 @@ MM_DBUS_PATH='/org/freedesktop/ModemManager'
MM_DBUS_INTERFACE_MODEM='org.freedesktop.ModemManager.Modem'
bus = dbus.SystemBus()
-proxy = bus.get_object(MM_DBUS_SERVICE, sys.argv[1])
+objpath = sys.argv[1]
+if objpath[:1] != '/':
+ objpath = "/org/freedesktop/ModemManager/Modems/" + str(objpath)
+proxy = bus.get_object(MM_DBUS_SERVICE, objpath)
modem = dbus.Interface(proxy, dbus_interface=MM_DBUS_INTERFACE_MODEM)
modem.Enable (False)
diff --git a/test/enable.py b/test/enable.py
index bfe1a6d..7fa218d 100755
--- a/test/enable.py
+++ b/test/enable.py
@@ -21,7 +21,10 @@ MM_DBUS_PATH='/org/freedesktop/ModemManager'
MM_DBUS_INTERFACE_MODEM='org.freedesktop.ModemManager.Modem'
bus = dbus.SystemBus()
-proxy = bus.get_object(MM_DBUS_SERVICE, sys.argv[1])
+objpath = sys.argv[1]
+if objpath[:1] != '/':
+ objpath = "/org/freedesktop/ModemManager/Modems/" + str(objpath)
+proxy = bus.get_object(MM_DBUS_SERVICE, objpath)
modem = dbus.Interface(proxy, dbus_interface=MM_DBUS_INTERFACE_MODEM)
modem.Enable (True)
diff --git a/test/info.py b/test/info.py
index 6659a3a..82057fa 100755
--- a/test/info.py
+++ b/test/info.py
@@ -224,8 +224,10 @@ def gsm_inspect(proxy, props):
bus = dbus.SystemBus()
-bus = dbus.SystemBus()
-proxy = bus.get_object(MM_DBUS_SERVICE, sys.argv[1])
+objpath = sys.argv[1]
+if objpath[:1] != '/':
+ objpath = "/org/freedesktop/ModemManager/Modems/%s" % str(objpath)
+proxy = bus.get_object(MM_DBUS_SERVICE, objpath)
# Properties
props = dbus.Interface(proxy, dbus_interface='org.freedesktop.DBus.Properties')
diff --git a/test/location.py b/test/location.py
index b6af387..96cd1e5 100755
--- a/test/location.py
+++ b/test/location.py
@@ -29,7 +29,10 @@ MM_MODEM_LOCATION_CAPABILITY_GSM_LAC_CI = 0x00000002
MM_MODEM_LOCATION_CAPABILITY_GPS_RAW = 0x00000004
bus = dbus.SystemBus()
-proxy = bus.get_object(MM_DBUS_SERVICE, sys.argv[1])
+objpath = sys.argv[1]
+if objpath[:1] != '/':
+ objpath = "/org/freedesktop/ModemManager/Modems/" + str(objpath)
+proxy = bus.get_object(MM_DBUS_SERVICE, objpath)
modem = dbus.Interface(proxy, dbus_interface=MM_DBUS_INTERFACE_MODEM)
props = dbus.Interface(proxy, dbus_interface=DBUS_INTERFACE_PROPERTIES)
diff --git a/test/mm-send-sms.py b/test/mm-send-sms.py
deleted file mode 100755
index 55d453c..0000000
--- a/test/mm-send-sms.py
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/usr/bin/python
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details:
-#
-# Copyright (C) 2009 Novell, Inc.
-#
-
-# An example on how to send an SMS message using ModemManager
-
-import sys
-import dbus
-
-if len(sys.argv) != 3:
- print "Usage: %s <number> <message>" % sys.argv[0]
- sys.exit(1)
-
-number = sys.argv[1]
-message = sys.argv[2]
-
-bus = dbus.SystemBus()
-
-manager_proxy = bus.get_object('org.freedesktop.ModemManager', '/org/freedesktop/ModemManager')
-manager_iface = dbus.Interface(manager_proxy, dbus_interface='org.freedesktop.ModemManager')
-modems = manager_iface.EnumerateDevices()
-if len(modems) == 0:
- print "No modems found"
- sys.exit(1)
-
-proxy = bus.get_object('org.freedesktop.ModemManager', modems[0])
-modem = dbus.Interface(proxy, dbus_interface='org.freedesktop.ModemManager.Modem')
-modem.Enable(True)
-
-msg_dict = dbus.Dictionary({ dbus.String('number') : dbus.String(number),
- dbus.String('text') : dbus.String(message)
- },
- signature=dbus.Signature("sv"))
-
-sms_iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.ModemManager.Modem.Gsm.SMS')
-try:
- sms_iface.Send(msg_dict)
-except:
- print "Sending message failed"
-finally:
- modem.Enable(False)
diff --git a/test/scan.py b/test/scan.py
new file mode 100755
index 0000000..eff470d
--- /dev/null
+++ b/test/scan.py
@@ -0,0 +1,89 @@
+#!/usr/bin/python
+# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details:
+#
+# Copyright (C) 2009 - 2010Red Hat, Inc.
+#
+
+import sys, dbus
+
+DBUS_INTERFACE_PROPERTIES='org.freedesktop.DBus.Properties'
+MM_DBUS_SERVICE='org.freedesktop.ModemManager'
+MM_DBUS_INTERFACE_MODEM='org.freedesktop.ModemManager.Modem'
+MM_DBUS_INTERFACE_MODEM_GSM_NETWORK='org.freedesktop.ModemManager.Modem.Gsm.Network'
+
+gsm_act = { 0: "(GSM)",
+ 1: "(GSM Compact)",
+ 2: "(UMTS)",
+ 3: "(EDGE)",
+ 4: "(HSDPA)",
+ 5: "(HSUPA)",
+ 6: "(HSPA)"
+ }
+
+bus = dbus.SystemBus()
+objpath = sys.argv[1]
+if objpath[:1] != '/':
+ objpath = "/org/freedesktop/ModemManager/Modems/" + str(objpath)
+proxy = bus.get_object(MM_DBUS_SERVICE, objpath)
+
+# Properties
+props = dbus.Interface(proxy, dbus_interface='org.freedesktop.DBus.Properties')
+
+mtype = props.Get(MM_DBUS_INTERFACE_MODEM, 'Type')
+if mtype == 2:
+ print "CDMA modems do not support network scans"
+ sys.exit(1)
+
+print "Driver: '%s'" % (props.Get(MM_DBUS_INTERFACE_MODEM, 'Driver'))
+print "Modem device: '%s'" % (props.Get(MM_DBUS_INTERFACE_MODEM, 'MasterDevice'))
+print "Data device: '%s'" % (props.Get(MM_DBUS_INTERFACE_MODEM, 'Device'))
+print ""
+
+net = dbus.Interface(proxy, dbus_interface=MM_DBUS_INTERFACE_MODEM_GSM_NETWORK)
+print "Scanning..."
+try:
+ results = net.Scan(timeout=120)
+except dbus.exceptions.DBusException, e:
+ print "Error scanning: %s" % e
+ results = {}
+
+for r in results:
+ status = r['status']
+ if status == "1":
+ status = "available"
+ elif status == "2":
+ status = "current"
+ elif status == "3":
+ status = "forbidden"
+ else:
+ status = "(Unknown)"
+
+ access_tech = ""
+ try:
+ access_tech_num = int(r['access-tech'])
+ access_tech = gsm_act[access_tech_num]
+ except KeyError:
+ pass
+
+ opnum = "(%s):" % r['operator-num']
+ # Extra space for 5-digit MCC/MNC
+ if r['operator-num'] == 5:
+ opnum += " "
+
+ if r.has_key('operator-long') and len(r['operator-long']):
+ print "%s %s %s %s" % (r['operator-long'], opnum, status, access_tech)
+ elif r.has_key('operator-short') and len(r['operator-short']):
+ print "%s %s %s %s" % (r['operator-short'], opnum, status, access_tech)
+ else:
+ print "%s: %s %s" % (r['operator-num'], status, access_tech)
+
diff --git a/test/send-pin.py b/test/send-pin.py
index 3cf47ee..002f1b0 100755
--- a/test/send-pin.py
+++ b/test/send-pin.py
@@ -33,7 +33,11 @@ if not sys.argv[2].isdigit():
os._exit(1)
bus = dbus.SystemBus()
-proxy = bus.get_object(MM_DBUS_SERVICE, sys.argv[1])
+objpath = sys.argv[1]
+if objpath[:1] != '/':
+ objpath = "/org/freedesktop/ModemManager/Modems/" + str(objpath)
+proxy = bus.get_object(MM_DBUS_SERVICE, objpath)
+
props = dbus.Interface(proxy, dbus_interface=DBUS_INTERFACE_PROPS)
req = props.Get(MM_DBUS_INTERFACE_MODEM, "UnlockRequired")
if req == "":
diff --git a/test/sms-get.py b/test/sms-get.py
new file mode 100755
index 0000000..981fb5d
--- /dev/null
+++ b/test/sms-get.py
@@ -0,0 +1,80 @@
+#!/usr/bin/python
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details:
+#
+# Copyright (C) 2009 Novell, Inc.
+# Copyright (C) 2009 - 2012 Red Hat, Inc.
+#
+
+# An example on how to read SMS messages using ModemManager
+
+import sys
+import dbus
+import os
+
+MM_DBUS_SERVICE='org.freedesktop.ModemManager'
+MM_DBUS_PATH='/org/freedesktop/ModemManager'
+MM_DBUS_INTERFACE_MODEM='org.freedesktop.ModemManager.Modem'
+MM_DBUS_INTERFACE_MODEM_SMS='org.freedesktop.ModemManager.Modem.Gsm.SMS'
+
+arglen = len(sys.argv)
+if arglen != 2 and arglen != 3:
+ print "Usage: %s <modem path> [message #]" % sys.argv[0]
+ sys.exit(1)
+
+msgnum = None
+if len(sys.argv) == 3:
+ msgnum = int(sys.argv[2])
+
+objpath = sys.argv[1]
+if objpath[:1] != '/':
+ objpath = "/org/freedesktop/ModemManager/Modems/" + str(objpath)
+
+# Create the modem properties proxy
+bus = dbus.SystemBus()
+proxy = bus.get_object(MM_DBUS_SERVICE, objpath)
+modem = dbus.Interface(proxy, dbus_interface="org.freedesktop.DBus.Properties")
+
+# Make sure the modem is enabled first
+if modem.Get(MM_DBUS_INTERFACE_MODEM, "Enabled") == False:
+ print "Modem is not enabled"
+ sys.exit(1)
+
+# Create the SMS interface proxy
+sms = dbus.Interface(proxy, dbus_interface=MM_DBUS_INTERFACE_MODEM_SMS)
+
+msgs = sms.List()
+i = 0
+for m in msgs:
+ print "-------------------------------------------------------------------"
+ smsc = ""
+ try:
+ smsc = m["smsc"]
+ except KeyError:
+ pass
+
+ print "%d: From: %s Time: %s SMSC: %s" % (m["index"], m["number"], m["timestamp"], smsc)
+ if len(m["text"]):
+ print " %s\n" % m["text"]
+ elif len(m["data"]):
+ print " Coding: %d" % m["data-coding-scheme"]
+ z = 1
+ s = ""
+ for c in m["data"]:
+ s += "%02X " % c
+ if not z % 16:
+ print " %s" % s
+ s = ""
+ z += 1
+ if len(s):
+ print " %s" % s
+ i += 1
+
diff --git a/test/sms-send.py b/test/sms-send.py
new file mode 100755
index 0000000..5977c20
--- /dev/null
+++ b/test/sms-send.py
@@ -0,0 +1,89 @@
+#!/usr/bin/python
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details:
+#
+# Copyright (C) 2009 Novell, Inc.
+#
+
+# An example on how to send an SMS message using ModemManager
+
+import sys
+import dbus
+import os
+
+arglen = len(sys.argv)
+if arglen != 4 and arglen != 6 and arglen != 8:
+ print "Usage: %s --number <number> [--smsc <smsc>] [--validity <minutes>] <message>" % sys.argv[0]
+ sys.exit(1)
+
+number = None
+validity = None
+smsc = None
+message = None
+x = 1
+while x < arglen - 1:
+ if sys.argv[x] == "--number":
+ x += 1
+ number = sys.argv[x].strip()
+ elif sys.argv[x] == "--validity":
+ x += 1
+ validity = int(sys.argv[x])
+ elif sys.argv[x] == "--smsc":
+ x += 1
+ smsc = sys.argv[x].strip()
+ else:
+ raise ValueError("Unknown option '%s'" % sys.argv[x])
+ x += 1
+
+try:
+ lang = os.getenv("LANG")
+ idx = lang.find(".")
+ if idx != -1:
+ lang = lang[idx + 1:]
+except KeyError:
+ lang = "utf-8"
+message = unicode(sys.argv[arglen - 1], "utf-8")
+
+
+bus = dbus.SystemBus()
+
+manager_proxy = bus.get_object('org.freedesktop.ModemManager', '/org/freedesktop/ModemManager')
+manager_iface = dbus.Interface(manager_proxy, dbus_interface='org.freedesktop.ModemManager')
+modems = manager_iface.EnumerateDevices()
+if len(modems) == 0:
+ print "No modems found"
+ sys.exit(1)
+
+proxy = bus.get_object('org.freedesktop.ModemManager', modems[0])
+modem = dbus.Interface(proxy, dbus_interface='org.freedesktop.ModemManager.Modem')
+modem.Enable(True)
+
+msg_dict = dbus.Dictionary(
+ {
+ dbus.String('number') : dbus.String(number),
+ dbus.String('text') : dbus.String(message)
+ },
+ signature=dbus.Signature("sv")
+)
+
+if smsc:
+ msg_dict[dbus.String('smsc')] = dbus.String(smsc)
+
+if validity:
+ msg_dict[dbus.String('validity')] = dbus.UInt32(validity)
+
+sms_iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.ModemManager.Modem.Gsm.SMS')
+try:
+ indexes = sms_iface.Send(msg_dict)
+ print "Message index: %d" % indexes[0]
+except Exception, e:
+ print "Sending message failed: %s" % e
+
diff --git a/test/ussd.py b/test/ussd.py
new file mode 100755
index 0000000..73b8f8e
--- /dev/null
+++ b/test/ussd.py
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details:
+#
+# Copyright (C) 2010 Guido Guenther <agx@sigxcpu.org>
+#
+# Usage: ./test/ussd.py /org/freedesktop/ModemManager/Modems/0 '*130#'
+
+import sys, dbus, re
+
+MM_DBUS_SERVICE='org.freedesktop.ModemManager'
+MM_DBUS_INTERFACE_USSD='org.freedesktop.ModemManager.Modem.Gsm.Ussd'
+
+if len(sys.argv) != 3:
+ print "Usage: %s dbus_object [<ussd>|cancel]" % sys.argv[0]
+ sys.exit(1)
+else:
+ arg = sys.argv[2]
+
+bus = dbus.SystemBus()
+objpath = sys.argv[1]
+if objpath[:1] != '/':
+ objpath = "/org/freedesktop/ModemManager/Modems/" + str(objpath)
+proxy = bus.get_object(MM_DBUS_SERVICE, objpath)
+
+modem = dbus.Interface(proxy, dbus_interface=MM_DBUS_INTERFACE_USSD)
+
+# For testing purposes treat all "common" USSD sequences as initiate and the
+# rest (except for cancel) as response. See GSM 02.90.
+initiate_re = re.compile('[*#]{1,3}1[0-9][0-9].*#')
+
+if initiate_re.match(arg):
+ ret = modem.Initiate(arg)
+elif arg == "cancel":
+ ret = modem.Cancel()
+else:
+ ret = modem.Respond(arg)
+print ret
+