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 design is deferred
8 * until multi-sensor dashboards are needed.
9 *
10 ******************************************************************************/
11
12#ifndef SENSOR_STREAM_H
13#define SENSOR_STREAM_H
14
15#include <stdbool.h>
16#include <stddef.h>
17#include <stdint.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23/* One-time FreeRTOS task spawn. Safe to call multiple times — subsequent
24 * calls are no-ops. Invoked lazily the first time a stream is started. */
26
27/* Start streaming sensor id at the given interval (clamped to [10, 5000] ms).
28 * Replaces any in-progress stream (v1 single-stream). Returns 0 on success,
29 * -1 if id is not recognised. */
30int sensor_stream_start(const char *id, uint32_t interval_ms);
31
32/* Stop the active stream. Idempotent. */
33void sensor_stream_stop(const char *id);
34
35/* Number of samples dropped because the NUS TX queue refused to accept
36 * them (link disconnected or buffer full). Exposed for bento.info.board. */
38
39/* True iff a stream is currently active. Used by the firmware-update handler
40 * to return {"ok":false,"error":"busy"} when a flash attempt races a running
41 * stream. */
43
44/* Stop any active stream unconditionally. Idempotent. Called by the firmware-
45 * update flow on Y-approve so the flasher operates on a quiescent device. */
47
48#ifdef __cplusplus
49}
50#endif
51
52#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.