diff --git a/bluez/simple-agent b/bluez/simple-agent index 4ed3cf0f09915cedc7bd13d0b6b6de435bda1a33..8c3ee3d8d636b46709c025e47369ca00c092bc4a 100755 --- a/bluez/simple-agent +++ b/bluez/simple-agent @@ -58,6 +58,29 @@ if __name__ == '__main__': mainloop.quit() bus = dbus.SystemBus() + + connman_bt_tech = dbus.Interface( + bus.get_object("net.connman", "/net/connman/technology/bluetooth"), + "net.connman.Technology") + + def property_changed(name, value): + if name == "Powered" and value: + print("Bluetooth powered on") + mainloop.quit() + + # Enable the connman bluetooth technology so that connman removes its + # rfkill on the bluetooth adaptors + match = connman_bt_tech.connect_to_signal("PropertyChanged", + property_changed) + try: + connman_bt_tech.SetProperty("Powered", True) + mainloop.run() + except dbus.DBusException as e: + if e.get_dbus_name() != "net.connman.Error.AlreadyEnabled": + raise(e) + finally: + match.remove() + manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.freedesktop.DBus.ObjectManager") agent_manager_iface = dbus.Interface(bus.get_object('org.bluez',