public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* python examples for keyboard connection
@ 2008-12-22  5:20 Brad Midgley
  2008-12-23 23:11 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Brad Midgley @ 2008-12-22  5:20 UTC (permalink / raw)
  To: linux-bluetooth@vger.kernel.org

Hey

I'm working on gumstix overo/oe so the regular gnome stuff is not
available. This system is running bluez 3.36. I can work on updating
to 4.x if it helps.

I was able to use this simple script to connect a mouse by specifying
its bdaddr on the command line. (Device-initiated reconnect does not
seem to work, but this succeeded on the first attempt anyway)

==================================
#!/usr/bin/python

import sys
import dbus

devices = sys.argv
del devices[0]

bus = dbus.SystemBus()
bmgr = dbus.Interface(bus.get_object('org.bluez', '/org/bluez'),
'org.bluez.Manager')
bus_id = bmgr.ActivateService('input')
imgr = dbus.Interface(bus.get_object(bus_id, '/org/bluez/input'),
'org.bluez.input.Manager')

for device in devices:
        path = imgr.CreateDevice(device)
        idev = dbus.Interface (bus.get_object(bus_id, path),
'org.bluez.input.Device')
        idev.Connect()
==================================

but it doesn't work for connecting a think outside keyboard:

root@overo:~# ./pairconnect.py 00:03:51:C9:EA:53
Traceback (most recent call last):
  File "./pairconnect.py", line 19, in <module>
    idev.Connect()
  File "/usr/lib/python2.5/site-packages/dbus/proxies.py", line 68, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib/python2.5/site-packages/dbus/proxies.py", line 140, in __call__
    **keywords)
  File "/usr/lib/python2.5/site-packages/dbus/connection.py", line
622, in call_blocking
    message, timeout)
dbus.exceptions.DBusException:
org.bluez.Error.ConnectionAttemptFailed: Required key not available

also, what should I do to look up a device first so I don't get this
on subsequent attempts:

dbus.exceptions.DBusException: org.bluez.Error.AlreadyExists: Input
Already exists

I'll document whatever works out on the wiki.

-- 
Brad Midgley

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-12-23 23:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-22  5:20 python examples for keyboard connection Brad Midgley
2008-12-23 23:11 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox