Add exception handling to some service method calls
[connman] / test / start-scanning
index 104a55b..cf36477 100755 (executable)
@@ -7,25 +7,19 @@ bus = dbus.SystemBus()
 manager = dbus.Interface(bus.get_object('org.moblin.connman', "/"),
                                        'org.moblin.connman.Manager')
 
-elements = manager.ListElements()
+properties = manager.GetProperties()
 
-for path in elements:
-       element = dbus.Interface(bus.get_object('org.moblin.connman', path),
-                                               'org.moblin.connman.Element')
+for path in properties["Devices"]:
+       device = dbus.Interface(bus.get_object('org.moblin.connman', path),
+                                               'org.moblin.connman.Device')
 
-       properties = element.GetProperties()
-
-       if (properties["Type"] != "device"):
-               continue
+       properties = device.GetProperties()
 
        print "[ %s ]" % (path)
 
-       if (properties["Subtype"] == "wifi"):
-               print "   Started WiFi scanning"
-               element.Update()
-       elif (properties["Subtype"] == "wimax")
-               print "   Started WiMAX scanning"
-               element.Update()
+       if properties["Type"] in ["wifi", "wimax"]:
+               print "   Started scanning"
+               device.ProposeScan()
        else:
                print "   No scanning"