mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2024-12-26 04:30:46 +01:00
141 lines
7.7 KiB
HTML
141 lines
7.7 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.9.1"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>esp-nimble-cpp: Usage Tips</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="resize.js"></script>
|
|
<script type="text/javascript" src="navtreedata.js"></script>
|
|
<script type="text/javascript" src="navtree.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
<div id="projectname">esp-nimble-cpp
|
|
 <span id="projectnumber">1.4.0</span>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.9.1 -->
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
|
|
/* @license-end */
|
|
</script>
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(function() {
|
|
initMenu('',true,false,'search.php','Search');
|
|
$(document).ready(function() { init_search(); });
|
|
});
|
|
/* @license-end */</script>
|
|
<div id="main-nav"></div>
|
|
</div><!-- top -->
|
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
|
<div id="nav-tree">
|
|
<div id="nav-tree-contents">
|
|
<div id="nav-sync" class="sync"></div>
|
|
</div>
|
|
</div>
|
|
<div id="splitbar" style="-moz-user-select:none;"
|
|
class="ui-resizable-handle">
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(document).ready(function(){initNavTree('md__usage_tips.html',''); initResizable(); });
|
|
/* @license-end */
|
|
</script>
|
|
<div id="doc-content">
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<div class="PageDoc"><div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">Usage Tips </div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<div class="textblock"><h1><a class="anchor" id="autotoc_md77"></a>
|
|
Put BLE functions in a task running on the NimBLE stack core</h1>
|
|
<p>When commands are sent to the stack from a different core they can experience delays in execution. <br />
|
|
This library detects this and invokes the esp32 IPC to reroute these commands through the correct core but this also increases overhead. <br />
|
|
Therefore it is highly recommended to create tasks for BLE to run on the same core, the macro <code>CONFIG_BT_NIMBLE_PINNED_TO_CORE</code> can be used to set the core. <br />
|
|
<br />
|
|
</p>
|
|
<h1><a class="anchor" id="autotoc_md78"></a>
|
|
Do not delete client instances unless necessary or unused</h1>
|
|
<p>When a client instance has been created and has connected to a peer device and it has retrieved service/characteristic information it will store that data for the life of the client instance. <br />
|
|
If you are periodically connecting to the same devices and you have deleted the client instance or the services when connecting again it will cause a retrieval of that information from the peer again. <br />
|
|
This results in significant energy drain on the battery of the devices, fragments heap, and reduces connection performance. <br />
|
|
</p>
|
|
<p>Client instances in this library use approximately 20% of the original bluedroid library, deleting them will provide much less gain than it did before. <br />
|
|
</p>
|
|
<p>It is recommended to retain the client instance in cases where the time between connecting to the same device is less than 5 minutes. <br />
|
|
<br />
|
|
<br />
|
|
</p>
|
|
<h1><a class="anchor" id="autotoc_md79"></a>
|
|
Only retrieve the services and characteristics needed</h1>
|
|
<p>As a client the use of <code><a class="el" href="class_nim_b_l_e_client.html#acb9007569b3bb13b3b49f3c4cb47b21a" title="Get a pointer to the vector of found services.">NimBLEClient::getServices</a></code> or <code><a class="el" href="class_nim_b_l_e_remote_service.html#a2c9e91c842598a6a9576c7b87af0863a" title="Get a pointer to the vector of found characteristics.">NimBLERemoteService::getCharacteristics</a></code> and using <code>true</code> for the parameter should be limited to devices that are not known. <br />
|
|
Instead <code>NimBLEClient::getService(NimBLEUUID)</code> or <code>NimBLERemoteService::getCharacteristic(NimBLEUUID)</code> should be used to access certain attributes that are useful to the application. <br />
|
|
This reduces energy consumed, heap allocated, connection time and improves overall efficiency. <br />
|
|
<br />
|
|
<br />
|
|
</p>
|
|
<h1><a class="anchor" id="autotoc_md80"></a>
|
|
Check return values</h1>
|
|
<p>Many user issues can be avoided by checking if a function returned successfully, by either testing for true/false such as when calling <code><a class="el" href="class_nim_b_l_e_client.html#ae9b3e8a9b47c7eaad040b485bda958a1" title="Connect to an advertising device.">NimBLEClient::connect</a></code>, <br />
|
|
or nullptr such as when calling <code><a class="el" href="class_nim_b_l_e_client.html#ae22379ab10bd82932d2303fb3753c366" title="Get the service BLE Remote Service instance corresponding to the uuid.">NimBLEClient::getService</a></code>. The latter being a must, as calling a method on a nullptr will surely result in a crash. <br />
|
|
Most of the functions in this library return something that should be checked before proceeding. <br />
|
|
<br />
|
|
<br />
|
|
</p>
|
|
<h1><a class="anchor" id="autotoc_md81"></a>
|
|
There will be bugs - please report them</h1>
|
|
<p>No code is bug free and unit testing will not find them all on it's own. If you encounter a bug, please report it along with any logs and decoded backtrace if applicable. <br />
|
|
Best efforts will be made to correct any errors ASAP. <br />
|
|
</p>
|
|
<p>Bug reports can be made at <a href="https://github.com/h2zero/NimBLE-Arduino/issues">https://github.com/h2zero/NimBLE-Arduino/issues</a> or <a href="https://github.com/h2zero/esp-nimble-cpp/issues">https://github.com/h2zero/esp-nimble-cpp/issues</a>. <br />
|
|
Questions and suggestions will be happily accepted there as well. </p>
|
|
</div></div><!-- contents -->
|
|
</div><!-- PageDoc -->
|
|
</div><!-- doc-content -->
|
|
<!-- start footer part -->
|
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
|
<ul>
|
|
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
</html>
|