python examples for keyboard connection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux