bluez: add new package
authorNicolas Thill <nico@openwrt.org>
Fri, 9 Jan 2015 20:04:35 +0000 (21:04 +0100)
committerNicolas Thill <nico@openwrt.org>
Fri, 9 Jan 2015 20:04:35 +0000 (21:04 +0100)
This merges & obsoletes bluez-libs & bluez-utils from old packages feed.

Signed-off-by: Nicolas Thill <nico@openwrt.org>
utils/bluez/Makefile [new file with mode: 0644]
utils/bluez/files/bluetooth.config [new file with mode: 0644]
utils/bluez/files/bluetooth.dbus [new file with mode: 0644]
utils/bluez/files/bluez-utils.init [new file with mode: 0644]
utils/bluez/files/givepin [new file with mode: 0644]
utils/bluez/patches/200-uart-speed.patch [new file with mode: 0644]
utils/bluez/patches/201-readline.patch [new file with mode: 0644]

diff --git a/utils/bluez/Makefile b/utils/bluez/Makefile
new file mode 100644 (file)
index 0000000..ffd7460
--- /dev/null
@@ -0,0 +1,91 @@
+#
+# Copyright (C) 2006-2015 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=bluez
+PKG_VERSION:=5.27
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=http://www.kernel.org/pub/linux/bluetooth/
+PKG_MD5SUM:=a8fc508690e497e88c2c0b373cd653a8
+
+PKG_LICENSE:=GPL-2.0
+PKG_LICENSE_FILES:=COPYING
+PKG_MAINTAINER:=Nicolas Thill <nico@openwrt.org>
+
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/nls.mk
+
+define Package/bluez/Default
+  TITLE:=Bluetooth
+  URL:=http://www.bluez.org/
+endef
+
+define Package/bluez-libs
+$(call Package/bluez/Default)
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE+= library
+  DEPENDS:=+libpthread
+endef
+
+define Package/bluez-utils
+$(call Package/bluez/Default)
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE+= utilities
+  DEPENDS:=+bluez-libs +libpthread +dbus +glib2 +libical +libncurses +libreadline $(INTL_DEPENDS) $(ICONV_DEPENDS)
+endef
+
+define Package/bluez-utils/conffiles
+/etc/bluetooth/hcid.conf
+/etc/bluetooth/rfcomm.conf
+/etc/config/bluetooth
+endef
+
+CONFIGURE_ARGS += \
+       --enable-client \
+       --enable-datafiles \
+       --enable-experimental \
+       --enable-library \
+       --enable-monitor \
+       --enable-obex \
+       --enable-threads \
+       --enable-tools \
+       --disable-android \
+       --disable-cups \
+       --disable-manpages \
+       --disable-sixaxis \
+       --disable-systemd \
+       --disable-test \
+       --disable-udev \
+
+TARGET_CPPFLAGS += \
+       -D_GNU_SOURCE
+
+define Package/bluez-libs/install
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libbluetooth.so.* $(1)/usr/lib/
+endef
+
+define Package/bluez-utils/install
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(CP) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin/
+       $(INSTALL_DIR) $(1)/etc/config
+       $(INSTALL_DATA) ./files/bluetooth.config $(1)/etc/config/bluetooth
+       $(INSTALL_DIR) $(1)/etc/dbus-1/system.d/
+       $(INSTALL_DATA) ./files/bluetooth.dbus $(1)/etc/dbus-1/system.d/bluetooth.conf
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/bluez-utils.init $(1)/etc/init.d/bluez-utils
+endef
+
+$(eval $(call BuildPackage,bluez-libs))
+$(eval $(call BuildPackage,bluez-utils))
diff --git a/utils/bluez/files/bluetooth.config b/utils/bluez/files/bluetooth.config
new file mode 100644 (file)
index 0000000..42f390c
--- /dev/null
@@ -0,0 +1,32 @@
+config hcid
+#      option config   /etc/bluetooth/hcid.conf
+       option enabled  1
+
+config hciattach
+       option initspeed        115200
+       option tty      ttyS1
+       option type     csr
+       option speed    115200
+       option flow     noflow
+       option enabled  0
+
+config rfcomm
+#      option config   /etc/bluetooth/rfcomm.conf
+       option enabled  0
+
+config dund
+       option listen   true
+       option persist  true
+       option msdun    true
+       option interface dund
+       option unit     1
+       option pppdopts "ktune proxyarp 192.168.1.1:192.168.1.2 ms-dns 192.168.1.1"
+       option enabled  0
+
+config pand
+       option listen   true
+       option autozap  true
+       option role     "NAP"
+       option master   true
+       option persist  true
+       option enabled  0
diff --git a/utils/bluez/files/bluetooth.dbus b/utils/bluez/files/bluetooth.dbus
new file mode 100644 (file)
index 0000000..88545fa
--- /dev/null
@@ -0,0 +1,37 @@
+<!-- This configuration file specifies the required security policies
+     for Bluetooth core daemon to work. -->
+
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+
+  <!-- ../system.conf have denied everything, so we just punch some holes -->
+
+  <policy user="root">
+    <allow own="org.bluez"/>
+  </policy>
+
+  <policy at_console="true">
+    <allow send_path="/"/>
+    <allow send_path="/org/bluez"/>
+
+    <allow send_destination="org.bluez.Manager"/>
+    <allow receive_sender="org.bluez.Manager"/>
+
+    <allow send_destination="org.bluez.Adapter"/>
+    <allow receive_sender="org.bluez.Adapter"/>
+
+    <allow send_destination="org.bluez.Device"/>
+    <allow receive_sender="org.bluez.Device"/>
+
+    <allow send_destination="org.bluez.Service"/>
+    <allow receive_sender="org.bluez.Service"/>
+
+    <allow send_destination="org.bluez.Database"/>
+    <allow receive_sender="org.bluez.Database"/>
+
+    <allow send_destination="org.bluez.Security"/>
+    <allow receive_sender="org.bluez.Security"/>
+  </policy>
+
+</busconfig>
diff --git a/utils/bluez/files/bluez-utils.init b/utils/bluez/files/bluez-utils.init
new file mode 100644 (file)
index 0000000..e9320ae
--- /dev/null
@@ -0,0 +1,131 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2007 OpenWrt.org
+
+#start after dbus (60)
+START=62
+
+append_bool() {
+       local section="$1"
+       local option="$2"
+       local value="$3"
+       local _val
+       config_get_bool _val "$section" "$option" '0'
+       [ $_val -gt 0 ] && append args "$3"
+}
+
+append_string() {
+       local section="$1"
+       local option="$2"
+       local value="$3"
+       local default="$4"
+       local _val
+       config_get _val "$section" "$option" "$default"
+       [ -n "$_val" ] && append args "$3 $_val"
+}
+
+hcid_config() {
+       local cfg="$1"
+       config_get_bool enabled "$cfg" "enabled" '1'
+       [ $enabled -gt 0 ] || return 1
+       args=""
+       append_bool "$cfg" nodaemon "-n"
+       append_string "$cfg" config "-f"
+       service_start /usr/sbin/hcid $args
+}
+
+hciattach_config() {
+       local cfg="$1"
+       config_get_bool enabled "$cfg" "enabled" '1'
+       [ $enabled -gt 0 ] || return 1
+       args=""
+       append_string "$cfg" initspeed "-s" "115200"
+       append_string "$cfg" tty " " "ttyS1"
+       append_string "$cfg" type " " "csr"
+       append_string "$cfg" speed " " "115200"
+       append_string "$cfg" flow " " "noflow"
+       service_start /usr/sbin/hciattach $args
+}
+
+rfcomm_config() {
+       local cfg="$1"
+       config_get_bool enabled "$cfg" "enabled" '1'
+       [ $enabled -gt 0 ] || return 1
+       args=""
+       append_string "$cfg" config "-f"
+       /usr/bin/rfcomm $args bind all
+}
+
+dund_config() {
+       local cfg="$1"
+       config_get_bool enabled "$cfg" "enabled" '1'
+       [ $enabled -gt 0 ] || return 1
+       args=""
+       append_bool "$cfg" listen "--listen"
+       append_string "$cfg" connect "--connect"
+       append_string "$cfg" mrouter "--mrouter"
+       append_bool "$cfg" search "--search"
+       append_string "$cfg" channel "--channel"
+       append_string "$cfg" device "--device"
+       append_bool "$cfg" nosdp "--nosdp"
+       append_bool "$cfg" auth "--auth"
+       append_bool "$cfg" encrypt "--encrypt"
+       append_bool "$cfg" secure "--secure"
+       append_bool "$cfg" master "--master"
+       append_bool "$cfg" nodetach "--nodetach"
+       append_bool "$cfg" persist "--persist"
+       append_string "$cfg" pppd "--pppd"
+       append_bool "$cfg" msdun "--msdun"
+       append_bool "$cfg" activesync "--activesync"
+       append_bool "$cfg" cache "--cache"
+
+       append_string "$cfg" pppdopts ""
+       config_get ifn "$cfg" interface
+       if [ -n "$ifn" ]; then
+               config_get unit "$cfg" unit
+               [ -z "$unit" ] || append args "unit $unit ipparam $ifn linkname $ifn"
+       fi
+
+       service_start /usr/bin/dund $args
+}
+
+pand_config() {
+       local cfg="$1"
+       config_get_bool enabled "$cfg" "enabled" '1'
+       [ $enabled -gt 0 ] || return 1
+       args=""
+       append_bool "$cfg" listen "--listen"
+       append_string "$cfg" connect "--connect"
+       append_bool "$cfg" autozap "--autozap"
+       append_bool "$cfg" search "--search"
+       append_string "$cfg" role "--role"
+       append_string "$cfg" service "--service"
+       append_string "$cfg" ethernet "--ethernet"
+       append_string "$cfg" device "--device"
+       append_bool "$cfg" nosdp "-D"
+       append_bool "$cfg" auth "-A"
+       append_bool "$cfg" encrypt "-E"
+       append_bool "$cfg" secure "-S"
+       append_bool "$cfg" master "-M"
+       append_bool "$cfg" nodetach "-n"
+       append_bool "$cfg" persist "--persist"
+       append_bool "$cfg" cache "--cache"
+       append_string "$cfg" pidfile "--pidfile"
+       service_start /usr/bin/pand $args
+}
+
+start() {
+       config_load bluetooth
+       config_foreach hcid_config hcid
+       config_foreach hciattach_config hciattach
+       config_foreach rfcomm_config rfcomm
+       config_foreach dund_config dund
+       config_foreach pand_config pand
+}
+
+stop() {
+       service_stop /usr/bin/dund
+       service_stop /usr/bin/pand
+       /usr/bin/rfcomm release all
+       service_stop /usr/sbin/hciattach
+       service_stop /usr/sbin/hcid
+}
diff --git a/utils/bluez/files/givepin b/utils/bluez/files/givepin
new file mode 100644 (file)
index 0000000..e52a338
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# Write bluetooth PIN number here:
+pin=
+
+if [ -z "$pin" ]; then
+       msg="Set bluetooth PIN in file $0"
+       logger -p user.err "$msg"
+       for i in /dev/pts/* ; do
+               [ -w $i ] && echo "$msg" > $i
+       done
+else
+       echo "PIN:$pin"
+fi
diff --git a/utils/bluez/patches/200-uart-speed.patch b/utils/bluez/patches/200-uart-speed.patch
new file mode 100644 (file)
index 0000000..ebe0153
--- /dev/null
@@ -0,0 +1,40 @@
+--- a/tools/hciattach.c
++++ b/tools/hciattach.c
+@@ -101,20 +101,37 @@ int uart_speed(int s)
+               return B230400;
+       case 460800:
+               return B460800;
++/* FIX: Not all platform support this high serial speed
++   claudyus84 @gamil.com
++*/
++#ifdef B500000
+       case 500000:
+               return B500000;
++#endif
++#ifdef B576000
+       case 576000:
+               return B576000;
++#endif
++#ifdef B921600
+       case 921600:
+               return B921600;
++#endif
++#ifdef B1000000
+       case 1000000:
+               return B1000000;
++#endif
++#ifdef B1152000
+       case 1152000:
+               return B1152000;
++#endif
++#ifdef B1500000
+       case 1500000:
+               return B1500000;
++#endif
++#ifdef B2000000
+       case 2000000:
+               return B2000000;
++#endif
+ #ifdef B2500000
+       case 2500000:
+               return B2500000;
diff --git a/utils/bluez/patches/201-readline.patch b/utils/bluez/patches/201-readline.patch
new file mode 100644 (file)
index 0000000..9d5bec0
--- /dev/null
@@ -0,0 +1,43 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -2038,7 +2038,7 @@ unit_tests = $(am__append_32) unit/test-
+ @CLIENT_TRUE@                                 monitor/uuid.h monitor/uuid.c
+ @CLIENT_TRUE@client_bluetoothctl_LDADD = gdbus/libgdbus-internal.la @GLIB_LIBS@ @DBUS_LIBS@ \
+-@CLIENT_TRUE@                         -lreadline
++@CLIENT_TRUE@                         -lreadline -lncurses
+ @MONITOR_TRUE@monitor_btmon_SOURCES = monitor/main.c monitor/bt.h \
+ @MONITOR_TRUE@                                monitor/display.h monitor/display.c \
+@@ -2245,13 +2245,13 @@ unit_tests = $(am__append_32) unit/test-
+ @READLINE_TRUE@                               client/display.h
+ @READLINE_TRUE@attrib_gatttool_LDADD = lib/libbluetooth-internal.la \
+-@READLINE_TRUE@                       src/libshared-glib.la @GLIB_LIBS@ -lreadline
++@READLINE_TRUE@                       src/libshared-glib.la @GLIB_LIBS@ -lreadline -lncurses
+ @READLINE_TRUE@tools_obex_client_tool_SOURCES = $(gobex_sources) $(btio_sources) \
+ @READLINE_TRUE@                                               tools/obex-client-tool.c
+ @READLINE_TRUE@tools_obex_client_tool_LDADD = lib/libbluetooth-internal.la \
+-@READLINE_TRUE@                                               @GLIB_LIBS@ -lreadline
++@READLINE_TRUE@                                               @GLIB_LIBS@ -lreadline -lncurses
+ @READLINE_TRUE@tools_obex_server_tool_SOURCES = $(gobex_sources) $(btio_sources) \
+ @READLINE_TRUE@                                               tools/obex-server-tool.c
+@@ -2261,13 +2261,13 @@ unit_tests = $(am__append_32) unit/test-
+ @READLINE_TRUE@                               client/display.h client/display.c
+ @READLINE_TRUE@tools_bluetooth_player_LDADD = gdbus/libgdbus-internal.la \
+-@READLINE_TRUE@                               @GLIB_LIBS@ @DBUS_LIBS@ -lreadline
++@READLINE_TRUE@                               @GLIB_LIBS@ @DBUS_LIBS@ -lreadline -lncurses
+ @READLINE_TRUE@tools_obexctl_SOURCES = tools/obexctl.c \
+ @READLINE_TRUE@                               client/display.h client/display.c
+ @READLINE_TRUE@tools_obexctl_LDADD = gdbus/libgdbus-internal.la \
+-@READLINE_TRUE@                               @GLIB_LIBS@ @DBUS_LIBS@ -lreadline
++@READLINE_TRUE@                               @GLIB_LIBS@ @DBUS_LIBS@ -lreadline -lncurses
+ @EXPERIMENTAL_TRUE@tools_gatt_service_SOURCES = tools/gatt-service.c
+ @EXPERIMENTAL_TRUE@tools_gatt_service_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ gdbus/libgdbus-internal.la