mirror of git://git.sysmocom.de/ofono
test: Rework the gnss test slightly
Rework the test to avoid going over 80 characters / line, eliminate some unneded empty lines and use slightly simpler variable names
This commit is contained in:
parent
00f612b78d
commit
069bd3c8ee
|
@ -8,19 +8,22 @@ import dbus
|
||||||
import dbus.service
|
import dbus.service
|
||||||
import dbus.mainloop.glib
|
import dbus.mainloop.glib
|
||||||
|
|
||||||
|
GNSS_INTERFACE = "org.ofono.AssistedSatelliteNavigation"
|
||||||
|
AGENT_INTERFACE = "org.ofono.PositioningRequestAgent"
|
||||||
|
|
||||||
class PositioningAgent(dbus.service.Object):
|
class PositioningAgent(dbus.service.Object):
|
||||||
@dbus.service.method("org.ofono.PositioningRequestAgent",
|
@dbus.service.method(AGENT_INTERFACE,
|
||||||
in_signature="", out_signature="")
|
in_signature="", out_signature="")
|
||||||
def Release(self):
|
def Release(self):
|
||||||
print "Release"
|
print "Release"
|
||||||
mainloop.quit()
|
mainloop.quit()
|
||||||
|
|
||||||
@dbus.service.method("org.ofono.PositioningRequestAgent",
|
@dbus.service.method(AGENT_INTERFACE,
|
||||||
in_signature="s", out_signature="")
|
in_signature="s", out_signature="")
|
||||||
def Request(self, xml):
|
def Request(self, xml):
|
||||||
print "positioning data: %s" % (xml)
|
print "positioning data: %s" % (xml)
|
||||||
|
|
||||||
@dbus.service.method("org.ofono.PositioningRequestAgent",
|
@dbus.service.method(AGENT_INTERFACE,
|
||||||
in_signature="", out_signature="")
|
in_signature="", out_signature="")
|
||||||
def ResetAssistanceData(self):
|
def ResetAssistanceData(self):
|
||||||
print "Reset Assistance Data request received"
|
print "Reset Assistance Data request received"
|
||||||
|
@ -34,27 +37,26 @@ def print_menu():
|
||||||
print "[x] Exit"
|
print "[x] Exit"
|
||||||
print "-----------------------------------------------------------"
|
print "-----------------------------------------------------------"
|
||||||
|
|
||||||
def stdin_handler(fd, condition, positioning, path):
|
def stdin_handler(fd, condition, gnss, path):
|
||||||
|
|
||||||
in_key = os.read(fd.fileno(), 8).rstrip()
|
in_key = os.read(fd.fileno(), 8).rstrip()
|
||||||
if in_key == '0':
|
if in_key == '0':
|
||||||
xml = raw_input('type the element and press enter: ')
|
xml = raw_input('type the element and press enter: ')
|
||||||
try:
|
try:
|
||||||
positioning.SendPositioningElement(dbus.String(xml))
|
gnss.SendPositioningElement(dbus.String(xml))
|
||||||
print "ok"
|
print "ok"
|
||||||
except dbus.DBusException, e:
|
except dbus.DBusException, e:
|
||||||
print "Unable to send positioning element"
|
print "Unable to send positioning element"
|
||||||
|
|
||||||
elif in_key == '1':
|
elif in_key == '1':
|
||||||
try:
|
try:
|
||||||
positioning.RegisterPositioningRequestAgent("/test/posagent")
|
gnss.RegisterPositioningRequestAgent("/test/posagent")
|
||||||
print "ok"
|
print "ok"
|
||||||
except dbus.DBusException, e:
|
except dbus.DBusException, e:
|
||||||
print "Unable to register positioning agent"
|
print "Unable to register positioning agent"
|
||||||
|
|
||||||
elif in_key == '2':
|
elif in_key == '2':
|
||||||
try:
|
try:
|
||||||
positioning.UnregisterPositioningRequestAgent(path)
|
gnss.UnregisterPositioningRequestAgent(path)
|
||||||
print "ok"
|
print "ok"
|
||||||
except dbus.DBusException, e:
|
except dbus.DBusException, e:
|
||||||
print "Unable to unregister positioning agent"
|
print "Unable to unregister positioning agent"
|
||||||
|
@ -64,7 +66,6 @@ def stdin_handler(fd, condition, positioning, path):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
if len(sys.argv) < 1:
|
if len(sys.argv) < 1:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -75,17 +76,18 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
modems = manager.GetModems()
|
modems = manager.GetModems()
|
||||||
for path, properties in modems:
|
for path, properties in modems:
|
||||||
if "org.ofono.AssistedSatelliteNavigation" not in properties["Interfaces"]:
|
if GNSS_INTERFACE not in properties["Interfaces"]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
positioning = dbus.Interface(bus.get_object('org.ofono', path),
|
gnss = dbus.Interface(bus.get_object('org.ofono', path),
|
||||||
'org.ofono.AssistedSatelliteNavigation')
|
GNSS_INTERFACE)
|
||||||
|
|
||||||
path = "/test/posagent"
|
path = "/test/posagent"
|
||||||
agent = PositioningAgent(bus, path)
|
agent = PositioningAgent(bus, path)
|
||||||
|
|
||||||
print_menu()
|
print_menu()
|
||||||
|
|
||||||
gobject.io_add_watch(sys.stdin, gobject.IO_IN, stdin_handler, positioning, path)
|
gobject.io_add_watch(sys.stdin, gobject.IO_IN, stdin_handler,
|
||||||
|
gnss, path)
|
||||||
mainloop = gobject.MainLoop()
|
mainloop = gobject.MainLoop()
|
||||||
mainloop.run()
|
mainloop.run()
|
||||||
|
|
Loading…
Reference in New Issue