blob: 5cde89dcb370bf68fe25ffdeef8a99e84cb8595d [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Enabling Newt Manager in Your Application &mdash; Apache Mynewt latest documentation</title>
<link rel="shortcut icon" href="../../_static/mynewt-logo-only-newt32x32.png"/>
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/css/sphinx_theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/css/bootstrap-3.0.3.min.css" type="text/css" />
<link rel="stylesheet" href="../../_static/css/v2.css" type="text/css" />
<link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />
<link rel="stylesheet" href="../../_static/css/restructuredtext.css" type="text/css" />
<link rel="stylesheet" href="../../_static/css/overrides.css" type="text/css" />
<link rel="index" title="Index"
href="../../genindex.html"/>
<link rel="search" title="Search" href="../../search.html"/>
<link rel="top" title="Apache Mynewt latest documentation" href="../../index.html"/>
<link rel="up" title="Remote Device Management" href="devmgmt.html"/>
<link rel="next" title="Over-the-Air Image Upgrade" href="ota_upgrade_nrf52.html"/>
<link rel="prev" title="Remote Device Management" href="devmgmt.html"/>
<script src="../../_static/js/modernizr.min.js"></script>
<script>
(function(i, s, o, g, r, a, m) {
i["GoogleAnalyticsObject"] = r;
(i[r] =
i[r] ||
function() {
(i[r].q = i[r].q || []).push(arguments);
}),
(i[r].l = 1 * new Date());
(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m);
})(window, document, "script", "//www.google-analytics.com/analytics.js", "ga");
ga("create", "UA-72162311-1", "auto");
ga("send", "pageview");
</script>
</head>
<body class="not-front page-documentation" role="document" >
<div id="wrapper">
<div class="container">
<div id="banner" class="row v2-main-banner">
<a class="logo-cell" href="/">
<img class="logo" src="../../_static/img/logo.png">
</a>
<div class="tagline-cell">
<h4 class="tagline">An OS to build, deploy and securely manage billions of devices</h4>
</div>
<div class="news-cell">
<div class="well">
<h4>Latest News:</h4> <a href="/download">Apache Mynewt 1.11.0, Apache NimBLE 1.6.0 </a> released September 7, 2023)
</div>
</div>
</div>
</div>
<header>
<nav id="navbar" class="navbar navbar-inverse" role="navigation">
<div class="container">
<!-- Collapsed navigation -->
<div class="navbar-header">
<!-- Expander button -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Expanded navigation -->
<div class="navbar-collapse collapse">
<!-- Main navigation -->
<ul class="nav navbar-nav navbar-right">
<li>
<a href="/"><i class="fa fa-home" style="font-size: larger;"></i></a>
</li>
<li class="important">
<a href="/quick-start/">Quick Start</a>
</li>
<li>
<a href="/about/">About</a>
</li>
<li>
<a href="/talks/">Talks</a>
</li>
<li class="active">
<a href="/documentation/">Documentation</a>
</li>
<li>
<a href="/download/">Download</a>
</li>
<li>
<a href="/community/">Community</a>
</li>
<li>
<a href="/events/">Events</a>
</li>
</ul>
<!-- Search, Navigation and Repo links -->
<ul class="nav navbar-nav navbar-right">
</ul>
</div>
</div>
</nav>
</header>
<!-- STARTS MAIN CONTENT -->
<div id="main-content">
<div id="breadcrumb">
<div class="container">
<a href="/documentation/">Docs</a> /
<a href="../tutorials.html">Tutorials</a> /
<a href="devmgmt.html">Remote Device Management</a> /
Enabling Newt Manager in Your Application
<div class="sourcelink">
<a href="https://github.com/apache/mynewt-documentation/edit/master/docs/tutorials/devmgmt/add_newtmgr.rst" class="icon icon-github"
rel="nofollow"> Edit on GitHub</a>
</div>
</div>
</div>
<!-- STARTS CONTAINER -->
<div class="container">
<!-- STARTS .content -->
<div id="content" class="row">
<!-- STARTS .container-sidebar -->
<div class="container-sidebar col-xs-12 col-sm-3">
<div id="docSidebar" class="sticky-container">
<div role="search" class="sphinx-search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search documentation" class="search-documentation" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<!-- Note: only works when deployed -->
<select class="form-control" onchange="if (this.value) window.location.href=this.value">
<option value="/latest" selected>
Version: latest
</option>
<option value="/v1_11_0" >
Version: 1.11.0
</option>
<option value="/v1_10_0" >
Version: 1.10.0
</option>
<option value="/v1_9_0" selected="selected" >
Version: 1.9.0
</option>
<option value="/v1_8_0" >
Version: 1.8.0
</option>
<option value="/v1_7_0" >
Version: 1.7.0
</option>
<option value="/v1_6_0" >
Version: 1.6.0
</option>
<option value="/v1_5_0" >
Version: 1.5.0
</option>
<option value="/v1_4_0" >
Version: 1.4.0
</option>
<option value="/v1_3_0/os/introduction" >
Version: 1.3.0
</option>
<option value="/v1_2_0/os/introduction" >
Version: 1.2.0
</option>
<option value="/v1_1_0/os/introduction" >
Version: 1.1.0
</option>
<option value="/v1_0_0/os/introduction" >
Version: 1.0.0
</option>
<option value="/v0_9_0/os/introduction" >
Version: 0.9.0
</option>
</select>
<div class="region region-sidebar">
<div class="docs-menu">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../index.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../get_started/index.html">Setup &amp; Get Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../concepts.html">Concepts</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../tutorials.html">Tutorials</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../blinky/blinky.html">Project Blinky</a></li>
<li class="toctree-l2"><a class="reference internal" href="../repo/add_repos.html">Working with repositories</a></li>
<li class="toctree-l2"><a class="reference internal" href="../slinky/project-slinky.html">Project Slinky for Remote Comms</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ble/ble.html">Bluetooth Low Energy</a></li>
<li class="toctree-l2"><a class="reference internal" href="../lora/lorawanapp.html">LoRa</a></li>
<li class="toctree-l2"><a class="reference internal" href="../os_fundamentals/os_fundamentals.html">OS Fundamentals</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="devmgmt.html">Remote Device Management</a><ul class="current">
<li class="toctree-l3 current"><a class="current reference internal" href="#">Enable Newt Manager in Any App</a></li>
<li class="toctree-l3"><a class="reference internal" href="ota_upgrade_nrf52.html">Upgrade an Image Over-The-Air</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../sensors/sensors.html">Sensors</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tooling/tooling.html">Tooling</a></li>
<li class="toctree-l2"><a class="reference internal" href="../other/other.html">Other</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../external_links.html">Third-party Resources</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../os/os_user_guide.html">OS User Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../network/index.html">BLE User Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../newt/index.html">Newt Tool Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../newtmgr/index.html">Newt Manager Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mynewt_faq/index.html">Mynewt FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../misc/index.html">Appendix</a></li>
</ul>
</div>
</div>
</div>
<!-- ENDS STICKY CONTAINER -->
</div>
<!-- ENDS .container-sidebar -->
<div class="col-xs-12 col-sm-9">
<div class="alert alert-warning">
<p>
Version 1.9.0 is not the most recent version of the
Apache Mynewt documentation. Click <a href="/latest">here</a> to
read the latest version.
</p>
</div>
<div class="">
<div class="rst-content">
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="enabling-newt-manager-in-your-application">
<h1>Enabling Newt Manager in Your Application<a class="headerlink" href="#enabling-newt-manager-in-your-application" title="Permalink to this headline"></a></h1>
<p>In order for your application to communicate with the newtmgr tool and
process Newt Manager commands, you must enable Newt Manager device
management and the support to process Newt Manager commands in your
application. This tutorial explains how to add the support to your
application.</p>
<p>This tutorial assumes that you have read the <a class="reference internal" href="../../os/modules/devmgmt/newtmgr.html"><span class="doc">Device Management with
Newt Manager</span></a> guide and are familiar
with the <code class="docutils literal notranslate"><span class="pre">newtmgr</span></code> and <code class="docutils literal notranslate"><span class="pre">oicmgr</span></code> frameworks and all the options that
are available to customize your application.</p>
<p>This tutorial shows you how to configure your application to:</p>
<ul class="simple">
<li><p>Use the newtmgr framework.</p></li>
<li><p>Use serial transport to communicate with the newtmgr tool.</p></li>
<li><p>Support all Newt Manager commands.</p></li>
</ul>
<p>See <span class="xref std std-doc">Other Configuration Options</span> on
how to customize your application.</p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#prerequisites" id="id1">Prerequisites</a></p></li>
<li><p><a class="reference internal" href="#use-an-existing-project" id="id2">Use an Existing Project</a></p></li>
<li><p><a class="reference internal" href="#modify-package-dependencies-and-configurations" id="id3">Modify Package Dependencies and Configurations</a></p></li>
<li><p><a class="reference internal" href="#modify-the-source" id="id4">Modify the Source</a></p></li>
<li><p><a class="reference internal" href="#build-the-targets" id="id5">Build the Targets</a></p></li>
<li><p><a class="reference internal" href="#create-the-application-image" id="id6">Create the Application Image</a></p></li>
<li><p><a class="reference internal" href="#load-the-image" id="id7">Load the Image</a></p></li>
<li><p><a class="reference internal" href="#set-up-a-connection-profile" id="id8">Set Up a Connection Profile</a></p></li>
<li><p><a class="reference internal" href="#communicate-with-your-application" id="id9">Communicate with Your Application</a></p></li>
<li><p><a class="reference internal" href="#other-configuration-options" id="id10">Other Configuration Options</a></p>
<ul>
<li><p><a class="reference internal" href="#newtmgr-framework-transport-protocol-options" id="id11">Newtmgr Framework Transport Protocol Options</a></p></li>
<li><p><a class="reference internal" href="#oicmgr-framework-options" id="id12">Oicmgr Framework Options</a></p></li>
<li><p><a class="reference internal" href="#customize-the-newt-manager-commands-that-your-application-supports" id="id13">Customize the Newt Manager Commands that Your Application Supports</a></p></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="prerequisites">
<h2><a class="toc-backref" href="#id1">Prerequisites</a><a class="headerlink" href="#prerequisites" title="Permalink to this headline"></a></h2>
<p>Ensure that you have met the following prerequisites before continuing
with this tutorial:</p>
<ul class="simple">
<li><p>Have Internet connectivity to fetch remote Mynewt components.</p></li>
<li><p>Have a cable to establish a serial USB connection between the board
and the laptop.</p></li>
<li><p>Install the newt tool and toolchains (See <a class="reference internal" href="../../get_started/index.html"><span class="doc">Basic
Setup</span></a>).</p></li>
<li><p>Install the <span class="xref std std-doc">newtmgr tool</span>.</p></li>
</ul>
</div>
<div class="section" id="use-an-existing-project">
<h2><a class="toc-backref" href="#id2">Use an Existing Project</a><a class="headerlink" href="#use-an-existing-project" title="Permalink to this headline"></a></h2>
<p>We assume that you have worked through at least some of the other
tutorials and have an existing project. In this example, we modify the
<code class="docutils literal notranslate"><span class="pre">btshell</span></code> app to enable Newt Manager support. We call our target
<code class="docutils literal notranslate"><span class="pre">myble</span></code>. You can create the target using any name you choose.</p>
</div>
<div class="section" id="modify-package-dependencies-and-configurations">
<h2><a class="toc-backref" href="#id3">Modify Package Dependencies and Configurations</a><a class="headerlink" href="#modify-package-dependencies-and-configurations" title="Permalink to this headline"></a></h2>
<p>Add the following packages to the <code class="docutils literal notranslate"><span class="pre">pkg.deps</span></code> parameter in your target
or application <code class="docutils literal notranslate"><span class="pre">pkg.yml</span></code> file:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">pkg.deps:</span>
<span class="go"> - &quot;@apache-mynewt-core/mgmt/mgmt&quot;</span>
<span class="go"> - &quot;@apache-mynewt-core/mgmt/smp/transport/smp_shell&quot;</span>
<span class="go"> - &quot;@apache-mynewt-core/mgmt/imgmgr&quot;</span>
<span class="go"> - &quot;@apache-mynewt-core/sys/console/full&quot;</span>
<span class="go"> - &quot;@apache-mynewt-core/sys/log/full&quot;</span>
<span class="go"> - &quot;@apache-mynewt-core/sys/stats/full&quot;</span>
<span class="go"> - &quot;@apache-mynewt-core/sys/config&quot;</span>
<span class="go"> - &quot;@apache-mynewt-core/test/crash_test&quot;</span>
<span class="go"> - &quot;@apache-mynewt-core/test/runtest&quot;</span>
</pre></div>
</div>
<p>Each package provides the following Newt Manager functionality:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">mgmt/mgmt</span></code>: Supports the newtmgr framework and the Newt Manager
<code class="docutils literal notranslate"><span class="pre">echo</span></code>, <code class="docutils literal notranslate"><span class="pre">taskstat</span></code> <code class="docutils literal notranslate"><span class="pre">mpstat</span></code>, <code class="docutils literal notranslate"><span class="pre">datetime</span></code>, and <code class="docutils literal notranslate"><span class="pre">reset</span></code>
commands.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">mgmt/newtmgr/smp/transport/nmgr_shell</span></code>: Supports serial transport.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">mgmt/imgmgr</span></code>: Supports the <code class="docutils literal notranslate"><span class="pre">newtmgr</span> <span class="pre">image</span></code> command.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">sys/console/full</span></code>: Supports a text-based IO interface with completion.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">sys/log/full</span></code>: Supports the <code class="docutils literal notranslate"><span class="pre">newtmgr</span> <span class="pre">log</span></code> command.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">sys/stats/full</span></code>: Supports the <code class="docutils literal notranslate"><span class="pre">newtmgr</span> <span class="pre">stat</span></code> command.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">sys/config</span></code>: Supports the <code class="docutils literal notranslate"><span class="pre">newtmgr</span> <span class="pre">config</span></code> command.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">test/crash_test</span></code>: Supports the <code class="docutils literal notranslate"><span class="pre">newtmgr</span> <span class="pre">crash</span></code> command.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">test/runtest</span></code>: Supports the <code class="docutils literal notranslate"><span class="pre">newt</span> <span class="pre">run</span></code> command.</p></li>
</ul>
<p>Add the following configuration setting values to the <code class="docutils literal notranslate"><span class="pre">syscfg.vals</span></code>
parameter in the target or application <code class="docutils literal notranslate"><span class="pre">syscfg.yml</span></code> file:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">syscfg.vals:</span>
<span class="go"> LOG_NEWTMGR: 1</span>
<span class="go"> STATS_NEWTMGR: 1</span>
<span class="go"> CONFIG_NEWTMGR: 1</span>
<span class="go"> CRASH_TEST_NEWTMGR: 1</span>
<span class="go"> RUNTEST_NEWTMGR: 1</span>
<span class="go"> SHELL_TASK: 1</span>
<span class="go"> SHELL_NEWTMGR: 1</span>
</pre></div>
</div>
<p>The first five configuration settings enable support for the Newt
Manager <code class="docutils literal notranslate"><span class="pre">log</span></code>, <code class="docutils literal notranslate"><span class="pre">stat</span></code>, <code class="docutils literal notranslate"><span class="pre">config</span></code>, <code class="docutils literal notranslate"><span class="pre">crash</span></code>, and <code class="docutils literal notranslate"><span class="pre">run</span></code> commands.
The <code class="docutils literal notranslate"><span class="pre">SHELL_TASK</span></code> setting enables the shell for serial transport. The
<code class="docutils literal notranslate"><span class="pre">SHELL_NEWTMGR</span></code> setting enables newtmgr support in the shell.</p>
<p>Note that you may need to override additional configuration settings
that are specific to each package to customize the package
functionality.</p>
</div>
<div class="section" id="modify-the-source">
<h2><a class="toc-backref" href="#id4">Modify the Source</a><a class="headerlink" href="#modify-the-source" title="Permalink to this headline"></a></h2>
<p>By default, the <code class="docutils literal notranslate"><span class="pre">mgmt</span></code> package uses the Mynewt default event queue to
receive request events from the newtmgr tool. These events are processed
in the context of the application main task.</p>
<p>You can specify a different event queue for the package to use. If you
choose to use a dedicated event queue, you must create a task to process
events from this event queue. The <code class="docutils literal notranslate"><span class="pre">mgmt</span></code> package executes and handles
newtmgr request events in the context of this task. The <code class="docutils literal notranslate"><span class="pre">mgmt</span></code> package
exports the <code class="docutils literal notranslate"><span class="pre">mgmt_evq_set()</span></code> function that allows you to specify an
event queue.</p>
<p>This example uses the Mynewt default event queue and you do not need to
modify your application source.</p>
<p>If you choose to use a different event queue, see <a class="reference internal" href="../os_fundamentals/event_queue.html"><span class="doc">Events and Event
Queues</span></a> for details on how to initialize an event
queue and create a task to process the events. You will also need to
modify your <code class="docutils literal notranslate"><span class="pre">main.c</span></code> to add the call to the <code class="docutils literal notranslate"><span class="pre">mgmt_evq_set()</span></code>
function as follows:</p>
<p>Add the <code class="docutils literal notranslate"><span class="pre">mgmt/mgmt.h</span></code> header file:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;mgmt/mgmt.h&gt;</span>
</pre></div>
</div>
<p>Add the call to specify the event queue. In the <code class="docutils literal notranslate"><span class="pre">main()</span></code> function,
scroll down to the <code class="docutils literal notranslate"><span class="pre">while</span> <span class="pre">(1)</span></code> loop and add the following statement
above the loop:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">mgmt_evq_set</span><span class="p">(</span><span class="o">&amp;</span><span class="n">my_eventq</span><span class="p">)</span>
</pre></div>
</div>
<p>where <code class="docutils literal notranslate"><span class="pre">my_eventq</span></code> is an event queue that you have initialized.</p>
</div>
<div class="section" id="build-the-targets">
<h2><a class="toc-backref" href="#id5">Build the Targets</a><a class="headerlink" href="#build-the-targets" title="Permalink to this headline"></a></h2>
<p>Build the two targets as follows:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>newt<span class="w"> </span>build<span class="w"> </span>nrf52_boot
<span class="go">&lt;snip&gt;</span>
<span class="go">App successfully built: ./bin/nrf52_boot/boot/mynewt/mynewt.elf</span>
<span class="gp">$ </span>newt<span class="w"> </span>build<span class="w"> </span>myble
<span class="go">Compiling hci_common.c</span>
<span class="go">Compiling util.c</span>
<span class="go">Archiving nimble.a</span>
<span class="go">Compiling os.c</span>
<span class="go">&lt;snip&gt;</span>
</pre></div>
</div>
</div>
<div class="section" id="create-the-application-image">
<h2><a class="toc-backref" href="#id6">Create the Application Image</a><a class="headerlink" href="#create-the-application-image" title="Permalink to this headline"></a></h2>
<p>Generate an application image for the <code class="docutils literal notranslate"><span class="pre">myble</span></code> target. You can use any
version number you choose.</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>newt<span class="w"> </span>create-image<span class="w"> </span>myble<span class="w"> </span><span class="m">1</span>.0.0
<span class="go">App image successfully generated: ./bin/makerbeacon/apps/btshell/btshell.img</span>
<span class="go">Build manifest: ./bin/makerbeacon/apps/btshell/manifest.json</span>
</pre></div>
</div>
</div>
<div class="section" id="load-the-image">
<h2><a class="toc-backref" href="#id7">Load the Image</a><a class="headerlink" href="#load-the-image" title="Permalink to this headline"></a></h2>
<p>Ensure the USB connector is in place and the power LED on the board is
lit. Turn the power switch on your board off, then back on to reset the
board after loading the image.</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>newt<span class="w"> </span>load<span class="w"> </span>nrf52_boot
<span class="gp">$ </span>newt<span class="w"> </span>load<span class="w"> </span>myble
</pre></div>
</div>
</div>
<div class="section" id="set-up-a-connection-profile">
<h2><a class="toc-backref" href="#id8">Set Up a Connection Profile</a><a class="headerlink" href="#set-up-a-connection-profile" title="Permalink to this headline"></a></h2>
<p>The newtmgr tool requires a connection profile in order to connect to
your board. If you have not done so, follow the
<a class="reference internal" href="../../newtmgr/command_list/newtmgr_conn.html"><span class="doc">instructions</span></a> for
setting up your connection profile.</p>
</div>
<div class="section" id="communicate-with-your-application">
<h2><a class="toc-backref" href="#id9">Communicate with Your Application</a><a class="headerlink" href="#communicate-with-your-application" title="Permalink to this headline"></a></h2>
<p>Once you have a connection profile set up, you can connect to your
device with <code class="docutils literal notranslate"><span class="pre">newtmgr</span> <span class="pre">-c</span> <span class="pre">myconn</span> <span class="pre">&lt;command&gt;</span></code> to run commands in your
application.</p>
<p>Issue the <code class="docutils literal notranslate"><span class="pre">echo</span></code> command to ensure that your application is
communicating with the newtmgr tool:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>newtmgr<span class="w"> </span>-c<span class="w"> </span>myconn<span class="w"> </span><span class="nb">echo</span><span class="w"> </span>hello
<span class="go">hello</span>
</pre></div>
</div>
<p>Test your application to ensure that it can process a Newt Manager
command that is supported by a different package. Issue the <code class="docutils literal notranslate"><span class="pre">stat</span></code>
command to see the BLE stats.</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">stat group: ble_att</span>
<span class="go"> 0 error_rsp_rx</span>
<span class="go"> 0 error_rsp_tx</span>
<span class="go"> 0 exec_write_req_rx</span>
<span class="go"> 0 exec_write_req_tx</span>
<span class="go"> 0 exec_write_rsp_rx</span>
<span class="go"> 0 exec_write_rsp_tx</span>
<span class="go"> 0 find_info_req_rx</span>
<span class="go"> 0 find_info_req_tx</span>
<span class="go"> 0 find_info_rsp_rx</span>
<span class="go"> 0 find_info_rsp_tx</span>
<span class="go"> 0 find_type_value_req_rx</span>
<span class="go"> ...</span>
<span class="go"> 0 read_type_req_tx</span>
<span class="go"> 0 read_type_rsp_rx</span>
<span class="go"> 0 read_type_rsp_tx</span>
<span class="go"> 0 write_cmd_rx</span>
<span class="go"> 0 write_cmd_tx</span>
<span class="go"> 0 write_req_rx</span>
<span class="go"> 0 write_req_tx</span>
<span class="go"> 0 write_rsp_rx</span>
<span class="go"> 0 write_rsp_tx</span>
</pre></div>
</div>
<p>Your application is now able to communicate with the newtmgr tool.</p>
</div>
<div class="section" id="other-configuration-options">
<h2><a class="toc-backref" href="#id10">Other Configuration Options</a><a class="headerlink" href="#other-configuration-options" title="Permalink to this headline"></a></h2>
<p>This section explains how to customize your application to use other
Newt Manager protocol options.</p>
<div class="section" id="newtmgr-framework-transport-protocol-options">
<h3><a class="toc-backref" href="#id11">Newtmgr Framework Transport Protocol Options</a><a class="headerlink" href="#newtmgr-framework-transport-protocol-options" title="Permalink to this headline"></a></h3>
<p>The newtmgr framework currently supports BLE and serial transport
protocols. To configure the transport protocols that are supported,
modify the <code class="docutils literal notranslate"><span class="pre">pkg.yml</span></code> and <code class="docutils literal notranslate"><span class="pre">syscfg.yml</span></code> files as follows:</p>
<ul class="simple">
<li><p>Add the <code class="docutils literal notranslate"><span class="pre">mgmt/newtmgr/transport/ble</span></code> package to the <code class="docutils literal notranslate"><span class="pre">pkg.deps</span></code>
parameter to enable BLE transport.</p></li>
<li><p>Add the <code class="docutils literal notranslate"><span class="pre">mgmt/newtmgr/transport/nmgr_shell</span></code> package to the
<code class="docutils literal notranslate"><span class="pre">pkg.deps</span></code> parameter, and add <code class="docutils literal notranslate"><span class="pre">SHELL_TASK:</span> <span class="pre">1</span></code> and
<code class="docutils literal notranslate"><span class="pre">SHELL_NEWTMGR</span></code> to the <code class="docutils literal notranslate"><span class="pre">syscfg.vals</span></code> parameter to enable serial
transport when your application also uses the
<a class="reference internal" href="../../os/modules/shell/shell.html"><span class="doc">Shell</span></a>.</p></li>
<li><p>Add the <code class="docutils literal notranslate"><span class="pre">mgmt/newtmgr/transport/nmgr_uart</span></code> package to the
<code class="docutils literal notranslate"><span class="pre">pkg.deps</span></code> parameter to enable serial transport over a UART port.
You can use this package instead of the <code class="docutils literal notranslate"><span class="pre">nmgr_shell</span></code> package when
your application does not use the
<a class="reference internal" href="../../os/modules/shell/shell.html"><span class="doc">Shell</span></a> or you want to use a dedicated
UART port to communicate with newtmgr. You can change the
<code class="docutils literal notranslate"><span class="pre">NMGR_UART</span></code> and <code class="docutils literal notranslate"><span class="pre">NMGR_URART_SPEED</span></code> sysconfig values to specify a
different port.</p></li>
</ul>
</div>
<div class="section" id="oicmgr-framework-options">
<h3><a class="toc-backref" href="#id12">Oicmgr Framework Options</a><a class="headerlink" href="#oicmgr-framework-options" title="Permalink to this headline"></a></h3>
<p>To use the oicmgr framework instead of the newtmgr framework, modify the
<code class="docutils literal notranslate"><span class="pre">pkg.yml</span></code> and <code class="docutils literal notranslate"><span class="pre">syscfg.yml</span></code> files as follows:</p>
<ul class="simple">
<li><p>Add the <code class="docutils literal notranslate"><span class="pre">mgmt/oicmgr</span></code> package (instead of the <code class="docutils literal notranslate"><span class="pre">mgmt/newtmgr</span></code> and
<code class="docutils literal notranslate"><span class="pre">mgmt/newtmgr/transport</span></code> packages as described previously) to the
<code class="docutils literal notranslate"><span class="pre">pkg.deps</span></code> parameter.</p></li>
<li><p>Add <code class="docutils literal notranslate"><span class="pre">OC_SERVER:</span> <span class="pre">1</span></code> to the <code class="docutils literal notranslate"><span class="pre">syscfg.vals</span></code> parameter.</p></li>
</ul>
<p>Oicmgr supports the IP, serial, and BLE transport protocols. To
configure the transport protocols that are supported, set the
configuration setting values in the <code class="docutils literal notranslate"><span class="pre">syscfg.vals</span></code> parameter as
follows:</p>
<ul class="simple">
<li><p>Add <code class="docutils literal notranslate"><span class="pre">OC_TRANSPORT_IP:</span> <span class="pre">1</span></code> to enable IP transport.</p></li>
<li><p>Add <code class="docutils literal notranslate"><span class="pre">OC_TRANSPORT_GATT:</span> <span class="pre">1</span></code> to enable BLE transport.</p></li>
<li><p>Add <code class="docutils literal notranslate"><span class="pre">OC_TRANSPORT_SERIAL:</span> <span class="pre">1</span></code>, <code class="docutils literal notranslate"><span class="pre">SHELL_TASK:</span> <span class="pre">1</span></code>,
<code class="docutils literal notranslate"><span class="pre">SHELL_NEWTMGR:1</span></code> to enable serial transport.</p></li>
</ul>
</div>
<div class="section" id="customize-the-newt-manager-commands-that-your-application-supports">
<h3><a class="toc-backref" href="#id13">Customize the Newt Manager Commands that Your Application Supports</a><a class="headerlink" href="#customize-the-newt-manager-commands-that-your-application-supports" title="Permalink to this headline"></a></h3>
<p>We recommend that you only enable support for the Newt Manager commands
that your application uses to reduce your application code size. To
configure the commands that are supported, set the configuration setting
values in the <code class="docutils literal notranslate"><span class="pre">syscfg.vals</span></code> parameter as follows:</p>
<ul class="simple">
<li><p>Add <code class="docutils literal notranslate"><span class="pre">LOG_NEWTMGR:</span> <span class="pre">1</span></code> to enable support for the <code class="docutils literal notranslate"><span class="pre">newtmgr</span> <span class="pre">log</span></code>
command.</p></li>
<li><p>Add <code class="docutils literal notranslate"><span class="pre">STATS_NEWTMGR:</span> <span class="pre">1</span></code> to enable support for the <code class="docutils literal notranslate"><span class="pre">newtmgr</span> <span class="pre">stat</span></code>
command.</p></li>
<li><p>Add <code class="docutils literal notranslate"><span class="pre">CONFIG_NEWTMGR:</span> <span class="pre">1</span></code> to enable support for the
<code class="docutils literal notranslate"><span class="pre">newtmgr</span> <span class="pre">config</span></code> command.</p></li>
<li><p>Add <code class="docutils literal notranslate"><span class="pre">CRASH_TEST_NEWTMGR:</span> <span class="pre">1</span></code> to enable support for the
<code class="docutils literal notranslate"><span class="pre">newtmgr</span> <span class="pre">crash</span></code> command.</p></li>
<li><p>Add <code class="docutils literal notranslate"><span class="pre">RUNTEST_NEWTMGR:</span> <span class="pre">1</span></code> to enable support for the
<code class="docutils literal notranslate"><span class="pre">newtmgr</span> <span class="pre">crash</span></code> command.</p></li>
</ul>
<p>Notes:</p>
<ul class="simple">
<li><p>When you enable Newt Manager support, using either the newtmgr or
oicmgr framework, your application automatically supports the Newt
Manager <code class="docutils literal notranslate"><span class="pre">echo</span></code>, <code class="docutils literal notranslate"><span class="pre">taskstat</span></code>, <code class="docutils literal notranslate"><span class="pre">mpstat</span></code>, <code class="docutils literal notranslate"><span class="pre">datetime</span></code>, and
<code class="docutils literal notranslate"><span class="pre">reset</span></code> commands. These commands cannot be configured individually.</p></li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">mgmt/imgmgr</span></code> package does not provide a configuration setting
to enable or disable support for the <code class="docutils literal notranslate"><span class="pre">newtmgr</span> <span class="pre">image</span></code> command. Do
not specify the package in the <code class="docutils literal notranslate"><span class="pre">pkg.deps</span></code> parameter if your device
has limited flash memory and cannot support Over-The-Air (OTA)
firmware upgrades.</p></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="rst-footer-buttons row" role="navigation" aria-label="footer navigation">
<a href="ota_upgrade_nrf52.html" class="btn btn-neutral float-right" title="Over-the-Air Image Upgrade" accesskey="n">Next: Over-the-Air Image Upgrade <span class="fa fa-arrow-circle-right"></span></a>
<a href="devmgmt.html" class="btn btn-neutral" title="Remote Device Management" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous: Remote Device Management</a>
</div>
</div>
</div>
</div>
<!-- ENDS CONTENT SECTION -->
</div>
<!-- ENDS .content -->
</div>
</div>
<footer>
<div class="container">
<div class="row">
<div class="col-xs-12">
<p class="copyright">Apache Mynewt is available under Apache License, version 2.0.</p>
</div>
<div class="col-xs-12">
<div class="logos">
<img src="../../_static/img/asf_logo_wide_small.png" alt="Apache" title="Apache">
<small class="footnote">
Apache Mynewt, Mynewt, Apache, the Apache feather logo, and the Apache Mynewt project logo are either
registered trademarks or trademarks of the Apache Software Foundation in the United States and other countries.
</small>
<a href="">
<img src="../../_static/img/add_to_slack.png" alt="Slack Icon" title="Join our Slack Community" />
</a>
</div>
</div>
</div>
</div>
</footer>
</div>
<!-- ENDS #wrapper -->
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'latest',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt',
LINK_SUFFIX: '.html'
};
</script>
<script type="text/javascript" src="../../_static/jquery.js"></script>
<script type="text/javascript" src="../../_static/underscore.js"></script>
<script type="text/javascript" src="../../_static/doctools.js"></script>
<script type="text/javascript" src="../../_static/js/bootstrap-3.0.3.min.js"></script>
<script type="text/javascript" src="../../_static/js/affix.js"></script>
<script type="text/javascript" src="../../_static/js/main.js"></script>
</body>
</html>