Armadillo
Armadillo-Box WS1/BLE Gateway

BLE Support

Based upon a Japanese blog “Try the newest bluez on Armadillo-IoT,” this article explains how to add Bluetooth Low Energy support.

Bluetooth adapter used here is Logitec LBT-UAN04C2BK, which is a Bluetooth 4.0 support USB adapter (Sold in Japan).

Customizing Kernel

Specify “vender/Product” by make menuconfig

(AtmarkTechno) Vendor
(Armadillo-Box WS1) AtmarkTechno Products


Make Bluetooth effective by putting check marks on the certain parts of Linux Kernel Configuration. Please look at right below for the details. Linux Kernel Configuration

[*] Networking support  ---> 
--- Bluetooth subsystem support
    <*>   RFCOMM protocol support     &#12288;<-- Mark it for being effective
    [*]     RFCOMM TTY support    &#12288;    <-- Mark it for being effective
    <*>   BNEP protocol support         <-- Mark it for being effective
    [*]     Multicast filter support    <-- Mark it for being effective
    [*]     Protocol filter support     <-- Mark it for being effective
    <*>   HIDP protocol support         <-- Mark it for being effective
    Bluetooth device drivers  --->
        <*> HCI USB driver              <-- Mark it for being effective

Configuration of UserLand

At this time, Java is not used. Since Java generally occupies a lot space in UserLand, Java is NOT included. Since atmark dist is deployed at ramfs, please remove other unnecessary applications and files, using “make menuconfig.” (Available memory will increase if unneeded applications and files are removed as many as possible.)

atmark@atde5:~/atmark-dist$ make menuconfig
 
Userland Configuration
Miscellaneous Applications  --->
[ ] java &#12288;<-- Remove check mark

Cross compile for Bluez

Build Bluez.
Down load the source code of Bluez and extract it. (As of November 15, 2015, the newest version is 5.36.)

atmark@atde5:~$ wget https://www.kernel.org/pub/linux/bluetooth/bluez-5.36.tar.xz
atmark@atde5:~$ tar Jxf bluez-5.36.tar.xz


Install the local packages of libical to ATDES.

atmark@atde5:~$ wget http://ftp.jp.debian.org/debian/pool/main/libi/libical/libical0_0.48-2_armel.deb
atmark@atde5:~$ dpkg-cross  -v --build --arch armel libical0_0.48-2_armel.deb
atmark@atde5:~$ sudo dpkg -i libical0-armel-cross_0.48-2_all.deb
atmark@atde5:~$ wget http://ftp.jp.debian.org/debian/pool/main/libi/libical/libical-dev_0.48-2_armel.deb
atmark@atde5:~$ dpkg-cross  -v --build --arch armel libical-dev_0.48-2_armel.deb
atmark@atde5:~$ sudo dpkg -i libical-dev-armel-cross_0.48-2_all.deb


Execute configure.

atmark@atde5:~$ cd bluez-5.36/
atmark@atde5:~/bluez-5.36$ ./configure --build=i686 --host=arm-linux-gnueabi --enable-threads --enable-library \
                          --disable-udev --disable-systemd --prefix=/usr


Execute make.

atmark@atde5:~/bluez-5.36$ make


Execute make install, and install it to ROM image directory of atmark dist.

atmark@atde5:~/bluez-5.36$ make install DESTDIR=/home/atmark/atmark-dist/romfs/


Remove unnecessary files such as documents.

atmark@atde5:~/bluez-5.36$ rm -rf /home/atmark/atmark-dist/romfs/usr/share/man/


Manually install gatttool, which is not installed by make install.

atmark@atde5:~/bluez-5.36$ cp attrib/gatttool /home/atmark/atmark-dist/romfs/usr/bin/

Installing D-bus

Download D-bus deb package.

atmark@atde5:~/bluez-5.36$ cd 
atmark@atde5:~$ wget http://ftp.gnome.org/mirror/cdimage/snapshot/Debian/pool/main/d/dbus/dbus_1.6.8-1+deb7u1_armel.deb


Extract D-bus deb package in ROM image directory of atmark dist.

atmark@atde5:~$ rm -rf atmark-dist/romfs/usr/share/doc
atmark@atde5:~$ rm -rf atmark-dist/romfs/usr/share/man


Including init-funcions, which D-bus package is depending, extract lsb-base deb package in ROM image directory of atmark dist. Then, remove unnecessary documents.

atmark@atde5:~$ wget http://ftp.jp.debian.org/debian/pool/main/l/lsb/lsb-base_4.1+Debian8+deb7u1_all.deb
atmark@atde5:~$ dpkg -x lsb-base_4.1+Debian8+deb7u1_all.deb atmark-dist/romfs/
atmark@atde5:~$ rm -rf atmark-dist/romfs/usr/share/doc


Add user/group, which execute D-sub daemon.

Recreating image

Complete the process so far, add BLE to Kernel and UserLand. Now, create the images of those Kernel and UserLand, which include BLE supports.

atmark@atde5:~$ cd atmark-dist
atmark@atde5:~/atmark-dist$ make romfs
atmark@atde5:~/atmark-dist$ make image

Please make sure that the files, which are located at the below atmark-dist/images/, are updated.

Checking operation

Please rewrite Kernel and UserLand to newly created ones. To rewrite the images, please follows the directions, which is explained in this page (written in Japanese). This method is the fastest way to rewrite the images if Armadillo-Box WS1 is connected to a netowrk.

hermit> tftpdl 192.168.0.90 192.168.0.164 --blksize=1024 –kernel=linux.bin.gz
hermit> tftpdl 192.168.0.90 192.168.0.164 --blksize=1024 –userland=romfs.img.gz


The status of hci0 is automatically set to up.
(Configurations of dbus start and bluetooth start are NOT required.)

Check the current status of BLE support.

code>
Doing scan around the neighborhood, look for BLE devices, which are currently in advertise.

code>
Doing scan correctly, obtain the list.
Using gatttool, connect one of the devices in the list by interactive mode.

[root@abws1-0 (ttymxc1) ~]# gatttool -i hci0 -b D9:9E:B9:CE:47:FD -t random -I
[D9:9E:B9:CE:47:FD][LE]> connect
Attempting to connect to D9:9E:B9:CE:47:FD
Connection successful
[D9:9E:B9:CE:47:FD][LE]> help
help                                           Show this help
exit                                           Exit interactive mode
quit                                           Exit interactive mode
connect         [address [address type]]       Connect to a remote device
disconnect                                     Disconnect from a remote device
primary         [UUID]                         Primary Service Discovery
included        [start hnd [end hnd]]          Find Included Services
characteristics [start hnd [end hnd [UUID]]]   Characteristics Discovery
char-desc       [start hnd] [end hnd]          Characteristics Descriptor Discovery
char-read-hnd   <handle>                       Characteristics Value/Descriptor Read by handle
char-read-uuid  <UUID> [start hnd] [end hnd]   Characteristics Value/Descriptor Read by UUID
char-write-req  <handle> <new value>           Characteristic Value Write (Write Request)
char-write-cmd  <handle> <new value>           Characteristic Value Write (No response)
sec-level       [low | medium | high]          Set security level. Default: low
mtu             <value>                        Exchange MTU for GATT/ATT
[D9:9E:B9:CE:47:FD][LE]> primary
attr handle: 0x0001, end grp handle: 0x0007 uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x0008, end grp handle: 0x0008 uuid: 00001801-0000-1000-8000-00805f9b34fb
attr handle: 0x0009, end grp handle: 0x000b uuid: 0000bc00-0000-1000-8000-00805f9b34fb
attr handle: 0x000c, end grp handle: 0xffff uuid: bc000020-227d-902f-c2a8-0eb884017953
[D9:9E:B9:CE:47:FD][LE]>quit
[root@abws1-0 (ttymxc1) ~]#

Then, successfully read the primary service information.

Revision History


Front page   New List of pages Search Recent changes   RSS of recent changes