aboutsummaryrefslogtreecommitdiffstats
path: root/examples/dbus/test_bt_list_handles.py
blob: 6b514bf3db1f37a05721dab3f5d787e5ad03ab68 (plain) (blame)
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
#!/usr/bin/env python

import sys
import dbus
from efl import dbus_mainloop
from efl import ecore


def print_remote_handles(adapter, bdaddr):
    handles = [hex(int(h)) \
               for h in list(adapter.GetRemoteServiceHandles(bdaddr, ""))]
    print "Handles:", handles
    ecore.idler_add(ecore.main_loop_quit)
    return False


if len(sys.argv) != 2:
    print "USAGE: %s <bdaddr>" % sys.argv[0]
    sys.exit(1)

dbus_ml = dbus_mainloop.DBusEcoreMainLoop()
bus = dbus.SystemBus(mainloop=dbus_ml)

obj = bus.get_object("org.bluez", "/org/bluez/hci0")
adapter = dbus.Interface(obj, "org.bluez.Adapter")

ecore.idler_add(print_remote_handles, adapter, sys.argv[1])
ecore.main_loop_begin()