blob: b1ed6daf3a7cab1c28864991d77c5f91cc3431a9 [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>Mynewt FAQ - Bluetooth &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="Mynewt FAQ" href="index.html"/>
<link rel="next" title="Mynewt FAQ - Bootloader and Firmware Upgrade" href="boot_faq.html"/>
<link rel="prev" title="Mynewt FAQ - Administrative" href="admin_faq.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="index.html">Mynewt FAQ</a> /
Mynewt FAQ - Bluetooth
<div class="sourcelink">
<a href="https://github.com/apache/mynewt-documentation/edit/master/docs/mynewt_faq/bluetooth_faq.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"><a class="reference internal" href="../tutorials/tutorials.html">Tutorials</a></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 current"><a class="reference internal" href="index.html">Mynewt FAQ</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="admin_faq.html">Administrative</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Bluetooth</a></li>
<li class="toctree-l2"><a class="reference internal" href="boot_faq.html">Bootloader and Firmware Upgrade</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules_faq.html">Drivers and Modules</a></li>
<li class="toctree-l2"><a class="reference internal" href="fs_faq.html">File System</a></li>
<li class="toctree-l2"><a class="reference internal" href="hardware_faq.html">Hardware-Specific</a></li>
<li class="toctree-l2"><a class="reference internal" href="syntax_faq.html">Mynewt Syntax and Semantics</a></li>
<li class="toctree-l2"><a class="reference internal" href="nfc_faq.html">NFC</a></li>
<li class="toctree-l2"><a class="reference internal" href="newt_faq.html">Newt</a></li>
<li class="toctree-l2"><a class="reference internal" href="newtmgr_faq.html">Newt Manager</a></li>
<li class="toctree-l2"><a class="reference internal" href="port_faq.html">Porting Mynewt</a></li>
<li class="toctree-l2"><a class="reference internal" href="troubleshoot_faq.html">Troubleshooting</a></li>
</ul>
</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="mynewt-faq-bluetooth">
<h1>Mynewt FAQ - Bluetooth<a class="headerlink" href="#mynewt-faq-bluetooth" title="Permalink to this headline"></a></h1>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#nimble-on-nrf52840" id="id1">NimBLE on nRF52840</a></p></li>
<li><p><a class="reference internal" href="#trigger-exactly-one-ble-advertisement-immediately" id="id2">Trigger Exactly One BLE Advertisement Immediately</a></p></li>
<li><p><a class="reference internal" href="#supported-bluetooth-radio-transceivers" id="id3">Supported Bluetooth Radio Transceivers</a></p></li>
<li><p><a class="reference internal" href="#nimble-operational-questions" id="id4">NimBLE Operational Questions</a></p></li>
<li><p><a class="reference internal" href="#blemesh-forgets-all-keys-on-restart" id="id5"><code class="docutils literal notranslate"><span class="pre">blemesh</span></code> Forgets All Keys on Restart</a></p></li>
<li><p><a class="reference internal" href="#l2cap-connection" id="id6">L2CAP Connection</a></p></li>
<li><p><a class="reference internal" href="#bitbang-ble-mesh-ble-advertising" id="id7">Bitbang, BLE Mesh, BLE Advertising</a></p></li>
<li><p><a class="reference internal" href="#extended-advertising-with-btshell" id="id8">Extended Advertising with <code class="docutils literal notranslate"><span class="pre">btshell</span></code></a></p></li>
<li><p><a class="reference internal" href="#configuring-maximum-number-of-connections-for-blehci" id="id9">Configuring Maximum Number of Connections for <code class="docutils literal notranslate"><span class="pre">blehci</span></code></a></p></li>
<li><p><a class="reference internal" href="#disconnect-crash-while-writing-analog-value-from-central-module" id="id10">Disconnect/Crash While Writing Analog Value From Central Module</a></p></li>
<li><p><a class="reference internal" href="#documentation-for-ble-gap-disc-params" id="id11">Documentation for <code class="docutils literal notranslate"><span class="pre">ble_gap_disc_params</span></code></a></p></li>
<li><p><a class="reference internal" href="#multicast-messaging-and-group-messaging" id="id12">Multicast Messaging and Group Messaging</a></p></li>
<li><p><a class="reference internal" href="#read-the-value-of-a-characteristic-of-a-peripheral-device-from-a-central-device" id="id13">Read the Value of a Characteristic of a Peripheral Device from a Central Device</a></p></li>
</ul>
</div>
<div class="section" id="nimble-on-nrf52840">
<h2><a class="toc-backref" href="#id1">NimBLE on nRF52840</a><a class="headerlink" href="#nimble-on-nrf52840" title="Permalink to this headline"></a></h2>
<p><strong>Q</strong>: Is the nRF52840 supported by NimBLE?</p>
<p><strong>A</strong>: The nRF52840 is supported, including Bluetooth 5 features.</p>
</div>
<div class="section" id="trigger-exactly-one-ble-advertisement-immediately">
<h2><a class="toc-backref" href="#id2">Trigger Exactly One BLE Advertisement Immediately</a><a class="headerlink" href="#trigger-exactly-one-ble-advertisement-immediately" title="Permalink to this headline"></a></h2>
<p><strong>Q</strong>: Is there a way to trigger exactly one BLE advertisement immediately? I basically want to use BLE as a means
to advertise to a whole group of devices and it needs to be relatively time-precise. Hoping for about 1ms precision,
but it’s okay if there’s a delay as long as it’s deterministic.</p>
<p><strong>A</strong>: With extended advertising you can enable an advertising instance for exactly 1 advertising event but there will
be some delay before controller starts advertising which depends on the level of precision. The NimBLE controller always
schedules the 1st advertising event with a constant 5ms delay. However, if there are other things scheduled in the
controller it may need to schedule it later so it’s not guaranteed to be deterministic. Periodic advertising is currently
not supported.</p>
</div>
<div class="section" id="supported-bluetooth-radio-transceivers">
<h2><a class="toc-backref" href="#id3">Supported Bluetooth Radio Transceivers</a><a class="headerlink" href="#supported-bluetooth-radio-transceivers" title="Permalink to this headline"></a></h2>
<p><strong>Q</strong>: Are there any other Bluetooth radio transceivers that are supported already or anyone working on? If there is a
Bluetooth radio that can be integrated using the HCI, we can use the NimBLE host? If so, I suppose we don’t need detailed
specs of the Bluetooth radio?</p>
<p><strong>A</strong>: You should be able to run the NimBLE host against pretty much any controller using HCI. We have a BLE controller
implementation for Nordic only, but host (in theory) should work with all. More likely, it will work with 5.0 controller.
For 4.x controllers it may fail on initialization since we do not check controller features - but this can be fixed as
for other radio transceivers. For example, there’s NXP KW41Z which has BLE-compatible radio documented. However, NXP
documentation is more or less a description of zillions of different registers so not as friendly as the one from Nordic
which explains how to actually use it.</p>
</div>
<div class="section" id="nimble-operational-questions">
<h2><a class="toc-backref" href="#id4">NimBLE Operational Questions</a><a class="headerlink" href="#nimble-operational-questions" title="Permalink to this headline"></a></h2>
<p><strong>Q</strong>: Can I update firmware via BLE for multiple devices simultaneously using a single device/phone supporting Bluetooth?</p>
<p><strong>A</strong>: Yes, it is possible to update several Nimble devices simultaneously from a single phone (e.g., central) as long as
the central can handle all the simultaneous Bluetooth connections. You can also do it using your computer as a central with
newtmgr. Just open two terminals and initiate a newtmgr image upload command in each, each to a different device. You will,
however, get better overall throughput if you limit yourself to one upgrade at a time.</p>
<p><strong>Q</strong>: I have the following doubts on NimBLE: The document says 32+ concurrent connections, multiple connections in simultaneous
central and peripheral roles. Does that mean the “device running NimBLE” can connect to 32 different other devices like phones?</p>
<p><strong>A</strong>: Yes, with one caveat: each of the 32 centrals needs to be sufficiently cooperative in choosing connection partners
(<a class="reference external" href="http://www.novelbits.io/ble-connection-intervals/">http://www.novelbits.io/ble-connection-intervals/</a>). Your app might need to request different connection parameters from
the centrals (using <code class="docutils literal notranslate"><span class="pre">ble_gap_update_params</span></code>).</p>
<p>Of course, you will also need to build the Mynewt image device with a configuration suitable for 32 concurrent connections
(e.g., <code class="docutils literal notranslate"><span class="pre">NIMBLE_MAX_CONNECTIONS=32</span></code>, etc.)</p>
</div>
<div class="section" id="blemesh-forgets-all-keys-on-restart">
<h2><a class="toc-backref" href="#id5"><code class="docutils literal notranslate"><span class="pre">blemesh</span></code> Forgets All Keys on Restart</a><a class="headerlink" href="#blemesh-forgets-all-keys-on-restart" title="Permalink to this headline"></a></h2>
<p><strong>Q</strong>: Is it expected that the blemesh example forgets all the keys on restart and needs to be provisioned again? If so,
how can I implement key persistence myself? Is there any API to obtain / provide mesh keys before the mesh node is started?
I found bt_mesh_provision, but the comment there seems to indicate that this is not the right way to use it.</p>
<p><strong>A</strong>: Mesh implementations do not persist keys at the moment. There is a plan to add it but not sure about timeline. It
probably needs to be implemented inside mesh implementation so there’s no API, but if you’d like to hack something I suggest
taking a look at shell.c and testing.c - there are some testing functions to add/display keys. Another area to look if you
actually want to persist keys to flash is <code class="docutils literal notranslate"><span class="pre">net/nimble/host/store/config/src/ble_store_config.c</span></code>. This is the code that
persists and restores security material for (non-mesh) Bluetooth.</p>
</div>
<div class="section" id="l2cap-connection">
<h2><a class="toc-backref" href="#id6">L2CAP Connection</a><a class="headerlink" href="#l2cap-connection" title="Permalink to this headline"></a></h2>
<p><strong>Q</strong>: I want to do an L2CAP connection, and am trying the auth-passkey command, but am not sure about the parameters <code class="docutils literal notranslate"><span class="pre">psm</span></code>,
<code class="docutils literal notranslate"><span class="pre">action</span></code>, and <code class="docutils literal notranslate"><span class="pre">oob</span></code>. What is <code class="docutils literal notranslate"><span class="pre">psm</span></code>, and what is the value of that parameter in the btshell command <code class="docutils literal notranslate"><span class="pre">l2cap-connect</span></code>? How
do I set the parameters <code class="docutils literal notranslate"><span class="pre">action</span></code> and <code class="docutils literal notranslate"><span class="pre">oob</span></code>?</p>
<p><strong>A</strong>: <code class="docutils literal notranslate"><span class="pre">psm</span></code> stands for Protocol Service Multiplexer. You pass the <code class="docutils literal notranslate"><span class="pre">psm</span></code> value to either <code class="docutils literal notranslate"><span class="pre">l2-cap-connect</span></code> or
<code class="docutils literal notranslate"><span class="pre">l2cap-create-server</span></code>. The parameters <code class="docutils literal notranslate"><span class="pre">action</span></code> and <code class="docutils literal notranslate"><span class="pre">oob</span></code> are just passing constant values as defined in the API.</p>
</div>
<div class="section" id="bitbang-ble-mesh-ble-advertising">
<h2><a class="toc-backref" href="#id7">Bitbang, BLE Mesh, BLE Advertising</a><a class="headerlink" href="#bitbang-ble-mesh-ble-advertising" title="Permalink to this headline"></a></h2>
<p><strong>Q</strong>: Is it possible to run bitbanging and BLE mesh at the same time? How about running BLE Mesh and BLE advertising at
the same time?</p>
<p><strong>A</strong>: It is possible to run bitbanging and BLE mesh at the same time, but the bitbanging UART takes a lot of CPU on Nordic.
We’ve run it at 9600 which would probably be okay for lower rate devices, but for reliability it is recommended to run at
4800. If this is just for the console and your UART port is tied up, <code class="docutils literal notranslate"><span class="pre">rtt</span></code> is recommended. Take a look at
<a class="reference internal" href="../tutorials/tooling/segger_rtt.html"><span class="doc">Segger RTT Console</span></a> for more information. However, bitbanger can be handy given limited UARTs.</p>
<p>You can certainly continue advertisements during connections, if you are using the GATT bearer for mesh. Mesh is also tied
into the ext-adv bearer in Mynewt, which also allows for interleaving, even if you’re transmitting mesh data on advertising channels.</p>
</div>
<div class="section" id="extended-advertising-with-btshell">
<h2><a class="toc-backref" href="#id8">Extended Advertising with <code class="docutils literal notranslate"><span class="pre">btshell</span></code></a><a class="headerlink" href="#extended-advertising-with-btshell" title="Permalink to this headline"></a></h2>
<p><strong>Q</strong>: I am using <code class="docutils literal notranslate"><span class="pre">btshell</span></code> for advertising with nRF52. When I use 31 bytes, <code class="docutils literal notranslate"><span class="pre">mfg_data</span></code> accepts the data with extended
advertising. But when I use more bytes than that, <code class="docutils literal notranslate"><span class="pre">mfg_data</span></code> doesn’t accept it. Is 251 byte payload supported in extended
advertising? How can I send more than a 251 byte payload on extended advertising?</p>
<p><strong>A</strong>: You need to set the <code class="docutils literal notranslate"><span class="pre">BLE_EXT_ADV_MAX_SIZE</span></code> syscfg to your required value. For example:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">newt target amend &lt;your_target&gt; syscfg=BLE_EXT_ADV=1:BLE_EXT_ADV_MAX_SIZE=1650</span>
</pre></div>
</div>
<p>The default is 31 bytes, and the max is 1650.</p>
<p>Keep in mind that with extended advertising, you cannot set advertising data for an instance configured as scannable
(e.g. <code class="docutils literal notranslate"><span class="pre">advertise-configure</span> <span class="pre">scannable=1</span></code>). Either set scan response data using <code class="docutils literal notranslate"><span class="pre">advertise-set-scan-rsp</span></code> command
(parameters are the same as for <code class="docutils literal notranslate"><span class="pre">advertise-set-adv-data</span></code>) or configure the instance as non-scannable. For example,
<code class="docutils literal notranslate"><span class="pre">advertise-configure</span></code> alone will configure the instance as non-connectable and non-scannable which means you can
set advertising data. Also note that if you continue to use a scannable instance you will need to perform active
scanning in order to get scan response data.</p>
<p>FYI, legacy advertising instances can accept both advertising and scan response data but since they use legacy PDUs
the limit is still 31 bytes.</p>
</div>
<div class="section" id="configuring-maximum-number-of-connections-for-blehci">
<h2><a class="toc-backref" href="#id9">Configuring Maximum Number of Connections for <code class="docutils literal notranslate"><span class="pre">blehci</span></code></a><a class="headerlink" href="#configuring-maximum-number-of-connections-for-blehci" title="Permalink to this headline"></a></h2>
<p><strong>Q</strong>: How do I set the maximum number of connections for the <code class="docutils literal notranslate"><span class="pre">blehci</span></code> <a class="reference internal" href="../tutorials/ble/blehci_project.html"><span class="doc">example</span></a>?
I see there is a <code class="docutils literal notranslate"><span class="pre">MYNEWT_VAL_BLE_MAX_CONNECTIONS</span></code>, but I don’t know how to set it.</p>
<p><strong>A</strong>: You can to set it in target settings:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">newt target amend &lt;target&gt; syscfg=BLE_MAX_CONNECTIONS=2</span>
</pre></div>
</div>
<p>and then rebuild using <code class="docutils literal notranslate"><span class="pre">newt</span> <span class="pre">build</span> <span class="pre">&lt;target&gt;</span></code>. <code class="docutils literal notranslate"><span class="pre">MYNEWT_VAL_BLE_MAX_CONNECTIONS</span></code> is just a symbol that is defined in
<code class="docutils literal notranslate"><span class="pre">syscfg.h</span></code> which is autogenerated by <code class="docutils literal notranslate"><span class="pre">newt</span></code> tool and contains all the settings set at package/app/target level.</p>
<p><strong>Q</strong>: What if I need to set 2 constants? What’s the syntax?</p>
<p><strong>A</strong>: You can set each setting in separate commands or separate <code class="docutils literal notranslate"><span class="pre">key=value</span></code> pairs with colon:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">newt target amend &lt;target&gt; syscfg=FOO=1:BAR=2</span>
</pre></div>
</div>
<p><strong>Q</strong>: How do you know the constant is <code class="docutils literal notranslate"><span class="pre">BLE_MAX_CONNECTIONS</span></code> and not <code class="docutils literal notranslate"><span class="pre">MYNEWT_VAL_BLE_MAX_CONNECTIONS</span></code>?
Is there a place I can see those names?</p>
<p><strong>A</strong>: This is actually one of NimBLE’s settings - you can find these settings available for different packages in the
<code class="docutils literal notranslate"><span class="pre">syscfg.yml</span></code> files in the repository. You can also use <code class="docutils literal notranslate"><span class="pre">newt</span> <span class="pre">target</span> <span class="pre">config</span> <span class="pre">show</span> <span class="pre">&lt;target&gt;</span></code> to show all settings with
their current values, and then change any of these settings accordingly. Each setting will get a symbol prefixed by
<code class="docutils literal notranslate"><span class="pre">MYNEWT_VAL_</span></code> in the autogenerated <code class="docutils literal notranslate"><span class="pre">syscfg.h</span></code> file so you can get the actual setting name from this symbol. For more
info on System Configuration and Initialization, please visit the <a class="reference internal" href="../os/modules/sysinitconfig/sysinitconfig.html"><span class="doc">Compile-Time Configuration and Initialization</span></a> page in the OS User Guide.</p>
</div>
<div class="section" id="disconnect-crash-while-writing-analog-value-from-central-module">
<h2><a class="toc-backref" href="#id10">Disconnect/Crash While Writing Analog Value From Central Module</a><a class="headerlink" href="#disconnect-crash-while-writing-analog-value-from-central-module" title="Permalink to this headline"></a></h2>
<p><strong>Q</strong>: I’m trying to write analog sensor data from my central module to my peripheral module. I can receive the values
from the ADC callback perfectly, but I’m not able to write them to the peripheral module. The peripheral module disconnects
right when the <code class="docutils literal notranslate"><span class="pre">ble_gattc_write_flat</span></code> command is called. What could be causing the issue?</p>
<p><strong>A</strong>: First, check the reason for the disconnect. The gap event callback should indicate the reason in <code class="docutils literal notranslate"><span class="pre">disconnect.reason</span></code>.
If the code never reaches the disconnect callback, then the code most likely crashed. If so, check whether <code class="docutils literal notranslate"><span class="pre">ble_gattc_write_flat</span></code>
is called from an interrupt context. Calling into the BLE host from within an interrupt is a bad idea in general, and may cause a
crash to occur because the Bluetooth host attempts to log to the console during the write procedure. Logging to the console uses
quite a bit of stack space, so it is likely that the interrupt stack is overflowing.</p>
<p>Instead, you should send an event to the event queue and handle this in a task context. You’ll need to associate the characteristic
data with the event so that your event callback knows what payload to pass to the <code class="docutils literal notranslate"><span class="pre">ble_gattc_write_flat()</span></code> function. If you don’t
need to perform multiple writes in rapid succession, then you can just use a single global event and single global buffer. However,
you will still need to make sure your buffer doesn’t become corrupted by a subsequent ADC interrupt while you are in mid-write.</p>
</div>
<div class="section" id="documentation-for-ble-gap-disc-params">
<h2><a class="toc-backref" href="#id11">Documentation for <code class="docutils literal notranslate"><span class="pre">ble_gap_disc_params</span></code></a><a class="headerlink" href="#documentation-for-ble-gap-disc-params" title="Permalink to this headline"></a></h2>
<p><strong>Q</strong>: Is there documentation somewhere on correct values for <code class="docutils literal notranslate"><span class="pre">ble_gap_disc_params</span></code>? I’m trying to do a passive discovery and getting
<code class="docutils literal notranslate"><span class="pre">BLE_HS_EINVAL</span></code>.</p>
<p><strong>A</strong>: Unfortunately, not at the moment. Here is a brief description of the fields:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">itvl</span></code>: This is defined as the time interval from when the Controller started its last LE scan until it begins the subsequent LE scan. (units=0.625 msec)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">window</span></code>: The duration of the LE scan. <code class="docutils literal notranslate"><span class="pre">LE_Scan_Window</span></code> shall be less than or equal to <code class="docutils literal notranslate"><span class="pre">LE_Scan_Interval</span></code> (units=0.625 msec)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">filter_policy</span></code>: The only useful documentation is the table in the Bluetooth spec (section 2.E.7.8.10). This field controls which types of devices to listen for.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">limited</span></code>: If set, only discover devices in limited discoverable mode.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">passive</span></code>: If set, don’t send scan requests to advertisers (i.e., don’t request additional advertising data).</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">filter_duplicates</span></code>: If set, the controller ignores all but the first advertisement from each device.</p></li>
</ul>
</div>
<div class="section" id="multicast-messaging-and-group-messaging">
<h2><a class="toc-backref" href="#id12">Multicast Messaging and Group Messaging</a><a class="headerlink" href="#multicast-messaging-and-group-messaging" title="Permalink to this headline"></a></h2>
<p><strong>Q</strong>: Is it possible to send a broadcast message by one of the devices present in the mesh (e.g. broadcast an event which happened)? Something like a push notification instead of continuously polling for it by a client.</p>
<p><strong>A</strong>: It is possible to do so with a publish model. Group address or virtual address should help here, according to the Mesh spec. There is no real documentation on it but you can try it out on our <code class="docutils literal notranslate"><span class="pre">btmesh_shell</span></code> app. There is a <code class="docutils literal notranslate"><span class="pre">shell.c</span></code> file which exposes configuration client which you can use for testing (e.g. you can subscribe to virtual addresses). You can also trigger sending messages to devices. By playing with the <code class="docutils literal notranslate"><span class="pre">dst</span></code> command, you probably should be able to set destination to some group. However, since we do not support the provisioner role, there is a command provision which sets fixed keys so you can create a mesh network out of a couple of nodes without the actual provisioner.</p>
</div>
<div class="section" id="read-the-value-of-a-characteristic-of-a-peripheral-device-from-a-central-device">
<h2><a class="toc-backref" href="#id13">Read the Value of a Characteristic of a Peripheral Device from a Central Device</a><a class="headerlink" href="#read-the-value-of-a-characteristic-of-a-peripheral-device-from-a-central-device" title="Permalink to this headline"></a></h2>
<p><strong>Q</strong>: I want to read the value of a characteristic of a peripheral device from a central device which runs on Mynewt OS. How can I obtain the value using the following function?</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">int</span><span class="w"> </span><span class="nf">ble_gattc_read</span><span class="p">(</span><span class="kt">uint16_t</span><span class="w"> </span><span class="n">conn_handle</span><span class="p">,</span><span class="w"> </span><span class="kt">uint16_t</span><span class="w"> </span><span class="n">attr_handle</span><span class="p">,</span>
<span class="w"> </span><span class="n">ble_gatt_attr_fn</span><span class="w"> </span><span class="o">*</span><span class="n">cb</span><span class="p">,</span><span class="w"> </span><span class="kt">void</span><span class="w"> </span><span class="o">*</span><span class="n">cb_arg</span><span class="p">);</span>
</pre></div>
</div>
<p><strong>A</strong>: To see an example of this function being used, take a look at the <code class="docutils literal notranslate"><span class="pre">blecent</span></code> sample app. The data is in <code class="docutils literal notranslate"><span class="pre">attr-&gt;om</span></code>, which is an <code class="docutils literal notranslate"><span class="pre">mbuf</span></code> struct. There are dedicated APIs to access data in mbufs (see <code class="docutils literal notranslate"><span class="pre">os_mbuf.h</span></code>). <code class="docutils literal notranslate"><span class="pre">attr-&gt;om-&gt;om_data</span></code> is a raw pointer to access data in mbuf so you could also use it, but keep in mind that data in mbuf can be fragmented so you may not be able to access them easily like this. Thus, it is safer to use mbuf APIs instead. <code class="docutils literal notranslate"><span class="pre">os_mbuf_copydata</span></code> should be especially useful here since it can copy data from mbuf to flat buffer.</p>
</div>
</div>
</div>
</div>
<div class="rst-footer-buttons row" role="navigation" aria-label="footer navigation">
<a href="boot_faq.html" class="btn btn-neutral float-right" title="Mynewt FAQ - Bootloader and Firmware Upgrade" accesskey="n">Next: Mynewt FAQ - Bootloader and Firmware Upgrade <span class="fa fa-arrow-circle-right"></span></a>
<a href="admin_faq.html" class="btn btn-neutral" title="Mynewt FAQ - Administrative" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous: Mynewt FAQ - Administrative</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>