Personal tools

Difference between revisions of "1-1-1-1-3-1-6"

From ICOP tech wiki

Jump to: navigation, search
(Created page with " <div id="column-content"> <div id="content"> <a id="top"></a> <h1 id="firstHeading" class="firstHeading">IMX BLE</h1> <div id="bodyContent"> <h3 id="...")
 
 
Line 1: Line 1:
<div id="column-content">
+
{{PageHeader|Bluetooth Low Energy}}
<div id="content">
+
{{DocImage|category1=Yocto|category2=VAR-SOM-MX6}}[[Category: DART-6UL]][[Category: VAR-SOM-MX7]][[Category:DART-MX8M]][[Category:DART-MX8M-MINI]] __toc__
<a id="top"></a>
+
{{note| NOTES:<br>
<h1 id="firstHeading" class="firstHeading">IMX BLE</h1>
+
#Please make sure your Bluetooth device is powered on and ready for use. Follow the [[IMX Bluetooth#Device_identification|Bluetooth wiki]] page if required.
<div id="bodyContent">
+
|info}}
<h3 id="siteSub">From Variscite Wiki</h3>
+
 
<div id="contentSub"></div>
+
= Finding BLE devices =
<div id="jump-to-nav">Jump to: <a href="#column-one">navigation</a>, <a href="#searchInput">search</a></div> <!-- start content -->
+
 
<div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><p><span style="font-size:16pt;">Bluetooth Low Energy</span>
+
Use '''btmgmt''' tool to find BLE devices and detect their MAC address type (random vs public).
</p>
 
<hr /> <div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
 
<ul>
 
<li class="toclevel-1 tocsection-1"><a href="#Finding_BLE_devices"><span class="tocnumber">1</span> <span class="toctext">Finding BLE devices</span></a></li>
 
<li class="toclevel-1 tocsection-2"><a href="#Connecting_to_BLE_devices"><span class="tocnumber">2</span> <span class="toctext">Connecting to BLE devices</span></a></li>
 
<li class="toclevel-1 tocsection-3"><a href="#Accessing_BLE_devices"><span class="tocnumber">3</span> <span class="toctext">Accessing BLE devices</span></a></li>
 
<li class="toclevel-1 tocsection-4"><a href="#Receiving_notifications_from_BLE_devices"><span class="tocnumber">4</span> <span class="toctext">Receiving notifications from BLE devices</span></a></li>
 
</ul>
 
</div>
 
  
<div class="note note-info"> NOTES:<br>
 
<ol>
 
<li>Please make sure your Bluetooth device is powered on and ready for use. Follow the <a href="/index.php?title=IMX_Bluetooth#Device_identification" title="IMX Bluetooth">Bluetooth wiki</a> page if required.
 
</li>
 
</ol>
 
</div>
 
<h1><span class="mw-headline" id="Finding_BLE_devices"><span class="mw-headline-number">1</span> Finding BLE devices</span></h1>
 
<p>Use <b>btmgmt</b> tool to find BLE devices and detect their MAC address type (random vs public).
 
</p>
 
 
<pre>
 
<pre>
 
root@var-som-mx6:~# btmgmt find -l
 
root@var-som-mx6:~# btmgmt find -l
Line 36: Line 18:
 
hci0 type 7 discovering off
 
hci0 type 7 discovering off
 
</pre>
 
</pre>
<p>In this example a single BLE device was detected, having MAC address 74:B9:AB:CF:13:A9 and random MAC address type
+
 
</p>
+
In this example a single BLE device was detected, having MAC address 74:B9:AB:CF:13:A9 and random MAC address type
<h1><span class="mw-headline" id="Connecting_to_BLE_devices"><span class="mw-headline-number">2</span> Connecting to BLE devices</span></h1>
+
 
<p>Use <b>gatttool</b> to connect to BLE devices. Pass "-t random" parameter if scan has reported a random MAC address.
+
= Connecting to BLE devices =
</p>
+
Use '''gatttool''' to connect to BLE devices. Pass "-t random" parameter if scan has reported a random MAC address.
 
<pre>
 
<pre>
 
root@var-som-mx6:~# gatttool -t random -b 74:B9:AB:CF:13:A9 -I
 
root@var-som-mx6:~# gatttool -t random -b 74:B9:AB:CF:13:A9 -I
[74:B9:AB:CF:13:A9][LE]&gt; connect
+
[74:B9:AB:CF:13:A9][LE]> connect
 
Attempting to connect to 74:B9:AB:CF:13:A9
 
Attempting to connect to 74:B9:AB:CF:13:A9
[74:B9:AB:CF:13:A9][LE]&gt;
+
[74:B9:AB:CF:13:A9][LE]>
 
Connection successful
 
Connection successful
 
Indication handle = 0x0003 value: 01 00 ff ff
 
Indication handle = 0x0003 value: 01 00 ff ff
[74:B9:AB:CF:13:A9][LE]&gt;
+
[74:B9:AB:CF:13:A9][LE]>
 
</pre>
 
</pre>
<h1><span class="mw-headline" id="Accessing_BLE_devices"><span class="mw-headline-number">3</span> Accessing BLE devices</span></h1>
+
 
<p>After successful connection BLE device characteristics can be accessed via <b>gatttool</b>. Continuing the example above:
+
= Accessing BLE devices =
</p>
+
 
 +
After successful connection BLE device characteristics can be accessed via '''gatttool'''. Continuing the example above:
 
<pre>
 
<pre>
[74:B9:AB:CF:13:A9][LE]&gt; characteristics  
+
[74:B9:AB:CF:13:A9][LE]> characteristics  
 
handle: 0x0002, char properties: 0x20, char value handle: 0x0003, uuid: 00002a05-0000-1000-8000-00805f9b34fb
 
handle: 0x0002, char properties: 0x20, char value handle: 0x0003, uuid: 00002a05-0000-1000-8000-00805f9b34fb
 
handle: 0x0015, char properties: 0x02, char value handle: 0x0016, uuid: 00002a00-0000-1000-8000-00805f9b34fb
 
handle: 0x0015, char properties: 0x02, char value handle: 0x0016, uuid: 00002a00-0000-1000-8000-00805f9b34fb
Line 60: Line 43:
 
handle: 0x0019, char properties: 0x02, char value handle: 0x001a, uuid: 00002aa6-0000-1000-8000-00805f9b34fb
 
handle: 0x0019, char properties: 0x02, char value handle: 0x001a, uuid: 00002aa6-0000-1000-8000-00805f9b34fb
 
handle: 0x0029, char properties: 0x12, char value handle: 0x002a, uuid: 00002a19-0000-1000-8000-00805f9b34fb
 
handle: 0x0029, char properties: 0x12, char value handle: 0x002a, uuid: 00002a19-0000-1000-8000-00805f9b34fb
[74:B9:AB:CF:13:A9][LE]&gt; char-read-hnd 0x0002
+
[74:B9:AB:CF:13:A9][LE]> char-read-hnd 0x0002
 
Characteristic value/descriptor: 20 03 00 05 2a  
 
Characteristic value/descriptor: 20 03 00 05 2a  
[74:B9:AB:CF:13:A9][LE]&gt; char-read-hnd 0x0015
+
[74:B9:AB:CF:13:A9][LE]> char-read-hnd 0x0015
 
Characteristic value/descriptor: 02 16 00 00 2a  
 
Characteristic value/descriptor: 02 16 00 00 2a  
[74:B9:AB:CF:13:A9][LE]&gt; char-read-hnd 0x0017
+
[74:B9:AB:CF:13:A9][LE]> char-read-hnd 0x0017
 
Characteristic value/descriptor: 02 18 00 01 2a  
 
Characteristic value/descriptor: 02 18 00 01 2a  
[74:B9:AB:CF:13:A9][LE]&gt; char-read-hnd 0x0019
+
[74:B9:AB:CF:13:A9][LE]> char-read-hnd 0x0019
 
Characteristic value/descriptor: 02 1a 00 a6 2a  
 
Characteristic value/descriptor: 02 1a 00 a6 2a  
[74:B9:AB:CF:13:A9][LE]&gt; char-read-hnd 0x0029
+
[74:B9:AB:CF:13:A9][LE]> char-read-hnd 0x0029
 
Characteristic value/descriptor: 12 2a 00 19 2a  
 
Characteristic value/descriptor: 12 2a 00 19 2a  
 
</pre>
 
</pre>
<h1><span class="mw-headline" id="Receiving_notifications_from_BLE_devices"><span class="mw-headline-number">4</span> Receiving notifications from BLE devices</span></h1>
+
 
<p>Notifications sent from connected BLE devices can be seen in <b>gatttool</b>. The example below shows notification sent by Android "BLE Peripheral Simulator"
+
= Receiving notifications from BLE devices =
</p>
+
 
 +
Notifications sent from connected BLE devices can be seen in '''gatttool'''. The example below shows notification sent by Android "BLE Peripheral Simulator"
 
<pre>
 
<pre>
[74:B9:AB:CF:13:A9][LE]&gt;
+
[74:B9:AB:CF:13:A9][LE]>
 
Notification handle = 0x002a value: 08 3c 00 00
 
Notification handle = 0x002a value: 08 3c 00 00
[74:B9:AB:CF:13:A9][LE]&gt;
+
[74:B9:AB:CF:13:A9][LE]>
 
</pre>
 
</pre>

Latest revision as of 15:24, 10 March 2020

Bluetooth Low Energy


NOTES:
  1. Please make sure your Bluetooth device is powered on and ready for use. Follow the Bluetooth wiki page if required.

Finding BLE devices

Use btmgmt tool to find BLE devices and detect their MAC address type (random vs public).

root@var-som-mx6:~# btmgmt find -l
Discovery started
hci0 type 7 discovering on
hci0 dev_found: 74:B9:AB:CF:13:A9 type LE Random rssi -90 flags 0x0000
AD flags 0x1a 
name Galaxy S5
hci0 type 7 discovering off

In this example a single BLE device was detected, having MAC address 74:B9:AB:CF:13:A9 and random MAC address type

Connecting to BLE devices

Use gatttool to connect to BLE devices. Pass "-t random" parameter if scan has reported a random MAC address.

root@var-som-mx6:~# gatttool -t random -b 74:B9:AB:CF:13:A9 -I
[74:B9:AB:CF:13:A9][LE]> connect
Attempting to connect to 74:B9:AB:CF:13:A9
[74:B9:AB:CF:13:A9][LE]>
Connection successful
Indication handle = 0x0003 value: 01 00 ff ff
[74:B9:AB:CF:13:A9][LE]>

Accessing BLE devices

After successful connection BLE device characteristics can be accessed via gatttool. Continuing the example above:

[74:B9:AB:CF:13:A9][LE]> characteristics 
handle: 0x0002, char properties: 0x20, char value handle: 0x0003, uuid: 00002a05-0000-1000-8000-00805f9b34fb
handle: 0x0015, char properties: 0x02, char value handle: 0x0016, uuid: 00002a00-0000-1000-8000-00805f9b34fb
handle: 0x0017, char properties: 0x02, char value handle: 0x0018, uuid: 00002a01-0000-1000-8000-00805f9b34fb
handle: 0x0019, char properties: 0x02, char value handle: 0x001a, uuid: 00002aa6-0000-1000-8000-00805f9b34fb
handle: 0x0029, char properties: 0x12, char value handle: 0x002a, uuid: 00002a19-0000-1000-8000-00805f9b34fb
[74:B9:AB:CF:13:A9][LE]> char-read-hnd 0x0002
Characteristic value/descriptor: 20 03 00 05 2a 
[74:B9:AB:CF:13:A9][LE]> char-read-hnd 0x0015
Characteristic value/descriptor: 02 16 00 00 2a 
[74:B9:AB:CF:13:A9][LE]> char-read-hnd 0x0017
Characteristic value/descriptor: 02 18 00 01 2a 
[74:B9:AB:CF:13:A9][LE]> char-read-hnd 0x0019
Characteristic value/descriptor: 02 1a 00 a6 2a 
[74:B9:AB:CF:13:A9][LE]> char-read-hnd 0x0029
Characteristic value/descriptor: 12 2a 00 19 2a 

Receiving notifications from BLE devices

Notifications sent from connected BLE devices can be seen in gatttool. The example below shows notification sent by Android "BLE Peripheral Simulator"

[74:B9:AB:CF:13:A9][LE]>
Notification handle = 0x002a value: 08 3c 00 00
[74:B9:AB:CF:13:A9][LE]>