2
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details:
14
# Copyright (C) 2010 Guido Guenther <agx@sigxcpu.org>
16
# Usage: ./test/ussd.py /org/freedesktop/ModemManager/Modems/0 '*130#'
20
MM_DBUS_SERVICE='org.freedesktop.ModemManager'
21
MM_DBUS_INTERFACE_USSD='org.freedesktop.ModemManager.Modem.Gsm.Ussd'
23
if len(sys.argv) != 3:
24
print "Usage: %s dbus_object [<ussd>|cancel]" % sys.argv[0]
29
bus = dbus.SystemBus()
31
if objpath[:1] != '/':
32
objpath = "/org/freedesktop/ModemManager/Modems/" + str(objpath)
33
proxy = bus.get_object(MM_DBUS_SERVICE, objpath)
35
modem = dbus.Interface(proxy, dbus_interface=MM_DBUS_INTERFACE_USSD)
37
# For testing purposes treat all "common" USSD sequences as initiate and the
38
# rest (except for cancel) as response. See GSM 02.90.
39
initiate_re = re.compile('[*#]{1,3}1[0-9][0-9].*#')
41
if initiate_re.match(arg):
42
ret = modem.Initiate(arg)
46
ret = modem.Respond(arg)