1197 lines
35 KiB
HTML
1197 lines
35 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
<meta name="generator" content="mkdocs-1.6.1, mkdocs-terminal-4.8.0">
|
|
|
|
<meta name="description" content="MeshCore fork meshcore-tth -- repeater antispam, diagnostics, OTA, Czech mesh defaults">
|
|
|
|
|
|
<link rel="canonical" href="https://tth-pub.pages.rfa.cz/meshcore-tth/stats-bundle/"><link rel="icon" type="image/png" sizes="192x192" href="../img/android-chrome-192x192.png" />
|
|
<link rel="icon" type="image/png" sizes="512x512" href="../img/android-chrome-512x512.png" />
|
|
<link rel="apple-touch-icon" sizes="180x180" href="../img/apple-touch-icon.png" />
|
|
<link rel="shortcut icon" type="image/png" sizes="48x48" href="../img/favicon.ico" />
|
|
<link rel="icon" type="image/png" sizes="16x16" href="../img/favicon-16x16.png" />
|
|
<link rel="icon" type="image/png" sizes="32x32" href="../img/favicon-32x32.png" />
|
|
|
|
|
|
|
|
|
|
<title>Stats bundle -- one request per scrape (repeater) - MeshCore TTH</title>
|
|
|
|
|
|
<link href="../css/fontawesome/css/fontawesome.min.css" rel="stylesheet">
|
|
<link href="../css/fontawesome/css/solid.min.css" rel="stylesheet">
|
|
<link href="../css/normalize.css" rel="stylesheet">
|
|
<link href="../css/terminal.css" rel="stylesheet">
|
|
<link href="../css/theme.css" rel="stylesheet">
|
|
<link href="../css/theme.tile_grid.css" rel="stylesheet">
|
|
<link href="../css/theme.footer.css" rel="stylesheet">
|
|
<!-- dark color palette -->
|
|
<link href="../css/palettes/dark.css" rel="stylesheet">
|
|
|
|
<!-- page layout -->
|
|
<style>
|
|
/* initially set page layout to a one column grid */
|
|
.terminal-mkdocs-main-grid {
|
|
display: grid;
|
|
grid-column-gap: 1.4em;
|
|
grid-template-columns: auto;
|
|
grid-template-rows: auto;
|
|
}
|
|
|
|
/*
|
|
* when side navigation is not hidden, use a two column grid.
|
|
* if the screen is too narrow, fall back to the initial one column grid layout.
|
|
* in this case the main content will be placed under the navigation panel.
|
|
*/
|
|
@media only screen and (min-width: 70em) {
|
|
.terminal-mkdocs-main-grid {
|
|
grid-template-columns: 4fr 9fr;
|
|
}
|
|
}</style>
|
|
|
|
<!-- cursor_animation override -->
|
|
<style>
|
|
#mkdocs-terminal-site-name.terminal-prompt::after {
|
|
display: none;
|
|
}
|
|
</style>
|
|
|
|
|
|
<link href="../_stylesheets/tth.css" rel="stylesheet">
|
|
|
|
|
|
|
|
|
|
<!-- search css support -->
|
|
<link href="../css/search/bootstrap-modal.css" rel="stylesheet">
|
|
<!-- search scripts -->
|
|
<script>
|
|
var base_url = "..",
|
|
shortcuts = "{}";
|
|
</script>
|
|
<script src="../js/jquery/jquery-1.10.1.min.js" defer></script>
|
|
<script src="../js/bootstrap/bootstrap.min.js" defer></script>
|
|
<script src="../js/mkdocs/base.js" defer></script>
|
|
|
|
|
|
|
|
|
|
<script src="../search/main.js"></script>
|
|
|
|
|
|
|
|
</head>
|
|
|
|
<body class="terminal"><div class="container">
|
|
<div class="terminal-nav">
|
|
<header class="terminal-logo">
|
|
<div id="mkdocs-terminal-site-name" class="logo terminal-prompt"><a href="https://tth-pub.pages.rfa.cz/meshcore-tth/" class="no-style">MeshCore TTH</a></div>
|
|
</header>
|
|
|
|
<nav class="terminal-menu">
|
|
|
|
<ul vocab="https://schema.org/" typeof="BreadcrumbList">
|
|
|
|
|
|
<li property="itemListElement" typeof="ListItem">
|
|
<a href=".." class="menu-item " property="item" typeof="WebPage">
|
|
<span property="name">About the fork</span>
|
|
</a>
|
|
<meta property="position" content="0">
|
|
</li>
|
|
|
|
|
|
<li property="itemListElement" typeof="ListItem">
|
|
<a href="../cs/" class="menu-item " property="item" typeof="WebPage">
|
|
<span property="name">Česky</span>
|
|
</a>
|
|
<meta property="position" content="1">
|
|
</li>
|
|
|
|
|
|
<li property="itemListElement" typeof="ListItem">
|
|
<a href="https://git.rfa.cz/tth-pub/meshcore-tth" class="menu-item " property="item" typeof="WebPage">
|
|
<span property="name">Repository</span>
|
|
</a>
|
|
<meta property="position" content="2">
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li property="itemListElement" typeof="ListItem">
|
|
<a href="#" class="menu-item" data-toggle="modal" data-target="#mkdocs_search_modal" property="item" typeof="SearchAction">
|
|
<i aria-hidden="true" class="fa fa-search"></i> <span property="name">Search</span>
|
|
</a>
|
|
<meta property="position" content="3">
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<div class="terminal-mkdocs-main-grid"><aside id="terminal-mkdocs-side-panel"><nav>
|
|
<ul class="terminal-mkdocs-side-nav-items">
|
|
|
|
<li class="terminal-mkdocs-side-nav-li">
|
|
|
|
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="..">About the fork</a>
|
|
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="terminal-mkdocs-side-nav-li">
|
|
|
|
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="../cs/">Česky</a>
|
|
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="terminal-mkdocs-side-nav-li">
|
|
|
|
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="https://git.rfa.cz/tth-pub/meshcore-tth">Repository</a>
|
|
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="terminal-mkdocs-side-nav-li">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="
|
|
|
|
|
|
|
|
terminal-mkdocs-side-nav-item terminal-mkdocs-side-nav-section-no-index">Fork meshcore-tth</span>
|
|
|
|
|
|
|
|
|
|
|
|
<ul class="terminal-mkdocs-side-nav-li-ul">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="terminal-mkdocs-side-nav-li-ul-li">
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="../tth-commands/">Console commands</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="terminal-mkdocs-side-nav-li-ul-li">
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="../ota/">Firmware update by the admin (OTA)</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="terminal-mkdocs-side-nav-li-ul-li">
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="../power/">Power saving</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="terminal-mkdocs-side-nav-li-ul-li">
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="../budka-sensor/">Budka as a sensor</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="terminal-mkdocs-side-nav-li-ul-li">
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="../ble-lora-coexistence/">BLE/LoRa coexistence</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</li>
|
|
|
|
<li class="terminal-mkdocs-side-nav-li">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="
|
|
|
|
|
|
|
|
terminal-mkdocs-side-nav-item terminal-mkdocs-side-nav-section-no-index">MeshCore (upstream)</span>
|
|
|
|
|
|
|
|
|
|
|
|
<ul class="terminal-mkdocs-side-nav-li-ul">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="terminal-mkdocs-side-nav-li-ul-li">
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="../meshcore/">Introduction</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="terminal-mkdocs-side-nav-li-ul-li">
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="../faq/">FAQ</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="terminal-mkdocs-side-nav-li-ul-li">
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="../cli_commands/">CLI commands</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="terminal-mkdocs-side-nav-li-ul-li">
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="../companion_cli/">Companion CLI</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="terminal-mkdocs-side-nav-li-ul-li">
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="../companion_protocol/">Companion protocol</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="terminal-mkdocs-side-nav-li-ul-li">
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="../terminal_chat_cli/">Terminal chat CLI</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="terminal-mkdocs-side-nav-li-ul-li">
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="../kiss_modem_protocol/">KISS modem protocol</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="terminal-mkdocs-side-nav-li-ul-li">
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="../packet_format/">Packet format</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="terminal-mkdocs-side-nav-li-ul-li">
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="../payloads/">Payloads</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="terminal-mkdocs-side-nav-li-ul-li">
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="../stats_binary_frames/">Stats binary frames</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="terminal-mkdocs-side-nav-li-ul-li">
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="../number_allocations/">Number allocations</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="terminal-mkdocs-side-nav-li-ul-li">
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="../qr_codes/">QR codes</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="terminal-mkdocs-side-nav-li-ul-li">
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="../radio_presets/">Radio presets</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="terminal-mkdocs-side-nav-li-ul-li">
|
|
|
|
|
|
|
|
<a class="terminal-mkdocs-side-nav-item" href="../nrf52_power_management/">nRF52 power management</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav><hr>
|
|
<nav>
|
|
<ul>
|
|
<li><a href="#stats-bundle-one-request-per-scrape-repeater">Stats bundle -- one request per scrape (repeater)</a></li>
|
|
<li><a href="#request">Request</a></li><li><a href="#reply">Reply</a></li><li><a href="#prefs_crc16">prefs_crc16</a></li><li><a href="#version-and-compatibility">Version and compatibility</a></li><li><a href="#sizes">Sizes</a></li>
|
|
</ul>
|
|
</nav>
|
|
</aside>
|
|
<main id="terminal-mkdocs-main-content">
|
|
<section id="mkdocs-terminal-content">
|
|
<h1 id="stats-bundle-one-request-per-scrape-repeater">Stats bundle -- one request per scrape (repeater)</h1>
|
|
<div class="admonition warning">
|
|
<p class="admonition-title">Warning</p>
|
|
<p>Part of an experimental fork, not meant for regular users. The request is
|
|
not part of upstream's protocol.</p>
|
|
</div>
|
|
<p>A monitoring scrape used to cost a login (when the session had expired),
|
|
<code>REQ_TYPE_GET_STATUS</code>, <code>REQ_TYPE_GET_TELEMETRY_DATA</code> (the node's sensors) and, for the filter
|
|
counters, more CLI round trips -- up to 6 packets over several hops. The
|
|
<strong>stats bundle</strong> answers all of it in <strong>one request and one reply</strong>.</p>
|
|
<p>Code: <code>src/helpers/StatsBundle.h</code> (encoder, decoder, prefs CRC; native tests in
|
|
<code>test/test_stats_bundle</code>), glue in <code>examples/simple_repeater/MyMesh.cpp</code>
|
|
(<code>handleRequest</code>). Reference implementation in Python and test vectors:
|
|
<code>test/vectors/gen_stats_bundle_vectors.py</code> -> <code>test/vectors/stats_bundle_vectors.json</code>
|
|
(<code>--check</code> verifies the JSON). Python 3 stdlib only, meant to be lifted into
|
|
the exporter and the Ansible collection as it is.</p>
|
|
<h2 id="request">Request</h2>
|
|
<p>A normal logged-in <code>REQ</code> (like <code>GET_STATUS</code>); the first payload byte is the type.</p>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>byte</th>
|
|
<th>meaning</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>0</td>
|
|
<td><code>REQ_TYPE_STATS_BUNDLE = 0xF1</code> (our private range next to <code>REQ_TYPE_FW_OTA = 0xF0</code>; both outside upstream's 0x01..0x09)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>1</td>
|
|
<td><code>page</code>, optional, default 0</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>An unknown page gets no reply. A build without the bundle ignores the type
|
|
(upstream firmware answers nothing to an unknown type): a reader that gets no
|
|
reply to page 0 falls back to <code>GET_STATUS</code> + <code>GET_TELEMETRY_DATA</code>.</p>
|
|
<p><strong>Who may read what.</strong> An <strong>admin</strong> gets everything. A guest or read-only login
|
|
gets exactly what <code>GET_STATUS</code> and the telemetry give it today -- status
|
|
and telemetry records (ids 1..21) and the sensor record (id 42, below), nothing
|
|
else. Sensors follow the telemetry rules: a <strong>guest</strong> is answered as telemetry
|
|
answers a guest (base set, so no sensors and no id 42); any other login gets
|
|
all of them, as a <code>GET_TELEMETRY_DATA</code> with the default (all permissions) mask
|
|
does.</p>
|
|
<h2 id="reply">Reply</h2>
|
|
<p>The reply carries the 4-byte tag of the request, then at most <strong>150 B</strong> of
|
|
bundle (the same budget as the OTA reply: tag + 150 B pads to 160 B and the
|
|
companion's push frame must stay within <code>MAX_FRAME_SIZE</code> 176).</p>
|
|
<div class="highlight"><pre><span></span><code>[ver = 1][page << 4 | pages] record record ...
|
|
</code></pre></div>
|
|
<p><code>pages</code> is the total number of pages (1..15), <code>page</code> the one in this reply.</p>
|
|
<p><strong>Record</strong> = key byte <code>(id << 2) | wire_type</code>, id 0..63:</p>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>wire type</th>
|
|
<th>value</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>0</td>
|
|
<td>varint: LEB128, unsigned 32 bit (low 7 bits first, bit 7 = more). Signed values are <strong>zigzag</strong> <code>(x << 1) ^ (x >> 31)</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>1</td>
|
|
<td>length (varint) + that many bytes</td>
|
|
</tr>
|
|
<tr>
|
|
<td>2, 3</td>
|
|
<td>reserved; a reader that meets one drops the page</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>A reader <strong>skips ids it does not know</strong> (wt 0: read the varint; wt 1: skip the
|
|
length), so ids can be added without a version bump. The version byte changes
|
|
only when an existing id changes meaning. Only <strong>non-zero</strong> counters are sent;
|
|
an absent counter is 0. Always sent for an admin: ids 32, 33, 34 (see below).</p>
|
|
<p><strong>A zero byte where a record key is expected ends the page.</strong> Id 0 is never
|
|
used; the reply arrives padded with zeros to the cipher block (AES, 16 B --
|
|
the companion hands the padding over too: 139 B of bundle came as 140 B, a
|
|
page 1 of 30 B as 44 B). A reader that takes <code>0x00</code> as a record with id 0
|
|
reads past the data and fails the page.</p>
|
|
<h3 id="ids">Ids</h3>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>id</th>
|
|
<th>name</th>
|
|
<th>value</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>1</td>
|
|
<td><code>batt_mv</code></td>
|
|
<td>mV</td>
|
|
</tr>
|
|
<tr>
|
|
<td>2</td>
|
|
<td><code>temp_dc</code></td>
|
|
<td>MCU temperature, 0.1 C, zigzag (absent when the board has none; sent even when 0)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>3</td>
|
|
<td><code>uptime</code></td>
|
|
<td>s</td>
|
|
</tr>
|
|
<tr>
|
|
<td>4 / 5</td>
|
|
<td><code>air_tx</code> / <code>air_rx</code></td>
|
|
<td>total TX / RX airtime, s</td>
|
|
</tr>
|
|
<tr>
|
|
<td>6 / 7</td>
|
|
<td><code>noise</code> / <code>rssi</code></td>
|
|
<td>dBm, zigzag</td>
|
|
</tr>
|
|
<tr>
|
|
<td>8</td>
|
|
<td><code>snr4</code></td>
|
|
<td>SNR x 4, zigzag</td>
|
|
</tr>
|
|
<tr>
|
|
<td>9</td>
|
|
<td><code>tx_queue</code></td>
|
|
<td>packets in the outbound queue</td>
|
|
</tr>
|
|
<tr>
|
|
<td>10 / 11</td>
|
|
<td><code>recv</code> / <code>sent</code></td>
|
|
<td>packets</td>
|
|
</tr>
|
|
<tr>
|
|
<td>12 / 13</td>
|
|
<td><code>sent_flood</code> / <code>sent_direct</code></td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td>14 / 15</td>
|
|
<td><code>recv_flood</code> / <code>recv_direct</code></td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td>16</td>
|
|
<td><code>err_events</code></td>
|
|
<td>the error flag <strong>bits</strong> of <code>RepeaterStats.err_events</code> (a bit set, not a count of errors)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>17 / 18</td>
|
|
<td><code>direct_dups</code> / <code>flood_dups</code></td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td>19</td>
|
|
<td><code>recv_errors</code></td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td>20 / 21</td>
|
|
<td><code>tx_start_fail</code> / <code>tx_timeout</code></td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td><em>the fields of <code>RepeaterStats</code> plus telemetry; ids 1..21 are all a guest sees</em></td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td>24</td>
|
|
<td><code>fair_group</code></td>
|
|
<td>FairnessLimiter drops, channel (group) bucket</td>
|
|
</tr>
|
|
<tr>
|
|
<td>25</td>
|
|
<td><code>fair_sender</code></td>
|
|
<td>sender bucket</td>
|
|
</tr>
|
|
<tr>
|
|
<td>26</td>
|
|
<td><code>fair_advert</code></td>
|
|
<td>advert bucket</td>
|
|
</tr>
|
|
<tr>
|
|
<td>27</td>
|
|
<td><code>fair_window</code></td>
|
|
<td>per-origin advert window</td>
|
|
</tr>
|
|
<tr>
|
|
<td>32</td>
|
|
<td><code>rules_auto</code></td>
|
|
<td><code>count << 16 | crc16</code> of the <code>auto</code> <code>filter flow</code> rules</td>
|
|
</tr>
|
|
<tr>
|
|
<td>33</td>
|
|
<td><code>rules_static</code></td>
|
|
<td>the same for the static ones</td>
|
|
</tr>
|
|
<tr>
|
|
<td>34</td>
|
|
<td><code>prefs_crc</code></td>
|
|
<td><code>prefs_crc16</code>, below</td>
|
|
</tr>
|
|
<tr>
|
|
<td>35</td>
|
|
<td><code>pwr_flags</code></td>
|
|
<td>adaptive battery power save (<code>set pwr.rxgain</code> / <code>set pwr.rxps</code>): bit 0 rxgain stage active, bit 1 rxps stage active, bit 2 rxgain configured, bit 3 rxps configured</td>
|
|
</tr>
|
|
<tr>
|
|
<td>36</td>
|
|
<td><code>n_counters</code></td>
|
|
<td>number of flow slots with a non-zero counter (see "Pages")</td>
|
|
</tr>
|
|
<tr>
|
|
<td>40 (wt 1)</td>
|
|
<td><code>counters</code></td>
|
|
<td>a run of triples <code>slot, dropped, passed</code>, each a varint</td>
|
|
</tr>
|
|
<tr>
|
|
<td>41 (wt 1)</td>
|
|
<td><code>rule</code></td>
|
|
<td>one rule, below</td>
|
|
</tr>
|
|
<tr>
|
|
<td>42 (wt 1)</td>
|
|
<td><code>env_lpp</code></td>
|
|
<td>the node's sensors, below</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p><code>rules_auto</code> / <code>rules_static</code> are the <code>crc16</code> values of <code>filter flow</code>
|
|
(CRC-16/CCITT-FALSE over the canonical serialization, see
|
|
<a href="../tth-commands/#forward-deny-rules----filter-flow-every-repeater">tth-commands.md</a>
|
|
and <code>test/vectors/flow_rules_vectors.json</code>), with the entry count above them.
|
|
An empty set is <code>0x0000FFFF</code>.</p>
|
|
<p><strong>Sensor record</strong> (id 42): the <strong>CayenneLPP bytes</strong> (<code>[channel][type][data]</code>
|
|
repeated, the format of a <code>GET_TELEMETRY_DATA</code> reply) of the node's sensors
|
|
<strong>without channel 1</strong>. Channel 1 is the node itself -- battery and MCU
|
|
temperature are already ids 1 and 2 (GPS, where a build reports it, is also on
|
|
channel 1 and so not here). It is what a telemetry request would add for the
|
|
same login: environment sensors (temperature, humidity, pressure, INA, ...) on
|
|
channels 2.., in the order the node initialised them. The record is <strong>omitted</strong>
|
|
when there is nothing to send (no sensors, a guest); readings are whole, and
|
|
those that would not fit in 128 B (<code>SB_ENV_MAX</code>) are left out, never cut. A
|
|
reader decodes it like a telemetry reply; types and scaling are in
|
|
<code>lpp_decode()</code> of the Python reference (e.g. <code>02 67 00E1</code> = channel 2,
|
|
temperature 22.5 C; <code>02 68 3C</code> = humidity 30 %; <code>02 73 271C</code> = pressure
|
|
1001.2 hPa; 11 B for the three).</p>
|
|
<p><strong>Rule record</strong> (id 41): <code>slot</code> (varint) <code>kind</code> (1 B, ASCII) <code>klen</code> (1 B)
|
|
<code>key</code> (klen B) <code>mf</code> (1 B) then, in this order and only when flagged,
|
|
<code>secs</code> (varint, mode throttle), <code>expires</code> (varint, absolute unix),
|
|
<code>left</code> (varint, seconds to expiry by the two clocks of <code>filter flow</code>).
|
|
<code>mf</code>: bits 0-1 mode (0 block, 1 throttle, 2 dry), bit 2 <code>auto</code>, bit 3 has
|
|
<code>expires</code>, bit 4 has <code>left</code>.</p>
|
|
<h3 id="pages">Pages</h3>
|
|
<p><code>slot_id</code> is the index in the <strong>sorted</strong> rule table of <code>filter flow</code>
|
|
((kind, key) order) and <strong>moves on <code>add</code> / <code>del</code> / expiry</strong>.</p>
|
|
<ul>
|
|
<li><strong>Page 0</strong> is what is read every scrape: ids 1..21, fairness, ids 32..36, the
|
|
<strong>sensor record</strong> (id 42) and as many <code>(slot, dropped, passed)</code> as fit in the
|
|
150 B -- for every slot with a non-zero counter, in slot order -- and, <strong>when
|
|
they fit, the rule records (id 41)</strong> after them: a record is never split, and
|
|
what does not fit moves to page 1 and on. The rule table holds <strong>24 rules</strong>
|
|
(<code>FLOW_MAX</code>). A realistic node (2 rules, a few fairness drops, the full
|
|
status, 3 sensors) needs 129 B including the rule records; 16 slots with
|
|
counters do not fit, so the rest of the triples spills to page 1. The sensor
|
|
record comes before the counters and rules, so it takes page 0 ahead of
|
|
them; one too big for what is left of page 0 starts page 1 (whole), after
|
|
the CRC records.</li>
|
|
<li><strong>Pages 1..</strong> hold, in this order, a sensor record that did not fit page 0,
|
|
the <strong>spilled counter triples</strong> (id 40, the slots that did not fit on page 0,
|
|
still in slot order) and then the <strong>rule records</strong> (id 41) that did not fit
|
|
page 0, one record per slot in slot order. A record is never
|
|
split; a page is closed when the next record does not fit. Every page after
|
|
the first starts with the records <code>rules_auto</code> and <code>rules_static</code> (8 B).</li>
|
|
<li><code>n_counters</code> (id 36) tells how many slots have counters. When the triples on
|
|
page 0 are fewer than <code>n_counters</code>, the rest is on pages 1.. -- read them.</li>
|
|
</ul>
|
|
<h3 id="reader-rule-pairing">Reader rule (pairing)</h3>
|
|
<p><code>(slot_id, dropped, passed)</code> means nothing without the table that numbered the
|
|
slots. So:</p>
|
|
<ol>
|
|
<li>Fetch page 0. Compare <code>rules_auto</code> and <code>rules_static</code> with the values of the
|
|
previous scrape (the reader keeps its <code>slot_id -> rule</code> map and the CRCs it
|
|
was built from).</li>
|
|
<li><strong>If either CRC changed</strong> (or the reader has no map yet): fetch pages 1.. <strong>first</strong>,
|
|
build the new map from the rule records, and only then pair the page 0
|
|
triples with it. Spilled counter triples (id 40 on pages 1..) are read in the
|
|
same pass.</li>
|
|
<li>If <code>n_counters</code> is greater than the triples on page 0 but the CRCs did not
|
|
change, fetch the pages 1.. for the spilled counters as well.</li>
|
|
<li><strong>Every page 1.. opens with the two CRC records (ids 32, 33) of page 0.</strong> If
|
|
the pair on any later page differs from page 0, the table changed between the
|
|
requests (a concurrent <code>add</code>, an expiry): <strong>drop this scrape's counters</strong> and
|
|
try the next scrape. Never assign numbers to old keys.</li>
|
|
</ol>
|
|
<p>When the CRCs are unchanged and nothing spilled, the reader needs no page 1.. at
|
|
all: one request, one reply. The drift check against the signed inventory (#44) compares
|
|
<code>rules_static</code> and <code>prefs_crc</code> with the values computed from it; the agent
|
|
(#43) does the same for <code>rules_auto</code>.</p>
|
|
<h2 id="prefs_crc16"><code>prefs_crc16</code></h2>
|
|
<p>CRC-16/CCITT-FALSE (poly 0x1021, init 0xFFFF, no reflection, no final xor;
|
|
check value of "123456789" is 0x29B1) over the canonical serialization of the
|
|
prefs that Ansible manages. All integers big-endian.</p>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>#</th>
|
|
<th>bytes</th>
|
|
<th>field</th>
|
|
<th>encoding</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>1</td>
|
|
<td>1</td>
|
|
<td>serialization version</td>
|
|
<td><code>2</code> (since regions; <code>1</code> had none)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>2</td>
|
|
<td>4</td>
|
|
<td>radio frequency</td>
|
|
<td>MHz x 1000 rounded: <code>round(869.432 * 1000)</code> = 869432</td>
|
|
</tr>
|
|
<tr>
|
|
<td>3</td>
|
|
<td>4</td>
|
|
<td>bandwidth</td>
|
|
<td>kHz x 1000 rounded (62.5 -> 62500)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>4</td>
|
|
<td>1</td>
|
|
<td><code>sf</code></td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td>5</td>
|
|
<td>1</td>
|
|
<td><code>cr</code></td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td>6</td>
|
|
<td>1</td>
|
|
<td>TX power</td>
|
|
<td>dBm, two's complement</td>
|
|
</tr>
|
|
<tr>
|
|
<td>7</td>
|
|
<td>1 + n</td>
|
|
<td>node name</td>
|
|
<td>length (<= 31) + the UTF-8 bytes as stored</td>
|
|
</tr>
|
|
<tr>
|
|
<td>8</td>
|
|
<td>1</td>
|
|
<td>advert interval</td>
|
|
<td>the stored value (<code>advert_interval</code>, minutes / 2)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>9</td>
|
|
<td>1</td>
|
|
<td>flood advert interval</td>
|
|
<td>hours</td>
|
|
</tr>
|
|
<tr>
|
|
<td>10</td>
|
|
<td>1</td>
|
|
<td><code>flood.max</code></td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td>11</td>
|
|
<td>1</td>
|
|
<td><code>flood.max</code> unscoped</td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td>12</td>
|
|
<td>1</td>
|
|
<td><code>flood.max</code> advert</td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td>13</td>
|
|
<td>1</td>
|
|
<td>path hash mode</td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td>14</td>
|
|
<td>1</td>
|
|
<td><code>repeat</code></td>
|
|
<td>the stored <code>disable_fwd</code> (1 = repeating off)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>15</td>
|
|
<td>1</td>
|
|
<td><code>powersaving</code></td>
|
|
<td>0 / 1</td>
|
|
</tr>
|
|
<tr>
|
|
<td>16</td>
|
|
<td>1</td>
|
|
<td><code>radio.rxgain</code></td>
|
|
<td><code>rx_boosted_gain</code> 0 / 1</td>
|
|
</tr>
|
|
<tr>
|
|
<td>17</td>
|
|
<td>1</td>
|
|
<td><code>rxps</code> enabled</td>
|
|
<td>0 / 1 (all <code>rxps</code> bytes 0 in a build without <code>WITH_RX_POWERSAVING</code>)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>18</td>
|
|
<td>4</td>
|
|
<td><code>rxps</code> RX time</td>
|
|
<td>microseconds</td>
|
|
</tr>
|
|
<tr>
|
|
<td>19</td>
|
|
<td>4</td>
|
|
<td><code>rxps</code> sleep time</td>
|
|
<td>microseconds</td>
|
|
</tr>
|
|
<tr>
|
|
<td>20</td>
|
|
<td>1</td>
|
|
<td><code>rxps</code> level</td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td>21</td>
|
|
<td>1</td>
|
|
<td><code>rxps</code> preamble</td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td>22</td>
|
|
<td>1</td>
|
|
<td>bridge</td>
|
|
<td><code>bridge.enabled</code> 0 / 1</td>
|
|
</tr>
|
|
<tr>
|
|
<td>23</td>
|
|
<td>1 + n</td>
|
|
<td>home region</td>
|
|
<td>name, see "Regions" below (empty = none)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>24</td>
|
|
<td>1</td>
|
|
<td>region count</td>
|
|
<td><code>N</code>, number of regions (the root <code>*</code> is not counted)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>25..</td>
|
|
<td>N x (1 + n, 1 + m, 1)</td>
|
|
<td>regions</td>
|
|
<td><code>name</code>, <code>parent</code>, <code>flood</code>, sorted, see below</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<h3 id="regions-rows-23-25">Regions (rows 23-25)</h3>
|
|
<p>Appended after the bridge byte, so the CRC of a node and of the inventory can
|
|
be compared without any RF traffic. Everything is <strong>length-prefixed UTF-8</strong>
|
|
(1 length byte, then the bytes, like the node name):</p>
|
|
<div class="highlight"><pre><span></span><code>home_name N { name parent flood } x N
|
|
</code></pre></div>
|
|
<ul>
|
|
<li><strong>Name</strong> (<code>home</code>, <code>name</code>, <code>parent</code>): one leading <code>#</code> dropped (the CLI and
|
|
<code>meshcore_region</code> ignore it too), at most 31 bytes; the root <code>*</code>, an unset
|
|
value and "no parent" are all the <strong>empty</strong> string (length byte 0).</li>
|
|
<li><strong>home_name</strong>: the home region (<code>region home</code>); empty when there is none
|
|
(stored home id 0, which the CLI shows as <code>*</code>).</li>
|
|
<li><strong>N</strong>: one byte, the number of regions.</li>
|
|
<li><strong>Region</strong>: <code>name</code>, <code>parent</code> (the name of the parent; empty = child of the
|
|
root), <code>flood</code> (1 byte: 1 = flood allowed, 0 = denied, <code>region allowf</code> /
|
|
<code>region denyf</code>).</li>
|
|
<li><strong>Order</strong>: sorted by <strong>bytes</strong> of <code>name</code> (memcmp, a shorter prefix first), then
|
|
of <code>parent</code>. Insertion order, internal ids, and the order of <code>region</code> output
|
|
do not matter. A parent id that no region has (a corrupt map) is written as
|
|
the name <code>?</code>, which no real region can have, so it shows up as drift.</li>
|
|
</ul>
|
|
<p>Not in it: the root's own flood flag, the default flood scope
|
|
(<code>region default</code>; the module sets it only when <code>mc_default_scope</code> is given,
|
|
so the inventory does not always have a value), internal ids. The CRC reads the
|
|
<strong>live</strong> map, so a <code>region</code> change that was not yet saved (<code>region save</code>) is
|
|
already in it; after a reboot it is gone again.</p>
|
|
<p><strong>From the inventory alone</strong> (role <code>repeater-state</code>, module <code>meshcore_region</code>):</p>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>inventory</th>
|
|
<th>in the serialization</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td><code>mc_region_home</code> (default <code>"*"</code> when absent)</td>
|
|
<td><code>home_name</code>; <code>"*"</code> -> empty</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>mc_regions</code> list</td>
|
|
<td>one region per item; <code>N</code> = its length</td>
|
|
</tr>
|
|
<tr>
|
|
<td>item <code>name</code></td>
|
|
<td><code>name</code>, without <code>#</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>item <code>parent</code> (default <code>"*"</code>)</td>
|
|
<td><code>parent</code>; <code>"*"</code> -> empty</td>
|
|
</tr>
|
|
<tr>
|
|
<td>item <code>flood</code> (default <code>true</code>)</td>
|
|
<td><code>flood</code> 1 / 0</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Example, <code>mc_regions: [{name: cz}, {name: cz-ulk, parent: cz}, {name: cz-sudety,
|
|
parent: cz}, {name: cs}]</code> with <code>mc_region_home: cz-ulk</code> gives (hex)
|
|
<code>06 637a2d756c6b | 04 | 02 6373 00 01 | 02 637a 00 01 | 09 637a2d7375646574
|
|
79 02 637a 01 | 06 637a2d756c6b 02 637a 01</code> (spaces and bars only for reading);
|
|
the whole serialization has CRC <code>D5FD</code> (vector <code>cz_repeater</code>, and the same
|
|
map in another order, <code>cz_repeater_reordered</code>). <code>regions_canonical()</code> in the
|
|
Python reference is the whole recipe: lift it as it is.</p>
|
|
<p>Reference: <code>prefs_canonical()</code> in <code>test/vectors/gen_stats_bundle_vectors.py</code>;
|
|
test vectors (canonical bytes and CRC for three nodes, one with a denied-flood region) in
|
|
<code>test/vectors/stats_bundle_vectors.json</code>.</p>
|
|
<p><strong>Not in it:</strong> the <code>filter flow</code> rules (they have <code>rules_auto</code> /
|
|
<code>rules_static</code>), <code>filter</code> age and dry-run, FairnessLimiter caps, passwords,
|
|
guest and ACL entries, the adaptive battery thresholds (<code>pwr.*</code>, their own files) and GPS settings.
|
|
Adding a field means a new serialization version byte (and a new vector).</p>
|
|
<h2 id="version-and-compatibility">Version and compatibility</h2>
|
|
<p>The sensor record is a <strong>new id</strong> (42), not a new meaning of an old one, so the
|
|
version byte stays <code>1</code>: a reader that does not know id 42 skips it by its length
|
|
(<code>wt 1</code>), as the format requires of every reader. A reader that knows it and
|
|
talks to a node without it (a release from before this record) finds no id 42 --
|
|
the same as a node with no sensors; telling the two apart takes the firmware
|
|
version, not the bundle.</p>
|
|
<h2 id="sizes">Sizes</h2>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>case</th>
|
|
<th>page 0</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>guest (status + telemetry)</td>
|
|
<td>60 B</td>
|
|
</tr>
|
|
<tr>
|
|
<td>admin, empty table, short status</td>
|
|
<td>18 B</td>
|
|
</tr>
|
|
<tr>
|
|
<td>admin, 2 rules, a few fairness drops, full status</td>
|
|
<td>116 B (one page)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>the same + 3 sensors (temperature, humidity, pressure: 11 B LPP + 2 B header)</td>
|
|
<td>129 B (one page)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>admin, empty table, full status, 3 sensors</td>
|
|
<td>93 B</td>
|
|
</tr>
|
|
<tr>
|
|
<td>read-only, full status, 3 sensors</td>
|
|
<td>73 B</td>
|
|
</tr>
|
|
<tr>
|
|
<td>admin, 2 rules, a 124 B sensor record</td>
|
|
<td>82 B + 145 B + 35 B (3 pages; the sensors on page 1)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>admin, 16 rules with counters</td>
|
|
<td>149 B + 145 B + 150 B + 70 B (4 pages)</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>The boundary cases (149 / 150 B fit, 151 B moves the last record to page 1)
|
|
are in the vectors.</p>
|
|
</section>
|
|
|
|
</main>
|
|
</div>
|
|
<hr><footer>
|
|
<div class="terminal-mkdocs-footer-grid">
|
|
<div id="terminal-mkdocs-footer-copyright-info">
|
|
|
|
<p class="text-center text-muted">Source: <a href="https://git.rfa.cz/tth-pub/meshcore-tth">git.rfa.cz/tth-pub/meshcore-tth</a> ·</p>
|
|
Site built with <a href="http://www.mkdocs.org">MkDocs</a> and <a href="https://github.com/ntno/mkdocs-terminal">Terminal for MkDocs</a>.
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
</div>
|
|
|
|
|
|
<div class="modal" id="mkdocs_search_modal" tabindex="-1" role="alertdialog" aria-modal="true" aria-labelledby="searchModalLabel">
|
|
<div class="modal-dialog modal-lg" role="search">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="searchModalLabel">Search</h5>
|
|
<button type="button" class="close btn btn-default btn-ghost" data-dismiss="modal" aria-label="Close">x</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<p id="searchInputLabel">Type to start searching</p>
|
|
<form>
|
|
<div class="form-group">
|
|
<input type="search" class="form-control" aria-labelledby="searchInputLabel" placeholder="" id="mkdocs-search-query" title="Please enter search terms here">
|
|
</div>
|
|
</form>
|
|
<div id="mkdocs-search-results" data-no-results-text="No document matches found"></div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</body>
|
|
|
|
</html> |