With the help of a Bluetooh 4.0 USB module, we can turn pcDuino into a bluetooth 4.0 BLE beacon device.
We follow Adafruit’s nice tutorial that was created for Raspberry pi. However, if we follow the steps, it works perfectly on pcDuino.
1. Setting up pcDuino
The follows are the steps need to be setup on pcDuino.
1. Install dependency libraries.
$sudo apt-get install libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev
2. Download Bluez
$sudo mkdir bluez $cd bluez $sudo wget www.kernel.org/pub/linux/bluetooth/bluez-5.11.tar.xz
3. Compile and install Bluez
$sudo unxz bluez-5.11.tar.xz $sudo tar xvf bluez-5.11.tar $cd bluez-5.11 $sudo ./configure --disable-systemd $sudo make $sudo make install
4. Plug in Bluetooth USB dongle
After we finish the installation of Bluez, we can plug in the bluetooth 4.0 USB dongle and reset pcDuino.
2. Setting up broadcasting of Beacon
1. Check if the Bluetooth 4.0 USB dongle is recognized or not
We use the command ‘$tools/hciconfigure’ to check. If Bluetooth 4.0 USB dongle is recognized correctly, the following is the output:
2. Enable Bluetooth 4.0 USB Dongle
From the above screen, we can see that the USB dongle status is ‘DOWN’. We can issue the following commands to able it.
$sudo tools/hciconfig hciO up $sudo tools/hciconfig hci0 leadv $sudo tools/hciconfig hci0 noscan
We can see the status of the bluetooth USB dongle has been changed to ‘UP RUNNING’.
3. Broadcasting Beacon date
We can use the following command to issue beacon data:
$sudo tools/hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 E2 0A 39 F4 73 F5 4B C4 A1 2F 17 D1 AD 07 A9 61 00 00 00 00 C8 00
FF identifies the start of the Manufacturer Specific Data, 4C 00 is Apple’s company ID (0x004C), and then you can see the rest of the Beacon payload until C8
If we install ‘Beacon toolkit’ from apple store, we can see pcDuino is broadcasting beacon: