SDK สำหรับ TESAIoT Dev Kit
คู่มืออ้างอิง API และ Tutorial (ModusToolbox)
Toggle main menu visibility
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
22
extern
"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. */
27
int
sensor_stream_init
(
void
);
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. */
32
int
sensor_stream_start
(
const
char
*
id
, uint32_t interval_ms);
33
34
/* Stop the active stream. Idempotent. */
35
void
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. */
39
uint32_t
sensor_stream_dropped_count
(
void
);
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. */
44
bool
sensor_stream_is_active
(
void
);
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. */
48
void
sensor_stream_stop_all
(
void
);
49
50
#ifdef __cplusplus
51
}
52
#endif
53
54
#endif
/* SENSOR_STREAM_H */
sensor_stream_stop_all
void sensor_stream_stop_all(void)
หยุด stream ที่ทำงานอยู่ทั้งหมดโดยไม่มีเงื่อนไข — เป็นเส้นทางพักเครื่องให้นิ่งก่อนอัปเดต
sensor_stream_is_active
bool sensor_stream_is_active(void)
คืน true ก็ต่อเมื่อมี stream ทำงานอยู่ เป็นตัวกัน "busy" ของ handler การอัปเดต
sensor_stream_stop
void sensor_stream_stop(const char *id)
หยุด stream ที่ทำงานอยู่ เป็น idempotent
sensor_stream_start
int sensor_stream_start(const char *id, uint32_t interval_ms)
เริ่มสตรีมเซนเซอร์หนึ่งตัว ผู้เรียกที่มีอยู่จริงในของที่ส่งมอบบีบค่า interval ให้อยู่ในช่วง [10,...
sensor_stream_dropped_count
uint32_t sensor_stream_dropped_count(void)
จำนวนตัวอย่างที่เส้นทาง NUS TX ปฏิเสธไว้ (link หลุดหรือบัฟเฟอร์เต็ม) ใช้ในข้อมูลวินิจฉัยของบอร์ด
sensor_stream_init
int sensor_stream_init(void)
สร้าง task ครั้งเดียว ถูกเรียกแบบ lazy โดย sensor_stream_start() — ห้ามเรียกโดยตรง
dist
ble_nus
include
sensor_stream.h
Generated by
1.18.0