ESPectre SDK
2.8.0-280-gac7af68
Wi-Fi CSI motion sensing for ESP32 firmware
Toggle main menu visibility
Loading...
Searching...
No Matches
runtime_diagnostics.h
Go to the documentation of this file.
1
/*
2
* ESPectre - Runtime Diagnostics
3
*
4
* Runtime diagnostics snapshot helpers.
5
*
6
* Author: Francesco Pace <francesco.pace@gmail.com>
7
* SPDX-License-Identifier: GPL-3.0-only
8
* Commercial licensing available under separate agreement; see LICENSING.md.
9
*/
10
#pragma once
11
12
#include <cstdint>
13
#include <functional>
14
15
#include "
runtime_interface.h
"
16
#include "
runtime_snapshot.h
"
17
18
namespace
espectre
{
19
20
/**
21
* Rate and link diagnostics derived from cumulative runtime counters.
22
*
23
* Produced by `RuntimeDiagnosticsSampler`, never by the runtime directly: the
24
* runtime only exposes monotonic totals, and the rates here are what those
25
* totals moved by between two periodic sensing updates.
26
*
27
* A zero rate means the counter did not move over the interval, and the first
28
* sample after `RuntimeDiagnosticsSampler::reset()` reports zero rates because
29
* it establishes the baseline. The link fields are carried through either way.
30
*/
31
struct
RuntimeDiagnosticsSample
{
32
/** Traffic packets per second sent or observed by the active traffic source. */
33
float
traffic_tx_pps
{0.0f};
34
/** Raw CSI callbacks per second, before any capture-level validation. */
35
float
csi_callback_pps
{0.0f};
36
/** CSI packets per second accepted by capture validation. */
37
float
csi_accepted_pps
{0.0f};
38
/** CSI packets per second admitted to the detector's temporal grid. */
39
float
csi_admitted_pps
{0.0f};
40
/** CSI packets per second rejected by capture-level validation. */
41
float
csi_filtered_pps
{0.0f};
42
/** Missing detector slots per second. */
43
float
csi_missing_slots_pps
{0.0f};
44
/** Same-slot excess drops per second. */
45
float
csi_excess_pps
{0.0f};
46
/** Stale temporal drops per second. */
47
float
csi_stale_pps
{0.0f};
48
/** Out-of-order temporal drops per second. */
49
float
csi_out_of_order_pps
{0.0f};
50
/** Valid-slot occupancy of the active temporal detector window. */
51
float
csi_occupancy_ratio
{0.0f};
52
/** RSSI of the current association. `INT8_MIN` when unavailable. */
53
int8_t
wifi_rssi_dbm
{INT8_MIN};
54
/** Primary channel of the current association. Zero when unavailable. */
55
uint8_t
wifi_channel
{0U};
56
};
57
58
/**
59
* Converts cumulative diagnostics into rates over the interval between reads.
60
*
61
* Call `reset()` when the owning frontend starts. Counter resets are treated
62
* as a new epoch, so rearming a traffic source cannot underflow a rate.
63
*
64
* @code
65
* // once, at frontend startup:
66
* sampler.reset(controller.diagnostics(), now_ms);
67
* // whenever the owning frontend already produces a sensing update:
68
* latest = sampler.sample(controller.diagnostics(), now_ms);
69
* @endcode
70
*
71
* @par Threading
72
* Not synchronized, and it holds the previous read. Sample it from the task
73
* that owns the runtime.
74
*/
75
class
RuntimeDiagnosticsSampler
{
76
public
:
77
/**
78
* Establish the baseline the next `sample()` measures against.
79
*
80
* @param snapshot Current cumulative counters.
81
* @param now_ms Monotonic frontend clock, in milliseconds.
82
*/
83
void
reset
(
const
RuntimeDiagnosticsSnapshot
&snapshot, uint32_t now_ms);
84
/**
85
* Derive rates since the previous read and adopt this one as the baseline.
86
*
87
* The caller owns the window. Shipped frontends invoke this from their
88
* existing periodic sensing update, so diagnostics do not add a timer.
89
*
90
* @param snapshot Current cumulative counters.
91
* @param now_ms Monotonic frontend clock, in milliseconds.
92
* @return Rates over the elapsed interval. The link fields are always
93
* carried through; the rates are zero when there is no baseline yet
94
* or no time has elapsed.
95
*/
96
RuntimeDiagnosticsSample
sample
(
const
RuntimeDiagnosticsSnapshot
&snapshot, uint32_t now_ms);
97
98
private
:
99
RuntimeDiagnosticsSnapshot
previous_{};
100
uint32_t previous_ms_{0U};
101
bool
baseline_ready_{
false
};
102
};
103
104
using
runtime_diagnostic_visitor_t
= std::function<void(
const
char
*key,
const
char
*value)>;
105
106
void
visit_runtime_diagnostics
(
const
RuntimeConfig
&config,
107
const
RuntimeSnapshot
&snapshot,
108
runtime_diagnostic_visitor_t
visitor);
109
110
}
// namespace espectre
espectre::RuntimeDiagnosticsSampler
Converts cumulative diagnostics into rates over the interval between reads.
Definition
runtime_diagnostics.h:75
espectre::RuntimeDiagnosticsSampler::reset
void reset(const RuntimeDiagnosticsSnapshot &snapshot, uint32_t now_ms)
Establish the baseline the next sample() measures against.
espectre::RuntimeDiagnosticsSampler::sample
RuntimeDiagnosticsSample sample(const RuntimeDiagnosticsSnapshot &snapshot, uint32_t now_ms)
Derive rates since the previous read and adopt this one as the baseline.
espectre
Definition
espectre_sdk_version.h:62
espectre::visit_runtime_diagnostics
void visit_runtime_diagnostics(const RuntimeConfig &config, const RuntimeSnapshot &snapshot, runtime_diagnostic_visitor_t visitor)
espectre::runtime_diagnostic_visitor_t
std::function< void(const char *key, const char *value)> runtime_diagnostic_visitor_t
Definition
runtime_diagnostics.h:104
runtime_interface.h
Runtime configuration and the backend contract behind it.
runtime_snapshot.h
espectre::RuntimeConfig
Everything the runtime needs to know before setup().
Definition
runtime_interface.h:59
espectre::RuntimeDiagnosticsSample
Rate and link diagnostics derived from cumulative runtime counters.
Definition
runtime_diagnostics.h:31
espectre::RuntimeDiagnosticsSample::wifi_channel
uint8_t wifi_channel
Primary channel of the current association.
Definition
runtime_diagnostics.h:55
espectre::RuntimeDiagnosticsSample::csi_accepted_pps
float csi_accepted_pps
CSI packets per second accepted by capture validation.
Definition
runtime_diagnostics.h:37
espectre::RuntimeDiagnosticsSample::csi_stale_pps
float csi_stale_pps
Stale temporal drops per second.
Definition
runtime_diagnostics.h:47
espectre::RuntimeDiagnosticsSample::csi_missing_slots_pps
float csi_missing_slots_pps
Missing detector slots per second.
Definition
runtime_diagnostics.h:43
espectre::RuntimeDiagnosticsSample::traffic_tx_pps
float traffic_tx_pps
Traffic packets per second sent or observed by the active traffic source.
Definition
runtime_diagnostics.h:33
espectre::RuntimeDiagnosticsSample::csi_out_of_order_pps
float csi_out_of_order_pps
Out-of-order temporal drops per second.
Definition
runtime_diagnostics.h:49
espectre::RuntimeDiagnosticsSample::csi_callback_pps
float csi_callback_pps
Raw CSI callbacks per second, before any capture-level validation.
Definition
runtime_diagnostics.h:35
espectre::RuntimeDiagnosticsSample::csi_admitted_pps
float csi_admitted_pps
CSI packets per second admitted to the detector's temporal grid.
Definition
runtime_diagnostics.h:39
espectre::RuntimeDiagnosticsSample::csi_filtered_pps
float csi_filtered_pps
CSI packets per second rejected by capture-level validation.
Definition
runtime_diagnostics.h:41
espectre::RuntimeDiagnosticsSample::csi_occupancy_ratio
float csi_occupancy_ratio
Valid-slot occupancy of the active temporal detector window.
Definition
runtime_diagnostics.h:51
espectre::RuntimeDiagnosticsSample::csi_excess_pps
float csi_excess_pps
Same-slot excess drops per second.
Definition
runtime_diagnostics.h:45
espectre::RuntimeDiagnosticsSample::wifi_rssi_dbm
int8_t wifi_rssi_dbm
RSSI of the current association.
Definition
runtime_diagnostics.h:53
espectre::RuntimeDiagnosticsSnapshot
Low-frequency counters and radio state used by optional diagnostic surfaces.
Definition
runtime_snapshot.h:36
espectre::RuntimeSnapshot
A consistent view of the sensing state at one instant.
Definition
runtime_snapshot.h:76
src
cpp
runtime
runtime_diagnostics.h
Generated by
1.17.0