SDK for TESAIoT Dev Kit
API reference & tutorials (ModusToolbox)
Loading...
Searching...
No Matches
sensor_stream.h
Go to the documentation of this file.
1/*******************************************************************************
2 * File Name: sensor_stream.h
3 *
4 * Description: Periodic sensor sampler for the Bento Desktop Buddy bridge.
5 * Emits `bento.sensor.data` NUS events at a caller-specified
6 * interval. v1 supports a single active stream at a time; the
7 * ring-of-active-streams described in SPEC §5.3.2 is deferred
8 * until multi-sensor dashboards are needed.
9 *
10 * Reference: TESAIoT_PLAN/2026-4/Bento_Buddy/SPEC.md §5.3.2–§5.3.3.
11 *
12 ******************************************************************************/
13
14#ifndef SENSOR_STREAM_H
15#define SENSOR_STREAM_H
16
17#include <stdbool.h>
18#include <stddef.h>
19#include <stdint.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/* One-time FreeRTOS task spawn. Safe to call multiple times — subsequent
26 * calls are no-ops. Invoked lazily the first time a stream is started. */
28
29/* Start streaming sensor id at the given interval (clamped to [10, 5000] ms).
30 * Replaces any in-progress stream (v1 single-stream). Returns 0 on success,
31 * -1 if id is not recognised. */
32int sensor_stream_start(const char *id, uint32_t interval_ms);
33
34/* Stop the active stream. Idempotent. */
35void sensor_stream_stop(const char *id);
36
37/* Number of samples dropped because the NUS TX queue refused to accept
38 * them (link disconnected or buffer full). Exposed for bento.info.board. */
40
41/* True iff a stream is currently active. Used by the firmware-update handler
42 * to return {"ok":false,"error":"busy"} when a flash attempt races a running
43 * stream. */
45
46/* Stop any active stream unconditionally. Idempotent. Called by the firmware-
47 * update flow on Y-approve so the flasher operates on a quiescent device. */
49
50#ifdef __cplusplus
51}
52#endif
53
54#endif /* SENSOR_STREAM_H */
void sensor_stream_stop_all(void)
Stop any active stream unconditionally — the quiesce-before-update path.
bool sensor_stream_is_active(void)
True iff a stream is active; the update handler's "busy" guard.
void sensor_stream_stop(const char *id)
Stop the active stream; idempotent.
int sensor_stream_start(const char *id, uint32_t interval_ms)
Start streaming one sensor; the shipped caller clamps the interval to [10, 5000] ms.
uint32_t sensor_stream_dropped_count(void)
Samples the NUS TX path refused (link down or buffer full); board-info diagnostics.
int sensor_stream_init(void)
One-time task spawn, invoked lazily by sensor_stream_start() — never call directly.