SDK สำหรับ TESAIoT Dev Kit
คู่มืออ้างอิง API และ Tutorial (MTB & µPython)
Toggle main menu visibility
Loading...
Searching...
No Matches
nus_commands.h
Go to the documentation of this file.
1
/*******************************************************************************
2
* File Name: nus_commands.h
3
*
4
* Description: Command dispatcher + ack/status emitter for NUS wire protocol.
5
* Separated from nus_protocol.c so the framer/parser stays
6
* transport-only and command-set changes are localized here.
7
*
8
******************************************************************************/
9
10
#ifndef NUS_COMMANDS_H
11
#define NUS_COMMANDS_H
12
13
#include <stddef.h>
14
#include <stdint.h>
15
16
#include "vendor/jsmn.h"
17
18
#ifdef __cplusplus
19
extern
"C"
{
20
#endif
21
22
/* Called by nus_protocol when the outer object contains a top-level "cmd"
23
* string. Dispatches to the right handler and emits the ack frame. */
24
void
nus_commands_dispatch
(
const
char
*json,
size_t
json_len,
25
const
jsmntok_t
*toks,
int
n_toks,
26
const
jsmntok_t
*t_cmd);
27
28
/* Emit a generic ack frame. Passing n = 0 or error = NULL skips those
29
* fields. ack_cmd must be non-NULL; len specifies bytes to copy. */
30
void
nus_commands_emit_ack
(
const
char
*ack_cmd,
size_t
ack_cmd_len,
31
const
char
*ok_true_or_null,
32
const
char
*error_or_null,
33
int
n);
34
35
/* Handle the time-sync one-shot frame {"time":[epoch,tz]}. No ack emitted. */
36
void
nus_commands_handle_time_sync
(
const
char
*json,
const
jsmntok_t
*toks,
int
n);
37
38
/* Push a bento.radio.state event to the desktop. Registered with the
39
* radio scheduler from main.c so every BLE↔WiFi transition surfaces in
40
* the Desktop Buddy UI without a round-trip poll. Signature matches
41
* radio_scheduler.h::radio_scheduler_on_state_fn_t — we forward-declare
42
* the struct here to avoid pulling radio_scheduler.h into every TU that
43
* includes nus_commands.h. */
44
struct
radio_status_s
;
45
void
nus_radio_emit_state_event
(
const
struct
radio_status_s
*st);
46
47
#ifdef __cplusplus
48
}
49
#endif
50
51
#endif
/* NUS_COMMANDS_H */
jsmntok_t
struct jsmntok jsmntok_t
Definition
bento_fw.h:37
nus_commands_emit_ack
void nus_commands_emit_ack(const char *ack_cmd, size_t ack_cmd_len, const char *ok_true_or_null, const char *error_or_null, int n)
ส่ง ack ของคำสั่ง (ชื่อ verb ถูกตัดตายตัวที่ 32 อักขระ) คืนค่า void — ความล้มเหลวในการส่งจึงมองไม่เห็...
nus_commands_dispatch
void nus_commands_dispatch(const char *json, size_t json_len, const jsmntok_t *toks, int n_toks, const jsmntok_t *t_cmd)
ส่งเฟรมที่มี "cmd" ระดับบนสุดต่อไปยัง handler ของมัน เป็นเรื่องภายในของเส้นทาง RX
nus_commands_handle_time_sync
void nus_commands_handle_time_sync(const char *json, const jsmntok_t *toks, int n)
จัดการเฟรม {"time":[epoch,tz]} แบบครั้งเดียว ไม่มีการส่ง ack ออกไป
nus_radio_emit_state_event
void nus_radio_emit_state_event(const struct radio_status_s *st)
hook on_state ที่ส่งมอบจริง — ใช้เป็นพอยน์เตอร์ฟังก์ชันเท่านั้น ห้ามเรียกโดยตรง
radio_status_s
Definition
radio_scheduler.h:57
dist
ble_nus
include
nus_commands.h
Generated by
1.18.0