Difference between revisions of "How to scan BLE devices"

[quality revision] [quality revision]
m
 
 

Template:ArticleMainWriter Template:ArticleApprovedVersion


This page lists the different operations needed to scan, connect and display BLE device information. BLE stands for Bluetooth Low Energy

1 Packages needed[edit]

  • bluez5

2 Configuration[edit]

Init file modification for automatic Bluetooth start
/etc/udev/rules.d/10-local.rules:

# Set bluetooth power up
ACTION=="add", KERNEL=="hci0", RUN+="/usr/bin/hciconfig hci0 up"

3 Existing tool selection[edit]

Bluez provides some tools, by default, to analyze Bluetooth networks.
hciconfig to configure hci connections
hcitool to scan, find a device, connect to a device, manage a device list.. deviceS may be normal or low energy
gatttool for BLE device management

3.1 BLE device connection step-by-step[edit]

Command to scan all low-energy Bluetooth hardware:

Board $> hciconfig hci0 up
Board $> hcitool lescan

To scan available BLE devices:

Board $> hcitool lewladd <BLE_MAC_ADDRRESS>

To add BLE device in the white list (optional):

Board $> hcitool lecc <BLE_MAC_ADDRESS>

To connect a BLE device:

Once a BLE device is identified, its characteristics (attibutes) can be discovered, read and modified using GATTTOOL.
GATTTOOL offers two working modes: interractive and non-interractive

3.1.1 Gatttool Interractive mode[edit]

Board $> gatttool -b <MAC Address> --interactive

In interractive mode, a new prompt is available to perform BLE commands.
connect: to connect to a specified device
primary: to disable all primary attributes
char-read-hnd <handle> to read specified handle/attribute values
char-write-cmd <handle> <value> to modify handle values

3.1.2 Gatttool Non-interractive mode:[edit]

In non-interractive mode, commands are issued one by one. At each command, GATTTOOL performs device connection, action and disconnection.
Few a few examples are given below:

Board $> gatttool -b <Mac Address> --primary 
Board $> gatttool -b <MAC Address> --characteristics
Board $> gatttool -b <MAC Address> --char-read
Board $> gatttool -b <MAC Address> --char-desc
<noinclude>

{{ArticleMainWriter | ChristopheR}}
{{ArticleApprovedVersion | ChristopheR | AlexandreT (Not Done), GeraldB (Not Done), LudovicB (Not Done), BernardP (Not Done), LoicP (Not Done) |No previous approved version | PhilipS - 04Jan'19 - 10183 | 14Jan'19}}
[[Category:Bluetooth]]</noinclude>

This page lists the different operations needed to scan, connect and display BLE device information.
BLE stands for '''B'''luetooth '''L'''ow '''E'''nergy

==Packages needed==
* bluez5

==Configuration==
Init file modification for automatic Bluetooth start <br>

/etc/udev/rules.d/10-local.rules:<pre>

# Set bluetooth power up
ACTION=="add", KERNEL=="hci0", RUN+="/usr/bin/hciconfig hci0 up"</pre>


==Existing tool selection==
Bluez provides some tools, by default, to analyze Bluetooth networks.<br>

'''hciconfig''' to configure hci connections <br>

'''hcitool''' to scan, find a device, connect to a device, manage a device list.. deviceS may be normal or low energy<br>

'''gatttool''' for BLE device management <br>


===BLE device connection step-by-step===

Command to scan all low-energy Bluetooth hardware:
 {{Board$}} hciconfig hci0 up
 {{Board$}} hcitool lescan

To scan available BLE devices:<br>

 {{Board$}} hcitool lewladd <BLE_MAC_ADDRRESS>


To add BLE device in the white list (optional):<br>

 {{Board$}} hcitool lecc <BLE_MAC_ADDRESS>


To connect a BLE device:<br>


Once a BLE device is identified, its characteristics (attibutes) can be discovered, read and modified using [[Network_tools#gatttool| GATTTOOL]].<br>

[[Network_tools#gatttool| GATTTOOL]] offers two working modes: interractive and non-interractive<br>


====Gatttool Interractive mode====
 {{Board$}} gatttool -b <MAC Address> --interactive

In interractive mode, a new prompt is available to perform BLE commands. <br>

'''connect''': to connect to a specified device<br>

'''primary''': to disable all primary attributes<br>

'''char-read-hnd <handle>''' to read specified handle/attribute values<br>

'''char-write-cmd <handle> <value>''' to modify handle values<br>


====Gatttool Non-interractive mode:====
In non-interractive mode, commands are issued one by one. At each command, [[Network_tools#gatttool| GATTTOOL]] performs device connection, action and disconnection.<br>

Few a few examples are given below:<br>

 {{Board$}} gatttool -b <Mac Address> --primary <br>

 {{Board$}} gatttool -b <MAC Address> --characteristics <br>

 {{Board$}} gatttool -b <MAC Address> --char-read <br>

 {{Board$}} gatttool -b <MAC Address> --char-desc <br>

<noinclude>

[[Category:Bluetooth]]
{{PublicationRequestId | 10183 | 2019-01-04 | PhilipS}}</noinclude>
Line 1: Line 1:
<noinclude>
 
{{ArticleMainWriter | ChristopheR}}
 
{{ArticleApprovedVersion | ChristopheR | AlexandreT (Not Done), GeraldB (Not Done), LudovicB (Not Done), BernardP (Not Done), LoicP (Not Done) |No previous approved version | PhilipS - 04Jan'19 - 10183 | 14Jan'19}}
 
[[Category:Bluetooth]]
 
</noinclude>
 
 
 
This page lists the different operations needed to scan, connect and display BLE device information.
 
This page lists the different operations needed to scan, connect and display BLE device information.
 
BLE stands for '''B'''luetooth '''L'''ow '''E'''nergy
 
BLE stands for '''B'''luetooth '''L'''ow '''E'''nergy
Line 58: Line 52:
 
  {{Board$}} gatttool -b <MAC Address> --char-read <br>
 
  {{Board$}} gatttool -b <MAC Address> --char-read <br>
 
  {{Board$}} gatttool -b <MAC Address> --char-desc <br>
 
  {{Board$}} gatttool -b <MAC Address> --char-desc <br>
  +
  +
<noinclude>
  +
[[Category:Bluetooth]]
  +
{{PublicationRequestId | 10183 | 2019-01-04 | PhilipS}}
  +
</noinclude>