瀏覽代碼

bluez: add new package

This merges & obsoletes bluez-libs & bluez-utils from old packages feed.

Signed-off-by: Nicolas Thill <nico@openwrt.org>
Nicolas Thill 10 年之前
父節點
當前提交
26725ee8a9

+ 91
- 0
utils/bluez/Makefile 查看文件

@@ -0,0 +1,91 @@
1
+#
2
+# Copyright (C) 2006-2015 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=bluez
11
+PKG_VERSION:=5.27
12
+PKG_RELEASE:=1
13
+
14
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
15
+PKG_SOURCE_URL:=http://www.kernel.org/pub/linux/bluetooth/
16
+PKG_MD5SUM:=a8fc508690e497e88c2c0b373cd653a8
17
+
18
+PKG_LICENSE:=GPL-2.0
19
+PKG_LICENSE_FILES:=COPYING
20
+PKG_MAINTAINER:=Nicolas Thill <nico@openwrt.org>
21
+
22
+PKG_INSTALL:=1
23
+
24
+include $(INCLUDE_DIR)/package.mk
25
+include $(INCLUDE_DIR)/nls.mk
26
+
27
+define Package/bluez/Default
28
+  TITLE:=Bluetooth
29
+  URL:=http://www.bluez.org/
30
+endef
31
+
32
+define Package/bluez-libs
33
+$(call Package/bluez/Default)
34
+  SECTION:=libs
35
+  CATEGORY:=Libraries
36
+  TITLE+= library
37
+  DEPENDS:=+libpthread
38
+endef
39
+
40
+define Package/bluez-utils
41
+$(call Package/bluez/Default)
42
+  SECTION:=utils
43
+  CATEGORY:=Utilities
44
+  TITLE+= utilities
45
+  DEPENDS:=+bluez-libs +libpthread +dbus +glib2 +libical +libncurses +libreadline $(INTL_DEPENDS) $(ICONV_DEPENDS)
46
+endef
47
+
48
+define Package/bluez-utils/conffiles
49
+/etc/bluetooth/hcid.conf
50
+/etc/bluetooth/rfcomm.conf
51
+/etc/config/bluetooth
52
+endef
53
+
54
+CONFIGURE_ARGS += \
55
+	--enable-client \
56
+	--enable-datafiles \
57
+	--enable-experimental \
58
+	--enable-library \
59
+	--enable-monitor \
60
+	--enable-obex \
61
+	--enable-threads \
62
+	--enable-tools \
63
+	--disable-android \
64
+	--disable-cups \
65
+	--disable-manpages \
66
+	--disable-sixaxis \
67
+	--disable-systemd \
68
+	--disable-test \
69
+	--disable-udev \
70
+
71
+TARGET_CPPFLAGS += \
72
+	-D_GNU_SOURCE
73
+
74
+define Package/bluez-libs/install
75
+	$(INSTALL_DIR) $(1)/usr/lib
76
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libbluetooth.so.* $(1)/usr/lib/
77
+endef
78
+
79
+define Package/bluez-utils/install
80
+	$(INSTALL_DIR) $(1)/usr/bin
81
+	$(CP) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin/
82
+	$(INSTALL_DIR) $(1)/etc/config
83
+	$(INSTALL_DATA) ./files/bluetooth.config $(1)/etc/config/bluetooth
84
+	$(INSTALL_DIR) $(1)/etc/dbus-1/system.d/
85
+	$(INSTALL_DATA) ./files/bluetooth.dbus $(1)/etc/dbus-1/system.d/bluetooth.conf
86
+	$(INSTALL_DIR) $(1)/etc/init.d
87
+	$(INSTALL_BIN) ./files/bluez-utils.init $(1)/etc/init.d/bluez-utils
88
+endef
89
+
90
+$(eval $(call BuildPackage,bluez-libs))
91
+$(eval $(call BuildPackage,bluez-utils))

+ 32
- 0
utils/bluez/files/bluetooth.config 查看文件

@@ -0,0 +1,32 @@
1
+config hcid
2
+#	option config	/etc/bluetooth/hcid.conf
3
+	option enabled	1
4
+
5
+config hciattach
6
+	option initspeed	115200
7
+	option tty	ttyS1
8
+	option type	csr
9
+	option speed	115200
10
+	option flow	noflow
11
+	option enabled 	0
12
+
13
+config rfcomm
14
+#	option config	/etc/bluetooth/rfcomm.conf
15
+	option enabled	0
16
+
17
+config dund
18
+	option listen	true
19
+	option persist	true
20
+	option msdun	true
21
+	option interface dund
22
+	option unit	1
23
+	option pppdopts	"ktune proxyarp 192.168.1.1:192.168.1.2 ms-dns 192.168.1.1"
24
+	option enabled	0
25
+
26
+config pand
27
+	option listen	true
28
+	option autozap	true
29
+	option role	"NAP"
30
+	option master	true
31
+	option persist	true
32
+	option enabled	0

+ 37
- 0
utils/bluez/files/bluetooth.dbus 查看文件

@@ -0,0 +1,37 @@
1
+<!-- This configuration file specifies the required security policies
2
+     for Bluetooth core daemon to work. -->
3
+
4
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
5
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
6
+<busconfig>
7
+
8
+  <!-- ../system.conf have denied everything, so we just punch some holes -->
9
+
10
+  <policy user="root">
11
+    <allow own="org.bluez"/>
12
+  </policy>
13
+
14
+  <policy at_console="true">
15
+    <allow send_path="/"/>
16
+    <allow send_path="/org/bluez"/>
17
+
18
+    <allow send_destination="org.bluez.Manager"/>
19
+    <allow receive_sender="org.bluez.Manager"/>
20
+
21
+    <allow send_destination="org.bluez.Adapter"/>
22
+    <allow receive_sender="org.bluez.Adapter"/>
23
+
24
+    <allow send_destination="org.bluez.Device"/>
25
+    <allow receive_sender="org.bluez.Device"/>
26
+
27
+    <allow send_destination="org.bluez.Service"/>
28
+    <allow receive_sender="org.bluez.Service"/>
29
+
30
+    <allow send_destination="org.bluez.Database"/>
31
+    <allow receive_sender="org.bluez.Database"/>
32
+
33
+    <allow send_destination="org.bluez.Security"/>
34
+    <allow receive_sender="org.bluez.Security"/>
35
+  </policy>
36
+
37
+</busconfig>

+ 131
- 0
utils/bluez/files/bluez-utils.init 查看文件

@@ -0,0 +1,131 @@
1
+#!/bin/sh /etc/rc.common
2
+# Copyright (C) 2007 OpenWrt.org
3
+
4
+#start after dbus (60)
5
+START=62
6
+
7
+append_bool() {
8
+	local section="$1"
9
+	local option="$2"
10
+	local value="$3"
11
+	local _val
12
+	config_get_bool _val "$section" "$option" '0'
13
+	[ $_val -gt 0 ] && append args "$3"
14
+}
15
+
16
+append_string() {
17
+	local section="$1"
18
+	local option="$2"
19
+	local value="$3"
20
+	local default="$4"
21
+	local _val
22
+	config_get _val "$section" "$option" "$default"
23
+	[ -n "$_val" ] && append args "$3 $_val"
24
+}
25
+
26
+hcid_config() {
27
+	local cfg="$1"
28
+	config_get_bool enabled "$cfg" "enabled" '1'
29
+	[ $enabled -gt 0 ] || return 1
30
+	args=""
31
+	append_bool "$cfg" nodaemon "-n"
32
+	append_string "$cfg" config "-f"
33
+	service_start /usr/sbin/hcid $args
34
+}
35
+
36
+hciattach_config() {
37
+	local cfg="$1"
38
+	config_get_bool enabled "$cfg" "enabled" '1'
39
+	[ $enabled -gt 0 ] || return 1
40
+	args=""
41
+	append_string "$cfg" initspeed "-s" "115200"
42
+	append_string "$cfg" tty " " "ttyS1"
43
+	append_string "$cfg" type " " "csr"
44
+	append_string "$cfg" speed " " "115200"
45
+	append_string "$cfg" flow " " "noflow"
46
+	service_start /usr/sbin/hciattach $args
47
+}
48
+
49
+rfcomm_config() {
50
+	local cfg="$1"
51
+	config_get_bool enabled "$cfg" "enabled" '1'
52
+	[ $enabled -gt 0 ] || return 1
53
+	args=""
54
+	append_string "$cfg" config "-f"
55
+	/usr/bin/rfcomm $args bind all
56
+}
57
+
58
+dund_config() {
59
+	local cfg="$1"
60
+	config_get_bool enabled "$cfg" "enabled" '1'
61
+	[ $enabled -gt 0 ] || return 1
62
+	args=""
63
+	append_bool "$cfg" listen "--listen"
64
+	append_string "$cfg" connect "--connect"
65
+	append_string "$cfg" mrouter "--mrouter"
66
+	append_bool "$cfg" search "--search"
67
+	append_string "$cfg" channel "--channel"
68
+	append_string "$cfg" device "--device"
69
+	append_bool "$cfg" nosdp "--nosdp"
70
+	append_bool "$cfg" auth "--auth"
71
+	append_bool "$cfg" encrypt "--encrypt"
72
+	append_bool "$cfg" secure "--secure"
73
+	append_bool "$cfg" master "--master"
74
+	append_bool "$cfg" nodetach "--nodetach"
75
+	append_bool "$cfg" persist "--persist"
76
+	append_string "$cfg" pppd "--pppd"
77
+	append_bool "$cfg" msdun "--msdun"
78
+	append_bool "$cfg" activesync "--activesync"
79
+	append_bool "$cfg" cache "--cache"
80
+
81
+	append_string "$cfg" pppdopts ""
82
+	config_get ifn "$cfg" interface
83
+	if [ -n "$ifn" ]; then
84
+		config_get unit "$cfg" unit
85
+		[ -z "$unit" ] || append args "unit $unit ipparam $ifn linkname $ifn"
86
+	fi
87
+
88
+	service_start /usr/bin/dund $args
89
+}
90
+
91
+pand_config() {
92
+	local cfg="$1"
93
+	config_get_bool enabled "$cfg" "enabled" '1'
94
+	[ $enabled -gt 0 ] || return 1
95
+	args=""
96
+	append_bool "$cfg" listen "--listen"
97
+	append_string "$cfg" connect "--connect"
98
+	append_bool "$cfg" autozap "--autozap"
99
+	append_bool "$cfg" search "--search"
100
+	append_string "$cfg" role "--role"
101
+	append_string "$cfg" service "--service"
102
+	append_string "$cfg" ethernet "--ethernet"
103
+	append_string "$cfg" device "--device"
104
+	append_bool "$cfg" nosdp "-D"
105
+	append_bool "$cfg" auth "-A"
106
+	append_bool "$cfg" encrypt "-E"
107
+	append_bool "$cfg" secure "-S"
108
+	append_bool "$cfg" master "-M"
109
+	append_bool "$cfg" nodetach "-n"
110
+	append_bool "$cfg" persist "--persist"
111
+	append_bool "$cfg" cache "--cache"
112
+	append_string "$cfg" pidfile "--pidfile"
113
+	service_start /usr/bin/pand $args
114
+}
115
+
116
+start() {
117
+	config_load bluetooth
118
+	config_foreach hcid_config hcid
119
+	config_foreach hciattach_config hciattach
120
+	config_foreach rfcomm_config rfcomm
121
+	config_foreach dund_config dund
122
+	config_foreach pand_config pand
123
+}
124
+
125
+stop() {
126
+	service_stop /usr/bin/dund
127
+	service_stop /usr/bin/pand
128
+	/usr/bin/rfcomm release all
129
+	service_stop /usr/sbin/hciattach
130
+	service_stop /usr/sbin/hcid
131
+}

+ 14
- 0
utils/bluez/files/givepin 查看文件

@@ -0,0 +1,14 @@
1
+#!/bin/sh
2
+
3
+# Write bluetooth PIN number here:
4
+pin=
5
+
6
+if [ -z "$pin" ]; then
7
+	msg="Set bluetooth PIN in file $0"
8
+	logger -p user.err "$msg"
9
+	for i in /dev/pts/* ; do
10
+		[ -w $i ] && echo "$msg" > $i
11
+	done
12
+else
13
+	echo "PIN:$pin"
14
+fi

+ 40
- 0
utils/bluez/patches/200-uart-speed.patch 查看文件

@@ -0,0 +1,40 @@
1
+--- a/tools/hciattach.c
2
++++ b/tools/hciattach.c
3
+@@ -101,20 +101,37 @@ int uart_speed(int s)
4
+ 		return B230400;
5
+ 	case 460800:
6
+ 		return B460800;
7
++/* FIX: Not all platform support this high serial speed
8
++   claudyus84 @gamil.com
9
++*/
10
++#ifdef B500000
11
+ 	case 500000:
12
+ 		return B500000;
13
++#endif
14
++#ifdef B576000
15
+ 	case 576000:
16
+ 		return B576000;
17
++#endif
18
++#ifdef B921600
19
+ 	case 921600:
20
+ 		return B921600;
21
++#endif
22
++#ifdef B1000000
23
+ 	case 1000000:
24
+ 		return B1000000;
25
++#endif
26
++#ifdef B1152000
27
+ 	case 1152000:
28
+ 		return B1152000;
29
++#endif
30
++#ifdef B1500000
31
+ 	case 1500000:
32
+ 		return B1500000;
33
++#endif
34
++#ifdef B2000000
35
+ 	case 2000000:
36
+ 		return B2000000;
37
++#endif
38
+ #ifdef B2500000
39
+ 	case 2500000:
40
+ 		return B2500000;

+ 43
- 0
utils/bluez/patches/201-readline.patch 查看文件

@@ -0,0 +1,43 @@
1
+--- a/Makefile.in
2
++++ b/Makefile.in
3
+@@ -2038,7 +2038,7 @@ unit_tests = $(am__append_32) unit/test-
4
+ @CLIENT_TRUE@					monitor/uuid.h monitor/uuid.c
5
+ 
6
+ @CLIENT_TRUE@client_bluetoothctl_LDADD = gdbus/libgdbus-internal.la @GLIB_LIBS@ @DBUS_LIBS@ \
7
+-@CLIENT_TRUE@				-lreadline
8
++@CLIENT_TRUE@				-lreadline -lncurses
9
+ 
10
+ @MONITOR_TRUE@monitor_btmon_SOURCES = monitor/main.c monitor/bt.h \
11
+ @MONITOR_TRUE@				monitor/display.h monitor/display.c \
12
+@@ -2245,13 +2245,13 @@ unit_tests = $(am__append_32) unit/test-
13
+ @READLINE_TRUE@				client/display.h
14
+ 
15
+ @READLINE_TRUE@attrib_gatttool_LDADD = lib/libbluetooth-internal.la \
16
+-@READLINE_TRUE@			src/libshared-glib.la @GLIB_LIBS@ -lreadline
17
++@READLINE_TRUE@			src/libshared-glib.la @GLIB_LIBS@ -lreadline -lncurses
18
+ 
19
+ @READLINE_TRUE@tools_obex_client_tool_SOURCES = $(gobex_sources) $(btio_sources) \
20
+ @READLINE_TRUE@						tools/obex-client-tool.c
21
+ 
22
+ @READLINE_TRUE@tools_obex_client_tool_LDADD = lib/libbluetooth-internal.la \
23
+-@READLINE_TRUE@						@GLIB_LIBS@ -lreadline
24
++@READLINE_TRUE@						@GLIB_LIBS@ -lreadline -lncurses
25
+ 
26
+ @READLINE_TRUE@tools_obex_server_tool_SOURCES = $(gobex_sources) $(btio_sources) \
27
+ @READLINE_TRUE@						tools/obex-server-tool.c
28
+@@ -2261,13 +2261,13 @@ unit_tests = $(am__append_32) unit/test-
29
+ @READLINE_TRUE@				client/display.h client/display.c
30
+ 
31
+ @READLINE_TRUE@tools_bluetooth_player_LDADD = gdbus/libgdbus-internal.la \
32
+-@READLINE_TRUE@				@GLIB_LIBS@ @DBUS_LIBS@ -lreadline
33
++@READLINE_TRUE@				@GLIB_LIBS@ @DBUS_LIBS@ -lreadline -lncurses
34
+ 
35
+ @READLINE_TRUE@tools_obexctl_SOURCES = tools/obexctl.c \
36
+ @READLINE_TRUE@				client/display.h client/display.c
37
+ 
38
+ @READLINE_TRUE@tools_obexctl_LDADD = gdbus/libgdbus-internal.la \
39
+-@READLINE_TRUE@				@GLIB_LIBS@ @DBUS_LIBS@ -lreadline
40
++@READLINE_TRUE@				@GLIB_LIBS@ @DBUS_LIBS@ -lreadline -lncurses
41
+ 
42
+ @EXPERIMENTAL_TRUE@tools_gatt_service_SOURCES = tools/gatt-service.c
43
+ @EXPERIMENTAL_TRUE@tools_gatt_service_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ gdbus/libgdbus-internal.la