QBluetoothLeUart/classQBluetoothLeUartClient.html
2022-08-05 07:46:55 +00:00

548 lines
42 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>QBluetoothLeUartClient class | Qt BluetoothLE UART library</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
<link rel="stylesheet" href="m-dark+documentation.compiled.css" />
<link rel="icon" href="favicon-dark.png" type="image/png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#0094ff" />
</head>
<body>
<header><nav id="navigation">
<div class="m-container">
<div class="m-row">
<a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m">Qt BluetoothLE UART library</a>
<div class="m-col-t-4 m-hide-m m-text-right m-nopadr">
<a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<path id="m-doc-search-icon-path" d="m6 0c-3.31 0-6 2.69-6 6 0 3.31 2.69 6 6 6 1.49 0 2.85-0.541 3.89-1.44-0.0164 0.338 0.147 0.759 0.5 1.15l3.22 3.79c0.552 0.614 1.45 0.665 2 0.115 0.55-0.55 0.499-1.45-0.115-2l-3.79-3.22c-0.392-0.353-0.812-0.515-1.15-0.5 0.895-1.05 1.44-2.41 1.44-3.89 0-3.31-2.69-6-6-6zm0 1.56a4.44 4.44 0 0 1 4.44 4.44 4.44 4.44 0 0 1-4.44 4.44 4.44 4.44 0 0 1-4.44-4.44 4.44 4.44 0 0 1 4.44-4.44z"/>
</svg></a>
<a id="m-navbar-show" href="#navigation" title="Show navigation"></a>
<a id="m-navbar-hide" href="#" title="Hide navigation"></a>
</div>
<div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
<div class="m-row">
<ol class="m-col-t-6 m-col-m-none">
</ol>
<ol class="m-col-t-6 m-col-m-none" start="1">
<li><a href="index.html">Introduction</a></li>
<li><a href="annotated.html">Classes</a></li>
<li><a href="refman.pdf">Download</a></li>
<li class="m-show-m"><a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<use href="#m-doc-search-icon-path" />
</svg></a></li>
</ol>
</div>
</div>
</div>
</div>
</nav></header>
<main><article>
<div class="m-container m-container-inflatable">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<h1>
QBluetoothLeUartClient <span class="m-thin">class</span>
</h1>
<p>The <a href="classQBluetoothLeUartClient.html" class="m-doc">QBluetoothLeUartClient</a> class can be used to talk to BluetoothLE devices via UART effordlessly. It can be used via C++ and QML.</p>
<nav class="m-block m-default">
<h3>Contents</h3>
<ul>
<li>
Reference
<ul>
<li><a href="#pub-types">Public types</a></li>
<li><a href="#pub-static-methods">Public static functions</a></li>
<li><a href="#pub-methods">Public functions</a></li>
<li><a href="#pub-slots">Public slots</a></li>
</ul>
</li>
</ul>
</nav>
<p>C++ example:</p><pre class="m-code"><span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;qbluetoothleuartclient.h&gt;</span><span class="cp"></span>
<span class="k">class</span><span class="w"> </span><span class="nc">MyBluetoothLeClass</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="n">QObject</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="k">public</span><span class="o">:</span><span class="w"></span>
<span class="w"> </span><span class="n">MyBluetoothLeClass</span><span class="p">(</span><span class="n">QObject</span><span class="o">*</span><span class="w"> </span><span class="n">parent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">nullptr</span><span class="p">)</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="n">QObject</span><span class="p">(</span><span class="n">parent</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="k">this</span><span class="o">-&gt;</span><span class="n">ble</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">QBluetoothLeUartClient</span><span class="p">();</span><span class="w"></span>
<span class="w"> </span><span class="n">connect</span><span class="p">(</span><span class="k">this</span><span class="o">-&gt;</span><span class="n">ble</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">QBluetoothLeUartClient</span><span class="o">::</span><span class="n">foundNewDevice</span><span class="p">,</span><span class="w"> </span><span class="k">this</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">MyBluetoothLeClass</span><span class="o">::</span><span class="n">handleFoundNewDevice</span><span class="p">);</span><span class="w"></span>
<span class="w"> </span><span class="n">connect</span><span class="p">(</span><span class="k">this</span><span class="o">-&gt;</span><span class="n">ble</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">QBluetoothLeUartClient</span><span class="o">::</span><span class="n">connectedToDevice</span><span class="p">,</span><span class="w"> </span><span class="k">this</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">MyBluetoothLeClass</span><span class="o">::</span><span class="n">handleBluetoothDeviceConected</span><span class="p">);</span><span class="w"></span>
<span class="w"> </span><span class="n">connect</span><span class="p">(</span><span class="k">this</span><span class="o">-&gt;</span><span class="n">ble</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">QBluetoothLeUartClient</span><span class="o">::</span><span class="n">dataReceived</span><span class="p">,</span><span class="w"> </span><span class="k">this</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">MyBluetoothLeClass</span><span class="o">::</span><span class="n">handleDataReceived</span><span class="p">);</span><span class="w"></span>
<span class="w"> </span><span class="k">this</span><span class="o">-&gt;</span><span class="n">ble</span><span class="o">-&gt;</span><span class="n">startScanningForDevices</span><span class="p">();</span><span class="w"></span>
<span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="k">private</span><span class="o">:</span><span class="w"></span>
<span class="w"> </span><span class="n">QBluetoothLeUartClient</span><span class="w"> </span><span class="o">*</span><span class="n">ble</span><span class="p">;</span><span class="w"></span>
<span class="k">private</span><span class="w"> </span><span class="n">slots</span><span class="o">:</span><span class="w"></span>
<span class="w"> </span><span class="kt">void</span><span class="w"> </span><span class="n">handleFoundNewDevice</span><span class="p">(</span><span class="n">QBluetoothLeUartDevice</span><span class="o">*</span><span class="w"> </span><span class="n">device</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="n">qDebug</span><span class="p">()</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="s">&quot;Found a device: name: &quot;</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">device</span><span class="o">-&gt;</span><span class="n">getName</span><span class="p">()</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="s">&quot; address: &quot;</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">device</span><span class="o">-&gt;</span><span class="n">getAddress</span><span class="p">();</span><span class="w"></span>
<span class="w"> </span><span class="k">if</span><span class="p">(</span><span class="n">device</span><span class="o">-&gt;</span><span class="n">getName</span><span class="p">()</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s">&quot;My device name&quot;</span><span class="p">){</span><span class="w"></span>
<span class="w"> </span><span class="k">this</span><span class="o">-&gt;</span><span class="n">ble</span><span class="o">-&gt;</span><span class="n">stopScanningForDevices</span><span class="p">();</span><span class="w"></span>
<span class="w"> </span><span class="k">this</span><span class="o">-&gt;</span><span class="n">ble</span><span class="o">-&gt;</span><span class="n">connectToDevice</span><span class="p">(</span><span class="n">device</span><span class="p">);</span><span class="w"></span>
<span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w"> </span><span class="kt">void</span><span class="w"> </span><span class="n">handleBluetoothDeviceConected</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="k">this</span><span class="o">-&gt;</span><span class="n">ble</span><span class="o">-&gt;</span><span class="n">sendData</span><span class="p">(</span><span class="s">&quot;This is my test message&quot;</span><span class="p">);</span><span class="w"></span>
<span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w"> </span><span class="kt">void</span><span class="w"> </span><span class="n">handleDataReceived</span><span class="p">(</span><span class="k">const</span><span class="w"> </span><span class="n">QString</span><span class="w"> </span><span class="o">&amp;</span><span class="n">s</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="n">qDebug</span><span class="p">()</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="s">&quot;Data received: &quot;</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">s</span><span class="p">;</span><span class="w"></span>
<span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">};</span><span class="w"></span></pre><p>QML example:</p><pre class="m-code"><span class="kr">import</span> <span class="nx">de</span><span class="p">.</span><span class="nx">itsblue</span><span class="p">.</span><span class="nx">bluetoothleuart</span> <span class="mf">1.0</span>
<span class="nx">QBluetoothLeUartClient</span> <span class="p">{</span>
<span class="kd">id: ble</span>
<span class="k">Component.onCompleted:</span> <span class="p">{</span>
<span class="nx">ble</span><span class="p">.</span><span class="nx">startScanningForDevices</span><span class="p">()</span>
<span class="p">}</span>
<span class="k">onFoundNewDevice:</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Found a device: name: &quot;</span> <span class="o">+</span> <span class="nx">device</span><span class="p">.</span><span class="nx">name</span> <span class="o">+</span> <span class="s2">&quot; address: &quot;</span> <span class="o">+</span> <span class="nx">device</span><span class="p">.</span><span class="nx">address</span><span class="p">)</span>
<span class="k">if</span><span class="p">(</span><span class="nx">device</span><span class="p">.</span><span class="nx">name</span> <span class="o">===</span> <span class="s2">&quot;My device name&quot;</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">ble</span><span class="p">.</span><span class="nx">stopScanningForDevices</span><span class="p">()</span>
<span class="nx">ble</span><span class="p">.</span><span class="nx">connectToDevice</span><span class="p">(</span><span class="nx">device</span><span class="p">)</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">onConnectedToDevice:</span> <span class="p">{</span>
<span class="nx">ble</span><span class="p">.</span><span class="nx">sendData</span><span class="p">(</span><span class="s2">&quot;This is my test message&quot;</span><span class="p">)</span>
<span class="p">}</span>
<span class="k">onDataReceived:</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Data received: &quot;</span> <span class="o">+</span> <span class="nx">data</span><span class="p">)</span>
<span class="p">}</span>
<span class="p">}</span></pre><p>To get all available devices in a model, use the <a href="classQBluetoothLeUartDeviceModel.html" class="m-doc">QBluetoothLeUartDeviceModel</a>.</p>
<section id="pub-types">
<h2><a href="#pub-types">Public types</a></h2>
<dl class="m-doc">
<dt>
<span class="m-doc-wrap-bumper">enum <a href="#af6052aceb355d5171ac0d20276211bb7" class="m-doc">BluetoothLeUartClientState</a> { </span><span class="m-doc-wrap"><a href="#af6052aceb355d5171ac0d20276211bb7a16ab5db5dd73533246deb4c3e62a15c0" class="m-doc">Idle</a> = 0,
<a href="#af6052aceb355d5171ac0d20276211bb7a73c62c3a44f56cead1d5d6e73ccd9ef3" class="m-doc">AdapterTurnedOff</a>,
<a href="#af6052aceb355d5171ac0d20276211bb7a70ca0d74d287cb73d0533ebbb19afde7" class="m-doc">LocationPermissionDenied</a>,
<a href="#af6052aceb355d5171ac0d20276211bb7ad909445369e196b44aeb5eb0d4de8829" class="m-doc">Scanning</a>,
<a href="#af6052aceb355d5171ac0d20276211bb7a16f5a126ec8a4f54041b4b425d9ecc57" class="m-doc">ScanFinished</a>,
<a href="#af6052aceb355d5171ac0d20276211bb7af83eacaf7ffa62c7831d7214a0de890a" class="m-doc">Connecting</a>,
<a href="#af6052aceb355d5171ac0d20276211bb7a609ce7ca1a8b38aa184b646632542d52" class="m-doc">ScanningForService</a>,
<a href="#af6052aceb355d5171ac0d20276211bb7adbdbfbfba03d4443c2b3828a7d675803" class="m-doc">ServiceFound</a>,
<a href="#af6052aceb355d5171ac0d20276211bb7a1b365b897dc9cbb49d1a31a2cba9f793" class="m-doc">Connected</a> }</span>
</dt>
<dd>The BluetoothLeUartState enum contains all state of the QBluetoothLeUart class.</dd>
</dl>
</section>
<section id="pub-static-methods">
<h2><a href="#pub-static-methods">Public static functions</a></h2>
<dl class="m-doc">
<dt id="a439ffef7bf397f5b502300cfc4c64cc6">
<span class="m-doc-wrap-bumper">static void <a href="#a439ffef7bf397f5b502300cfc4c64cc6" class="m-doc-self">init</a>(</span><span class="m-doc-wrap">)</span>
</dt>
<dd>Function to register QMl types.</dd>
</dl>
</section>
<section id="pub-methods">
<h2><a href="#pub-methods">Public functions</a></h2>
<dl class="m-doc">
<dt>
<span class="m-doc-wrap-bumper">void <a href="#a518dd07ab439c88f48537474517c0ac5" class="m-doc">setUUIDs</a>(</span><span class="m-doc-wrap">const char uartServiceUUID[36],
const char txUUID[36],
const char rxUUID[36])</span>
</dt>
<dd>Function to set the UUIDs of the bluetooth service.</dd>
</dl>
</section>
<section id="pub-slots">
<h2><a href="#pub-slots">Public slots</a></h2>
<dl class="m-doc">
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#a80bbbe83418b848e4a7db0cf5ef4f0f7" class="m-doc">startScanningForDevices</a>(</span><span class="m-doc-wrap">) -&gt; Q_INVOKABLE bool</span>
</dt>
<dd>Fuction to start scanning for devices.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#a6729698429cfc8b77fbe8f82c14f082e" class="m-doc">stopScanningForDevices</a>(</span><span class="m-doc-wrap">) -&gt; Q_INVOKABLE bool</span>
</dt>
<dd>Function to stop scanning for devices.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#a7280d732e1cb2c857b995f70443a49e9" class="m-doc">getAvailableDevices</a>(</span><span class="m-doc-wrap">) -&gt; Q_INVOKABLE QList&lt;<a href="classQBluetoothLeUartDevice.html" class="m-doc">QBluetoothLeUartDevice</a>*&gt;</span>
</dt>
<dd>Function to get all devices that were found during the last scan.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#a9338b59d55d929683808e5888066b0e6" class="m-doc">getAvailableDevicesDetailList</a>(</span><span class="m-doc-wrap">) -&gt; Q_INVOKABLE QVariantList</span>
</dt>
<dd>Function to get a variant list of all devices that were found during the last scan.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#abaa6dedcb1ea7036d077b5d38cfd147e" class="m-doc">getAvailableDevicesModel</a>(</span><span class="m-doc-wrap">) -&gt; Q_INVOKABLE <a href="classQBluetoothLeUartDeviceModel.html" class="m-doc">QBluetoothLeUartDeviceModel</a>*</span>
</dt>
<dd>Function to get a <a href="classQBluetoothLeUartDeviceModel.html" class="m-doc">QBluetoothLeUartDeviceModel</a> with all available devices.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#ac625b96aa0c295387ed813ee146c7110" class="m-doc">getCurrentDevice</a>(</span><span class="m-doc-wrap">) -&gt; Q_INVOKABLE <a href="classQBluetoothLeUartDevice.html" class="m-doc">QBluetoothLeUartDevice</a>*</span>
</dt>
<dd>Function to get the currently connected device.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#a50d74ef6dd2ac09d8e90af28b540abd7" class="m-doc">connectToDevice</a>(</span><span class="m-doc-wrap">int deviceId) -&gt; Q_INVOKABLE bool</span>
</dt>
<dd>Function connect to a device using its internal id.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#afae86d1aaa2301e1d811e62a75a0af73" class="m-doc">connectToDevice</a>(</span><span class="m-doc-wrap"><a href="classQBluetoothLeUartDevice.html" class="m-doc">QBluetoothLeUartDevice</a>* device) -&gt; Q_INVOKABLE bool</span>
</dt>
<dd>Function connect to a device using a <a href="classQBluetoothLeUartDevice.html" class="m-doc">QBluetoothLeUartDevice</a> object.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#ac9985bc027c769d1fc4c9640ba6895fa" class="m-doc">disconnectFromDevice</a>(</span><span class="m-doc-wrap">) -&gt; Q_INVOKABLE bool</span>
</dt>
<dd>Function to disconnect from the current device.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#af005db6ad589ef2e99f3a76b02d54836" class="m-doc">sendData</a>(</span><span class="m-doc-wrap">QString data,
bool asynchronous = true) -&gt; Q_INVOKABLE bool</span>
</dt>
<dd>Function to send data to the connected device.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#a094551beaf6d56e004bafa17b51b80cd" class="m-doc">getState</a>(</span><span class="m-doc-wrap">) const -&gt; Q_INVOKABLE <a href="classQBluetoothLeUartClient.html#af6052aceb355d5171ac0d20276211bb7" class="m-doc">QBluetoothLeUartClient::<wbr />BluetoothLeUartClientState</a></span>
</dt>
<dd>Function to get the current state of QBluetoothLeUart.</dd>
</dl>
</section>
<section>
<h2>Enum documentation</h2>
<section class="m-doc-details" id="af6052aceb355d5171ac0d20276211bb7"><div>
<h3>
enum QBluetoothLeUartClient::<wbr /><a href="#af6052aceb355d5171ac0d20276211bb7" class="m-doc-self">BluetoothLeUartClientState</a>
</h3>
<p>The BluetoothLeUartState enum contains all state of the QBluetoothLeUart class.</p>
<table class="m-table m-fullwidth m-flat m-doc">
<thead><tr><th style="width: 1%">Enumerators</th><th></th></tr></thead>
<tbody>
<tr>
<td><a href="#af6052aceb355d5171ac0d20276211bb7a16ab5db5dd73533246deb4c3e62a15c0" class="m-doc-self" id="af6052aceb355d5171ac0d20276211bb7a16ab5db5dd73533246deb4c3e62a15c0">Idle</a></td>
<td>
<p>Waiting for instrucions</p>
</td>
</tr>
<tr>
<td><a href="#af6052aceb355d5171ac0d20276211bb7a73c62c3a44f56cead1d5d6e73ccd9ef3" class="m-doc-self" id="af6052aceb355d5171ac0d20276211bb7a73c62c3a44f56cead1d5d6e73ccd9ef3">AdapterTurnedOff</a></td>
<td>
<p>The bluetooth adapter is turned off</p>
</td>
</tr>
<tr>
<td><a href="#af6052aceb355d5171ac0d20276211bb7a70ca0d74d287cb73d0533ebbb19afde7" class="m-doc-self" id="af6052aceb355d5171ac0d20276211bb7a70ca0d74d287cb73d0533ebbb19afde7">LocationPermissionDenied</a></td>
<td>
<p>The location permssion was denied and we are therfor unable to scan!</p>
</td>
</tr>
<tr>
<td><a href="#af6052aceb355d5171ac0d20276211bb7ad909445369e196b44aeb5eb0d4de8829" class="m-doc-self" id="af6052aceb355d5171ac0d20276211bb7ad909445369e196b44aeb5eb0d4de8829">Scanning</a></td>
<td>
<p>Scanning for devices</p>
</td>
</tr>
<tr>
<td><a href="#af6052aceb355d5171ac0d20276211bb7a16f5a126ec8a4f54041b4b425d9ecc57" class="m-doc-self" id="af6052aceb355d5171ac0d20276211bb7a16f5a126ec8a4f54041b4b425d9ecc57">ScanFinished</a></td>
<td>
<p>Scanning has finished, we are ready to connect</p>
</td>
</tr>
<tr>
<td><a href="#af6052aceb355d5171ac0d20276211bb7af83eacaf7ffa62c7831d7214a0de890a" class="m-doc-self" id="af6052aceb355d5171ac0d20276211bb7af83eacaf7ffa62c7831d7214a0de890a">Connecting</a></td>
<td>
<p>Trying to connect</p>
</td>
</tr>
<tr>
<td><a href="#af6052aceb355d5171ac0d20276211bb7a609ce7ca1a8b38aa184b646632542d52" class="m-doc-self" id="af6052aceb355d5171ac0d20276211bb7a609ce7ca1a8b38aa184b646632542d52">ScanningForService</a></td>
<td>
<p>Connection was successfull, now scanning for services</p>
</td>
</tr>
<tr>
<td><a href="#af6052aceb355d5171ac0d20276211bb7adbdbfbfba03d4443c2b3828a7d675803" class="m-doc-self" id="af6052aceb355d5171ac0d20276211bb7adbdbfbfba03d4443c2b3828a7d675803">ServiceFound</a></td>
<td>
<p>Services were found</p>
</td>
</tr>
<tr>
<td><a href="#af6052aceb355d5171ac0d20276211bb7a1b365b897dc9cbb49d1a31a2cba9f793" class="m-doc-self" id="af6052aceb355d5171ac0d20276211bb7a1b365b897dc9cbb49d1a31a2cba9f793">Connected</a></td>
<td>
<p>Connected. We are now ready to send and receive</p>
</td>
</tr>
</tbody>
</table>
</div></section>
</section>
<section>
<h2>Function documentation</h2>
<section class="m-doc-details" id="a518dd07ab439c88f48537474517c0ac5"><div>
<h3>
<span class="m-doc-wrap-bumper">void QBluetoothLeUartClient::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a518dd07ab439c88f48537474517c0ac5" class="m-doc-self">setUUIDs</a>(</span><span class="m-doc-wrap">const char uartServiceUUID[36],
const char txUUID[36],
const char rxUUID[36])</span></span>
</h3>
<p>Function to set the UUIDs of the bluetooth service.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">uartServiceUUID</td>
<td>Service UUID</td>
</tr>
<tr>
<td>txUUID</td>
<td>UUID of the characteristic used to send data</td>
</tr>
<tr>
<td>rxUUID</td>
<td>UUID of the characteristic used to receive data</td>
</tr>
</tbody>
</table>
</div></section>
<section class="m-doc-details" id="a80bbbe83418b848e4a7db0cf5ef4f0f7"><div>
<h3>
<span class="m-doc-wrap-bumper">Q_INVOKABLE bool QBluetoothLeUartClient::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a80bbbe83418b848e4a7db0cf5ef4f0f7" class="m-doc-self">startScanningForDevices</a>(</span><span class="m-doc-wrap">) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Fuction to start scanning for devices.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>true if the scan started, false if the current state was not Idle</td>
</tr>
</tfoot>
</table>
<p>This function will start the device scanning process and might emit the following signals during scanning:</p><ul><li>foundNewDevice() when a new device is found</li><li>avaliableDevicesChanged() when a new device is found</li><li>scanFinished() when the scan has finished</li><li>scanningErrorOccured() when an error occured</li></ul><aside class="m-note m-default"><h4>See also</h4><p>foundNewDevice()</p><p>avaliableDevicesChanged()</p><p>scanFinished()</p><p>scanningErrorOccured()</p></aside>
</div></section>
<section class="m-doc-details" id="a6729698429cfc8b77fbe8f82c14f082e"><div>
<h3>
<span class="m-doc-wrap-bumper">Q_INVOKABLE bool QBluetoothLeUartClient::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a6729698429cfc8b77fbe8f82c14f082e" class="m-doc-self">stopScanningForDevices</a>(</span><span class="m-doc-wrap">) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to stop scanning for devices.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>true if the scan was stopped, false if the current state was not Scanning</td>
</tr>
</tfoot>
</table>
</div></section>
<section class="m-doc-details" id="a7280d732e1cb2c857b995f70443a49e9"><div>
<h3>
<span class="m-doc-wrap-bumper">Q_INVOKABLE QList&lt;<a href="classQBluetoothLeUartDevice.html" class="m-doc">QBluetoothLeUartDevice</a>*&gt; QBluetoothLeUartClient::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a7280d732e1cb2c857b995f70443a49e9" class="m-doc-self">getAvailableDevices</a>(</span><span class="m-doc-wrap">) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to get all devices that were found during the last scan.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>List of all devices found during last scan</td>
</tr>
</tfoot>
</table>
<p>A <a href="classQBluetoothLeUartDevice.html" class="m-doc">QBluetoothLeUartDevice</a> object can be used to connect to the specific device</p><aside class="m-note m-default"><h4>See also</h4><p><a href="classQBluetoothLeUartClient.html#a50d74ef6dd2ac09d8e90af28b540abd7" class="m-doc">connectToDevice()</a></p></aside>
</div></section>
<section class="m-doc-details" id="a9338b59d55d929683808e5888066b0e6"><div>
<h3>
<span class="m-doc-wrap-bumper">Q_INVOKABLE QVariantList QBluetoothLeUartClient::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a9338b59d55d929683808e5888066b0e6" class="m-doc-self">getAvailableDevicesDetailList</a>(</span><span class="m-doc-wrap">) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to get a variant list of all devices that were found during the last scan.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>Variant list of all devices found during last scan</td>
</tr>
</tfoot>
</table>
<p>This will return a QVariantList that contains QVariantMaps. The maps contain the following keys:</p><ul><li>&quot;id&quot; (int): the internal id of the device (used to connect to it)</li><li>&quot;name&quot; (QString): the name of the device</li><li>&quot;address&quot; (QString): the bluetooth address of the device</li></ul><aside class="m-note m-default"><h4>See also</h4><p><a href="classQBluetoothLeUartClient.html#a50d74ef6dd2ac09d8e90af28b540abd7" class="m-doc">connectToDevice()</a></p></aside>
</div></section>
<section class="m-doc-details" id="abaa6dedcb1ea7036d077b5d38cfd147e"><div>
<h3>
<span class="m-doc-wrap-bumper">Q_INVOKABLE <a href="classQBluetoothLeUartDeviceModel.html" class="m-doc">QBluetoothLeUartDeviceModel</a>* QBluetoothLeUartClient::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#abaa6dedcb1ea7036d077b5d38cfd147e" class="m-doc-self">getAvailableDevicesModel</a>(</span><span class="m-doc-wrap">) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to get a <a href="classQBluetoothLeUartDeviceModel.html" class="m-doc">QBluetoothLeUartDeviceModel</a> with all available devices.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>A <a href="classQBluetoothLeUartDeviceModel.html" class="m-doc">QBluetoothLeUartDeviceModel</a> with all available devices</td>
</tr>
</tfoot>
</table>
<aside class="m-note m-default"><h4>See also</h4><p><a href="classQBluetoothLeUartDeviceModel.html" class="m-doc">QBluetoothLeUartDeviceModel</a></p></aside>
</div></section>
<section class="m-doc-details" id="ac625b96aa0c295387ed813ee146c7110"><div>
<h3>
<span class="m-doc-wrap-bumper">Q_INVOKABLE <a href="classQBluetoothLeUartDevice.html" class="m-doc">QBluetoothLeUartDevice</a>* QBluetoothLeUartClient::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#ac625b96aa0c295387ed813ee146c7110" class="m-doc-self">getCurrentDevice</a>(</span><span class="m-doc-wrap">) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to get the currently connected device.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>The currently connected device or nullptr if no device is connected</td>
</tr>
</tfoot>
</table>
</div></section>
<section class="m-doc-details" id="a50d74ef6dd2ac09d8e90af28b540abd7"><div>
<h3>
<span class="m-doc-wrap-bumper">Q_INVOKABLE bool QBluetoothLeUartClient::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a50d74ef6dd2ac09d8e90af28b540abd7" class="m-doc-self">connectToDevice</a>(</span><span class="m-doc-wrap">int deviceId) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function connect to a device using its internal id.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">deviceId</td>
<td>the internal id of the device</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Returns</th>
<td>false if the device was not found in the internal list of discovered devices, true otherwise</td>
</tr>
</tfoot>
</table>
<p>The id can be found using <a href="classQBluetoothLeUartClient.html#a9338b59d55d929683808e5888066b0e6" class="m-doc">getAvailableDevicesDetailList()</a> The connectedToDevice() signal will be emited as soon as the connection was successfull. As soon as that signal was emited, the <a href="classQBluetoothLeUartClient.html#af005db6ad589ef2e99f3a76b02d54836" class="m-doc">sendData()</a> slot can be used to send data and the dataReceived() signal will be emited whenever data is received.</p><aside class="m-note m-default"><h4>See also</h4><p><a href="classQBluetoothLeUartClient.html#a9338b59d55d929683808e5888066b0e6" class="m-doc">getAvailableDevicesDetailList()</a></p><p>connectedToDevice()</p><p>dataReceived()</p></aside>
</div></section>
<section class="m-doc-details" id="afae86d1aaa2301e1d811e62a75a0af73"><div>
<h3>
<span class="m-doc-wrap-bumper">Q_INVOKABLE bool QBluetoothLeUartClient::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#afae86d1aaa2301e1d811e62a75a0af73" class="m-doc-self">connectToDevice</a>(</span><span class="m-doc-wrap"><a href="classQBluetoothLeUartDevice.html" class="m-doc">QBluetoothLeUartDevice</a>* device) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function connect to a device using a <a href="classQBluetoothLeUartDevice.html" class="m-doc">QBluetoothLeUartDevice</a> object.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">device</td>
<td>The device to connect to</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Returns</th>
<td>false if the device was not found in the internal list of discovered devices, true otherwise</td>
</tr>
</tfoot>
</table>
<p>The <a href="classQBluetoothLeUartDevice.html" class="m-doc">QBluetoothLeUartDevice</a> can be found using <a href="classQBluetoothLeUartClient.html#a7280d732e1cb2c857b995f70443a49e9" class="m-doc">getAvailableDevices()</a> The connectedToDevice() signal will be emited as soon as the connection was successfull. As soon as that signal was emited, the <a href="classQBluetoothLeUartClient.html#af005db6ad589ef2e99f3a76b02d54836" class="m-doc">sendData()</a> slot can be used to send data and the dataReceived() signal will be emited whenever data is received.</p><aside class="m-note m-default"><h4>See also</h4><p><a href="classQBluetoothLeUartClient.html#a7280d732e1cb2c857b995f70443a49e9" class="m-doc">getAvailableDevices()</a></p><p>connectedToDevice()</p><p>dataReceived()</p></aside>
</div></section>
<section class="m-doc-details" id="ac9985bc027c769d1fc4c9640ba6895fa"><div>
<h3>
<span class="m-doc-wrap-bumper">Q_INVOKABLE bool QBluetoothLeUartClient::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#ac9985bc027c769d1fc4c9640ba6895fa" class="m-doc-self">disconnectFromDevice</a>(</span><span class="m-doc-wrap">) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to disconnect from the current device.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>false if no device was connected, true otherwise</td>
</tr>
</tfoot>
</table>
</div></section>
<section class="m-doc-details" id="af005db6ad589ef2e99f3a76b02d54836"><div>
<h3>
<span class="m-doc-wrap-bumper">Q_INVOKABLE bool QBluetoothLeUartClient::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#af005db6ad589ef2e99f3a76b02d54836" class="m-doc-self">sendData</a>(</span><span class="m-doc-wrap">QString data,
bool asynchronous = true) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to send data to the connected device.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">data</td>
<td>The data to send</td>
</tr>
<tr>
<td>asynchronous</td>
<td></td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Returns</th>
<td>false if there was not device connected, true otherwise</td>
</tr>
</tfoot>
</table>
</div></section>
<section class="m-doc-details" id="a094551beaf6d56e004bafa17b51b80cd"><div>
<h3>
<span class="m-doc-wrap-bumper">Q_INVOKABLE <a href="classQBluetoothLeUartClient.html#af6052aceb355d5171ac0d20276211bb7" class="m-doc">QBluetoothLeUartClient::<wbr />BluetoothLeUartClientState</a> QBluetoothLeUartClient::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a094551beaf6d56e004bafa17b51b80cd" class="m-doc-self">getState</a>(</span><span class="m-doc-wrap">) const <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to get the current state of QBluetoothLeUart.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>The current state</td>
</tr>
</tfoot>
</table>
<aside class="m-note m-default"><h4>See also</h4><p>BluetoothLeUartState</p></aside>
</div></section>
</section>
</div>
</div>
</div>
</article></main>
<div class="m-doc-search" id="search">
<a href="#!" onclick="return hideSearch()"></a>
<div class="m-container">
<div class="m-row">
<div class="m-col-m-8 m-push-m-2">
<div class="m-doc-search-header m-text m-small">
<div><span class="m-label m-default">Tab</span> / <span class="m-label m-default">T</span> to search, <span class="m-label m-default">Esc</span> to close</div>
<div id="search-symbolcount">&hellip;</div>
</div>
<div class="m-doc-search-content">
<form>
<input type="search" name="q" id="search-input" placeholder="Loading &hellip;" disabled="disabled" autofocus="autofocus" autocomplete="off" spellcheck="false" />
</form>
<noscript class="m-text m-danger m-text-center">Unlike everything else in the docs, the search functionality <em>requires</em> JavaScript.</noscript>
<div id="search-help" class="m-text m-dim m-text-center">
<p class="m-noindent">Search for symbols, directories, files, pages or
modules. You can omit any prefix from the symbol or file path; adding a
<code>:</code> or <code>/</code> suffix lists all members of given symbol or
directory.</p>
<p class="m-noindent">Use <span class="m-label m-dim">&darr;</span>
/ <span class="m-label m-dim">&uarr;</span> to navigate through the list,
<span class="m-label m-dim">Enter</span> to go.
<span class="m-label m-dim">Tab</span> autocompletes common prefix, you can
copy a link to the result using <span class="m-label m-dim"></span>
<span class="m-label m-dim">L</span> while <span class="m-label m-dim"></span>
<span class="m-label m-dim">M</span> produces a Markdown link.</p>
</div>
<div id="search-notfound" class="m-text m-warning m-text-center">Sorry, nothing was found.</div>
<ul id="search-results"></ul>
</div>
</div>
</div>
</div>
</div>
<script src="search-v2.js"></script>
<script src="searchdata-v2.js" async="async"></script>
<footer><nav>
<div class="m-container">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<p>Qt BluetoothLE UART library. Created with <a href="https://doxygen.org/">Doxygen</a> 1.9.4 and <a href="https://mcss.mosra.cz/">m.css</a>.</p>
</div>
</div>
</div>
</nav></footer>
</body>
</html>