I recently was trying to configure ibeacon on a BLE dongle (cambridge silicon radio) on a raspberry pi.
Reference: http://developer.radiusnetworks.com/2013/10/09/how-to-make-an-ibeacon-out-of-a-raspberry-pi.html
I get this message :
HCI Command: ogf 0x08, ocf 0x0008, plen 44
1E 02 01 1A 1A FF 4C 00 02 15 E2 C5 6D B5 DF FB 48 D2 B0 60
D0 F5 A7 10 96 E0 00 00 00 00 C9 00 00 00 00 00 00 00 00 00
00 00 00 00
> HCI Event: 0x0e plen 4
01 08 20 12
And the app does not even locate the beacon. Though I can see the dongle flashing some light on this command:
sudo hciconfig hci0 leadv 0
But nothing gets detected.
So go an APP named LIGHTBLUE from the appstore and it detects the bluetooth with a different UUID.
I have tried this a number of times now. And have completed all the steps in the tutorial. But this bluetooth device just wont show up.
Also, I am curious to know what is 0x08 and 0x0008
and if I want to cast a different UUID what should I do? But thats a later part...
Right now, THE BLUETOOTH wont cast the Estimote UUID as said by Radius Networks' tutorial.
Hope to receive some reply soon.
Command I wrote (after this not working I changed the power to C9):
$ sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 00 00 00 00 c5 00 00 00 00 00 00 00 00 00 00 00 00 00
and surprisingly, the error is: Error: Invalid HCI Command Parameters;
How come its invalid?
Is it because CSR supports 128bit rather than 64bit hex?
Thanks!
I saw the same issue as memoryhole where I had to remove the extra zeros.
I also had to enable advertising before I configured the advertising data for it to work properly with my dongle.
Here is the exact sequence/commands that worked for me:
sudo hciconfig hci0 up
sudo hciconfig hci0 leadv 3
sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 00 00 00 00 c5 00
This is what my version of the Radius script ended up looking like:
#!/bin/sh
. ./ibeacon.conf
echo "Launching virtual iBeacon..."
sudo hciconfig $BLUETOOTH_DEVICE up
sudo hciconfig $BLUETOOTH_DEVICE leadv 3
sudo hcitool -i $BLUETOOTH_DEVICE cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 $UUID $MAJOR $MINOR $POWER 00
echo "Complete"
This was on a Rasberry Pi with a ORICO BTA-402-BK branded BLE dongle (CSR8510 A10)
(I would have left this as a comment, but didn't have enough rep)
I also have a CSR based USB Dongle bought in Hong Kong. I got the LE Set Advertising Data command to work by removing the extra padding at the end. According to the Bluetooth 4.0 Specification the data field should be 31 octets long. I'm not sure why the Radius Networks tutorial adds the extra zeroes. Try this:
$ sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 00 00 00 00 c5 00
Note: I didn't run this on a Raspberry Pi, but an Ubuntu 12.04 laptop with bluez-4.98.
I bought a few of these from amazon:
http://www.amazon.de/CSL-Bluetooth-Adapter-Technologie-neuester-Standard/dp/B00C68IQ3C
and did not get it to work in the beginning following the Radius tut. Running hcidump in another window showed an error message when giving the hcitool command:
> HCI Event: Command Complete (0x0e) plen 4
LE Set Advertising Data (0x08|0x0008) ncmd 1
status 0x12
Error: Invalid HCI Command Parameters
After removing the extra 00's at the end of the hcitool command, it worked. My config file is:
export BLUETOOTH_DEVICE=hci0
# E2C56DB5-DFFB-48D2-B060-D0F5A71096E0
# export UUID="e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0"
export UUID="92 77 83 0A B2 EB 49 0F A1 DD 7F E3 8C 49 2E DE"
export MAJOR="00 00"
export MINOR="00 00"
export POWER="C5 00"
note the extra 00 in POWER! this extra 00 is important.
My beaconstart script is:
#!/bin/sh
. ./ibeacon.conf
echo "Launching virtual iBeacon..."
sudo hciconfig $BLUETOOTH_DEVICE up
sudo hciconfig $BLUETOOTH_DEVICE noleadv
sudo hciconfig hci0 noscan
sudo hciconfig $BLUETOOTH_DEVICE leadv 3
sudo hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 $UUID $MAJOR $MINOR $POWER
# sudo hciconfig $BLUETOOTH_DEVICE leadv 3
echo "Complete"
While try-and-erroring I also added the noscan and put the leadv 3 in FRONT of the hcitool command. But only after removing the extra 00s it started to work.
HCI Event: 0x0e plen 4 01 08 20 12
translate into: set advertising data command has finished running with error 0x12 "Invalid HCI Command Parameters"
ogf 0x08, ocf 0x0008 is the command to set the advertising packet's data, so you change the arguments to that command to modify the UUID. You want to change the part of the string of hex that corresponds to the UUID. Notice this:
sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15
e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 00 00 00 00 c5 00 00 00 00 00 00 00 00 00 00 00 00 00
iBeacon broadcasting Profile UUID
E2C56DB5-DFFB-48D2-B060-D0F5A71096E0 with a major of 0 and a minor of 0
Are you sure you have a Bluetooth 4.0 dongle? What's the exact command you typed in? (cut-n-copy it into your question)
Unfortunately, you need a different bluetooth dongle. There have been other reports of the CSR not working with the Bluez stack on the Raspberry Pi for iBeacon advertising. See here and here
I have verified the command you have above does not give an error when using the recommended IOGear GBU521.
I was successful with a Raspberry Pi and a Inateck csr4b5 BT Dongle which should contain CRS 8510. By complying to the BT specs 31 octets length just like memoryhole said and omitting the extra 00 octets at the end it worked.
Edit: Also worked with a Pearl Dongle Model PX-1632-675 and a CSL USB Bluetooth Nano Dongle CSL-Nr. 23996
Give it a try.
Cheers
Related
I want to use my computer as an iBeacon, and I don't succeed (On a Ubuntu 14.04 running in a virtualBox environement on Windows 8.1)
Here is the code I use
#!/bin/bash
sudo hciconfig hci0 up
sudo hciconfig hci0 noleadv
sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 e2 c5 6d b5 df fb 48 d2 b0 60 \
d0 f5 a7 10 96 e0 00 00 00 00 c5 00 00 00 00 00 00 00 00 00 00 00 00 00
sudo hciconfig hci0 leadv
My hciconfig result
hci0: Type: BR/EDR Bus: USB
BD Address: 00:C2:C6:18:C5:E9 ACL MTU: 310:10 SCO MTU: 64:8
UP RUNNING PSCAN ISCAN
RX bytes:5333127 acl:66 sco:0 events:887454 errors:0
TX bytes:40617442 acl:64 sco:0 commands:887224 errors:0
I have the bluez version 5.36 installed (checked with bluetoothd -v)
I have seen many Stack overflow post about this but cannot figure it out!
Check Here, Here or Here.
I have bought a real iBeacon to look about what works to help me, here is what I have:
Using hcidump -R I read this
< 01 0B 20 07 01 10 00 10 00 00 00
> 04 0E 04 01 0B 20 00
< 01 0C 20 02 01 01
> 04 0E 04 01 0C 20 00
> 04 3E 2A 02 01 00 01 4F 00 00 02 4D CD 1E 02 01 06 1A FF 4C
00 02 15 E2 C5 6D B5 DF FB 48 D2 B0 60 D0 F5 A7 10 96 E0 00
00 00 00 C5 BB
> 04 3E 2A 02 01 04 01 4F 00 00 02 4D CD 1E 02 0A F4 08 16 F0
FF 64 00 00 00 00 11 09 4D 69 6E 69 42 65 61 63 6F 6E 5F 30
30 30 37 39 BB
> 04 3E 2A 02 01 00 01 4F 00 00 02 4D CD 1E 02 01 06 1A FF 4C
00 02 15 E2 C5 6D B5 DF FB 48 D2 B0 60 D0 F5 A7 10 96 E0 00
00 00 00 C5 BB
> 04 3E 2A 02 01 04 01 4F 00 00 02 4D CD 1E 02 0A F4 08 16 F0
FF 64 00 00 00 00 11 09 4D 69 6E 69 42 65 61 63 6F 6E 5F 30
30 30 37 39 BB
< 01 0C 20 02 00 01
> 04 0E 04 01 0C 20 00
Problem is I don't understand why there so much different paquet size and type (maybe other bluetooth nonBeacon device).
I'm pretty sure that this is the beacon paquet, but theses data make no sense to me
04 3E 2A 02 01 00 01 4F 00 00 02 4D CD 1E 02 01 06 1A FF 4C
00 02 15 E2 C5 6D B5 DF FB 48 D2 B0 60 D0 F5 A7 10 96 E0 00
00 00 00 C5 BB
I have trying to use this to understand it but failed (using some stack overflow responses like the following)
First, in order to get BlueZ to advertise, the byte sequence you supply must include a valid BLE advertisement header, which is a minimum of 8 bytes. So to advertise "helloworld" you actually need to send:
sudo hcitool -i hci0 cmd 0x08 0x0008 10 02 01 1a 0c ff 18 01 48 45 4c 4c 4f 57 4f 52 4c 44
The first 8 bytes are the header and the next 10 bytes are the string "helloworld" encoded as 8-bit ASCII.
The first 8 bytes can be broken down like this:
10 # Total length of the advertising packet
02 # Number of bytes that follow in first AD structure
01 # Flags AD type
1A # Flags value 0x1A = 000011010
bit 0 (OFF) LE Limited Discoverable Mode
bit 1 (ON) LE General Discoverable Mode
bit 2 (OFF) BR/EDR Not Supported
bit 3 (ON) Simultaneous LE and BR/EDR to Same Device Capable (controller)
bit 4 (ON) Simultaneous LE and BR/EDR to Same Device Capable (Host)
0C # Number of bytes that follow in second (and last) AD structure
FF # Manufacturer specific data AD type
18 01 # Company identifier code (0x0118 == Radius Networks)
---------------------
If you got anything that can help me to understand how iBeacon paquet are constructed, thank you
Oh Gosh! I have found someone with exactly the same problem as me.
Look Here.
Response that helped from #Richard Wifall
I saw the same issue as memoryhole where I had to remove the extra zeros. I also had to enable advertising before I configured the advertising data for it to work properly with my dongle.
Here is the exact sequence/commands that worked for me:
sudo hciconfig hci0 up
sudo hciconfig hci0 leadv 3
sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 00 00 00 00 c5 00
This is what my version of the Radius script ended up looking like:
#!/bin/sh
../ibeacon.conf
echo "Launching virtual iBeacon..."
sudo hciconfig $BLUETOOTH_DEVICE up
sudo hciconfig $BLUETOOTH_DEVICE leadv 3
sudo hcitool -i $BLUETOOTH_DEVICE cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 $UUID $MAJOR $MINOR $POWER 00
echo "Complete"
This was on a Rasberry Pi with a ORICO BTA-402-BK branded BLE dongle (CSR8510 A10)
(I would have left this as a comment, but didn't have enough rep)
I have an iBeacon broadcasting every ~1280 ms from my Raspberry Pi, but I need it to broadcast every ~100ms how do I configure this?
How I'm set up:
I followed this guide:
http://www.wadewegner.com/2014/05/create-an-ibeacon-transmitter-with-the-raspberry-pi/
I have a Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
My config string:
hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 63 6F 3F 8F 64 91 4B EE 95 F7 D8 CC 64 A8 63 B5 00 00 00 00 C8 00
On my phone I see my iBeacon, the UUID is correct, the Major and Minor versions are correct. The problem I'm having is the broadcast rate.
Can I change this from ~1.2 seconds to ~100 ms?
Update 1:
I'm still getting errors.
pi#raspberrypi ~ $ sudo hciconfig hci0 up
pi#raspberrypi ~ $ sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 00 00 00 00 c5 00 00 00 00 00 00 00 00 00 00 00 00 00
< HCI Command: ogf 0x08, ocf 0x0008, plen 44
1E 02 01 1A 1A FF 4C 00 02 15 E2 C5 6D B5 DF FB 48 D2 B0 60
D0 F5 A7 10 96 E0 00 00 00 00 C5 00 00 00 00 00 00 00 00 00
00 00 00 00
> HCI Event: 0x0e plen 4
01 08 20 12
pi#raspberrypi ~ $ sudo hcitool -i hci0 cmd 0x08 0x0006 A0 00 A0 00 03 00 00 00 00 00 00 00 00 07 00
< HCI Command: ogf 0x08, ocf 0x0006, plen 15
A0 00 A0 00 03 00 00 00 00 00 00 00 00 07 00
> HCI Event: 0x0e plen 4
01 06 20 0C
pi#raspberrypi ~ $ sudo hcitool -i hci0 cmd 0x08 0x000a 01
< HCI Command: ogf 0x08, ocf 0x000a, plen 1
01
> HCI Event: 0x0e plen 4
01 0A 20 0C
Update 2:
I found a way to make it work:
hciconfig hci0 down
hciconfig hci0 up
hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 63 6F 3F 8F 64 91 4B EE 95 F7 D8 CC 64 A8 63 B5 00 00 00 00 C8 00
hcitool -i hci0 cmd 0x08 0x0006 20 00 A0 00 00 00 00 00 00 00 00 00 00 07 00
hcitool -i hci0 cmd 0x08 0x000A 01
hciconfig hci0 noscan
I think the key was the noscan part. I think if scan was on I couldn't change the advertisement frequency.
An additional resource I found useful:
https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=229737
Specifically Volume 2, Part E, Section 7.8 This gave me the actual description of the commands I was sending, instead of copy and paste programming.
You can increase the advertising rate to 10 Hz like this:
sudo hciconfig hci0 up
sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 00 00 00 00 c5 00 00 00 00 00 00 00 00 00 00 00 00 00
sudo hcitool -i hci0 cmd 0x08 0x0006 A0 00 A0 00 03 00 00 00 00 00 00 00 00 07 00
sudo hcitool -i hci0 cmd 0x08 0x000a 01
See here for more info:
Is there a way to increase BLE advertisement frequency in BlueZ?
I'm trying to change iBeacon broadcasting frequency on Asus USB-BT400. Currently it is 1Hz (tested on wireshark) and I want to change it to >10Hz. Even though it uses the same chipset as IOGear GBU521 (Broadcom BCM20702A0) there must be some differences between the two because the code (working on IOGear) doesn't work on Asus:
sudo hciconfig hci0 up
sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 00 00 00 00 c5 00 00 00 00 00 00 00 00 00 00 00 00 00
sudo hcitool -i hci0 cmd 0x08 0x0006 A0 00 A0 00 03 00 00 00 00 00 00 00 00 07 00
sudo hcitool -i hci0 cmd 0x08 0x000a 01
Also, in similar manner, the power level cannot be changed this way. Maybe the command structure for Asus is different?
There are some threads for how to apply bluez as ibeacon or BLE peripheral.
But when I use ble scanner (a BLE central application on Android), that reveal the bluz peripheral as dual mode.
How should I do to disable the classic mode in bluez?
Since you are referring to that thread, you probably use hcitool to set the advertisement data and options.
You need to set change the Flag for BR/EDR support to 0. Thats Bit 2 of the Flags field (See Part A Supplement of the Bluetooth Core Spezification, p.12).
So the original 0x1A changes to 0x16:
Change
sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 00 00 00 00 c5 00 00 00 00 00 00 00 00 00 00 00 00 00
to
sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 16 1a ff 4c 00 02 15 e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 00 00 00 00 c5 00 00 00 00 00 00 00 00 00 00 00 00 00
Running btmon on another shell while executing the commands allows you to observe whats going on exactly.
I have followed the instructions I have found on the internet for configuring the bluetooth 4 dongle with a Raspberry Pi. I thought it was going ok. Running 'hcitool dev'' shows me the device.
So I then created and ran a script:
#!/bin/bash
sudo hciconfig hci0 up
sudo hciconfig hci0 noleadv
sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 e5 9f fc b0 b5 2d 11 e3 a5 e2 08 00 20 0c 9a 66 00 00 00 00 c5 00
sudo hciconfig hci0 leadv 3
Running the above script gave the output:
LE set advertise enable on hci returned status 12
< HCI Command: ogf 0x08, ocf 0x0008, plen 32
1E 02 01 1A 1A FF 4C 00 02 15 E5 9F FC B0 B5 2D 11 E3 A5 E2
08 00 20 0C 9A 66 00 00 00 00 C5 00
> HCI Event: 0x0e plen 4
01 08 20 00
I don't know if the above output indicates success or failure, but I suspect all is not well because I installed Locate iB app from Radius Networks on my iPad and added in the details above for my iBeacon and the app cannot see it.
The details of the iBeacon I entered in the app are:
Proximity UUID = e59ffcb0-b52d-11e3-a5e2-0800200c9a66
Major = 0
Minor = 0
Power = -59
Any help greatly appreciated.
Paul