mirror of
https://github.com/pine64/bl_iot_sdk.git
synced 2024-11-19 14:13:48 +00:00
1045 lines
50 KiB
HTML
1045 lines
50 KiB
HTML
|
||
|
||
<!DOCTYPE html>
|
||
<html class="writer-html5" lang="zh" >
|
||
<head>
|
||
<meta charset="utf-8">
|
||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
||
<title>13. BLE — BL602 IoT SDK release_bl_iot_sdk_1.6.11-1-g66bb28da 文档</title>
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
|
||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||
<link rel="stylesheet" href="../../_static/style.css" type="text/css" />
|
||
<link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<!--[if lt IE 9]>
|
||
<script src="../../_static/js/html5shiv.min.js"></script>
|
||
<![endif]-->
|
||
|
||
|
||
<script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
|
||
<script src="../../_static/jquery.js"></script>
|
||
<script src="../../_static/underscore.js"></script>
|
||
<script src="../../_static/doctools.js"></script>
|
||
<script src="../../_static/language_data.js"></script>
|
||
|
||
<script type="text/javascript" src="../../_static/js/theme.js"></script>
|
||
|
||
|
||
<link rel="index" title="索引" href="../../genindex.html" />
|
||
<link rel="search" title="搜索" href="../../search.html" />
|
||
<link rel="next" title="14. Mesh" href="../demo_mesh/mesh.html" />
|
||
<link rel="prev" title="12. WiFi" href="../demo_wifi/wifi.html" />
|
||
</head>
|
||
|
||
<body class="wy-body-for-nav">
|
||
|
||
|
||
<div class="wy-grid-for-nav">
|
||
|
||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||
<div class="wy-side-scroll">
|
||
<div class="wy-side-nav-search" >
|
||
|
||
|
||
|
||
<a href="../../index.html" class="icon icon-home" alt="Documentation Home"> BL602 IoT SDK
|
||
|
||
|
||
|
||
</a>
|
||
|
||
|
||
|
||
|
||
<div class="version">
|
||
release_bl_iot_sdk_1.6.11-1-g66bb28da
|
||
</div>
|
||
|
||
|
||
|
||
|
||
<div role="search">
|
||
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
|
||
<input type="text" name="q" placeholder="在文档中搜索" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
|
||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<p class="caption"><span class="caption-text">Developer_Environment</span></p>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Developer_Environment/Developer_Environment.html">1. Developer Environment</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Developer_Environment/BLFlashEnv/BLFlashEnv.html">2. BLFlashEnv</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Developer_Environment/freedom_studio/freedom_studio.html">3. Freedom Studio</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Developer_Environment/eclipse/eclipse.html">4. Eclipse</a></li>
|
||
</ul>
|
||
<p class="caption"><span class="caption-text">Examples</span></p>
|
||
<ul class="current">
|
||
<li class="toctree-l1"><a class="reference internal" href="../helloworld/helloworld.html">1. Helloword</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../demo_aws/aws.html">2. aws</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../demo_peripherals_gpio/GPIO.html">3. GPIO</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../demo_peripherals_uart_echo/uart_echo.html">4. UART_echo</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../demo_peripherals_uart_ioctl/uart_ioctl.html">5. UART_ioctl</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../demo_protocols_http/http.html">6. Http client</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../demo_protocols_httpc/httpc.html">7. Httpc client</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../demo_storage_psm/psm.html">8. PSM</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../demo_storage_romfs/romfs.html">9. Romfs</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../demo_system_cli/cli.html">10. cli</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../demo_system_fdt/fdt.html">11. FDT</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../demo_wifi/wifi.html">12. WiFi</a></li>
|
||
<li class="toctree-l1 current"><a class="current reference internal" href="#">13. BLE</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="#id1">13.1. 总览</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="#id2">13.2. 使用步骤</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="#cli">13.3. Cli命令介绍</a><ul>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-init">13.3.1. <code class="docutils literal notranslate"><span class="pre">ble_init</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-auth">13.3.2. <code class="docutils literal notranslate"><span class="pre">ble_auth</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-unpair">13.3.3. <code class="docutils literal notranslate"><span class="pre">ble_unpair</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-start-adv">13.3.4. <code class="docutils literal notranslate"><span class="pre">ble_start_adv</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-stop-adv">13.3.5. <code class="docutils literal notranslate"><span class="pre">ble_stop_adv</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-start-scan">13.3.6. <code class="docutils literal notranslate"><span class="pre">ble_start_scan</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-stop-scan">13.3.7. <code class="docutils literal notranslate"><span class="pre">ble_stop_scan</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-conn-update">13.3.8. <code class="docutils literal notranslate"><span class="pre">ble_conn_update</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-security">13.3.9. <code class="docutils literal notranslate"><span class="pre">ble_security</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-get-device-name">13.3.10. <code class="docutils literal notranslate"><span class="pre">ble_get_device_name</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-set-device-name">13.3.11. <code class="docutils literal notranslate"><span class="pre">ble_set_device_name</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-read-local-address">13.3.12. <code class="docutils literal notranslate"><span class="pre">ble_read_local_address</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-set-adv-channel">13.3.13. <code class="docutils literal notranslate"><span class="pre">ble_set_adv_channel</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-connect">13.3.14. <code class="docutils literal notranslate"><span class="pre">ble_connect</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-disconnect">13.3.15. <code class="docutils literal notranslate"><span class="pre">ble_disconnect</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-select-conn">13.3.16. <code class="docutils literal notranslate"><span class="pre">ble_select_conn</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-auth-cancel">13.3.17. <code class="docutils literal notranslate"><span class="pre">ble_auth_cancel</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-auth-passkey-confirm">13.3.18. <code class="docutils literal notranslate"><span class="pre">ble_auth_passkey_confirm</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-auth-pairing-confirm">13.3.19. <code class="docutils literal notranslate"><span class="pre">ble_auth_pairing_confirm</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-auth-passkey">13.3.20. <code class="docutils literal notranslate"><span class="pre">ble_auth_passkey</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-exchange-mtu">13.3.21. <code class="docutils literal notranslate"><span class="pre">ble_exchange_mtu</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-discover">13.3.22. <code class="docutils literal notranslate"><span class="pre">ble_discover</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-read">13.3.23. <code class="docutils literal notranslate"><span class="pre">ble_read</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-write">13.3.24. <code class="docutils literal notranslate"><span class="pre">ble_write</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-write-without-rsp">13.3.25. <code class="docutils literal notranslate"><span class="pre">ble_write_without_rsp</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-subscribe">13.3.26. <code class="docutils literal notranslate"><span class="pre">ble_subscribe</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-unsubscribe">13.3.27. <code class="docutils literal notranslate"><span class="pre">ble_unsubscribe</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-set-data-len">13.3.28. <code class="docutils literal notranslate"><span class="pre">ble_set_data_len</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-conn-info">13.3.29. <code class="docutils literal notranslate"><span class="pre">ble_conn_info</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-disable">13.3.30. <code class="docutils literal notranslate"><span class="pre">ble_disable</span></code></a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#ble-set-tx-pwr">13.3.31. <code class="docutils literal notranslate"><span class="pre">ble_set_tx_pwr</span></code></a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../demo_mesh/mesh.html">14. Mesh</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../demo_blsync_ble/blsync_ble.html">15. BLSYNC-BLE</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../sdk_app_easyflash_boottimes/easyflash_boottimes.html">16. Easyflash4 boot times</a></li>
|
||
</ul>
|
||
<p class="caption"><span class="caption-text">Components</span></p>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Components/arch.html">1. arch</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Components/Command_line/helper.html">2. helper</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Components/Command_line/aos_cli.html">3. cli</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Components/Hal_drv/gpio.html">4. GPIO</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Components/Middleware/bloop/bloop.html">5. BLOOP</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Components/Middleware/blsync/blsync.html">6. BLSYNC</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Components/Middleware/dts/devicetree.html">7. device tree</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Components/Middleware/log/blog.html">8. blog</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Components/Middleware/security/security.html">9. Security</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Components/Middleware/vfs/vfs.html">10. AOS VFS</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Components/Middleware/yloop/yloop.html">11. yloop</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Components/Network/httpc/httpc.html">12. HTTPC</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Components/Network/https/https.html">13. HTTPS</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Components/Network/tls/tls.html">14. TLS</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Components/BLE/provision_WiFi/provision_WiFi.html">15. Provision_WiFi</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Components/BLE/mesh/mesh.html">16. Mesh</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Components/BLE/ble_stack/ble_stack.html">17. BLE</a></li>
|
||
</ul>
|
||
<p class="caption"><span class="caption-text">API</span></p>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../API/sys/cronalarms.html">1. cronalarms</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../API/wifi/wifi_mgmr.html">2. Wi-Fi Manager</a></li>
|
||
</ul>
|
||
|
||
|
||
|
||
</div>
|
||
|
||
</div>
|
||
</nav>
|
||
|
||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||
|
||
|
||
<nav class="wy-nav-top" aria-label="top navigation">
|
||
|
||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||
<a href="../../index.html">BL602 IoT SDK</a>
|
||
|
||
</nav>
|
||
|
||
|
||
<div class="wy-nav-content">
|
||
|
||
<div class="rst-content">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||
|
||
<ul class="wy-breadcrumbs">
|
||
|
||
<li><a href="../../index.html" class="icon icon-home"></a> »</li>
|
||
|
||
<li><span class="section-number">13. </span>BLE</li>
|
||
|
||
|
||
<li class="wy-breadcrumbs-aside">
|
||
|
||
|
||
<a href="../../_sources/Examples/demo_ble/ble.rst.txt" rel="nofollow"> 查看页面源码</a>
|
||
|
||
|
||
</li>
|
||
|
||
</ul>
|
||
|
||
|
||
<hr/>
|
||
</div>
|
||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||
<div itemprop="articleBody">
|
||
|
||
<div class="section" id="ble">
|
||
<span id="ble-index"></span><h1><span class="section-number">13. </span>BLE<a class="headerlink" href="#ble" title="永久链接至标题">¶</a></h1>
|
||
<div class="section" id="id1">
|
||
<h2><span class="section-number">13.1. </span>总览<a class="headerlink" href="#id1" title="永久链接至标题">¶</a></h2>
|
||
<p>本示例主要介绍如何使用ble。</p>
|
||
</div>
|
||
<div class="section" id="id2">
|
||
<h2><span class="section-number">13.2. </span>使用步骤<a class="headerlink" href="#id2" title="永久链接至标题">¶</a></h2>
|
||
<ul>
|
||
<li><p>编译 <code class="docutils literal notranslate"><span class="pre">customer_app/bl602_demo_event</span></code> 或 <code class="docutils literal notranslate"><span class="pre">customer_app/bl702_demo_event</span></code> 工程并下载工程;</p></li>
|
||
<li><p>使用 <code class="docutils literal notranslate"><span class="pre">stack_ble</span></code> 命令初始化ble,打印的部分log如下。</p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image15.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
<li><p>依次使用 <code class="docutils literal notranslate"><span class="pre">ble_init</span></code> 、 <code class="docutils literal notranslate"><span class="pre">ble_auth</span></code> 进行相关的初始化;</p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image24.png" />
|
||
</div>
|
||
<div class="figure align-default">
|
||
<img alt="" src="../../_images/image33.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
<li><p>使用 <code class="docutils literal notranslate"><span class="pre">ble_start_adv</span> <span class="pre">0</span> <span class="pre">0</span> <span class="pre">0x80</span> <span class="pre">0x80</span></code> 命令开启ble。</p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image42.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
<li><p>用户可以通过手机app <code class="docutils literal notranslate"><span class="pre">Ble</span> <span class="pre">connect</span></code> scan附近的蓝牙,找到我们的设备并连接。</p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image51.png" />
|
||
</div>
|
||
<div class="figure align-default">
|
||
<img alt="" src="../../_images/image6.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
<li><p>使用 <code class="docutils literal notranslate"><span class="pre">ble_conn_update</span> <span class="pre">0x6</span> <span class="pre">0x6</span> <span class="pre">0x0</span> <span class="pre">0x1f4</span></code> 更新连接参数。</p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image7.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
<li><p>SMP配对过程,由于security level不同,调用的命令也不相同,下面介绍level为2或者3的情况</p></li>
|
||
</ul>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>连接成功后使用 <code class="docutils literal notranslate"><span class="pre">ble_security</span> <span class="pre">2</span></code> 进行SMP过程。</p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image8.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
<ul>
|
||
<li><p>在串口打印出 <code class="docutils literal notranslate"><span class="pre">Confirm</span> <span class="pre">passkey</span> <span class="pre">for</span> <span class="pre">xx:xx:xx:xx:xx:xx</span> <span class="pre">(public)</span></code> ,输入 <code class="docutils literal notranslate"><span class="pre">ble_auth_pairing_confirm</span></code> 命令进行配对回复,打印的部分log如下。</p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image231.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
<li><p>在串口打印出 <code class="docutils literal notranslate"><span class="pre">Bonded</span> <span class="pre">with</span> <span class="pre">xx:xx:xx:xx:xx:xx</span> <span class="pre">(public)</span></code> ,表明SMP配对成功。</p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image10.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
<li><p>连接成功后使用 <code class="docutils literal notranslate"><span class="pre">ble_security</span> <span class="pre">3</span></code> 进行SMP过程。</p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image36.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
<ul>
|
||
<li><p>在串口打印出 <code class="docutils literal notranslate"><span class="pre">Confirm</span> <span class="pre">passkey</span> <span class="pre">for</span> <span class="pre">xx:xx:xx:xx:xx:xx</span> <span class="pre">(public):xxxxxx</span></code> ,输入 <code class="docutils literal notranslate"><span class="pre">ble_auth_passkey_confirm</span></code> 命令进行配对回复,打印的部分log如下。</p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image37.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
<li><p>在串口打印出 <code class="docutils literal notranslate"><span class="pre">Bonded</span> <span class="pre">with</span> <span class="pre">xx:xx:xx:xx:xx:xx</span> <span class="pre">(public)</span></code> ,表明SMP配对成功。</p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image38.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="cli">
|
||
<h2><span class="section-number">13.3. </span>Cli命令介绍<a class="headerlink" href="#cli" title="永久链接至标题">¶</a></h2>
|
||
<div class="section" id="ble-init">
|
||
<h3><span class="section-number">13.3.1. </span><code class="docutils literal notranslate"><span class="pre">ble_init</span></code><a class="headerlink" href="#ble-init" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:ble通用初始化,在所有ble cli操作前,需要先输入该命令</p></li>
|
||
<li><p>参数:无</p></li>
|
||
<li><p>示例:输入命令 <code class="docutils literal notranslate"><span class="pre">ble_init</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image24.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-auth">
|
||
<h3><span class="section-number">13.3.2. </span><code class="docutils literal notranslate"><span class="pre">ble_auth</span></code><a class="headerlink" href="#ble-auth" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:注册SMP接口函数</p></li>
|
||
<li><p>参数:无</p></li>
|
||
<li><p>示例:输入命令 <code class="docutils literal notranslate"><span class="pre">ble_auth</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image33.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-unpair">
|
||
<h3><span class="section-number">13.3.3. </span><code class="docutils literal notranslate"><span class="pre">ble_unpair</span></code><a class="headerlink" href="#ble-unpair" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>命令功能:清除配对key</p></li>
|
||
<li><p>第一个参数表示设备地址类型</p></li>
|
||
</ul>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>0:设备表示public地址类型</p></li>
|
||
<li><p>1:表示设备地址为random类型</p></li>
|
||
<li><p>2:表示设备地址为可解析的地址或者Public地址</p></li>
|
||
<li><p>3:表示设备地址为可解析的地址或者random地址</p></li>
|
||
</ul>
|
||
</div></blockquote>
|
||
<ul>
|
||
<li><p>第二个参数代表设备地址,高字节在前低字节在后,如果为0,代表清除所有设备的key</p></li>
|
||
<li><p>示例:输入命令 <code class="docutils literal notranslate"><span class="pre">ble_unpair</span> <span class="pre">0</span> <span class="pre">0</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image211.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-start-adv">
|
||
<h3><span class="section-number">13.3.4. </span><code class="docutils literal notranslate"><span class="pre">ble_start_adv</span></code><a class="headerlink" href="#ble-start-adv" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>命令功能表示:开启广播</p></li>
|
||
<li><p>第一个参数表示广播类型</p></li>
|
||
</ul>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>0:adv_ind 可连接可被扫描;</p></li>
|
||
<li><p>1:adv_scan_ind 不可被连接可被扫描;</p></li>
|
||
<li><p>2:adv_nonconn_ind 不可被连接不可被扫描;</p></li>
|
||
<li><p>3:adv_direct_ind 可被指定的设备连接不可被扫描</p></li>
|
||
</ul>
|
||
</div></blockquote>
|
||
<ul class="simple">
|
||
<li><p>第二个参数表示广播模式</p></li>
|
||
</ul>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>0:General discoverable;</p></li>
|
||
<li><p>1:non discoverable;</p></li>
|
||
<li><p>2:limit discoverable;</p></li>
|
||
</ul>
|
||
</div></blockquote>
|
||
<ul>
|
||
<li><p>第三个参数表示广播间隙最小值,其计算方式为 0.625ms * N,范围应在20 ms to 10.24 s之间</p></li>
|
||
<li><p>第四个参数表示广播间隙最大值,其计算方式为 0.625ms * N,范围应在20 ms to 10.24 s之间</p></li>
|
||
<li><p>示例:输入命令 <code class="docutils literal notranslate"><span class="pre">ble_start_adv</span> <span class="pre">0</span> <span class="pre">0</span> <span class="pre">0x80</span> <span class="pre">0x80</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image42.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-stop-adv">
|
||
<h3><span class="section-number">13.3.5. </span><code class="docutils literal notranslate"><span class="pre">ble_stop_adv</span></code><a class="headerlink" href="#ble-stop-adv" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:停止ADV广播</p></li>
|
||
<li><p>参数:无</p></li>
|
||
<li><p>示例:输入命令 <code class="docutils literal notranslate"><span class="pre">ble_stop_adv</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image17.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-start-scan">
|
||
<h3><span class="section-number">13.3.6. </span><code class="docutils literal notranslate"><span class="pre">ble_start_scan</span></code><a class="headerlink" href="#ble-start-scan" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>命令功能:表示扫描广播设备</p></li>
|
||
<li><p>第一个参数表示扫描类型</p></li>
|
||
</ul>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>0:表示scan passive type只监听广播数据</p></li>
|
||
<li><p>1:表示scan active,不仅监听当满足条件还会发scan_req包</p></li>
|
||
</ul>
|
||
</div></blockquote>
|
||
<ul class="simple">
|
||
<li><p>第二个参数表示过滤设备广播包</p></li>
|
||
</ul>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>0:表示不启用重复过滤</p></li>
|
||
<li><p>1:表示启用重复过滤</p></li>
|
||
<li><p>2:仅仅接收白名单列表发起的广播和scan response包,除了指定连接地址不是自己的adv_direct_ind广播包</p></li>
|
||
<li><p>4:使用扩展过滤策略,过滤设备</p></li>
|
||
</ul>
|
||
</div></blockquote>
|
||
<ul>
|
||
<li><p>第三个参数表示扫描间隙,其计算方式为 0.625ms * N,范围在2.5 ms to 10.24 s之间,其应该大于等于扫描窗口</p></li>
|
||
<li><p>第四个参数表示扫描窗口,其计算方式为 0.625ms * N,范围在2.5 ms to 10.24 s之间,其应该小于等于扫描间隙</p></li>
|
||
<li><p>示例:输入命令 <code class="docutils literal notranslate"><span class="pre">ble_start_scan</span> <span class="pre">0</span> <span class="pre">0</span> <span class="pre">0x80</span> <span class="pre">0x40</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image111.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-stop-scan">
|
||
<h3><span class="section-number">13.3.7. </span><code class="docutils literal notranslate"><span class="pre">ble_stop_scan</span></code><a class="headerlink" href="#ble-stop-scan" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:停止扫描</p></li>
|
||
<li><p>参数:无</p></li>
|
||
<li><p>示例:系统进入SCAN后,输入命令 <code class="docutils literal notranslate"><span class="pre">ble_stop_scan</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image141.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-conn-update">
|
||
<h3><span class="section-number">13.3.8. </span><code class="docutils literal notranslate"><span class="pre">ble_conn_update</span></code><a class="headerlink" href="#ble-conn-update" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:表示更新连接参数</p></li>
|
||
<li><p>第一个参数表示连接间隙的最小值,其计算方式为 N * 1.25 ms,其范围在7.5 ms to 4 s</p></li>
|
||
<li><p>第二个参数表示连接间隙的最大值,其计算方式为 N * 1.25 ms,其范围在7.5 ms to 4 s</p></li>
|
||
<li><p>第三个参数表示从设备时延多少个连接事件范围是0~499,比如:该值设置为1,表明延时一个事件的时间进行数据交互,作用是降低交互频率更省电</p></li>
|
||
<li><p>第四个参数表示连接超时时间,计算方式 N * 10 ms,范围是100 ms to 32 s</p></li>
|
||
<li><p>示例:连接成功后,输入命令 <code class="docutils literal notranslate"><span class="pre">ble_conn_update</span> <span class="pre">0x28</span> <span class="pre">0x28</span> <span class="pre">0x0</span> <span class="pre">0xf4</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image7.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-security">
|
||
<h3><span class="section-number">13.3.9. </span><code class="docutils literal notranslate"><span class="pre">ble_security</span></code><a class="headerlink" href="#ble-security" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>命令功能:设置SMP的加密等级</p></li>
|
||
<li><p>第一个参数表示加密等级,总共有5个等级</p></li>
|
||
</ul>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>0:仅用于BR/EDR,比如SDP服务;</p></li>
|
||
<li><p>1:表示不需要加密不需要认证的过程;</p></li>
|
||
<li><p>2:表示需要加密不需要认证的过程</p></li>
|
||
<li><p>3:表示需要加密和认证,比如双方需要输入PIN码</p></li>
|
||
<li><p>4:表示需要加密和认证,通过128bit的key</p></li>
|
||
<li><p>示例:连接成功后,输入命令 <code class="docutils literal notranslate"><span class="pre">ble_security</span> <span class="pre">2</span></code></p>
|
||
<div class="figure align-default">
|
||
<img alt="" src="../../_images/image8.png" />
|
||
</div>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-get-device-name">
|
||
<h3><span class="section-number">13.3.10. </span><code class="docutils literal notranslate"><span class="pre">ble_get_device_name</span></code><a class="headerlink" href="#ble-get-device-name" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:获取本地设备名称</p></li>
|
||
<li><p>参数:无</p></li>
|
||
<li><p>示例:输入命令 <code class="docutils literal notranslate"><span class="pre">ble_get_device_name</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image121.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-set-device-name">
|
||
<h3><span class="section-number">13.3.11. </span><code class="docutils literal notranslate"><span class="pre">ble_set_device_name</span></code><a class="headerlink" href="#ble-set-device-name" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:设置本地设备名称</p></li>
|
||
<li><p>参数:需要设置的设备名字</p></li>
|
||
<li><p>参数:无</p></li>
|
||
<li><p>示例:输入命令 <code class="docutils literal notranslate"><span class="pre">ble_set_device_name</span> <span class="pre">bl602</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image131.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-read-local-address">
|
||
<h3><span class="section-number">13.3.12. </span><code class="docutils literal notranslate"><span class="pre">ble_read_local_address</span></code><a class="headerlink" href="#ble-read-local-address" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:读取本地设备地址</p></li>
|
||
<li><p>参数:无</p></li>
|
||
<li><p>示例:输入命令 <code class="docutils literal notranslate"><span class="pre">ble_read_local_address</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image151.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-set-adv-channel">
|
||
<h3><span class="section-number">13.3.13. </span><code class="docutils literal notranslate"><span class="pre">ble_set_adv_channel</span></code><a class="headerlink" href="#ble-set-adv-channel" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:设置ADV通道</p></li>
|
||
<li><p>参数:需要设定的ADV通道数,其值范围为1-7,参数大小为1byte,bit0代表通道37,bit1代表通道38,bit2代表通道39</p></li>
|
||
<li><p>示例:输入命令 <code class="docutils literal notranslate"><span class="pre">ble_set_adv_channel</span> <span class="pre">4</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image16.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-connect">
|
||
<h3><span class="section-number">13.3.14. </span><code class="docutils literal notranslate"><span class="pre">ble_connect</span></code><a class="headerlink" href="#ble-connect" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>命令功能:连接指定地址的设备</p></li>
|
||
<li><p>第一个参数表示设备地址类型</p></li>
|
||
</ul>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>0:设备表示public地址类型</p></li>
|
||
<li><p>1:表示设备地址为random类型</p></li>
|
||
<li><p>2:表示设备地址为可解析的地址或者Public地址</p></li>
|
||
<li><p>3:表示设备地址为可解析的地址或者random地址</p></li>
|
||
</ul>
|
||
</div></blockquote>
|
||
<ul>
|
||
<li><p>第二个参数代表设备地址,高字节在前低字节在后</p></li>
|
||
<li><p>示例:输入命令 <code class="docutils literal notranslate"><span class="pre">ble_connect</span> <span class="pre">0</span> <span class="pre">18B905DE96E0</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image18.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-disconnect">
|
||
<h3><span class="section-number">13.3.15. </span><code class="docutils literal notranslate"><span class="pre">ble_disconnect</span></code><a class="headerlink" href="#ble-disconnect" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>命令功能:断开指定地址的设备的连接</p></li>
|
||
<li><p>第一个参数表示设备地址类型</p></li>
|
||
</ul>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>0:设备表示public地址类型</p></li>
|
||
<li><p>1:表示设备地址为random类型</p></li>
|
||
<li><p>2:表示设备地址为可解析的地址或者Public地址</p></li>
|
||
<li><p>3:表示设备地址为可解析的地址或者random地址</p></li>
|
||
</ul>
|
||
</div></blockquote>
|
||
<ul>
|
||
<li><p>第二个参数代表设备地址,高字节在前低字节在后</p></li>
|
||
<li><p>示例:连接成功后,输入命令 <code class="docutils literal notranslate"><span class="pre">ble_disconnect</span> <span class="pre">0</span> <span class="pre">18B905DE96E0</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image19.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-select-conn">
|
||
<h3><span class="section-number">13.3.16. </span><code class="docutils literal notranslate"><span class="pre">ble_select_conn</span></code><a class="headerlink" href="#ble-select-conn" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>命令功能:多个连接中,将某一个连接对象设置为当前连接对象</p></li>
|
||
<li><p>第一个参数表示设备地址类型</p></li>
|
||
</ul>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>0:设备表示public地址类型</p></li>
|
||
<li><p>1:表示设备地址为random类型</p></li>
|
||
<li><p>2:表示设备地址为可解析的地址或者Public地址</p></li>
|
||
<li><p>3:表示设备地址为可解析的地址或者random地址</p></li>
|
||
</ul>
|
||
</div></blockquote>
|
||
<ul>
|
||
<li><p>第二个参数代表设备地址,高字节在前低字节在后</p></li>
|
||
<li><p>示例:多个设备连接成功后,输入命令 <code class="docutils literal notranslate"><span class="pre">ble_select_conn</span> <span class="pre">1</span> <span class="pre">5F10546C8D83</span></code>,将选定的连接对象设置为当前连接对象,后续的ble_read等操作将会作用在该连接上</p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image20.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-auth-cancel">
|
||
<h3><span class="section-number">13.3.17. </span><code class="docutils literal notranslate"><span class="pre">ble_auth_cancel</span></code><a class="headerlink" href="#ble-auth-cancel" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:取消加密认证过程</p></li>
|
||
<li><p>参数:无</p></li>
|
||
<li><p>示例:当在SMP过程中,输入命令 <code class="docutils literal notranslate"><span class="pre">ble_auth_cancel</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image221.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-auth-passkey-confirm">
|
||
<h3><span class="section-number">13.3.18. </span><code class="docutils literal notranslate"><span class="pre">ble_auth_passkey_confirm</span></code><a class="headerlink" href="#ble-auth-passkey-confirm" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:接收到passkey后回复远端,并且对端设备在配对过程中也有显示该passkey; 例如:配对过程本地打印 Confirm passkey for 48:95:E6:73:1C:1A (random): 745491
|
||
;可发送该函数进行回复</p></li>
|
||
<li><p>参数:无</p></li>
|
||
<li><p>示例:当在SMP过程中,对应security level为3,需要输入命令 <code class="docutils literal notranslate"><span class="pre">ble_auth_passkey_confirm</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image9.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-auth-pairing-confirm">
|
||
<h3><span class="section-number">13.3.19. </span><code class="docutils literal notranslate"><span class="pre">ble_auth_pairing_confirm</span></code><a class="headerlink" href="#ble-auth-pairing-confirm" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:接收到远端配对请求,用此函数回复远端配对请求,例如:配对过程本地打印 Confirm pairing for 00:1B:DC:F2:20:E9 (public)
|
||
;可发送该函数进行回复</p></li>
|
||
<li><p>参数:无</p></li>
|
||
<li><p>示例:当在SMP过程中,对应的security level为2,输入命令 <code class="docutils literal notranslate"><span class="pre">ble_auth_pairing_confirm</span></code>,</p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image231.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-auth-passkey">
|
||
<h3><span class="section-number">13.3.20. </span><code class="docutils literal notranslate"><span class="pre">ble_auth_passkey</span></code><a class="headerlink" href="#ble-auth-passkey" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:请求输入passkey</p></li>
|
||
<li><p>参数:passkey值,其范围为0-999999</p></li>
|
||
<li><p>示例:当用ble_security 3命令进行配对,且SMP配对方法为PASSKEY_INPUT(代码中实现方法:用ble_auth注册smp接口函数时,在数据结构bt_conn_auth_cb中将函数passkey_entry填充,passkey_display与passkey_confirm不填充,其它接口函数默认即可),串口将打印出Enter passkey for XX:XX:XX:XX:XX:XX (public),此时输入命令 <code class="docutils literal notranslate"><span class="pre">ble_auth_passkey</span> <span class="pre">111111</span></code> 完成配对</p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image241.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-exchange-mtu">
|
||
<h3><span class="section-number">13.3.21. </span><code class="docutils literal notranslate"><span class="pre">ble_exchange_mtu</span></code><a class="headerlink" href="#ble-exchange-mtu" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:交换mtu大小</p></li>
|
||
<li><p>参数: 无</p></li>
|
||
<li><p>示例:连接成功后,输入命令 <code class="docutils literal notranslate"><span class="pre">ble_exchange_mtu</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image25.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-discover">
|
||
<h3><span class="section-number">13.3.22. </span><code class="docutils literal notranslate"><span class="pre">ble_discover</span></code><a class="headerlink" href="#ble-discover" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>命令功能:查询指定的服务或特性</p></li>
|
||
<li><p>第一个参数表示需要查询的类型</p></li>
|
||
</ul>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>0:primary</p></li>
|
||
<li><p>1:secondary</p></li>
|
||
<li><p>2:include</p></li>
|
||
<li><p>3:Characteristic</p></li>
|
||
<li><p>4:Descriptor</p></li>
|
||
</ul>
|
||
</div></blockquote>
|
||
<ul>
|
||
<li><p>第二个参数表示2BYTES的uuid</p></li>
|
||
<li><p>第三个参数表示起始句柄,占2BYTES</p></li>
|
||
<li><p>第四个参数表示结束句柄,占2BYTES</p></li>
|
||
<li><p>示例:连接成功后,输入命令 <code class="docutils literal notranslate"><span class="pre">ble_discover</span> <span class="pre">0</span> <span class="pre">0x1800</span> <span class="pre">0x1</span> <span class="pre">0xffff</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image26.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-read">
|
||
<h3><span class="section-number">13.3.23. </span><code class="docutils literal notranslate"><span class="pre">ble_read</span></code><a class="headerlink" href="#ble-read" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:读取指定句柄的数据</p></li>
|
||
<li><p>第一个参数表示句柄</p></li>
|
||
<li><p>第二个参数表示偏移量</p></li>
|
||
<li><p>示例:连接成功后,输入命令 <code class="docutils literal notranslate"><span class="pre">ble_read</span> <span class="pre">0x5</span> <span class="pre">0</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image27.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-write">
|
||
<h3><span class="section-number">13.3.24. </span><code class="docutils literal notranslate"><span class="pre">ble_write</span></code><a class="headerlink" href="#ble-write" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:指定句柄写入相应的数据</p></li>
|
||
<li><p>第一个参数表示句柄,占2bytes</p></li>
|
||
<li><p>第二个参数表示偏移量,占2bytes</p></li>
|
||
<li><p>第三个参数表示数据长度,占2bytes,最大不超过512</p></li>
|
||
<li><p>第四个参数表示需要写入的数据</p></li>
|
||
<li><p>示例:连接成功后,写入2个字节的数据,命令为 <code class="docutils literal notranslate"><span class="pre">ble_write</span> <span class="pre">0xf</span> <span class="pre">0</span> <span class="pre">2</span> <span class="pre">0102</span></code>,其中01为一个byte,02为一个byte</p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image28.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-write-without-rsp">
|
||
<h3><span class="section-number">13.3.25. </span><code class="docutils literal notranslate"><span class="pre">ble_write_without_rsp</span></code><a class="headerlink" href="#ble-write-without-rsp" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>命令功能:指定句柄写入相应的数据并且不需要回复</p></li>
|
||
<li><p>第一参数表示是否启动sign write命令</p></li>
|
||
</ul>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>0:不使能sign write命令</p></li>
|
||
<li><p>1:使能sign write命令</p></li>
|
||
</ul>
|
||
</div></blockquote>
|
||
<ul>
|
||
<li><p>第二个参数表示句柄,占2bytes,</p></li>
|
||
<li><p>第三个参数表示数据的长度,占2bytes,最大不超过512</p></li>
|
||
<li><p>第四个参数表示写入的数据</p></li>
|
||
<li><p>示例:连接成功后,写入2个字节的数据,命令为 <code class="docutils literal notranslate"><span class="pre">ble_write_without_rsp</span> <span class="pre">0</span> <span class="pre">0xf</span> <span class="pre">2</span> <span class="pre">0102</span></code>,其中01为一个byte,02为一个byte</p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image29.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-subscribe">
|
||
<h3><span class="section-number">13.3.26. </span><code class="docutils literal notranslate"><span class="pre">ble_subscribe</span></code><a class="headerlink" href="#ble-subscribe" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>命令功能:订阅CCC</p></li>
|
||
<li><p>第一个参数表示CCC句柄</p></li>
|
||
<li><p>第二个参数表示订阅值的句柄</p></li>
|
||
<li><p>第三个参数表示订阅类型</p></li>
|
||
</ul>
|
||
<blockquote>
|
||
<div><ul class="simple">
|
||
<li><p>1:表示notification</p></li>
|
||
<li><p>2:表示indication</p></li>
|
||
</ul>
|
||
</div></blockquote>
|
||
<ul>
|
||
<li><p>示例:连接成功后,输入命令 <code class="docutils literal notranslate"><span class="pre">ble_subscribe</span> <span class="pre">0xf</span> <span class="pre">0xd</span> <span class="pre">0x1</span></code>,表示使能CCC的notification</p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image30.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-unsubscribe">
|
||
<h3><span class="section-number">13.3.27. </span><code class="docutils literal notranslate"><span class="pre">ble_unsubscribe</span></code><a class="headerlink" href="#ble-unsubscribe" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:取消订阅CCC</p></li>
|
||
<li><p>参数:无</p></li>
|
||
<li><p>示例:输入命令 <code class="docutils literal notranslate"><span class="pre">ble_unsubscribe</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image311.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-set-data-len">
|
||
<h3><span class="section-number">13.3.28. </span><code class="docutils literal notranslate"><span class="pre">ble_set_data_len</span></code><a class="headerlink" href="#ble-set-data-len" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:设置pdu数据长度</p></li>
|
||
<li><p>第一个参数表示有效荷载传输的最大值,范围为0x001B - 0x00FB</p></li>
|
||
<li><p>第二个参数表示有效荷载传输的最大时间,范围值为0x0148 - 0x4290</p></li>
|
||
<li><p>示例:当连接成功后,发送命令 <code class="docutils literal notranslate"><span class="pre">ble_set_data_len</span> <span class="pre">0xfb</span> <span class="pre">0x0848</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image321.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-conn-info">
|
||
<h3><span class="section-number">13.3.29. </span><code class="docutils literal notranslate"><span class="pre">ble_conn_info</span></code><a class="headerlink" href="#ble-conn-info" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:获取所有的连接信息</p></li>
|
||
<li><p>参数:无</p></li>
|
||
<li><p>示例:当连接成功后,发送命令 <code class="docutils literal notranslate"><span class="pre">ble_conn_info</span></code> ,获取已连接的设备</p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image331.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-disable">
|
||
<h3><span class="section-number">13.3.30. </span><code class="docutils literal notranslate"><span class="pre">ble_disable</span></code><a class="headerlink" href="#ble-disable" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:注销BLE</p></li>
|
||
<li><p>参数:无</p></li>
|
||
<li><p>示例:当无scan/adv/connect事件,发送命令 <code class="docutils literal notranslate"><span class="pre">ble_disable</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image34.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
<div class="section" id="ble-set-tx-pwr">
|
||
<h3><span class="section-number">13.3.31. </span><code class="docutils literal notranslate"><span class="pre">ble_set_tx_pwr</span></code><a class="headerlink" href="#ble-set-tx-pwr" title="永久链接至标题">¶</a></h3>
|
||
<blockquote>
|
||
<div><ul>
|
||
<li><p>命令功能:设置发送功率</p></li>
|
||
<li><p>第一个参数表示设置功率值</p></li>
|
||
<li><p>示例:发送命令 <code class="docutils literal notranslate"><span class="pre">ble_set_tx_pwr</span> <span class="pre">0xa</span></code></p>
|
||
<blockquote>
|
||
<div><div class="figure align-default">
|
||
<img alt="" src="../../_images/image35.png" />
|
||
</div>
|
||
</div></blockquote>
|
||
</li>
|
||
</ul>
|
||
</div></blockquote>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
</div>
|
||
<footer>
|
||
|
||
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||
|
||
<a href="../demo_mesh/mesh.html" class="btn btn-neutral float-right" title="14. Mesh" accesskey="n" rel="next">下一页 <span class="fa fa-arrow-circle-right"></span></a>
|
||
|
||
|
||
<a href="../demo_wifi/wifi.html" class="btn btn-neutral float-left" title="12. WiFi" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> 上一页</a>
|
||
|
||
</div>
|
||
|
||
|
||
<hr/>
|
||
|
||
<div role="contentinfo">
|
||
<p>
|
||
|
||
© 版权所有 2020, Bouffalo Lab
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
|
||
利用 <a href="http://sphinx-doc.org/">Sphinx</a> 构建,使用了
|
||
|
||
<a href="https://github.com/rtfd/sphinx_rtd_theme">主题</a>
|
||
|
||
由 <a href="https://readthedocs.org">Read the Docs</a>开发.
|
||
|
||
</footer>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
</section>
|
||
|
||
</div>
|
||
|
||
|
||
<script type="text/javascript">
|
||
jQuery(function () {
|
||
SphinxRtdTheme.Navigation.enable(true);
|
||
});
|
||
</script>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
</body>
|
||
</html> |