SDK for TESAIoT Dev Kit
API reference & tutorials (ModusToolbox)
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
19extern "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. */
24void 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. */
30void 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. */
36void 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. */
44struct radio_status_s;
46
47#ifdef __cplusplus
48}
49#endif
50
51#endif /* NUS_COMMANDS_H */
struct jsmntok jsmntok_t
Definition bento_fw.h:37
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)
Emit a command ack (verb hard-truncated at 32 chars); void — a send failure is invisible.
void nus_commands_dispatch(const char *json, size_t json_len, const jsmntok_t *toks, int n_toks, const jsmntok_t *t_cmd)
Route a top-level "cmd" frame to its handler; internal to the RX path.
void nus_commands_handle_time_sync(const char *json, const jsmntok_t *toks, int n)
Handle the one-shot {"time":[epoch,tz]} frame; no ack is emitted.
void nus_radio_emit_state_event(const struct radio_status_s *st)
The shipped on_state hook — only ever used as a function pointer, never called directly.
Definition radio_scheduler.h:57