I have bluez-4.101 running now and it can see Bluetooth Low Energy devices..

root@OpenWrt:/usr/sbin# hcitool lescan
LE Scan ...
3C:2D:B7:84:99:86 ThermometerSensor
root@OpenWrt:/usr/sbin#

------------------------------------------

Why BTLE in a router? It provides an always-on place for a BTLE device
to dump data too. For example a pedometer or heart rate monitor. Any
time you are within in range of the router the device can
transparently dump data to the Internet.

Easy to add the BTLE hardware. Stick a $5 BTLE USB stick into the
router's USB port (if it has one).

----------------------------------------------------

This does most of the work. The init scripts aren't right yet and I am
starting things manually.
Basically just upgrade some packages.

diff --git a/feeds/packages/libs/glib2/Makefile
b/feeds/packages/libs/glib2/Makefile
index 21a7426..f402556 100644
--- a/feeds/packages/libs/glib2/Makefile
+++ b/feeds/packages/libs/glib2/Makefile
@@ -8,17 +8,17 @@
 include $(TOPDIR)/rules.mk

 PKG_NAME:=glib2
-PKG_VERSION:=2.26.1
-PKG_RELEASE:=3
+PKG_VERSION:=2.34.0
+PKG_RELEASE:=4

-PKG_SOURCE:=glib-$(PKG_VERSION).tar.bz2
+PKG_SOURCE:=glib-$(PKG_VERSION).tar.xz
 PKG_BUILD_DIR:=$(BUILD_DIR)/glib-$(PKG_VERSION)
-PKG_SOURCE_URL:=@GNOME/glib/2.26
-PKG_MD5SUM:=17535accceef55bcb17a74d73f9c2aef
+PKG_SOURCE_URL:=@GNOME/glib/2.34
+PKG_MD5SUM:=d80aef668f981b5dcf157633d13081c0

 PKG_FIXUP:=autoreconf
-PKG_BUILD_DEPENDS:=glib2/host libpthread zlib libintl
-HOST_BUILD_DEPENDS:=gettext/host libiconv/host
+PKG_BUILD_DEPENDS:=glib2/host libpthread zlib libintl libffi
+HOST_BUILD_DEPENDS:=gettext/host libiconv/host libffi/host dbus/host
 PKG_INSTALL:=1

 HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/glib-$(PKG_VERSION)
@@ -30,7 +30,7 @@ include $(INCLUDE_DIR)/nls.mk
 define Package/glib2
   SECTION:=libs
   CATEGORY:=Libraries
-  DEPENDS:=$(ICONV_DEPENDS) $(INTL_DEPENDS) +zlib +libpthread
+  DEPENDS:=$(ICONV_DEPENDS) $(INTL_DEPENDS) +zlib +libpthread +libffi
   TITLE:=glib 2.0
   URL:=http://www.gtk.org/
 endef
diff --git a/feeds/packages/libs/libffi/Makefile
b/feeds/packages/libs/libffi/Makefile
index e6bd7a6..0817ee4 100644
--- a/feeds/packages/libs/libffi/Makefile
+++ b/feeds/packages/libs/libffi/Makefile
@@ -19,6 +19,7 @@ PKG_FIXUP:=autoreconf
 PKG_INSTALL:=1

 include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk

 define Package/libffi
   SECTION:=libs
@@ -71,4 +72,5 @@ define Package/libffi/install
                $(1)/usr/lib/
 endef

+$(eval $(call HostBuild))
 $(eval $(call BuildPackage,libffi))
diff --git a/feeds/packages/utils/bluez/Makefile
b/feeds/packages/utils/bluez/Makefile
new file mode 100644
index 0000000..a3ce434
--- /dev/null
+++ b/feeds/packages/utils/bluez/Makefile
@@ -0,0 +1,82 @@
+#
+# Copyright (C) 2006-2012 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:=4.101
+PKG_RELEASE:=13
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.kernel.org/pub/linux/bluetooth/
+PKG_MD5SUM:=fb42cb7038c380eb0e2fa208987c96ad
+
+PKG_FIXUP:=autoreconf
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/nls.mk
+
+define Package/bluez
+  SECTION:=utils
+  CATEGORY:=Utilities
+  DEPENDS:=+bluez-libs +libpthread +glib2 +dbus $(INTL_DEPENDS)
$(ICONV_DEPENDS)
+  TITLE:=Bluetooth utilities
+  URL:=http://www.bluez.org/
+endef
+
+define Package/bluez/conffiles
+/etc/bluetooth/hcid.conf
+/etc/bluetooth/rfcomm.conf
+/etc/config/bluetooth
+endef
+
+CONFIGURE_ARGS += \
+       --disable-glib \
+       --enable-pand \
+       --enable-rfcomm \
+       --enable-dund \
+       --enable-serial \
+       --enable-network \
+       --enable-usb \
+       --enable-input \
+       --disable-audio \
+       --enable-health \
+       --enable-tools \
+       --enable-bccmd \
+       --enable-dfutool \
+       --enable-hid2hci \
+       --enable-test \
+       --enable-dbusoob \
+       --enable-gatt \
+       --with-bluez="$(STAGING_DIR)/usr/include" \
+       --with-usb=yes \
+
+define Build/Compile
+       $(MAKE) -C $(PKG_BUILD_DIR) \
+               LDFLAGS="$(TARGET_LDFLAGS) \
+                       -L$(ICONV_PREFIX)/lib \
+                       -L$(INTL_PREFIX)/lib -lm" \
+               DESTDIR="$(PKG_INSTALL_DIR)" \
+               all install
+endef
+
+define Package/bluez/install
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(CP) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin/
+       $(INSTALL_DIR) $(1)/usr/sbin
+       $(CP) $(PKG_INSTALL_DIR)/usr/sbin/* $(1)/usr/sbin/
+       $(INSTALL_DIR) $(1)/etc/bluetooth
+       $(CP) $(PKG_INSTALL_DIR)/etc/bluetooth/rfcomm.conf $(1)/etc/bluetooth/
+       $(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.init $(1)/etc/init.d/bluez
+endef
+
+$(eval $(call BuildPackage,bluez))
diff --git a/feeds/packages/utils/bluez/files/bluetooth.config
b/feeds/packages/utils/bluez/files/bluetooth.config
new file mode 100644
index 0000000..42f390c
--- /dev/null
+++ b/feeds/packages/utils/bluez/files/bluetooth.config
@@ -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/feeds/packages/utils/bluez/files/bluetooth.dbus
b/feeds/packages/utils/bluez/files/bluetooth.dbus
new file mode 100644
index 0000000..88545fa
--- /dev/null
+++ b/feeds/packages/utils/bluez/files/bluetooth.dbus
@@ -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/feeds/packages/utils/bluez/files/bluez.init
b/feeds/packages/utils/bluez/files/bluez.init
new file mode 100644
index 0000000..e9320ae
--- /dev/null
+++ b/feeds/packages/utils/bluez/files/bluez.init
@@ -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/feeds/packages/utils/bluez/files/givepin
b/feeds/packages/utils/bluez/files/givepin
new file mode 100644
index 0000000..e52a338
--- /dev/null
+++ b/feeds/packages/utils/bluez/files/givepin
@@ -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/feeds/packages/utils/dbus/Makefile
b/feeds/packages/utils/dbus/Makefile
index acaac2c..2dc7ab3 100644
--- a/feeds/packages/utils/dbus/Makefile
+++ b/feeds/packages/utils/dbus/Makefile
@@ -20,6 +20,7 @@ PKG_FIXUP:=autoreconf
 PKG_INSTALL:=1

 include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk

 TARGET_LDFLAGS+= \
        -Wl,-rpath-link=$(STAGING_DIR)/usr/lib \
@@ -182,6 +183,7 @@ define Package/dbus-utils/install
                $(1)/usr/bin/
 endef

+$(eval $(call HostBuild))
 $(eval $(call BuildPackage,libdbus))
 $(eval $(call BuildPackage,dbus))
 $(eval $(call BuildPackage,dbus-utils))


-- 
Jon Smirl
[email protected]
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to