Skip to contentSkip to conversation

How to test/debug bluetooth advertising [with hciconfig]?

DISCUSSION Richard Neill 4 participants 9 messages Aug 28, 2013 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Dear All,

I'm trying to get "hello world" working from the shell between 2 Bluetooth 4 dongles, in LE advertising mode. I wonder whether I could ask for some pointers?

As I understand it, Bluetooth low-energy supports up to 31 bytes of arbitrary text in the advertising packet. So it should be possible to set one dongle up in LE-advertising mode, and a second in LE-scan mode, and to transfer the "hello world" message from one to the other.

I'm rather stuck at the moment. I've discovered that there is an "LE Set Advertising Data" command, 0xcf (from "hciconfig hci0 commands_list"), and that "hcitool -i hci0 cmd 0xcf XXX YYY ZZZ" is how to send it. But I can't find any more documentation for the command set used by hcitool.

Can anyone help, with the commands I need, or by pointing me to the appropriate documentation/tutorial?

Thanks for your help,

Richard

#1 lore raw

Hi Richard,

Quoted 12 lines · Richard Neill

Dear All,

I'm trying to get "hello world" working from the shell between 2 Bluetooth 4 dongles, in LE advertising mode. I wonder whether I could ask for some pointers?

As I understand it, Bluetooth low-energy supports up to 31 bytes of arbitrary text in the advertising packet. So it should be possible to set one dongle up in LE-advertising mode, and a second in LE-scan mode, and to transfer the "hello world" message from one to the other.

Quoted 3 lines

I'm rather stuck at the moment. I've discovered that there is an "LE Set Advertising Data" command, 0xcf (from "hciconfig hci0 commands_list"), and that "hcitool -i hci0 cmd 0xcf XXX YYY ZZZ" is

$ hcitool cmd --help
Usage:
	cmd <ogf> <ocf> [parameters]

Check ogf and ocf from the Bluetooth Specification.

Best regards
Andrei Emeltchenko

#2 lore raw
Quoted 9 lines · Richard Neill
Quoted 5 lines

Dear All,

I'm trying to get "hello world" working from the shell between 2 Bluetooth 4 dongles, in LE advertising mode. I wonder whether I could ask for some pointers?

Check ogf and ocf from the Bluetooth Specification.

Dear Andrei,

Thanks for your reply. That was actually very helpful: by searching specifically for "ogf ocf Bluetooth specification", I was able to locate the right part of the relevant document (a 600 page PDF of Bluetooth 4.0 core).

However, before I delve into this in great detail, I wonder whether I am about to "re-invent the wheel". For example, if I wanted to use "ping" in a shell-script, I wouldn't normally begin by poking registers in the ethernet card.

If nobody else has written the utility, I'm happy to do so, (and I'll publish the results), but I wonder whether it has already been done?

Best wishes,

Richard

P.S. I sent a patch to hciconfig yesterday: was it sufficient to just post it to this list, or is there anything else I should do in order to get feedback and to have it considered for acceptance into bluez ?

#3 lore raw
In reply to Andrei Emeltchenko
Quoted 9 lines · Richard Neill
Quoted 5 lines

Dear All,

I'm trying to get "hello world" working from the shell between 2 Bluetooth 4 dongles, in LE advertising mode. I wonder whether I could ask for some pointers?

Check ogf and ocf from the Bluetooth Specification.

Dear Andrei,

Thanks for your reply. That was actually very helpful: by searching specifically for "ogf ocf Bluetooth specification", I was able to locate the right part of the relevant document (a 600 page PDF of Bluetooth 4.0 core).

However, before I delve into this in great detail, I wonder whether I am about to "re-invent the wheel". For example, if I wanted to use "ping" in a shell-script, I wouldn't normally begin by poking registers in the ethernet card.

If nobody else has written the utility, I'm happy to do so, (and I'll publish the results), but I wonder whether it has already been done?

Best wishes,

Richard

P.S. I sent a patch to hciconfig yesterday: was it sufficient to just post it to this list, or is there anything else I should do in order to get feedback and to have it considered for acceptance into bluez ?

#4 lore raw

Hi Richard,

Quoted 17 lines · Richard Neill
Quoted 9 lines · Richard Neill
Quoted 5 lines

Dear All,

I'm trying to get "hello world" working from the shell between 2 Bluetooth 4 dongles, in LE advertising mode. I wonder whether I could ask for some pointers?

Check ogf and ocf from the Bluetooth Specification.

Dear Andrei,

Thanks for your reply. That was actually very helpful: by searching specifically for "ogf ocf Bluetooth specification", I was able to locate the right part of the relevant document (a 600 page PDF of Bluetooth 4.0 core).

Quoted 4 lines

However, before I delve into this in great detail, I wonder whether I am about to "re-invent the wheel". For example, if I wanted to use "ping" in a shell-script, I wouldn't normally begin by poking registers in the ethernet card.

Then you should not use "hcitool cmd". Better use high level API.

Best regards
Andrei Emeltchenko

#5 lore raw

Dear Andrei,

Thanks for your help.

Quoted 7 lines
Quoted 5 lines

However, before I delve into this in great detail, I wonder whether I am about to "re-invent the wheel". For example, if I wanted to use "ping" in a shell-script, I wouldn't normally begin by poking registers in the ethernet card.

Then you should not use "hcitool cmd". Better use high level API.

I'd love to use a high level API. But where can I find it? There doesn't seem to be any documentation, or any example code for Bluetooth Low Energy on Linux.

BTLE documentation only seem to be documented for Windows, iOS, or Android. I'm sorry if I seem to be being dense, but while I can find lots of references to 2007-era bluetooth tutorials, lots of information on how wonderful BTLE is, and a lot of questions on eg stackexchange asking *how* to do this, there doesn't seem to be any starting point for actually doing it.

hciconfig looks to be the natural place to start (it has the commands to enable and disable LE advertising, but appears to have omit the command to set the advertising data itself).

Regards,

Richard

#6 lore raw
In reply to Richard Neill

Hi Richard,

Quoted 6 lines

Thanks for your reply. That was actually very helpful: by searching specifically for "ogf ocf Bluetooth specification", I was able to locate the right part of the relevant document (a 600 page PDF of Bluetooth 4.0 core).

However, before I delve into this in great detail, I wonder whether

Those ogf and ocf are just command identifiers, search by command you want to run and you will find them.

Best regards
Andrei Emeltchenko

#7 lore raw

Hi Richard:

Quoted 12 lines · Andrei Emeltchenko

Hi Richard,

Quoted 6 lines

Thanks for your reply. That was actually very helpful: by searching specifically for "ogf ocf Bluetooth specification", I was able to locate the right part of the relevant document (a 600 page PDF of Bluetooth 4.0 core).

However, before I delve into this in great detail, I wonder whether

Those ogf and ocf are just command identifiers, search by command you want to run and you will find them.

Quoted 7 lines

Best regards
Andrei Emeltchenko

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Sets the advertising data:
$sudo hcitool -i hci0 cmd 0x08 0x0008 03 02 01 06 $(perl -e 'print "00 " x 28 . "\n"')
Remember that the data needs to follow the EIR/AD format: see Core Spec page1761

Enable adv
$sudo hciconfig hci0 leadv

BR,
Claudio

#8 lore raw
Quoted 10 lines · Claudio Takahasi

Sets the advertising data:
$sudo hcitool -i hci0 cmd 0x08 0x0008 03 02 01 06 $(perl -e 'print "00 " x 28 . "\n"')
Remember that the data needs to follow the EIR/AD format: see Core Spec page1761

Enable adv
$sudo hciconfig hci0 leadv

BR,
Claudio

Dear Claudio,

Thanks very much - that's really helpful :-)

Best wishes,

Richard