SDK for TESAIoT Dev Kit
API reference & tutorials (ModusToolbox)
Toggle main menu visibility
Loading...
Searching...
No Matches
bento_fw.h
Go to the documentation of this file.
1
/*******************************************************************************
2
* File Name: bento_fw.h
3
*
4
* Description: Bento Desktop Buddy firmware-auto-update handlers (SPEC §5.6).
5
* Owns the state machine for:
6
*
7
* bento.fw.query — cheap read-only metadata probe
8
* bento.fw.update.begin — Y/N physical-ack + pre-flash prep
9
* bento.fw.update.complete — outbound event emitted on boot
10
*
11
* Physical-ack (ISSUE-027): every USB-over-SWD flash triggered
12
* from the desktop side MUST pass through an on-device LCD Y/N
13
* prompt showing the first 8 hex chars of the target SHA-256.
14
* No side-channel flash bypass, no timeout-default-to-yes.
15
*
16
* Re-pair model (ISSUE-028): bonds are RAM-only, so every reboot
17
* forces the desktop to re-pair. This module emits
18
* bento.fw.update.complete unconditionally on each first
19
* post-boot NUS connection — the desktop compares to its cached
20
* hash and decides whether to treat the event as "update just
21
* landed" or "just a reboot".
22
*
23
* Reference: TESAIoT_PLAN/2026-4/Bento_Buddy/SPEC.md §5.6 +
24
* §4.8.5 physical-ack +
25
* ISSUES.md ISSUE-022/-027/-028.
26
*
27
******************************************************************************/
28
29
#ifndef BENTO_FW_H
30
#define BENTO_FW_H
31
32
#include <stddef.h>
33
#include <stdint.h>
34
35
/* jsmn tokens — forward decl so this header stays light. */
36
struct
jsmntok;
37
typedef
struct
jsmntok
jsmntok_t
;
38
39
#ifdef __cplusplus
40
extern
"C"
{
41
#endif
42
43
/* Compile-time firmware version. Bumped via git tag on release.
44
* 1.0.9 = May 2026 — landed Phase 3 close-out:
45
* * F2.5 — fw_hash now hashes a build-deterministic identity
46
* string (BENTO_BUDDY_FW_VERSION|__DATE__|__TIME__) so
47
* the digest is stable across power-cycles of the same
48
* binary. The previous VTOR-based 128 KB scan hashed
49
* SRAM and produced a different digest every boot.
50
* * F1+F2.5 diagnostic — bento.fw.query response now carries a
51
* `_diag` block with hash + ble counters + uptime_ms
52
* so support can root-cause connectivity reports in a
53
* single round-trip without serial console access.
54
* * FW_TX_BUF 256 → 1024 to fit the new _diag payload.
55
*/
56
/* A project that declares BENTO_FW_VERSION in its Makefile wins. The constant
57
* below is the fallback for builds that declare nothing - and until 2026-09-02
58
* that was every project in the workspace, so an HMI Kit running 0.2.0 told the
59
* desktop it was 1.4.0 over both bento.info.board and bento.fw.query. Prefer
60
* the project's own number wherever one is supplied. */
61
#ifdef BENTO_FW_VERSION
62
#undef BENTO_BUDDY_FW_VERSION
63
#define BENTO_BUDDY_FW_VERSION BENTO_FW_VERSION
64
#endif
65
#ifndef BENTO_BUDDY_FW_VERSION
66
#define BENTO_BUDDY_FW_VERSION "1.4.0"
67
#endif
68
69
/* Handler for bento.fw.query. Emits the JSON ack on the NUS link. */
70
void
bento_fw_handle_query
(
const
char
*json,
71
const
jsmntok_t
*toks,
int
n_toks);
72
73
/* Handler for bento.fw.update.begin. Launches the LCD Y/N prompt and emits
74
* the final ack (approve → ok:true + sensor streams stopped; decline → error;
75
* timeout → error). Rate-limits duplicate prompts within 5 seconds. */
76
void
bento_fw_handle_update_begin
(
const
char
*json,
77
const
jsmntok_t
*toks,
int
n_toks);
78
79
/* Called from the BLE state-change hook the moment the link transitions to
80
* CONNECTED. Emits bento.fw.update.complete ONCE per boot so the desktop can
81
* reconcile whatever hash it cached against what's actually running.
82
* Idempotent — subsequent calls within the same boot are no-ops. */
83
void
bento_fw_emit_boot_complete
(
void
);
84
85
/* Called from ipc_bento_buddy_bridge.c when the CM55 LCD returns a Y/N
86
* decision for the current firmware-update prompt. `approve` is non-zero for
87
* Y (proceed with flash), zero for N (decline). No-op when there is no
88
* pending prompt. */
89
void
bento_fw_on_user_decision
(
int
approve);
90
91
#ifdef __cplusplus
92
}
93
#endif
94
95
#endif
/* BENTO_FW_H */
jsmntok_t
struct jsmntok jsmntok_t
Definition
bento_fw.h:37
bento_fw_on_user_decision
void bento_fw_on_user_decision(int approve)
Deliver the CM55 LCD Y/N decision for the current prompt; no-op when none is pending.
bento_fw_emit_boot_complete
void bento_fw_emit_boot_complete(void)
Emit bento.fw.update.complete once per boot on the first CONNECTED transition.
bento_fw_handle_update_begin
void bento_fw_handle_update_begin(const char *json, const jsmntok_t *toks, int n_toks)
Handler for bento.fw.update.begin: launches the LCD Y/N prompt; ack deferred to the decision.
bento_fw_handle_query
void bento_fw_handle_query(const char *json, const jsmntok_t *toks, int n_toks)
Handler for bento.fw.query: cheap read-only metadata probe. Dispatcher-only.
dist
ble_nus
include
bento_fw.h
Generated by
1.18.0