bluez4: simplify bbappend
The bbappend was created mostly to install an old version of the 'simple-agent' test application (the one included in the package was failing) but upstream (Poky) has fixed most of the issues, so our bbappend is just needed now to enable 'health' profile support. Signed-off-by: Javier Viguera <javier.viguera@digi.com>
This commit is contained in:
parent
99b153e30b
commit
f18590fc62
|
|
@ -0,0 +1,3 @@
|
|||
# Copyright (C) 2013 Digi International.
|
||||
|
||||
EXTRA_OECONF_append = " --enable-health"
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
# Copyright (C) 2013 Digi International.
|
||||
|
||||
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
|
||||
|
||||
# Use 'simple-agent' from bluez-4.98 to avoid a dependence in
|
||||
# gobject-introspection
|
||||
SRC_URI += "file://simple-agent"
|
||||
|
||||
# 'simple-agent' needs some python packages
|
||||
RDEPENDS_${PN} = "python-dbus python-pygobject"
|
||||
|
||||
EXTRA_OECONF_append = " --enable-health"
|
||||
|
||||
do_install_append() {
|
||||
install -m 0755 ${WORKDIR}/simple-agent ${D}${bindir}
|
||||
}
|
||||
|
|
@ -1,130 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import gobject
|
||||
|
||||
import sys
|
||||
import dbus
|
||||
import dbus.service
|
||||
import dbus.mainloop.glib
|
||||
from optparse import OptionParser
|
||||
|
||||
class Rejected(dbus.DBusException):
|
||||
_dbus_error_name = "org.bluez.Error.Rejected"
|
||||
|
||||
class Agent(dbus.service.Object):
|
||||
exit_on_release = True
|
||||
|
||||
def set_exit_on_release(self, exit_on_release):
|
||||
self.exit_on_release = exit_on_release
|
||||
|
||||
@dbus.service.method("org.bluez.Agent",
|
||||
in_signature="", out_signature="")
|
||||
def Release(self):
|
||||
print "Release"
|
||||
if self.exit_on_release:
|
||||
mainloop.quit()
|
||||
|
||||
@dbus.service.method("org.bluez.Agent",
|
||||
in_signature="os", out_signature="")
|
||||
def Authorize(self, device, uuid):
|
||||
print "Authorize (%s, %s)" % (device, uuid)
|
||||
authorize = raw_input("Authorize connection (yes/no): ")
|
||||
if (authorize == "yes"):
|
||||
return
|
||||
raise Rejected("Connection rejected by user")
|
||||
|
||||
@dbus.service.method("org.bluez.Agent",
|
||||
in_signature="o", out_signature="s")
|
||||
def RequestPinCode(self, device):
|
||||
print "RequestPinCode (%s)" % (device)
|
||||
return raw_input("Enter PIN Code: ")
|
||||
|
||||
@dbus.service.method("org.bluez.Agent",
|
||||
in_signature="o", out_signature="u")
|
||||
def RequestPasskey(self, device):
|
||||
print "RequestPasskey (%s)" % (device)
|
||||
passkey = raw_input("Enter passkey: ")
|
||||
return dbus.UInt32(passkey)
|
||||
|
||||
@dbus.service.method("org.bluez.Agent",
|
||||
in_signature="ou", out_signature="")
|
||||
def DisplayPasskey(self, device, passkey):
|
||||
print "DisplayPasskey (%s, %d)" % (device, passkey)
|
||||
|
||||
@dbus.service.method("org.bluez.Agent",
|
||||
in_signature="ou", out_signature="")
|
||||
def RequestConfirmation(self, device, passkey):
|
||||
print "RequestConfirmation (%s, %d)" % (device, passkey)
|
||||
confirm = raw_input("Confirm passkey (yes/no): ")
|
||||
if (confirm == "yes"):
|
||||
return
|
||||
raise Rejected("Passkey doesn't match")
|
||||
|
||||
@dbus.service.method("org.bluez.Agent",
|
||||
in_signature="s", out_signature="")
|
||||
def ConfirmModeChange(self, mode):
|
||||
print "ConfirmModeChange (%s)" % (mode)
|
||||
authorize = raw_input("Authorize mode change (yes/no): ")
|
||||
if (authorize == "yes"):
|
||||
return
|
||||
raise Rejected("Mode change by user")
|
||||
|
||||
@dbus.service.method("org.bluez.Agent",
|
||||
in_signature="", out_signature="")
|
||||
def Cancel(self):
|
||||
print "Cancel"
|
||||
|
||||
def create_device_reply(device):
|
||||
print "New device (%s)" % (device)
|
||||
mainloop.quit()
|
||||
|
||||
def create_device_error(error):
|
||||
print "Creating device failed: %s" % (error)
|
||||
mainloop.quit()
|
||||
|
||||
if __name__ == '__main__':
|
||||
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
||||
|
||||
bus = dbus.SystemBus()
|
||||
manager = dbus.Interface(bus.get_object("org.bluez", "/"),
|
||||
"org.bluez.Manager")
|
||||
|
||||
capability = "DisplayYesNo"
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option("-c", "--capability", action="store",
|
||||
type="string", dest="capability")
|
||||
(options, args) = parser.parse_args()
|
||||
if options.capability:
|
||||
capability = options.capability
|
||||
|
||||
if len(args) > 0:
|
||||
path = manager.FindAdapter(args[0])
|
||||
else:
|
||||
path = manager.DefaultAdapter()
|
||||
|
||||
adapter = dbus.Interface(bus.get_object("org.bluez", path),
|
||||
"org.bluez.Adapter")
|
||||
|
||||
path = "/test/agent"
|
||||
agent = Agent(bus, path)
|
||||
|
||||
mainloop = gobject.MainLoop()
|
||||
|
||||
if len(args) > 1:
|
||||
if len(args) > 2:
|
||||
device = adapter.FindDevice(args[1])
|
||||
adapter.RemoveDevice(device)
|
||||
|
||||
agent.set_exit_on_release(False)
|
||||
adapter.CreatePairedDevice(args[1], path, capability,
|
||||
reply_handler=create_device_reply,
|
||||
error_handler=create_device_error)
|
||||
else:
|
||||
adapter.RegisterAgent(path, capability)
|
||||
print "Agent registered"
|
||||
|
||||
mainloop.run()
|
||||
|
||||
#adapter.UnregisterAgent(path)
|
||||
#print "Agent unregistered"
|
||||
|
|
@ -13,4 +13,5 @@ inherit packagegroup
|
|||
RDEPENDS_${PN} = "\
|
||||
btfilter \
|
||||
bluez4 \
|
||||
bluez4-testtools \
|
||||
"
|
||||
|
|
|
|||
Loading…
Reference in New Issue