I have a custom GATT Server working as a plugin using BlueZ 4.101 on Linux. I am now trying to set custom Scan Response advertising data. I am using LightBlue on iOS to debug my GATT Server and advertising parameters. I tried the following code, and LightBlue can see the Advertising Payload and Device Name, but not the Scan Response data. How do I set custom Scan Response data with BlueZ?
# BLE Name
echo "<GATT SERVER> Setting BLE Advertising Name..."
btmgmt -i $BLUETOOTH_DEVICE name "My-Test-Device"
echo "<GATT SERVER> Starting BLE Advertising..."
hciconfig $BLUETOOTH_DEVICE leadv
# Adv Packet
echo "<GATT SERVER> Setting BLE Advertising Packets..."
hcitool -i hci0 cmd 0x08 0x0008 15 02 01 06 11 06 fa d8 43 31 14 09 0c ba e1 14 82 25 11 48 96 16
# | | | | | | -----------------------------------------------
# | | | | | | |
# | | | | | | +---- device state service UUID
# | | | | | |
# | | | | | +- Incomplete List of 128-bit Service Class UUIDs
# | | | | |
# | | | | +- Num bytes in -----------------------------------+
# | | | |
# | | | +- LE General Discoverable Mode, BR/EDR
# | | |
# | | +- Flags AD type
# | |
# | +nBytes+
# |
# +- Num bytes in -----------------------------------------------+
# Scan Response
echo "<GATT SERVER> Setting BLE Scan Response..."
hcitool -i hci0 cmd 0x08 0x0009 02 01 06 1A FF 02 5E 03 02 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Your command to set discovery response does not make any sense. Here is an exemple :
hcitool -i hci0 cmd 0x08 0x0009 14 13 09 74 68 65 20 70 69
hcitool -i hci0 cmd 0x08 0x0009 : set discovery response
14 : total payload length
13 : info payload length
09 : info type == name
74 68 65 20 70 69 : info payload => the name in ascii. here "the pi"
Please note that this won't work if you device is not connectable.
Related
Okay I need some Help... I got a bluetooth-le-weight-scale. I can connect my Raspberry Pi to this scale and get some data. But its not easy for me to read my values in this hex-salad.
After every measurement I get two lines of Information, which should contain my values
(I simulated all measurements ... Person 5 is just me pushing my hands on the scale .. Person 2 + 3 is me wearing socks on the scale, so no need to give me some medical advices if you find some unrealistic values :D )
Scale: starts with 5.0kg(officaly, but i can see a 4.9 as starting point), Max 180kg (this could be just a safety note. its a glass-scale), d = 100g
what I noted from the Display:
# | Person | m kg| Fat % | TbW % | Mus % | Bone kg | kcal | BMI
1 | 5 |13,3 | 5 | 72,7 | 60,1 | 0,8 | 1056 | 13,3
2 | 3 |73,6 | 26,3 | 51,1 | 34,2 | 3,5 | 2428 | 24,3
3 | 2 |76,8 | 18,5 | 61,1 | 41,9 | 3,4 | 2741 | 24,8
4 | 5 |15,0 | 5 | 70,3 | 58,4 | 0,9 | 1092 | 15,0
5 | 6 | 5,1 | 5 | 73 | 66,5 | 0,5 | 881 | 5,1
What I received via Bluetooth:
# | handle | Byte 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
-----------------------------------------------------------------------------
1 | 0x001b | value: 1d 32 05 00 fe 0f 13 11 11 01 12 00 ff 05 09 00 00 00 00
1 | 0x001e | value: 6f 0f 13 11 11 05 20 04 32 f0 d7 f2 59 f2 08 f0 00 00 00
-----------------------------------------------------------------------------
2 | 0x001b | value: 1d c0 1c 00 fe 45 06 00 00 7a 13 00 ff 03 09 00 00 00 00
2 | 0x001e | value: 6f 45 06 00 00 03 7c 09 07 f1 ff f1 56 f1 23 f0 00 00 00
-----------------------------------------------------------------------------
3 | 0x001b | value: 1d 00 1e 00 fe 37 01 00 00 d7 12 00 ff 02 09 00 00 00 00
3 | 0x001e | value: 6f 37 01 00 00 02 b5 0a b9 f0 63 f2 a3 f1 22 f0 00 00 00
-----------------------------------------------------------------------------
4 | 0x001b | value: 1d dc 05 00 fe 80 14 11 11 83 18 00 ff 05 09 00 00 00 00
4 | 0x001e | value: 6f 80 14 11 11 05 44 04 32 f0 bf f2 48 f2 09 f0 00 00 00
-----------------------------------------------------------------------------
5 | 0x001b | value: 1d fe 01 00 fe 5c 15 11 11 ac 16 00 ff 06 09 00 00 00 00
5 | 0x001e | value: 6f 5c 15 11 11 06 71 03 32 f0 da f2 99 f2 05 f0 00 00 00
Note:
Each time before receiving the values, I have to send my scale a Unix-timestamp.. most of the times, I had just send 1111111111 or 0000000000 or something like that.. but I did not note what I send.. sorry..
there is always another incoming line where I spotted the user values, that are stored in the scale. So I think these are unimportant but maybe I'm wrong
P2, male, Height: 176cm, Age: 34
P3, female, Height: 174cm, Age: 23
P5, male, Height: 100cm, Age: 10
so maybe someone could tell me, like where I can find the Information that represents my weight. I just have spotted the person numbers
thanks for helping & greetings from germany
ok ok.. I solved it...
0x1b:
weight: byte: 1 & 2
timestamp: byte 5-8
person: byte 13
0x1e:
timestamp: byte 1-4
person: 5
kcal: 6 & 7
fat: 8 & 9
tbw: 10 & 11
muscle: 12 & 13
bone: 14 & 15
To add some more details:
values decode as unsigned integers, little endian. For some obscure reason the 2 byte (short) integers have a most significant nibble as 0xf.
Transmission starts off with indication 0x25 which contains the programmed properties of the person detected (i.e. weight is within +/- 2 kg of last measurement).
0x25:
person: byte 2
gender: byte 4 (1=male, 2=female)
age: byte 5
size: byte 6
activity: byte 8 (0=normal, 3=high)
I have some PC/SC code that has encoded thousands of MIFARE cards. I now have a HID OMNIKEY 5127 CK reader and I cannot get it to authenticate. For a standard 1K MIFARE card I load the transport key with:
FF 82 20 00 06 FF FF FF FF FF FF
which succeeds and then to authenticate against the first block:
FF 88 00 00 60 00
and it gives 67 00. Has anyone else seen this?
The AUTHENTICATE command (CLA=FF, INS=88) has been declared obsolete in the PC/SC specification, so it might not be supported by that reader. You could instead try the GENERAL AUTHENTICATE command:
+-----+-----+----+----+----+---------+---------+----------+------+
| CLA | INS | P1 | P2 | Lc | Version | Address | Key type | Key# |
+-----+-----+----+----+----+---------+---------+----------+------+
| FF | 86 | 00 | 00 | 05 | 01 | 00 00 | 60 | 00 |
+-----+-----+----+----+----+---------+---------+----------+------+
The relevant part of the PC/SC specification is "Part3. Requirements for PC-Connected Interface Devices" (get it here).
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
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
I have a problem with my website, which is completely gzipped:
http://goout.cz/cs/fotoreporty/
The page can be easily shown in Chrome, but in Safari it never loads (and I suppose in other browsers as well. When I try:
curl -v http://goout.cz/cs/fotoreporty/ | gzip -d
I am getting expected results. But validation on
http://validator.w3.org/check?uri=http%3A%2F%2Fgoout.cz%2Fcs%2Ffotoreporty%2F#fatal-errors
yields:
The error was: Can't gunzip content: Header Error: Minimum header size is 10 bytes
What is wrong with the gzip format? How can I solve it? Thanks.
EDIT:
The gzip header seems to me okay to me:
$ curl http://goout.cz/cs/ | head -1 | hexdump | head -1
0000000 1f 8b 08 00 00 00 00 00 00 00 ed 5d cd 73 db 38
$ curl http://goout.cz/cs/fotoreporty/ | head -1 | hexdump | head -1
0000000 1f 8b 08 00 00 00 00 00 00 00 ed 7d cf 73 e3 46