mirror of
https://github.com/pine64/bl_iot_sdk.git
synced 2024-10-06 15:00:21 +00:00
305 lines
13 KiB
HTML
305 lines
13 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>3. cli — 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="4. GPIO" href="../Hal_drv/gpio.html" />
|
||
<link rel="prev" title="2. helper" href="helper.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>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Examples/helloworld/helloworld.html">1. Helloword</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Examples/demo_aws/aws.html">2. aws</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Examples/demo_peripherals_gpio/GPIO.html">3. GPIO</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Examples/demo_peripherals_uart_echo/uart_echo.html">4. UART_echo</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Examples/demo_peripherals_uart_ioctl/uart_ioctl.html">5. UART_ioctl</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Examples/demo_protocols_http/http.html">6. Http client</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Examples/demo_protocols_httpc/httpc.html">7. Httpc client</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Examples/demo_storage_psm/psm.html">8. PSM</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Examples/demo_storage_romfs/romfs.html">9. Romfs</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Examples/demo_system_cli/cli.html">10. cli</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Examples/demo_system_fdt/fdt.html">11. FDT</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Examples/demo_wifi/wifi.html">12. WiFi</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Examples/demo_ble/ble.html">13. BLE</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Examples/demo_mesh/mesh.html">14. Mesh</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Examples/demo_blsync_ble/blsync_ble.html">15. BLSYNC-BLE</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../../Examples/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 class="current">
|
||
<li class="toctree-l1"><a class="reference internal" href="../arch.html">1. arch</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="helper.html">2. helper</a></li>
|
||
<li class="toctree-l1 current"><a class="current reference internal" href="#">3. cli</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="#id1">3.1. 概述</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="#id2">3.2. 示例代码</a></li>
|
||
</ul>
|
||
</li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../Hal_drv/gpio.html">4. GPIO</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../Middleware/bloop/bloop.html">5. BLOOP</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../Middleware/blsync/blsync.html">6. BLSYNC</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../Middleware/dts/devicetree.html">7. device tree</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../Middleware/log/blog.html">8. blog</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../Middleware/security/security.html">9. Security</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../Middleware/vfs/vfs.html">10. AOS VFS</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../Middleware/yloop/yloop.html">11. yloop</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../Network/httpc/httpc.html">12. HTTPC</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../Network/https/https.html">13. HTTPS</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../Network/tls/tls.html">14. TLS</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../BLE/provision_WiFi/provision_WiFi.html">15. Provision_WiFi</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../BLE/mesh/mesh.html">16. Mesh</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../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">3. </span>cli</li>
|
||
|
||
|
||
<li class="wy-breadcrumbs-aside">
|
||
|
||
|
||
<a href="../../_sources/Components/Command_line/aos_cli.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="cli">
|
||
<h1><span class="section-number">3. </span>cli<a class="headerlink" href="#cli" title="永久链接至标题">¶</a></h1>
|
||
<div class="section" id="id1">
|
||
<h2><span class="section-number">3.1. </span>概述<a class="headerlink" href="#id1" title="永久链接至标题">¶</a></h2>
|
||
<p>linux下有强大的shell工具,可以让用户和片上系统进行交互,而在传统的单片机系统中,用户往往需要自行实现一套类似的交互工具。AliOS-Things原生带有一套名为cli(command-line
|
||
interface)的命令行交互工具,在提供基本的系统交互命令的基础上,也支持用户自定义命令。我们已经将其移植到我们到系统中,
|
||
同时对其做出了很多完善, 下面将介绍如何使用cli命令并执行</p>
|
||
</div>
|
||
<div class="section" id="id2">
|
||
<h2><span class="section-number">3.2. </span>示例代码<a class="headerlink" href="#id2" title="永久链接至标题">¶</a></h2>
|
||
<p>用户在只需在程序中调用<code class="docutils literal notranslate"><span class="pre">test_cli_init()</span></code>接口之后,就可以在shell中<code class="docutils literal notranslate"><span class="pre">test</span></code>,就可以打印<code class="docutils literal notranslate"><span class="pre">hello</span> <span class="pre">world.</span></code>如下图所示</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1">#</span>
|
||
<span class="c1">#</span>
|
||
<span class="c1"># test</span>
|
||
<span class="n">hello</span> <span class="n">world</span><span class="o">.</span>
|
||
<span class="c1">#</span>
|
||
<span class="c1">#</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>还有很多常用命令,请参考<a href="#id3"><span class="problematic" id="id4">`常用命令<../helper/helper.html>`_</span></a></p>
|
||
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">static</span> <span class="kt">void</span> <span class="nf">cmd_test_func</span><span class="p">(</span><span class="kt">char</span> <span class="o">*</span><span class="n">buf</span><span class="p">,</span> <span class="kt">int</span> <span class="n">len</span><span class="p">,</span> <span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">**</span><span class="n">argv</span><span class="p">)</span>
|
||
<span class="p">{</span>
|
||
<span class="n">printf</span><span class="p">(</span><span class="s">"hello world.</span><span class="se">\r\n</span><span class="s">"</span><span class="p">);</span>
|
||
<span class="k">return</span><span class="p">;</span>
|
||
<span class="p">}</span>
|
||
|
||
<span class="k">const</span> <span class="k">static</span> <span class="k">struct</span> <span class="n">cli_command</span> <span class="n">cmds_user</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span>
|
||
<span class="p">{</span><span class="s">"test"</span><span class="p">,</span> <span class="s">"it's test func "</span><span class="p">,</span> <span class="n">cmd_test_func</span><span class="p">}</span>
|
||
<span class="p">};</span>
|
||
|
||
<span class="kt">int</span> <span class="nf">test_cli_init</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span>
|
||
<span class="p">{</span>
|
||
<span class="k">return</span> <span class="n">aos_cli_register_commands</span><span class="p">(</span><span class="n">cmds_user</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">cmds_user</span><span class="p">)</span><span class="o">/</span><span class="k">sizeof</span><span class="p">(</span><span class="n">cmds_user</span><span class="p">[</span><span class="mi">0</span><span class="p">]));</span>
|
||
<span class="p">}</span>
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
</div>
|
||
<footer>
|
||
|
||
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||
|
||
<a href="../Hal_drv/gpio.html" class="btn btn-neutral float-right" title="4. GPIO" accesskey="n" rel="next">下一页 <span class="fa fa-arrow-circle-right"></span></a>
|
||
|
||
|
||
<a href="helper.html" class="btn btn-neutral float-left" title="2. helper" 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> |