Discussion:
How to test/debug bluetooth advertising [with hciconfig]?
Richard Neill
2013-08-28 10:22:01 UTC
Permalink
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
Andrei Emeltchenko
2013-08-28 10:39:58 UTC
Permalink
Hi Richard,
Post by 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.
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
Richard Neill
2013-08-28 11:10:43 UTC
Permalink
Post by Andrei Emeltchenko
Post by 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?
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 ?
Andrei Emeltchenko
2013-08-28 11:54:21 UTC
Permalink
Hi Richard,
Post by Richard Neill
Post by Andrei Emeltchenko
Post by 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?
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.
Then you should not use "hcitool cmd". Better use high level API.

Best regards
Andrei Emeltchenko
Richard Neill
2013-08-28 14:35:22 UTC
Permalink
Dear Andrei,

Thanks for your help.
Post by Andrei Emeltchenko
Post by Richard Neill
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
Andrei Emeltchenko
2013-08-28 12:12:50 UTC
Permalink
Hi Richard,
Post by Richard Neill
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
Claudio Takahasi
2013-08-28 14:10:41 UTC
Permalink
Hi Richard:

On Wed, Aug 28, 2013 at 9:12 AM, Andrei Emeltchenko
Post by Andrei Emeltchenko
Hi Richard,
Post by Richard Neill
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
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
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
Richard Neill
2013-08-28 14:45:18 UTC
Permalink
Post by Claudio Takahasi
$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

Richard Neill
2013-08-28 11:09:45 UTC
Permalink
Post by Andrei Emeltchenko
Post by 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?
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 ?
Loading...