0

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
Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
PhilBot
  • 748
  • 18
  • 85
  • 173
  • What do you want to include in your scan data? Your current scan response data doesn't make any sense to me. – Emil Sep 26 '17 at 17:36
  • Really just some custom bytes that I can design the scan response interface to be. Problem is, when I use my BLE112 Bluegiga Dongle with internal stack, LightBlue sees the Advertising Data and Scan Response custom data ( because that dongle has it's own internal stack ) and a command for that - but when I try to do the same scan response data in BlueZ as shown above, LightBlue sees nothing – PhilBot Sep 26 '17 at 18:10
  • Do you have an example of setting the scan response data? Thanks. – PhilBot Sep 26 '17 at 18:10
  • iOS parses it and therefore requires you to set it to something valid. If you set it to 02 09 41 (prepend to that 03 as length if you use the raw hcitool), that means you set the name to 'A'. 02=length for the following item including type, 09=Complete Name, 41='A'. – Emil Sep 26 '17 at 22:05

1 Answers1

1

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.

KrapocK
  • 56
  • 6