arduino / linino

102 stars 47 forks source link

Support for bluez bluetooth low energy #21

Closed dragom closed 10 years ago

dragom commented 10 years ago

Is it possible to upgrade bluez libraries to latest one to have support for LE? Current one looks that don't have le functions.

fibasile commented 10 years ago

Hi, I've compiled the bluez 5 and it works fine. It's quite big package and many files must be removed to fit into flash. I think I can send a pull request during the weekend.

Il giorno 08/gen/2014, alle ore 20:54, Dragoslav Mlakar notifications@github.com ha scritto:

Is it possible to upgrade bluez libraries to latest one to have support for LE? Current one looks that don't have le functions.

— Reply to this email directly or view it on GitHub.

dragom commented 10 years ago

Great!!! I'm trying to use bleno (https://github.com/sandeepmistry/bleno) on top of it. So I will also use node and npm. Probably can also use your packages?

fibasile commented 10 years ago

While I find the time for a full pull request, please find attached the Makefile i'm using for the bluez package. Just create a bluez folder into the trunk/feeds/packages/utils/ and compile it.

#
# 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:=5.11
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.kernel.org/pub/linux/bluetooth
PKG_MD5SUM:=0e3b3d3f5bf40ac7cd4df96da9aa24aa

PKG_FIXUP:=autoreconf

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/nls.mk

define Package/bluez
  SECTION:=utils
  CATEGORY:=Utilities
  DEPENDS:=+libpthread +libusb-compat +glib2 +dbus +udev $(INTL_DEPENDS) $(ICONV_DEPENDS)
  TITLE:=Bluetooth stack new version 
  URL:=http://www.bluez.org/
endef

define Package/bluez/conffiles
/etc/config/bluetooth
endef

CONFIGURE_ARGS += \
    --enable-library \
    --disable-systemd \
    --disable-monitor \
    --disable-cups \
        --disable-client \
        --disable-obex \
    --enable-usb \
    --disable-audio \
    --with-usb=yes \
    --with-udevdir="$(STAGING_DIR)/lib/udev"

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/hciconfig $(1)/usr/bin/
    $(CP) $(PKG_INSTALL_DIR)/usr/bin/hcitool $(1)/usr/bin/
endef

$(eval $(call BuildPackage,bluez))
dragom commented 10 years ago

Great! Will try. I'm just struggling to make basic build work. Will let you know when I am able to test it. https://github.com/dragom/linino

No additional patch, config files? Just Makefile?

fibasile commented 10 years ago

Yes, you need only this with the flags provided it compiles. Il 11/gen/2014 15:46 "Dragoslav Mlakar" notifications@github.com ha scritto:

Great! Will try. I'm just struggling to make basic build work. Will let you know when I am able to test it. https://github.com/dragom/linino

No additional patch, config files? Just Makefile?

— Reply to this email directly or view it on GitHubhttps://github.com/arduino/linino/issues/21#issuecomment-32097779 .

dragom commented 10 years ago

Thnx again. Will let you know how it goes. Probably will work the same also with 5.13 and appropriate PKG_MD5SUM.

Do you have any experience using bleno,noble on Yun?

dragom commented 10 years ago

It works! I am able to use Yun as ble beacon with this one http://www.amazon.co.uk/Belkin-USB-4-0-Bluetooth-Adapter/dp/B009IQB3US Now I will try to put also nodejs and bleno in action.

tigoe commented 10 years ago

Any luck getting BT Audio to work? I didn't have much luck with that.

t.

On Jan 11, 2014, at 3:53 PM, Dragoslav Mlakar notifications@github.com wrote:

It works! I am able to use Yun as ble beacon with this one http://www.amazon.co.uk/Belkin-USB-4-0-Bluetooth-Adapter/dp/B009IQB3US Now I will try to put also nodejs and bleno in action.

— Reply to this email directly or view it on GitHub.

fibasile commented 10 years ago

Personally I didn't try with audio.

Anyway, to compile audio support you need to edit bluez Makefile removing the --disable-audio flag. No idea if it compiles without errors.

fibasile commented 10 years ago

@dragom I tried to have it working as a beacon with two different dongles with no success. Can you paste the commands you are using?

dragom commented 10 years ago

@fibasile I have problems that device is recognized as bluetooth. This works with ubuntu but not on linino: /// As root: 1) Create the file: /etc/udev/rules.d/99-local-bluetooth.rules

2) Add the following line to the file: SUBSYSTEM=="usb", ATTRS{idVendor}=="050d", ATTRS{idProduct}=="065a", RUN+="/bin/sh -c 'modprobe btusb; echo 050d 065a > /sys/bus/usb/drivers/btusb/new_id'"

3) To pick up the change either Restart the udev service: /etc/init.d/udev restart or reboot //

So I manually activate when dongle is plugged in with: root@DrYun:~# hciconfig root@DrYun:~# echo 050d 065a > /sys/bus/usb/drivers/btusb/new_id root@DrYun:~# hciconfig hci0: Type: BR/EDR Bus: USB BD Address: 00:02:72:3E:1C:44 ACL MTU: 1021:8 SCO MTU: 64:1 UP RUNNING RX bytes:495 acl:0 sco:0 events:22 errors:0 TX bytes:369 acl:0 sco:0 commands:22 errors:0

root@DrYun:~# hciconfig hci0 up root@DrYun:~# hciconfig hci0 leadv

@tigoe Will try to compile with removing --disable-audio and version of bluez 5.13, publish ipk so you can try

fibasile commented 10 years ago

@dragom thx. I used a CSR 4.0 dongle and another unbranded one, both work fine on the detection phase. But none of them shows up as iBeacon. I was using the raspberry pi tutorial from radius network for that. I just saw a new tutorial from Adafruit (http://learn.adafruit.com/pibeacon-ibeacon-with-a-raspberry-pi), so I'll try again. Looks like issuing hciconfig hci0 noscan after your last command should do it.

dragom commented 10 years ago

@tigoe https://github.com/dragom/linino/releases/tag/bluez513

fibasile commented 10 years ago

Great, I can confirm iBeacon is now working using your latest ipk build and the adafruit tutorial linked above.

The dongle is an IOGear bluetooth 4.0 adapter (http://www.iogear.com/product/GBU521/)

dragom commented 10 years ago

@fibasile How do you make that system recognize adapter as bluetooth device? This do not work for me : SUBSYSTEM=="usb", ATTRS{idVendor}=="050d", ATTRS{idProduct}=="065a", RUN+="/bin/sh -c 'modprobe btusb; echo 050d 065a > /sys/bus/usb/drivers/btusb/new_id'"

fibasile commented 10 years ago

I just installed kmod-bluetooth ipk and plugged the device. Modprobe stuff should be long gone in these recent versions of linux.

2014/1/12 Dragoslav Mlakar notifications@github.com

@fibasile https://github.com/fibasile How do you make that system recognize adapter as bluetooth device? This do not work for me :

SUBSYSTEM=="usb", ATTRS{idVendor}=="050d", ATTRS{idProduct}=="065a", RUN+="/bin/sh -c 'modprobe btusb; echo 050d 065a > /sys/bus/usb/drivers/btusb/new_id'"

Reply to this email directly or view it on GitHubhttps://github.com/arduino/linino/issues/21#issuecomment-32130217 .

Fiore Basile Mobile. +39 3284576081 Email. fiore.basile@gmail.com Twitter. @fibasile