3 from __future__ import absolute_import, print_function, unicode_literals
5 from optparse import OptionParser, make_option
11 bus = dbus.SystemBus()
13 manager = dbus.Interface(bus.get_object("org.bluez", "/"),
17 make_option("-i", "--device", action="store",
18 type="string", dest="dev_id"),
20 parser = OptionParser(option_list=option_list)
22 (options, args) = parser.parse_args()
25 print("Usage: %s <address> [service]" % (sys.argv[0]))
28 # Fix-up in case of "connect" invocation that other scripts use
29 if args[0] == "connect":
37 device = bluezutils.find_device(args[0], options.dev_id)
39 network = dbus.Interface(bus.get_object("org.bluez", device.object_path),
42 iface = network.Connect(service)
44 print("Connected to %s service %s, interface %s" % (args[0], service, iface))
46 print("Press CTRL-C to disconnect")
50 print("Terminating connection")