File: set-sms-smsc

package info (click to toggle)
ofono 2.18-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,064 kB
  • sloc: ansic: 224,979; sh: 5,012; python: 4,040; makefile: 956
file content (31 lines) | stat: -rwxr-xr-x 916 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/python3
import sys
import dbus

if len(sys.argv) < 2:
        print("Usage: %s <SMSC address>" % (sys.argv[0]))
        sys.exit(1)

def message_service_center_address(sms, value):
        try:
            sms.SetProperty("ServiceCenterAddress", dbus.String(value))
        except dbus.DBusException as e:
            print("Unable to set correct Service Center Address - FAIL")
            exit(1)

bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object('org.ofono', '/'),'org.ofono.Manager')
modems = manager.GetModems()
value  = sys.argv[1]

for path, properties in modems:
	print("Setting SMSC for [ %s ]" % (path))

	if "org.ofono.MessageManager" not in properties["Interfaces"]:
		continue

	sms = dbus.Interface(bus.get_object('org.ofono', path),
					'org.ofono.MessageManager')

        message_service_center_address(sms, value)
        print("SMSC address Updated for [ %s ]" % (path))