summaryrefslogtreecommitdiff
path: root/test/test-device
diff options
context:
space:
mode:
authorMikel Astiz <mikel.astiz@bmw-carit.de>2012-12-05 13:51:39 +0100
committerJohan Hedberg <johan.hedberg@intel.com>2012-12-05 16:41:02 +0200
commit67dab2d2aeec9ab895da6afd528ec0c63e657ff4 (patch)
treea9efa382603f2635d9a1a9c689d917e940104809 /test/test-device
parent36128655eb69519ff6eb4b896a507249bb8a9c9d (diff)
downloadbluez-67dab2d2aeec9ab895da6afd528ec0c63e657ff4.tar.gz
test: Avoid using Adapter.FindDevice()
The method is now deprecated and thus the replacement utility library should be used in the test scripts.
Diffstat (limited to 'test/test-device')
-rwxr-xr-xtest/test-device57
1 files changed, 31 insertions, 26 deletions
diff --git a/test/test-device b/test/test-device
index f4a40c422..d40d65642 100755
--- a/test/test-device
+++ b/test/test-device
@@ -23,10 +23,6 @@ parser = OptionParser(option_list=option_list)
(options, args) = parser.parse_args()
-adapter = bluezutils.find_adapter(options.dev_id)
-
-adapter_path = adapter.object_path
-
if (len(args) < 1):
print("Usage: %s <command>" % (sys.argv[0]))
print("")
@@ -45,6 +41,9 @@ if (len(args) < 1):
sys.exit(1)
if (args[0] == "list"):
+ adapter = bluezutils.find_adapter(options.dev_id)
+ adapter_path = adapter.object_path
+
om = dbus.Interface(bus.get_object("org.bluez", "/"),
"org.freedesktop.DBus.ObjectManager")
objects = om.GetManagedObjects()
@@ -73,6 +72,7 @@ if (args[0] == "create"):
if (len(args) < 2):
print("Need address parameter")
else:
+ adapter = bluezutils.find_adapter(options.dev_id)
adapter.CreateDevice(args[1],
reply_handler=create_device_reply,
error_handler=create_device_error)
@@ -82,8 +82,14 @@ if (args[0] == "remove"):
if (len(args) < 2):
print("Need address or object path parameter")
else:
+ managed_objects = bluezutils.get_managed_objects()
+ adapter = bluezutils.find_adapter_in_objects(managed_objects,
+ options.dev_id)
try:
- path = adapter.FindDevice(args[1])
+ dev = bluezutils.find_device_in_objects(managed_objects,
+ args[1],
+ options.dev_id)
+ path = dev.object_path
except:
path = args[1]
adapter.RemoveDevice(path)
@@ -93,9 +99,7 @@ if (args[0] == "connect"):
if (len(args) < 2):
print("Need address parameter")
else:
- path = adapter.FindDevice(args[1])
- device = dbus.Interface(bus.get_object("org.bluez", path),
- "org.bluez.Device")
+ device = bluezutils.find_device(args[1], options.dev_id)
if (len(args) > 2):
device.ConnectProfile(args[2])
else:
@@ -106,9 +110,7 @@ if (args[0] == "disconnect"):
if (len(args) < 2):
print("Need address parameter")
else:
- path = adapter.FindDevice(args[1])
- device = dbus.Interface(bus.get_object("org.bluez", path),
- "org.bluez.Device")
+ device = bluezutils.find_device(args[1], options.dev_id)
if (len(args) > 2):
device.DisconnectProfile(args[2])
else:
@@ -119,9 +121,7 @@ if (args[0] == "discover"):
if (len(args) < 2):
print("Need address parameter")
else:
- path = adapter.FindDevice(args[1])
- device = dbus.Interface(bus.get_object("org.bluez", path),
- "org.bluez.Device")
+ device = bluezutils.find_device(args[1], options.dev_id)
if (len(args) < 3):
pattern = ""
else:
@@ -139,7 +139,7 @@ if (args[0] == "class"):
if (len(args) < 2):
print("Need address parameter")
else:
- path = adapter.FindDevice(args[1])
+ device = bluezutils.find_device(args[1], options.dev_id)
device = dbus.Interface(bus.get_object("org.bluez", path),
"org.freedesktop.DBus.Properties")
cls = device.Get("org.bluez.Device", "Class")
@@ -150,10 +150,11 @@ if (args[0] == "name"):
if (len(args) < 2):
print("Need address parameter")
else:
- path = adapter.FindDevice(args[1])
- device = dbus.Interface(bus.get_object("org.bluez", path),
+ device = bluezutils.find_device(args[1], options.dev_id)
+ path = device.object_path
+ props = dbus.Interface(bus.get_object("org.bluez", path),
"org.freedesktop.DBus.Properties")
- name = device.Get("org.bluez.Device", "Name")
+ name = props.Get("org.bluez.Device", "Name")
print(name)
sys.exit(0)
@@ -161,8 +162,9 @@ if (args[0] == "alias"):
if (len(args) < 2):
print("Need address parameter")
else:
- path = adapter.FindDevice(args[1])
- device = dbus.Interface(bus.get_object("org.bluez", path),
+ device = bluezutils.find_device(args[1], options.dev_id)
+ path = device.object_path
+ props = dbus.Interface(bus.get_object("org.bluez", path),
"org.freedesktop.DBus.Properties")
if (len(args) < 3):
alias = device.Get("org.bluez.Device", "Alias")
@@ -175,8 +177,9 @@ if (args[0] == "trusted"):
if (len(args) < 2):
print("Need address parameter")
else:
- path = adapter.FindDevice(args[1])
- device = dbus.Interface(bus.get_object("org.bluez", path),
+ device = bluezutils.find_device(args[1], options.dev_id)
+ path = device.object_path
+ props = dbus.Interface(bus.get_object("org.bluez", path),
"org.freedesktop.DBus.Properties")
if (len(args) < 3):
trusted = device.Get("org.bluez.Device", "Trusted")
@@ -195,8 +198,9 @@ if (args[0] == "blocked"):
if (len(args) < 2):
print("Need address parameter")
else:
- path = adapter.FindDevice(args[1])
- device = dbus.Interface(bus.get_object("org.bluez", path),
+ device = bluezutils.find_device(args[1], options.dev_id)
+ path = device.object_path
+ props = dbus.Interface(bus.get_object("org.bluez", path),
"org.freedesktop.DBus.Properties")
if (len(args) < 3):
blocked = device.Get("org.bluez.Device", "Blocked")
@@ -215,8 +219,9 @@ if (args[0] == "services"):
if (len(args) < 2):
print("Need address parameter")
else:
- path = adapter.FindDevice(args[1])
- device = dbus.Interface(bus.get_object("org.bluez", path),
+ device = bluezutils.find_device(args[1], options.dev_id)
+ path = device.object_path
+ props = dbus.Interface(bus.get_object("org.bluez", path),
"org.freedesktop.DBus.Properties")
services = device.Get("org.bluez.Device", "Services")
for path in services: