From: "Brad Midgley" <bmidgley@gmail.com>
To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>
Subject: python examples for keyboard connection
Date: Sun, 21 Dec 2008 22:20:02 -0700 [thread overview]
Message-ID: <d89ddf300812212120n31776bc9m9fc26790287f4d99@mail.gmail.com> (raw)
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
next reply other threads:[~2008-12-22 5:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-22 5:20 Brad Midgley [this message]
2008-12-23 23:11 ` python examples for keyboard connection Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d89ddf300812212120n31776bc9m9fc26790287f4d99@mail.gmail.com \
--to=bmidgley@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox