diff options
Diffstat (limited to 'recipes-connectivity/bluez')
18 files changed, 0 insertions, 1759 deletions
diff --git a/recipes-connectivity/bluez/bluez5.inc b/recipes-connectivity/bluez/bluez5.inc deleted file mode 100644 index 35ebd0c..0000000 --- a/recipes-connectivity/bluez/bluez5.inc +++ /dev/null @@ -1,159 +0,0 @@ -SUMMARY = "Linux Bluetooth Stack Userland V5" -PR = "m4" -DESCRIPTION = "Linux Bluetooth stack V5 userland components. These include a system configurations, daemons, tools and system libraries." -HOMEPAGE = "http://www.bluez.org" -SECTION = "libs" -LICENSE = "GPLv2+ & LGPLv2.1+" -LIC_FILES_CHKSUM = "file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e \ - file://COPYING.LIB;md5=fb504b67c50331fc78734fed90fb0e09 \ - file://src/main.c;beginline=1;endline=24;md5=9bc54b93cd7e17bf03f52513f39f926e" -DEPENDS = "udev libusb dbus-glib glib-2.0 libcheck readline" -RDEPENDS_${PN}-pand += "bash python-dbus python-logging python-syslog python-subprocess python-argparse" -RDEPENDS_${PN}-rfcomm += "bash python-pygobject python-syslog python-logging python-dbus" -PROVIDES += "bluez-hcidump" -RPROVIDES_${PN} += "bluez-hcidump" - -RCONFLICTS_${PN} = "bluez4" - -PACKAGECONFIG ??= "obex-profiles" -PACKAGECONFIG[obex-profiles] = "--enable-obex,--disable-obex,libical" -PACKAGECONFIG[experimental] = "--enable-experimental,--enable-experimental" - -SRC_URI = "\ - ${KERNELORG_MIRROR}/linux/bluetooth/bluez-${PV}.tar.xz \ - file://out-of-tree.patch \ - file://init \ - file://run-ptest \ - ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '', 'file://0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch', d)} \ - file://0001-tests-add-a-target-for-building-tests-without-runnin.patch \ - file://default \ - file://main.conf \ - file://bt-pan/init \ - file://bt-pan/default \ - file://bt-pan/bt-pan \ - file://rfcomm/rfcomm.py \ - file://rfcomm/init \ - file://rfcomm/default \ -" -S = "${WORKDIR}/bluez-${PV}" - -inherit autotools pkgconfig systemd update-rc.d distro_features_check ptest - -EXTRA_OECONF = "\ - --enable-tools \ - --disable-cups \ - --enable-test \ - --enable-datafiles \ - ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '--enable-systemd', '--disable-systemd', d)} \ - --enable-library \ - --enable-deprecated \ - --enable-experimental \ -" - -# bluez5 builds a large number of useful utilities but does not -# install them. Specify which ones we want put into ${PN}-noinst-tools. -NOINST_TOOLS_READLINE ??= "" -NOINST_TOOLS_EXPERIMENTAL ??= "" -NOINST_TOOLS = " \ - ${NOINST_TOOLS_READLINE} \ - ${@bb.utils.contains('PACKAGECONFIG', 'experimental', '${NOINST_TOOLS_EXPERIMENTAL}', '', d)} \ -" - -DBTEXEC = "${D}${libexecdir}/bluetooth/" - -do_install_append() { - install -d ${D}${INIT_D_DIR} - install -m 0755 ${WORKDIR}/init ${D}${INIT_D_DIR}/bluetooth - install -m 0755 ${WORKDIR}/bt-pan/init ${D}${INIT_D_DIR}/bt-pan - install -m 0755 ${WORKDIR}/rfcomm/init ${D}${INIT_D_DIR}/rfcomm - install -d ${DBTEXEC} - install -m 0755 ${WORKDIR}/bt-pan/bt-pan ${DBTEXEC} - install -m 0755 ${WORKDIR}/rfcomm/rfcomm.py ${DBTEXEC}/rfcomm - - install -d ${D}${sysconfdir}/bluetooth/ - if [ -f ${S}/profiles/audio/audio.conf ]; then - install -m 0644 ${S}/profiles/audio/audio.conf ${D}/${sysconfdir}/bluetooth/ - fi - if [ -f ${S}/profiles/network/network.conf ]; then - install -m 0644 ${S}/profiles/network/network.conf ${D}/${sysconfdir}/bluetooth/ - fi - if [ -f ${S}/profiles/input/input.conf ]; then - install -m 0644 ${S}/profiles/input/input.conf ${D}/${sysconfdir}/bluetooth/ - fi - - if [ -f ${D}/${sysconfdir}/init.d/bluetooth ]; then - sed -i -e 's#@LIBEXECDIR@#${libexecdir}#g' ${D}/${sysconfdir}/init.d/bluetooth - fi - - # Install desired tools that upstream leaves in build area - for f in ${NOINST_TOOLS} ; do - install -m 755 ${B}/$f ${D}/${bindir} - done - - # Patch python tools to use Python 3; they should be source compatible, but - # still refer to Python 2 in the shebang - sed -i -e '1s,#!.*python.*,#!${bindir}/python3,' ${D}${libdir}/bluez/test/* - - install -d ${D}${sysconfdir}/default - install -m 0644 ${WORKDIR}/default ${D}${sysconfdir}/default/bluetooth - install -m 0644 ${WORKDIR}/bt-pan/default ${D}${sysconfdir}/default/bt-pan - install -m 0644 ${WORKDIR}/rfcomm/default ${D}${sysconfdir}/default/rfcomm - install -m 0644 ${WORKDIR}/main.conf ${D}${sysconfdir}/bluetooth/ -} - -ALLOW_EMPTY_libasound-module-bluez = "1" -PACKAGES =+ "libasound-module-bluez ${PN}-testtools ${PN}-obex ${PN}-noinst-tools ${PN}-pand ${PN}-rfcomm" - -FILES_libasound-module-bluez = "${libdir}/alsa-lib/lib*.so ${datadir}/alsa" -FILES_${PN} += "${libdir}/bluetooth/plugins/*.so ${systemd_unitdir}/ ${datadir}/dbus-1" -CONFFILES_${PN} += "${sysconfdir}/default/bluetooth ${sysconfdir}/bluetooth/main.conf ${sysconfdir}/bluetooth/input.conf ${sysconfdir}/bluetooth/network.conf" -FILES_${PN}-dev += "\ - ${libdir}/bluetooth/plugins/*.la \ - ${libdir}/alsa-lib/*.la \ -" - -FILES_${PN}-obex = "${libexecdir}/bluetooth/obexd \ - ${exec_prefix}/lib/systemd/user/obex.service \ - ${datadir}/dbus-1/services/org.bluez.obex.service \ - " - -FILES_${PN}-pand = "${libexecdir}/bluetooth/bt-pan ${sysconfdir}/default/bt-pan ${sysconfdir}/init.d/bt-pan" -FILES_${PN}-rfcomm = "${libexecdir}/bluetooth/bt-pan ${sysconfdir}/default/bt-pan ${sysconfdir}/init.d/bt-pan" -FILES_${PN}-rfcomm = "${libexecdir}/bluetooth/rfcomm ${sysconfdir}/default/rfcomm ${sysconfdir}/init.d/rfcomm" -CONFFILES_${PN}-pand = "${sysconfdir}/default/bt-pan" -CONFFILES_${PN}-rfcomm = "${sysconfdir}/default/rfcomm" -SYSTEMD_SERVICE_${PN}-obex = "obex.service" - -FILES_${PN}-testtools = "${libdir}/bluez/test/*" - -def get_noinst_tools_paths (d, bb, tools): - s = list() - bindir = d.getVar("bindir", True) - for bdp in tools.split(): - f = os.path.basename(bdp) - s.append("%s/%s" % (bindir, f)) - return "\n".join(s) - -FILES_${PN}-noinst-tools = "${@get_noinst_tools_paths(d, bb, d.getVar('NOINST_TOOLS', True))}" - -RDEPENDS_${PN}-testtools += "python3 python3-dbus python3-pygobject" - -SYSTEMD_SERVICE_${PN} = "bluetooth.service" -INITSCRIPT_PACKAGES = "${PN} ${PN}-pand ${PN}-rfcomm" -INITSCRIPT_NAME_${PN} = "bluetooth" -INITSCRIPT_NAME_${PN}-pand = "bt-pan" -INITSCRIPT_NAME_${PN}-rfcomm = "rfcomm" -INITSCRIPT_PARAMS_${PN} = "defaults 20 20" -INITSCRIPT_PARAMS_${PN}-pand = "defaults 22 22" -INITSCRIPT_PARAMS_${PN}-rfcomm = "defaults 22 22" - -EXCLUDE_FROM_WORLD = "1" - -do_compile_ptest() { - oe_runmake buildtests -} - -do_install_ptest() { - cp -r ${B}/unit/ ${D}${PTEST_PATH} - rm -f ${D}${PTEST_PATH}/unit/*.o -} diff --git a/recipes-connectivity/bluez/bluez5/0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch b/recipes-connectivity/bluez/bluez5/0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch deleted file mode 100644 index 2fde7bc..0000000 --- a/recipes-connectivity/bluez/bluez5/0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch +++ /dev/null @@ -1,63 +0,0 @@ -From: Giovanni Campagna <gcampagna-cNUdlRotFMnNLxjTenLetw@public.gmane.org> -Date: Sat, 12 Oct 2013 17:45:25 +0200 -Subject: [PATCH] Allow using obexd without systemd in the user session - -Not all sessions run systemd --user (actually, the majority -doesn't), so the dbus daemon must be able to spawn obexd -directly, and to do so it needs the full path of the daemon. - -Upstream-Status: Denied - -Not accepted by upstream maintainer for being a distro specific -configuration. See thread: - -http://thread.gmane.org/gmane.linux.bluez.kernel/38725/focus=38843 - -Signed-off-by: Javier Viguera <javier.viguera@digi.com> ---- - Makefile.obexd | 4 ++-- - obexd/src/org.bluez.obex.service | 4 ---- - obexd/src/org.bluez.obex.service.in | 4 ++++ - 3 files changed, 6 insertions(+), 6 deletions(-) - delete mode 100644 obexd/src/org.bluez.obex.service - create mode 100644 obexd/src/org.bluez.obex.service.in - -diff --git a/Makefile.obexd b/Makefile.obexd -index 2e33cbc72f2b..d5d858c857b4 100644 ---- a/Makefile.obexd -+++ b/Makefile.obexd -@@ -2,12 +2,12 @@ - if SYSTEMD - systemduserunitdir = @SYSTEMD_USERUNITDIR@ - systemduserunit_DATA = obexd/src/obex.service -+endif - - dbussessionbusdir = @DBUS_SESSIONBUSDIR@ - dbussessionbus_DATA = obexd/src/org.bluez.obex.service --endif - --EXTRA_DIST += obexd/src/obex.service.in obexd/src/org.bluez.obex.service -+EXTRA_DIST += obexd/src/obex.service.in obexd/src/org.bluez.obex.service.in - - obex_plugindir = $(libdir)/obex/plugins - -diff --git a/obexd/src/org.bluez.obex.service b/obexd/src/org.bluez.obex.service -deleted file mode 100644 -index a53808884554..000000000000 ---- a/obexd/src/org.bluez.obex.service -+++ /dev/null -@@ -1,4 +0,0 @@ --[D-BUS Service] --Name=org.bluez.obex --Exec=/bin/false --SystemdService=dbus-org.bluez.obex.service -diff --git a/obexd/src/org.bluez.obex.service.in b/obexd/src/org.bluez.obex.service.in -new file mode 100644 -index 000000000000..9c815f246b77 ---- /dev/null -+++ b/obexd/src/org.bluez.obex.service.in -@@ -0,0 +1,4 @@ -+[D-BUS Service] -+Name=org.bluez.obex -+Exec=@libexecdir@/obexd -+SystemdService=dbus-org.bluez.obex.service diff --git a/recipes-connectivity/bluez/bluez5/0001-tests-add-a-target-for-building-tests-without-runnin.patch b/recipes-connectivity/bluez/bluez5/0001-tests-add-a-target-for-building-tests-without-runnin.patch deleted file mode 100644 index 24ddae6..0000000 --- a/recipes-connectivity/bluez/bluez5/0001-tests-add-a-target-for-building-tests-without-runnin.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 4bdf0f96dcaa945fd29f26d56e5b36d8c23e4c8b Mon Sep 17 00:00:00 2001 -From: Alexander Kanavin <alex.kanavin@gmail.com> -Date: Fri, 1 Apr 2016 17:07:34 +0300 -Subject: [PATCH] tests: add a target for building tests without running them - -Upstream-Status: Inappropriate [oe specific] -Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> ---- - Makefile.am | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/Makefile.am b/Makefile.am -index 1a48a71..ba3b92f 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -425,6 +425,9 @@ endif - TESTS = $(unit_tests) - AM_TESTS_ENVIRONMENT = MALLOC_CHECK_=3 MALLOC_PERTURB_=69 - -+# This allows building tests without running them -+buildtests: $(TESTS) -+ - if DBUS_RUN_SESSION - AM_TESTS_ENVIRONMENT += dbus-run-session -- - endif --- -2.8.0.rc3 - diff --git a/recipes-connectivity/bluez/bluez5/CVE-2017-1000250.patch b/recipes-connectivity/bluez/bluez5/CVE-2017-1000250.patch deleted file mode 100644 index 05359da..0000000 --- a/recipes-connectivity/bluez/bluez5/CVE-2017-1000250.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 9e009647b14e810e06626dde7f1bb9ea3c375d09 Mon Sep 17 00:00:00 2001 -From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> -Date: Wed, 13 Sep 2017 10:01:40 +0300 -Subject: sdp: Fix Out-of-bounds heap read in service_search_attr_req function - -Check if there is enough data to continue otherwise return an error. ---- - src/sdpd-request.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/sdpd-request.c b/src/sdpd-request.c -index 1eefdce..318d044 100644 ---- a/src/sdpd-request.c -+++ b/src/sdpd-request.c -@@ -917,7 +917,7 @@ static int service_search_attr_req(sdp_req_t *req, sdp_buf_t *buf) - } else { - /* continuation State exists -> get from cache */ - sdp_buf_t *pCache = sdp_get_cached_rsp(cstate); -- if (pCache) { -+ if (pCache && cstate->cStateValue.maxBytesSent < pCache->data_size) { - uint16_t sent = MIN(max, pCache->data_size - cstate->cStateValue.maxBytesSent); - pResponse = pCache->data; - memcpy(buf->data, pResponse + cstate->cStateValue.maxBytesSent, sent); --- -cgit v1.1 - diff --git a/recipes-connectivity/bluez/bluez5/bt-pan/bt-pan b/recipes-connectivity/bluez/bluez5/bt-pan/bt-pan deleted file mode 100755 index f142bb1..0000000 --- a/recipes-connectivity/bluez/bluez5/bt-pan/bt-pan +++ /dev/null @@ -1,422 +0,0 @@ -#!/usr/bin/env python2 -from __future__ import absolute_import, print_function - -import os, sys, time, types, subprocess, signal - -import dbus -import logging -import logging.handlers - -# cgitb is in python-misc and requires python-pkgutil and python-pydoc -# It is very usefull for analyzing exceptions. -# import cgitb - -# who am i -myscript = os.path.basename(__file__) - -# Log formating class -class flog: - # priority strings to be used - # with the __init__ function - priorities = { - 'debug': logging.DEBUG, - 'info': logging.INFO, - 'warn': logging.WARNING, - 'warning': logging.WARNING, - 'error': logging.ERROR, - 'critical': logging.CRITICAL, - } - - def __init__(self,myscript,facility,priority): - """ - Initialize for logging - - :param myscript: The name of the python program script - :param facility: The syslog facility, such as daemon or user - :param priority: The minimum priority to be printed to the log - :returns: Nothing - :raises TBD: logging class errors. - """ - name_len = str(len(myscript)) - self.myscript = myscript - self.log = logging.getLogger(myscript) - self.handler = logging.handlers.SysLogHandler(address=('/dev/log'),facility=facility) - self.default_fmt = ' %(levelname)-9s %(name)-' + name_len + 's %(message)s' - self.verbose_fmt1 = ' %(levelname)-9s %(name)-' + name_len + 's %(threadName)-14s ' - self.verbose_fmt2 = ' %(message)s' - formatter = logging.Formatter(self.default_fmt) - self.handler.setFormatter(formatter) - self.log.setLevel(self.priorities[priority]) # Minimum infolevel to log - self.log.addHandler(self.handler) - self.handler.createLock() - - def __default(self,func,*args): - self.handler.acquire() - formatter = logging.Formatter(self.default_fmt) - self.handler.setFormatter(formatter) - func(*args) - self.handler.release() - - def setThreshold(self,threshold): - """ - Change the syslog priority threshold - - :param priority: Character string corresponding to the threshold - """ - self.handler.acquire() - self.log.setLevel(self.priorities[threshold]) # Minimum infolevel to log - self.handler.release() - - def critical(self,*args): - """ - Prints a variable argument list at critical priority - - :returns: logging result - """ - self.__default(self.log.critical,*args) - - def error(self,*args): - """ - Prints a variable argument list at error priority - - :returns: logging result - """ - self.__default(self.log.error,*args) - - def warning(self,*args): - """ - Prints a variable argument list at warning priority - - :returns: logging result - """ - self.__default(self.log.warning,*args) - - # Python has no notice level! - - def info(self,*args): - """ - Prints a variable argument list at info priority - - :returns: logging result - """ - self.__default(self.log.info,*args) - - def debug(self,*args): - """ - Prints a variable argument list at debug priority - - Printing debug includes function name and line - number. - - :returns: logging result - """ - caller_frame = sys._getframe().f_back - callerfunc = caller_frame.f_code.co_name + '@' + str(caller_frame.f_lineno); - callerfunc = callerfunc.ljust(16) - self.handler.acquire() - log = logging.getLogger(self.myscript) - formatter = logging.Formatter(self.verbose_fmt1+callerfunc+self.verbose_fmt2) - self.handler.setFormatter(formatter) - log.debug(*args) - self.handler.release() - -# End of log handler - -### ~bluezutils.py - -iface_base = 'org.bluez' -iface_dev = '{}.Device1'.format(iface_base) -iface_adapter = '{}.Adapter1'.format(iface_base) -iface_props = 'org.freedesktop.DBus.Properties' -global lg - -# Will this write to syslog????? -class BTError(Exception): pass - -def get_bus(): - bus = getattr(get_bus, 'cached_obj', None) - if not bus: bus = get_bus.cached_obj = dbus.SystemBus() - return bus - -def get_manager(): - manager = getattr(get_manager, 'cached_obj', None) - if not manager: - try: - manager = get_manager.cached_obj = dbus.Interface( - get_bus().get_object(iface_base, '/'), - 'org.freedesktop.DBus.ObjectManager' ) - except dbus.exceptions.DBusException as e: - s="" - try: - s = e.__dict__["_dbus_error_name"] - except KeyError: - pass - unk = 'org.freedesktop.DBus.Error.ServiceUnknown' - cexit = 'org.freedesktop.DBus.Error.Spawn.ChildExited' - if (s == unk) or (s == cexit): - msg = 'Is bluetoothd running? Bluetooth tree missing from DBUS' - lg.error(msg) - print(msg) - exit(1) - else: - raise - return manager - -def prop_get(obj, k, iface=None): - if iface is None: iface = obj.dbus_interface - return obj.Get(iface, k, dbus_interface=iface_props) -def prop_set(obj, k, v, iface=None): - if iface is None: iface = obj.dbus_interface - return obj.Set(iface, k, v, dbus_interface=iface_props) - -msg='' -def find_adapter(pattern=None): - try: - adapter = find_adapter_in_objects(get_manager().GetManagedObjects(), pattern) - - # DBusException - # Original code: - # template = "An exception of type {0} occurred. Arguments:\n{1!r}" - # message = template.format(type(ex).__name__, ex.args) - # print message - # dbus.exceptions.DBusException: - # org.freedesktop.DBus.Error.AccessDenied: - except dbus.exceptions.DBusException as e: - s="" - try: - s = e.__dict__["_dbus_error_name"] - except KeyError: - pass - - if "org.freedesktop.DBus.Error.AccessDenied" == s: - rot="You do not have sufficient privilege to run bt-pan" - print(rot) - lg.error(rot) - exit(1) - else: - raise - return adapter - -def find_adapter_in_objects(objects, pattern=None): - bus, obj = get_bus(), None - for path, ifaces in objects.iteritems(): - adapter = ifaces.get(iface_adapter) - if adapter is None: continue - if not pattern or pattern == adapter['Address'] or path.endswith(pattern): - obj = bus.get_object(iface_base, path) - yield dbus.Interface(obj, iface_adapter) - if obj is None: - msg = 'Bluetooth adapter not found' - lg.error(msg) - raise BTError(msg) - -def find_device(device_address, adapter_pattern=None): - return find_device_in_objects(get_manager().GetManagedObjects(), device_address, adapter_pattern) - -def find_device_in_objects(objects, device_address, adapter_pattern=None): - bus = get_bus() - path_prefix = '' - if adapter_pattern: - if not isinstance(adapter_pattern, types.StringTypes): adapter = adapter_pattern - else: adapter = find_adapter_in_objects(objects, adapter_pattern) - path_prefix = adapter.object_path - for path, ifaces in objects.iteritems(): - device = ifaces.get(iface_dev) - if device is None: continue - if device['Address'] == device_address and path.startswith(path_prefix): - obj = bus.get_object(iface_base, path) - return dbus.Interface(obj, iface_dev) - msg = 'Bluetooth device not found' - lg.error(msg) - raise BTError(msg) - -pidPath = "" - -def writePidFile(device): - global pidPath - pid = str(os.getpid()) - pidPath = '/run/bt-pan.' + device + '.pid' - f = open(pidPath, 'w') - f.write(pid) - f.close() - -def hexdump(string): - return ":".join("{:02x}".format(ord(c)) for c in string) - -### bt-pan - -def main(args=None): - import argparse - global lg - - # Set up logging initially info and above - lg = flog(myscript,'daemon','info') - - # cgitb.enable(format='text') - - parser = argparse.ArgumentParser( - description='BlueZ bluetooth PAN network server/client.') - - parser.add_argument('-i', '--device', metavar='local-addr/pattern', - help='Local device address/pattern to use (if not default).') - parser.add_argument('-a', '--device-all', action='store_true', - help='Use all local hci devices, not just default one.' - ' Only valid with "server" mode, mutually exclusive with --device option.') - parser.add_argument('-u', '--uuid', - metavar='uuid_or_shortcut', default='nap', - help='Service UUID to use. Can be either full UUID' - ' or one of the shortcuts: gn, panu, nap. Default: %(default)s.') - parser.add_argument('--systemd', action='store_true', - help='Use systemd service' - ' notification/watchdog mechanisms in daemon modes, if available.') - parser.add_argument('--debug', - action='store_true', help='Verbose operation mode.') - - cmds = parser.add_subparsers( dest='call', - title='Supported operations (have their own suboptions as well)' ) - - cmd = cmds.add_parser('server', help='Run infinitely as a NAP network server.') - cmd.add_argument('iface_name', - help='Bridge interface name to which each link will be added by bluez.' - ' It must be created and configured before starting the server.') - - cmd = cmds.add_parser('client', help='Connect to a PAN network.') - cmd.add_argument('remote_addr', help='Remote device address to connect to.') - cmd.add_argument('-d', '--disconnect', action='store_true', - help='Instead of connecting (default action), disconnect' - ' (if connected) and exit. Overrides all other options for this command.') - cmd.add_argument('-w', '--wait', action='store_true', - help='Go into an endless wait-loop after connection, terminating it on exit.') - cmd.add_argument('-c', '--if-not-connected', action='store_true', - help='Dont raise error if connection is already established.') - cmd.add_argument('-r', '--reconnect', action='store_true', - help='Force reconnection if some connection is already established.') - - opts = parser.parse_args() - - if opts.debug: - lg.setThreshold('debug') - - if not opts.device_all: devs = [next(iter(find_adapter(opts.device)))] - else: - if opts.call != 'server': - parser.error('--device-all option is only valid with "server" mode.') - devs = list(find_adapter()) - devs = dict((prop_get(dev, 'Address'), dev) for dev in devs) - for dev_addr, dev in devs.viewitems(): - prop_set(dev, 'Powered', True) - lg.debug('Using local device (addr: %s): %s', dev_addr, dev.object_path) - - wait_iter_noop = 3600 - if opts.systemd: - from systemd import daemon - def wait_iter(): - if not wait_iter.sd_ready: - daemon.notify('READY=1') - daemon.notify('STATUS=Running in {} mode...'.format(opts.call)) - wait_iter.sd_ready = True - time.sleep(wait_iter.timeout) - if wait_iter.sd_wdt: daemon.notify('WATCHDOG=1') - wd_pid, wd_usec = (os.environ.get(k) for k in ['WATCHDOG_PID', 'WATCHDOG_USEC']) - if wd_pid and wd_pid.isdigit() and int(wd_pid) == os.getpid(): - wd_interval = float(wd_usec) / 2e6 # half of interval in seconds - assert wd_interval > 0, wd_interval - else: wd_interval = None - if wd_interval: - lg.debug('Initializing systemd watchdog pinger with interval: %ss', wd_interval) - wait_iter.sd_wdt, wait_iter.timeout = True, min(wd_interval, wait_iter_noop) - else: wait_iter.sd_wdt, wait_iter.timeout = False, wait_iter_noop - wait_iter.sd_ready = False - else: wait_iter = lambda: time.sleep(wait_iter_noop) - signal.signal(signal.SIGTERM, lambda sig,frm: sys.exit(0)) - - - if opts.call == 'server': - inm = opts.iface_name - brctl = subprocess.Popen( - ['brctl', 'show', inm], - stdout=open(os.devnull, 'wb'), stderr=subprocess.PIPE ) - brctl_stderr = brctl.stderr.read() - writePidFile(opts.iface_name) - if brctl.wait() or brctl_stderr: - lg.error('brctl check failed for interface (missing?): {}'.format(inm)) - lg.error('Bridge interface must be added and configured before starting server, e.g. with:') - lg.error(' brctl addbr {}'.format(inm)) - lg.error(' brctl setfd {} 0'.format(inm)) - lg.error(' brctl stp {} off'.format(inm)) - lg.error(' ip addr add 10.101.225.84/24 dev {}'.format(inm)) - lg.error(' ip link set {} up'.format(inm)) - return 1 - - servers = list() - try: - for dev_addr, dev in devs.viewitems(): - server = dbus.Interface(dev, 'org.bluez.NetworkServer1') - server.Unregister(opts.uuid) # in case already registered - server.Register(opts.uuid, opts.iface_name) - servers.append(server) - lg.debug( 'Registered uuid %r with' - ' bridge/dev: %s / %s', opts.uuid, opts.iface_name, dev_addr ) - while True: wait_iter() - except KeyboardInterrupt: pass - finally: - if servers: - for server in servers: server.Unregister(opts.uuid) - lg.debug('Unregistered server uuids') - - - elif opts.call == 'client': - dev_remote = find_device(opts.remote_addr, devs.values()[0]) - lg.debug( 'Using remote device (addr: %s): %s', - prop_get(dev_remote, 'Address'), dev_remote.object_path ) - try: dev_remote.ConnectProfile(opts.uuid) - except: pass # no idea why it fails sometimes, but still creates dbus interface - net = dbus.Interface(dev_remote, 'org.bluez.Network1') - - if opts.disconnect: - try: net.Disconnect() - except dbus.exceptions.DBusException as err: - if err.get_dbus_name() != 'org.bluez.Error.Failed': raise - connected = prop_get(net, 'Connected') - if connected: raise - lg.debug( - 'Disconnected from network' - ' (dev_remote: %s, addr: %s) uuid %r, by explicit command', - dev_remote.object_path, prop_get(dev_remote, 'Address'), opts.uuid ) - return - - for n in xrange(2): - try: iface = net.Connect(opts.uuid) - except dbus.exceptions.DBusException as err: - if err.get_dbus_name() != 'org.bluez.Error.Failed': raise - connected = prop_get(net, 'Connected') - if not connected: raise - if opts.reconnect: - lg.debug( 'Detected pre-established connection' - ' (iface: %s), reconnecting', prop_get(net, 'Interface') ) - net.Disconnect() - continue - if not opts.if_not_connected: raise - else: break - lg.debug( - 'Connected to network (dev_remote: %s, addr: %s) uuid %r with iface: %s', - dev_remote.object_path, prop_get(dev_remote, 'Address'), opts.uuid, iface ) - - if opts.wait: - try: - while True: wait_iter() - except KeyboardInterrupt: pass - finally: - net.Disconnect() - lg.debug('Disconnected from network') - - - else: raise ValueError(opts.call) - global pidPath - try: - os.remove(pidPath) - except OSError: - pass - lg.debug('Finished') - -if __name__ == '__main__': sys.exit(main()) diff --git a/recipes-connectivity/bluez/bluez5/bt-pan/default b/recipes-connectivity/bluez/bluez5/bt-pan/default deleted file mode 100755 index c960298..0000000 --- a/recipes-connectivity/bluez/bluez5/bt-pan/default +++ /dev/null @@ -1,2 +0,0 @@ -ENABLED="no" -PANOPTS="--debug" diff --git a/recipes-connectivity/bluez/bluez5/bt-pan/init b/recipes-connectivity/bluez/bluez5/bt-pan/init deleted file mode 100755 index 3f7062e..0000000 --- a/recipes-connectivity/bluez/bluez5/bt-pan/init +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -NAME=bt-pan -SERVER=/usr/libexec/bluetooth/${NAME} -PYTHON=$(readlink -f /usr/bin/python2) -BRIDGE=pan0 -DNAME="${NAME}.${BRIDGE}" -PIDFILE="/run/${DNAME}.pid" - -ENABLED=yes -[ -f /etc/default/$NAME ] && . /etc/default/$NAME - -if [ "$ENABLED" != "yes" ]; then - echo "$NAME: disabled in /etc/default" - exit -fi - -case $1 in - start) - echo "Starting ${DNAME}" - /usr/sbin/start-stop-daemon -S -p ${PIDFILE} -x ${PYTHON} -b -- ${SERVER} ${PANOPTS} server $BRIDGE - ;; - - stop) - /usr/sbin/start-stop-daemon -K -p ${PIDFILE} -x ${PYTHON} - echo "Stopping ${DNAME}" - ;; - - restart) - $0 stop - $0 start - ;; - - *) - echo "Usage: $0 {start|stop|restart}" - exit 2 - ;; -esac - - diff --git a/recipes-connectivity/bluez/bluez5/default b/recipes-connectivity/bluez/bluez5/default deleted file mode 100644 index e912922..0000000 --- a/recipes-connectivity/bluez/bluez5/default +++ /dev/null @@ -1,8 +0,0 @@ -# Set to 1 to enable bluetooth daemon -BLUETOOTH_ENABLED=0 - -# Use the following to setup bluetooth usability -BLUETOOTHCTL_CMD="power on\ndiscoverable on\npairable on\n" - -#Compatilitity mode -#MOREOPTIONS="-C" diff --git a/recipes-connectivity/bluez/bluez5/init b/recipes-connectivity/bluez/bluez5/init deleted file mode 100755 index 4d84195..0000000 --- a/recipes-connectivity/bluez/bluez5/init +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/sh - -PATH=/sbin:/bin:/usr/sbin:/usr/bin -DESC=bluetooth - -DAEMON=/usr/libexec/bluetooth/bluetoothd - -# If you want to be ignore error of "org.freedesktop.hostname1", -# please enable NOPLUGIN_OPTION. -# NOPLUGIN_OPTION="--noplugin=hostname" -NOPLUGIN_OPTION="" -SSD_OPTIONS="--oknodo --quiet --exec $DAEMON -- $NOPLUGIN_OPTION" - -test -f $DAEMON || exit 0 - -# FIXME: any of the sourced files may fail if/with syntax errors -test -f /etc/default/bluetooth && . /etc/default/bluetooth -test -f /etc/default/rcS && . /etc/default/rcS - -set -e - -case $1 in - start) - echo "Starting $DESC" - - if test "$BLUETOOTH_ENABLED" = 0; then - echo "disabled. see /etc/default/bluetooth" - exit 0 - fi - - start-stop-daemon --start --background $SSD_OPTIONS $MOREOPTIONS - sleep 1 - if [[ -n ${BLUETOOTHCTL_CMD} ]] ; then - echo -e "${BLUETOOTHCTL_CMD}" | /usr/bin/bluetoothctl 2>&1 | logger -t bluetoothctl -p daemon.info - fi - echo "${DAEMON##*/}" - - ;; - stop) - echo "Stopping $DESC" - if test "$BLUETOOTH_ENABLED" = 0; then - echo "disabled." - exit 0 - fi - start-stop-daemon --stop $SSD_OPTIONS - echo "${DAEMON}" - ;; - restart|force-reload) - $0 stop - sleep 1 - $0 start - ;; - status) - pidof ${DAEMON} >/dev/null - status=$? - if [ $status -eq 0 ]; then - echo "bluetooth is running." - else - echo "bluetooth is not running" - fi - exit $status - ;; - *) - N=/etc/init.d/bluetooth - echo "Usage: $N {start|stop|restart|force-reload|status}" >&2 - exit 1 - ;; -esac - -exit 0 - -# vim:noet diff --git a/recipes-connectivity/bluez/bluez5/main.conf b/recipes-connectivity/bluez/bluez5/main.conf deleted file mode 100644 index 40ad113..0000000 --- a/recipes-connectivity/bluez/bluez5/main.conf +++ /dev/null @@ -1,108 +0,0 @@ -[General] - -# Default adapter name -# Defaults to 'BlueZ X.YZ' -Name = MTCDT-Bluez - -# Default device class. Only the major and minor device class bits are -# considered. Defaults to '0x000000'. -#Class = 0x000100 - -# How long to stay in discoverable mode before going back to non-discoverable -# The value is in seconds. Default is 180, i.e. 3 minutes. -# 0 = disable timer, i.e. stay discoverable forever -DiscoverableTimeout = 0 - -# How long to stay in pairable mode before going back to non-discoverable -# The value is in seconds. Default is 0. -# 0 = disable timer, i.e. stay pairable forever -#PairableTimeout = 0 - -# Automatic connection for bonded devices driven by platform/user events. -# If a platform plugin uses this mechanism, automatic connections will be -# enabled during the interval defined below. Initially, this feature -# intends to be used to establish connections to ATT channels. Default is 60. -AutoConnectTimeout = 0 - -# Use vendor id source (assigner), vendor, product and version information for -# DID profile support. The values are separated by ":" and assigner, VID, PID -# and version. -# Possible vendor id source values: bluetooth, usb (defaults to usb) -#DeviceID = bluetooth:1234:5678:abcd - -# Do reverse service discovery for previously unknown devices that connect to -# us. This option is really only needed for qualification since the BITE tester -# doesn't like us doing reverse SDP for some test cases (though there could in -# theory be other useful purposes for this too). Defaults to 'true'. -#ReverseServiceDiscovery = true - -# Enable name resolving after inquiry. Set it to 'false' if you don't need -# remote devices name and want shorter discovery cycle. Defaults to 'true'. -#NameResolving = true - -# Enable runtime persistency of debug link keys. Default is false which -# makes debug link keys valid only for the duration of the connection -# that they were created for. -#DebugKeys = false - -# Restricts all controllers to the specified transport. Default value -# is "dual", i.e. both BR/EDR and LE enabled (when supported by the HW). -# Possible values: "dual", "bredr", "le" -#ControllerMode = dual - -# Enables Multi Profile Specification support. This allows to specify if -# system supports only Multiple Profiles Single Device (MPSD) configuration -# or both Multiple Profiles Single Device (MPSD) and Multiple Profiles Multiple -# Devices (MPMD) configurations. -# Possible values: "off", "single", "multiple" -#MultiProfile = off - -# Permanently enables the Fast Connectable setting for adapters that -# support it. When enabled other devices can connect faster to us, -# however the tradeoff is increased power consumptions. This feature -# will fully work only on kernel version 4.1 and newer. Defaults to -# 'false'. -#FastConnectable = false - -# Default privacy setting. -# Enables use of private address. -# Possible values: "off", "device", "network" -# "network" option not supported currently -# Defaults to "off" -# Privacy = off - -[GATT] -# GATT attribute cache. -# Possible values: -# always: Always cache attributes even for devices not paired, this is -# recommended as it is best for interoperability, with more consistent -# reconnection times and enables proper tracking of notifications for all -# devices. -# yes: Only cache attributes of paired devices. -# no: Never cache attributes -# Default: always -#Cache = always - -[Policy] -# -# The ReconnectUUIDs defines the set of remote services that should try -# to be reconnected to in case of a link loss (link supervision -# timeout). The policy plugin should contain a sane set of values by -# default, but this list can be overridden here. By setting the list to -# empty the reconnection feature gets disabled. -#ReconnectUUIDs=00001112-0000-1000-8000-00805f9b34fb,0000111f-0000-1000-8000-00805f9b34fb,0000110a-0000-1000-8000-00805f9b34fb - -# ReconnectAttempts define the number of attempts to reconnect after a link -# lost. Setting the value to 0 disables reconnecting feature. -#ReconnectAttempts=7 - -# ReconnectIntervals define the set of intervals in seconds to use in between -# attempts. -# If the number of attempts defined in ReconnectAttempts is bigger than the -# set of intervals the last interval is repeated until the last attempt. -#ReconnectIntervals=1,2,4,8,16,32,64 - -# AutoEnable defines option to enable all controllers when they are found. -# This includes adapters present on start as well as adapters that are plugged -# in later on. Defaults to 'false'. -AutoEnable=true diff --git a/recipes-connectivity/bluez/bluez5/out-of-tree.patch b/recipes-connectivity/bluez/bluez5/out-of-tree.patch deleted file mode 100644 index 3ee79d7..0000000 --- a/recipes-connectivity/bluez/bluez5/out-of-tree.patch +++ /dev/null @@ -1,26 +0,0 @@ -From ed55b49a226ca3909f52416be2ae5ce1c5ca2cb2 Mon Sep 17 00:00:00 2001 -From: Ross Burton <ross.burton@intel.com> -Date: Fri, 22 Apr 2016 15:40:37 +0100 -Subject: [PATCH] Makefile.obexd: add missing mkdir in builtin.h generation - -In parallel out-of-tree builds it's possible that obexd/src/builtin.h is -generated before the target directory has been implicitly created. Solve this by -creating the directory before writing into it. - -Upstream-Status: Submitted -Signed-off-by: Ross Burton <ross.burton@intel.com> ---- - Makefile.obexd | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/Makefile.obexd b/Makefile.obexd -index 2e33cbc..c8286f0 100644 ---- a/Makefile.obexd -+++ b/Makefile.obexd -@@ -105,2 +105,3 @@ obexd/src/plugin.$(OBJEXT): obexd/src/builtin.h - obexd/src/builtin.h: obexd/src/genbuiltin $(obexd_builtin_sources) -+ $(AM_V_at)$(MKDIR_P) $(dir $@) - $(AM_V_GEN)$(srcdir)/obexd/src/genbuiltin $(obexd_builtin_modules) > $@ --- -2.8.0.rc3 - diff --git a/recipes-connectivity/bluez/bluez5/rfcomm/default b/recipes-connectivity/bluez/bluez5/rfcomm/default deleted file mode 100755 index 613a72c..0000000 --- a/recipes-connectivity/bluez/bluez5/rfcomm/default +++ /dev/null @@ -1,2 +0,0 @@ -ENABLED="no" -RFCOMMOPTS="--debug --login" diff --git a/recipes-connectivity/bluez/bluez5/rfcomm/init b/recipes-connectivity/bluez/bluez5/rfcomm/init deleted file mode 100755 index 69455d8..0000000 --- a/recipes-connectivity/bluez/bluez5/rfcomm/init +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -NAME=rfcomm -SERVER=/usr/libexec/bluetooth/${NAME} -PYTHON=$(readlink -f /usr/bin/python2) -PIDFILE="/run/${NAME}.pid" - -ENABLED=yes -[ -f /etc/default/$NAME ] && . /etc/default/$NAME - -if [ "$ENABLED" != "yes" ]; then - echo "$NAME: disabled in /etc/default" - exit -fi - -case $1 in - start) - echo "Starting ${NAME}" - echo /usr/sbin/start-stop-daemon -S -p ${PIDFILE} -x ${PYTHON} -b -- ${SERVER} ${RFCOMMOPTS} - /usr/sbin/start-stop-daemon -S -p ${PIDFILE} -x ${PYTHON} -b -- ${SERVER} ${RFCOMMOPTS} - ;; - - stop) - /usr/sbin/start-stop-daemon -K -p ${PIDFILE} -x ${PYTHON} - echo "Stopping ${DNAME}" - ;; - - restart) - $0 stop - $0 start - ;; - - *) - echo "Usage: $0 {start|stop|restart}" - exit 2 - ;; -esac - - diff --git a/recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py b/recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py deleted file mode 100644 index e8f2554..0000000 --- a/recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py +++ /dev/null @@ -1,650 +0,0 @@ -#!/usr/bin/env python2 -import thread -import os -import dbus -import dbus.service -import dbus.mainloop.glib -from gi.repository import GObject, GLib -import sys -import time -import threading -import socket -import logging -import logging.handlers -import syslog -import grp -import stat -import atexit -import re -import mmap -import subprocess -import threading -import struct -import fcntl -import termios -import signal -import time -import bluetooth - -# Do we need stty onlcr???? - -#SerialPortProfile = '00001101-0000-1000-8000-00805f9b34fb' - -global lg -global opts -global RFCOMMDIR -RFCOMMDIR = '/run/rfcomm' -SLAVEDIR='/dev/pts' -BLUEZLIB='/var/lib/bluetooth' - -global TTY_GID # Group-ID number of the TTY group -global doterm # If true, this python program is a terminal console. -global needpseudot # Login option and pseudoterminal option -needpseudot = False -global terminatenow -terminatenow = False - -myscript = os.path.basename(__file__) -class dopidfile(object): - pidPath = "/" - - def writePidFile(self): - global pidPath - pid = str(os.getpid()) - pidPath = '/run/rfcomm' + '.pid' - f = open(pidPath, 'w') - f.write(pid) - f.close() - - def rmPidFile(self): - try: - os.remove(pidPath) - except OSError: - pass - - -# Log formating class -class flog: - # priority strings to be used - # with the __init__ function - priorities = { - 'debug': logging.DEBUG, - 'info': logging.INFO, - 'warn': logging.WARNING, - 'warning': logging.WARNING, - 'error': logging.ERROR, - 'critical': logging.CRITICAL, - } - - def __init__(self,myscript,facility,priority): - """ - Initialize for logging - - :param myscript: The name of the python program script - :param facility: The syslog facility, such as daemon or user - :param priority: The minimum priority to be printed to the log - :returns: Nothing - :raises TBD: logging class errors. - """ - name_len = str(len(myscript)) - self.myscript = myscript - self.log = logging.getLogger(myscript) - self.handler = logging.handlers.SysLogHandler(address=('/dev/log'),facility=facility) - self.default_fmt = ' %(levelname)-9s %(name)-' + name_len + 's %(message)s' - self.verbose_fmt1 = ' %(levelname)-9s %(name)-' + name_len + 's %(threadName)-14s ' - self.verbose_fmt2 = ' %(message)s' - formatter = logging.Formatter(self.default_fmt) - self.handler.setFormatter(formatter) - self.log.setLevel(self.priorities[priority]) # Minimum infolevel to log - self.log.addHandler(self.handler) - self.handler.createLock() - - def __default(self,func,*args): - self.handler.acquire() - formatter = logging.Formatter(self.default_fmt) - self.handler.setFormatter(formatter) - func(*args) - self.handler.release() - - def setThreshold(self,threshold): - """ - Change the syslog priority threshold - - :param priority: Character string corresponding to the threshold - """ - self.handler.acquire() - self.log.setLevel(self.priorities[threshold]) # Minimum infolevel to log - self.handler.release() - - def critical(self,*args): - """ - Prints a variable argument list at critical priority - - :returns: logging result - """ - self.__default(self.log.critical,*args) - - def error(self,*args): - """ - Prints a variable argument list at error priority - - :returns: logging result - """ - self.__default(self.log.error,*args) - - def warning(self,*args): - """ - Prints a variable argument list at warning priority - - :returns: logging result - """ - self.__default(self.log.warning,*args) - - # Python has no notice level! - - def info(self,*args): - """ - Prints a variable argument list at info priority - - :returns: logging result - """ - self.__default(self.log.info,*args) - - def debug(self,*args): - """ - Prints a variable argument list at debug priority - - Printing debug includes function name and line - number. - - :returns: logging result - """ - caller_frame = sys._getframe().f_back - callerfunc = caller_frame.f_code.co_name + '@' + str(caller_frame.f_lineno); - callerfunc = callerfunc.ljust(16) - self.handler.acquire() - log = logging.getLogger(self.myscript) - formatter = logging.Formatter(self.verbose_fmt1+callerfunc+self.verbose_fmt2) - self.handler.setFormatter(formatter) - log.debug(*args) - self.handler.release() - -# End of log handler - - - -# Thread to create login process, with -# stdin, stdout, stderr matching the file descriptor -# This is because NewConnection cannot create threads or -# use a mutex. Workarounds are pipes, IPC semamphores, -# IPC messaging -class logins(object): - slavefd = -1 - - # Thread to wait on our children - def IgnoreWait(self,pid): - lg.debug("IgnoreWait: Waiting on process pid: %d" % (pid.pid)) - pid.wait() - lg.debug("login terminated: %d" % (pid.pid)) - - def StartLogin(self,rpipe,mainloop): - datafd='' - masters = [] - lg.debug("StartLogin enter: rpipe fd=%d" % (rpipe)) - while 1: - try: - datafd=os.read(rpipe,8) - except Exception as e: - lg.error('os.read error: %s' % (e)) - lg.debug('Done with StartLogin, calling quit') - for fd in masters: - os.close(fd) - os.kill(os.getpid(), signal.SIGINT) - thread.exit() - # Single integer. - (slavefd,masterfd) = struct.unpack("ii",bytearray(datafd)) - if masterfd > 0: - masters.append(masterfd) - lg.debug("StartLogin: slavefd %d" % (slavefd)) - if slavefd < 0: - lg.debug("Told to exit, so exiting StartLogin thread") - os.close(rpipe) - # We try to close all the masters, as it gets - # things wound down in a hurry. - for fd in masters: - lg.debug('StartLogin: Try to close fd %d' % (fd)) - try: - os.close(fd) - except Exception as e: - lg.debug('StartLogin (ignore error): OK: Did not close fd: %d %s' % (fd,e)) - sys.exc_clear() - os.kill(os.getpid(), signal.SIGINT) - thread.exit() - # Start login with fd, and close it. - Env = {'TERM': 'dumb'} - self.slavefd = slavefd - lg.debug('Popen slavefd: %d' % (slavefd)) - try: - # Mar 16 14:23:35 mtcdt daemon.err ERROR rfcomm.py Popen login: global name 's' is not defined - pid = subprocess.Popen(['/bin/login','--'],env=Env,preexec_fn = lambda: ( os.setsid(),fcntl.ioctl(0, termios.TIOCSCTTY, 0) ),stdin=slavefd,stdout=slavefd,stderr=slavefd,close_fds=True,cwd='/') - lg.debug('Start IgnoreWait thread') - try: - IgnoreWaitThread = threading.Thread(target=self.IgnoreWait,args=[pid]) - except Exception as e: - lg.error('IgnoreWaitThread: threading.Thread: %s' % (e)) - try: - IgnoreWaitThread.start() - except Exception as e: - lg.error('IgnoreWaitThread: start: %s' % (e)) - except Exception as e: - lg.error('Popen login: %s' % (e)) - os.close(slavefd) - -class Profile(dbus.service.Object): - fd = -1 - readThread = None - path = None - io_id = -1 - io_id2 = -1 - hup_id = -1 - hup_id2 = -1 - io_pty_master = -1 - io_pty_slave = -1 - slavePath = None - linkPath = None - w = -1 - # True False pseudonyms for making code readable (or not!) - exiting = True - notexiting = False - - @dbus.service.method('org.bluez.Profile1', - in_signature='', - out_signature='') - def Release(self): - lg.info('Release/quit') - mainloop.quit() - - @dbus.service.method("org.bluez.Profile1", - in_signature="", out_signature="") - def Cancel(self): - lg.info("Cancel") - - def removeLink(self,state): - lg.debug('removeLink: state: %r' % (state)) - path = self.linkPath - lg.debug('removeLink: path %s' % (path)) - if state == self.exiting: - lg.debug('Clearing out linkPath') - self.linkPath = None # Burn bridges, do it once. - if path and os.path.lexists(path): - try: - os.remove(path) - except Exception as e: - lg.error("os.remove(self.linkPath): Tried to remove %s" % (path)) - lg.error('%s' % (e)) - - - - # New Connection is called when a new Bluetooth - # is established - @dbus.service.method('org.bluez.Profile1', - in_signature='oha{sv}', - out_signature='') - def NewConnection(self, path, fd, properties): - dbus.mainloop.glib.threads_init() - self.fd = fd.take() # Extract File Descriptor from dbus UnixFD class. - self.path = path - - # Bluetooth address portion of the path - address = os.path.basename(self.path) - - numaddr = address[address.find("_")+1:] - # Replace _ with : - Name = bluetooth.lookup_name(numaddr.replace("_",":")) - - print('NewConnection(%s, %s, %s:%d)' % (path,Name,type(fd).__name__,self.fd)) - lg.info('NewConnection(%s, %s, %s:%d)' % (path,Name,type(fd).__name__,self.fd)) - atexit.register(self.RequestDisconnection,self.path) - lg.debug('Past atexit.register') - - # Get a pseudoterminal to provide an I/O driver for - # a program that needs a TTY. - if needpseudot: - (self.io_pty_master,self.io_pty_slave) = os.openpty() - slavestat = os.fstat(self.io_pty_slave) - self.minor = os.minor(slavestat.st_rdev) - lg.debug('pseudoterminal major and minor: (%d,%d)' % (os.major(slavestat.st_rdev),self.minor)) - if not os.path.isdir(RFCOMMDIR): - lg.debug('Before mkdir: RFCOMMDIR %s' % (RFCOMMDIR)) - os.mkdir(RFCOMMDIR,0755) - - - lg.debug('Address %s' % (address)) - self.linkPath = RFCOMMDIR + '/' + address + '_' + Name + '_pts' + str(self.minor) - self.slavePath = SLAVEDIR + '/' + str(self.minor) - lg.debug('termPath %s' % (self.linkPath)) - self.removeLink(self.notexiting) - # linkPath was removed - - lg.debug('os.symlink(%s,%s)' % (self.slavePath,self.linkPath)) - old = os.umask(002) - lg.debug('past umask') - try: - os.symlink(self.slavePath,self.linkPath) - try: - atexit.register(self.removeLink,self.exiting); - except Exception as e: - lg.error('Register atexit: %s' % (e)) - except Exception as e: - lg.error('symlink failed: %s' % (e)) - return False - lg.debug('Before umask') - os.umask(old) - lg.debug('After umask') - # os.chown(self.myPath,0,TTY_GID) - - # Completed pseudoterminal case to create device and node - - # + For loopback, we only monitor the RFCOMM line (self.fd). - # + For interactive (not pseudoterminal or loopback option, - # we monitor the stdin (0) and the RFCOMM line for input - # + For pseudoterminal, we monitor input on the RFCOMM line, - # and the slave pseudoterminal. - # Note that io_add_watch causes a poll to be done by the - # python GI library. The callback functions (io_term and io_cb) - # will be called when there is an event on the file descriptor - # being polled. - sys.stdout.flush() - if not opts.loopback: - if needpseudot: - local_fd = self.io_pty_master - lg.debug('NewConnection: master_fd: %d slave_fd: %d' % (local_fd,self.io_pty_slave)) #success to here. - else: - # stdin - local_fd = 0 - lg.debug('Ready to do io_add_watch on local_fd: %d' % (local_fd)) - try: - self.io_id2 = GObject.io_add_watch(local_fd, - GObject.PRIORITY_DEFAULT, - GObject.IO_IN | GObject.IO_PRI | GObject.IO_HUP | GObject.IO_ERR, - self.io_term) - except Exception as e: - lg.error('io_addwatch failed for local_fd %d: IO_IN, IO_PRI %s' % (local_fd,e)) - - if opts.login: - # Writing the slave file descriptor causes the login process to start. - lg.debug('opts.login is true slave fd: %d pipe: %d' % (self.io_pty_slave,self.w)) - try: - os.write(self.w,struct.pack('ii',self.io_pty_slave,self.io_pty_master)) - except Exception as e: - lg.error('os.write of slave fd:%d master fd: %d failed: %s' % (self.io_pty_slave,self.io_pty_slave,e)) - os.close(self.io_pty_slave) - self.io_pty_slave = -1 - return False - self.io_pty_slave = -1 - - if doterm: - lg.debug('Profile: Write the prompt') - os.write(1,'TTY> ') - - lg.debug('NewConnection: doterm: %s, io_add_watch is next' % doterm) - - self.io_id = GObject.io_add_watch(self.fd, - GObject.PRIORITY_DEFAULT, - GObject.IO_IN | GObject.IO_PRI | GObject.IO_HUP | GObject.IO_ERR, - self.io_cb) - lg.debug('io_id(remote input) = %d io_id2(local input) = %d' % (self.io_id,self.io_id2)) - - - # I/O read from Bluetooth remote to local application. - def io_cb(self, fd, conditions): - if terminatenow: - self.RequestDisconnection(self.path) - - if (conditions & GObject.IO_HUP or conditions & GObject.IO_ERR): - lg.debug('Found HUP on fd: %d, so terminate' % (fd)) - self.RequestDisconnection(self.path) - return False - # Read from remote - data = None - try: - data = os.read(fd, 1024) - except: - return True - lg.debug('io_cb: past read: doterm: %s' % doterm) - if opts.loopback: - toutput = fd # same as input - else: - toutput = self.io_pty_master - - if opts.loopback or needpseudot or opts.login: - if data: - start = 0 - remain = len(data) - result = 1 - lg.debug('remain is %d entering the loop' % (remain)) - while remain > 0 and result > 0: - try: - result = os.write(toutput,data) - except Exception as e: - lg.debug('os.write failed: %s' % (e)) - return True - lg.debug('os.write returned %d for %s remain: %d' % (result,data,remain)) - if remain != result and remain > 0: - remain -= result - lg.debug('remain is now %d result is %d' % (remain,result)) - data = data[-remain:] - lg.debug('remain to print %s' % (data)) - else: - remain = 0 - lg.debug('returning true to end this routing') - return True - - if data and len(data) > 0: - final = data[-1] - if data[-1] == '\n': - date = data[:-1] - if doterm: - print('\n'+data.decode('ascii')) - os.write(1,'TTY> ') - - return True - - # I/O written to bluetooth from local slave (application write to remote) - def io_term(self, fd0, conditions): - if terminatenow: - self.RequestDisconnection(self.path) - if (conditions & GObject.IO_HUP or conditions & GObject.IO_ERR): - lg.debug('Found HUP on fd0: %d, so terminate' % (fd0)) - self.RequestDisconnection(self.path) - return False - # Read from local (not used for loopback) - data = None - data = os.read(fd0, 1024) - lg.debug('io_term: fd0: %d len(data): %d' % (fd0,len(data))) - if not data: - # No Data == EOF - self.RequestDisconnection(self.path) - return True - #for character in data: - # print character, character.encode('hex') - try: - os.write(self.fd,data) - except Exception as e: - print '%s' % (e) - lg.error('%s' % (e)) - self.RequestDisconnection(self.path) - return True - if doterm: - os.write(fd0,'TTY> ') - return True - - @dbus.service.method('org.bluez.Profile1', - in_signature='o', - out_signature='') - def RequestDisconnection(self, path): - print('RequestDisconnection(%s)' % (path)) - lg.info('RequestDisconnection(%s)' % (path)) - if self.fd != -1: - lg.debug('closing fd: %s' % (self.fd)) - s = socket.fromfd(self.fd,socket.AF_INET,socket.SOCK_STREAM) - result = s.shutdown(socket.SHUT_RDWR) - lg.debug('After shutdown fd: %s %s %s' % (self.fd,' result:',result)) - result = os.close(self.fd) - lg.debug('After closing fd: %s %s %s' % (self.fd,' result:',result)) - self.fd = -1 - if self.io_id != -1: - lg.debug('remove id: %s' % (self.io_id)) - rmv = GObject.source_remove(self.io_id) - self.io_id = -1 - if self.io_id2 != -1: - lg.debug('closing id2: %s' % (self.io_id2)) - rmv = GObject.source_remove(self.io_id2) - lg.debug('removed id2: %s %s %s' % (self.io_id2,'result: ',rmv)) - self.io_id2 = -1 - if self.hup_id != -1: - lg.debug('closing hup_id: %s' % (self.hup_id)) - rmv = GObject.source_remove(self.hup_id) - lg.debug('removed id2: %s %s %s' % (self.hup_id,'result: ',rmv)) - self.hup_id = -1 - if self.hup_id2 != -1: - lg.debug('closing hup_id2: %s' % (self.hup_id2)) - rmv = GObject.source_remove(self.hup_id2) - lg.debug('removed id2: %s %s %s' % (self.hup_id2,'result: ',rmv)) - self.hup_id2 = -1 - if needpseudot: - if self.io_pty_slave != -1: - os.close(self.io_pty_slave) - self.io_pty_slave = -1 - if self.io_pty_master != -1: - try: - savefd = self.io_pty_master - self.io_pty_master = -1 - os.close(savefd) - except Exception as e: - lg.error("close(io_pty_master): Tried to close %d" % (savefd)) - lg.error('%s' % (e)) - - self.removeLink(self.exiting) - -def terminationHandler(mainloop): - lg.debug('SIGTERM: terminationHandler was called') - mainloop.quit() - - -if __name__ == '__main__': - import argparse - - doterm = False - TTY_GID = grp.getgrnam('tty').gr_gid - # Set up logging initially info and above - lg = flog(myscript,'daemon','info') - - parser = argparse.ArgumentParser( - description='BlueZ RFCOMM server.') - - parser.add_argument('-u', '--uuid', - metavar='uuid_or_shortcut', default='spp', - help='Service UUID to use. Can be either full UUID' - ' or one of the shortcuts: gn, panu, nap. Default: %(default)s.') - parser.add_argument('--pseudoterminal', action='store_true', - help='Create a pseudoterminal and put slave in /run/rfcomm' - ' Suitable for background operation.') - parser.add_argument('--loopback', action='store_true', - help='Echo data for testing (exclusive with pseudoterminal)') - parser.add_argument('--debug', - action='store_true', help='Verbose operation mode.') - parser.add_argument('--login', - action='store_true', help='Use RFCOMM to log into this device.') - opts = parser.parse_args() - - if opts.debug: - lg.setThreshold('debug') - - if opts.pseudoterminal and opts.loopback: - msg = 'Cannot have both pseudoterminal and loopback option' - print msg - lg.error(msg) - exit(1) - if not opts.pseudoterminal and not opts.loopback and not opts.login: - doterm = True - print "main: doterm is %s" % (str(doterm)) - - if opts.pseudoterminal or opts.login: - needpseudot = True - - - - dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) - - bus = dbus.SystemBus() - - manager = dbus.Interface(bus.get_object('org.bluez', - '/org/bluez'), - 'org.bluez.ProfileManager1') - - mainloop = GObject.MainLoop() - - GLib.unix_signal_add(GLib.PRIORITY_HIGH,signal.SIGTERM,terminationHandler,mainloop) - mypidfile = dopidfile() - mypidfile.writePidFile() - - if opts.login: - # Need to create thead to exec logins. - rpipe,wpipe = os.pipe() - loginProcess = logins() - Profile.w = wpipe - lg.debug('Call threading next') - try: - StartLoginThread = threading.Thread(target=loginProcess.StartLogin,args=[rpipe,mainloop]) - except Exception as e: - lg.error('threading.Thread: StartLogin %s' % (e)) - try: - StartLoginThread.start() - except Exception as e: - lg.error('StartLogin.start: %s' % (e)) - - - profile_path = '/foo/bar/profile' - - SPP_opts = { - 'AutoConnect': True, - 'Role': 'server', - 'Name': 'SerialPort' - } - - print('Starting Serial Port Profile...') - lg.info('Starting Serial Port Profile...') - - profile = Profile(bus, profile_path) - - try: - manager.RegisterProfile(profile_path, opts.uuid, SPP_opts) - except dbus.exceptions.DBusException as inst: - print 'dbus exception:',inst._dbus_error_name - lg.error('dbus exception: %s',inst._dbus_error_name) - if inst._dbus_error_name == 'org.freedesktop.DBus.Error.AccessDenied': - print 'Try running as root' - exit(1) - - lg.debug('Completed Register Profile...') - dbus.mainloop.glib.threads_init() - lg.debug('Completed threads init... Now mainloop.run') - try: - mainloop.run() - except KeyboardInterrupt: - pass - except Exception as e: - lg.error('mainloop exception: %s' % (e)) - print '\nSerial Port Profile: ERROR Goodbye' - lg.error('Serial Port Profile: ERROR Goodbye') - data = struct.pack('i',-1) - os.write(wpipe,data) - mainloop.quit() - - lg.info('Serial Port Profile: Goodbye') - if opts.login: - data = struct.pack('ii',-1,-1) - os.write(wpipe,data) - mypidfile.rmPidFile() - mainloop.quit() diff --git a/recipes-connectivity/bluez/bluez5/run-ptest b/recipes-connectivity/bluez/bluez5/run-ptest deleted file mode 100644 index 21df00c..0000000 --- a/recipes-connectivity/bluez/bluez5/run-ptest +++ /dev/null @@ -1,31 +0,0 @@ -#! /bin/sh - -cd unit - -failed=0 -all=0 - -for f in test-*; do - "./$f" - case "$?" in - 0) - echo "PASS: $f" - all=$((all + 1)) - ;; - 77) - echo "SKIP: $f" - ;; - *) - echo "FAIL: $f" - failed=$((failed + 1)) - all=$((all + 1)) - ;; - esac -done - -if [ "$failed" -eq 0 ] ; then - echo "All $all tests passed" -else - echo "$failed of $all tests failed" -fi - diff --git a/recipes-connectivity/bluez/bluez5_%.bbappend b/recipes-connectivity/bluez/bluez5_%.bbappend deleted file mode 100644 index ab89900..0000000 --- a/recipes-connectivity/bluez/bluez5_%.bbappend +++ /dev/null @@ -1,4 +0,0 @@ -EXTRA_OECONF += "--enable-deprecated --enable-experimental" - -RDEPENDS_${PN}-rfcomm += "python-pybluez" - diff --git a/recipes-connectivity/bluez/bluez5_5.47.bb b/recipes-connectivity/bluez/bluez5_5.47.bb deleted file mode 100644 index fb17add..0000000 --- a/recipes-connectivity/bluez/bluez5_5.47.bb +++ /dev/null @@ -1,55 +0,0 @@ -require bluez5.inc - -REQUIRED_DISTRO_FEATURES = "bluez5" - -SRC_URI[md5sum] = "783e15f65e70cdb8f721c659e140dd56" -SRC_URI[sha256sum] = "cf75bf7cd5d564f21cc4a2bd01d5c39ce425397335fd47d9bbe43af0a58342c8" - -# noinst programs in Makefile.tools that are conditional on READLINE -# support -NOINST_TOOLS_READLINE ?= " \ - attrib/gatttool \ - tools/obex-client-tool \ - tools/obex-server-tool \ - tools/bluetooth-player \ - tools/obexctl \ - tools/btmgmt \ -" - -# noinst programs in Makefile.tools that are conditional on EXPERIMENTAL -# support -NOINST_TOOLS_EXPERIMENTAL ?= " \ - emulator/btvirt \ - emulator/b1ee \ - emulator/hfp \ - tools/3dsp \ - tools/mgmt-tester \ - tools/gap-tester \ - tools/l2cap-tester \ - tools/sco-tester \ - tools/smp-tester \ - tools/hci-tester \ - tools/rfcomm-tester \ - tools/bdaddr \ - tools/avinfo \ - tools/avtest \ - tools/scotest \ - tools/amptest \ - tools/hwdb \ - tools/hcieventmask \ - tools/hcisecfilter \ - tools/btinfo \ - tools/btattach \ - tools/btsnoop \ - tools/btproxy \ - tools/btiotest \ - tools/mcaptest \ - tools/cltest \ - tools/oobtest \ - tools/seq2bseq \ - tools/ibeacon \ - tools/btgatt-client \ - tools/btgatt-server \ - tools/gatt-service \ - profiles/iap/iapd \ -" diff --git a/recipes-connectivity/bluez/python-gatt-server_1.0.bb b/recipes-connectivity/bluez/python-gatt-server_1.0.bb deleted file mode 100644 index 76069f6..0000000 --- a/recipes-connectivity/bluez/python-gatt-server_1.0.bb +++ /dev/null @@ -1,24 +0,0 @@ -inherit allarch -HOMEPAGE = "https://github.com/Jumperr-labs/python-gatt-server" -SRCREV = "a39ef9773e9ba845f4303b1dfd2efddf24b02238" -PR = "r0" - -S = "${WORKDIR}/git" - -LICENSE = "GPLv2" -LIC_FILES_CHKSUM = "file://LICENSE;md5=c53d04442d1a229d62549856b7ec456a" - -SRC_URI = "git://github.com/Jumperr-labs/python-gatt-server.git;protocol=git" - -RDEPENDS_${PN} += "python-dbus python-pygobject" - -DBTEXEC = "${libexecdir}/bluetooth/" -DEST = "${D}${DBTEXEC}" - -FILES_${PN} = "${DBTEXEC}" - - -do_install_append() { - install -d ${DEST}/${PN} - install -m 0755 ${S}/*.py ${DEST}/${PN} -} |
