/usr/share/ofono/scripts/test-network-registration is in ofono-scripts 1.21-1ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #!/usr/bin/python3
from gi.repository import GLib
import sys
import dbus
import dbus.mainloop.glib
def network_property_changed(name, value):
print("Network Registration property '%s' changed to '%s'" %\
(name, value))
if name == 'Name' and canexit:
mainloop.quit()
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: %s [modem] <path> - Register to PLMN on <path>" %\
(sys.argv[0]))
print("Usage: %s [modem] default - Register to default PLMN" %\
(sys.argv[0]))
sys.exit(1)
canexit = False
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object('org.ofono', '/'),
'org.ofono.Manager')
if len(sys.argv) == 3:
path = sys.argv[1]
plmn = sys.argv[2]
else:
modems = manager.GetModems()
path = modems[0][0]
plmn = sys.argv[1]
netreg = dbus.Interface(bus.get_object('org.ofono', path),
'org.ofono.NetworkRegistration')
netreg.connect_to_signal("PropertyChanged", network_property_changed)
props = netreg.GetProperties()
print("Status is: '%s', Operator Name is: '%s'" %\
(props['Status'], props['Name']))
if 'LocationAreaCode' in props and 'CellId' in props:
print("Location: '%d', Cell: '%d'" %\
(props['LocationAreaCode'], props['CellId']))
if 'Technology' in props:
print("Technology: '%s'" % (props['Technology']))
try:
if plmn == 'default':
netreg.Register()
else:
obj = bus.get_object('org.ofono', plmn);
op = dbus.Interface(obj, 'org.ofono.NetworkOperator')
op.Register()
except dbus.DBusException as e:
print("Unable to register: %s" % e)
sys.exit(1)
canexit = True
mainloop = GLib.MainLoop()
mainloop.run()
|