SDK สำหรับ TESAIoT Dev Kit
คู่มืออ้างอิง API และ Tutorial (MTB & µPython)
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
#ifndef BENTO_BUDDY_FW_VERSION
57
#define BENTO_BUDDY_FW_VERSION "1.4.0"
58
#endif
59
60
/* Handler for bento.fw.query. Emits the JSON ack on the NUS link. */
61
void
bento_fw_handle_query
(
const
char
*json,
62
const
jsmntok_t
*toks,
int
n_toks);
63
64
/* Handler for bento.fw.update.begin. Launches the LCD Y/N prompt and emits
65
* the final ack (approve → ok:true + sensor streams stopped; decline → error;
66
* timeout → error). Rate-limits duplicate prompts within 5 seconds. */
67
void
bento_fw_handle_update_begin
(
const
char
*json,
68
const
jsmntok_t
*toks,
int
n_toks);
69
70
/* Called from the BLE state-change hook the moment the link transitions to
71
* CONNECTED. Emits bento.fw.update.complete ONCE per boot so the desktop can
72
* reconcile whatever hash it cached against what's actually running.
73
* Idempotent — subsequent calls within the same boot are no-ops. */
74
void
bento_fw_emit_boot_complete
(
void
);
75
76
/* Called from ipc_bento_buddy_bridge.c when the CM55 LCD returns a Y/N
77
* decision for the current firmware-update prompt. `approve` is non-zero for
78
* Y (proceed with flash), zero for N (decline). No-op when there is no
79
* pending prompt. */
80
void
bento_fw_on_user_decision
(
int
approve);
81
82
#ifdef __cplusplus
83
}
84
#endif
85
86
#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)
ส่งผลการตัดสินใจ Y/N จากจอ LCD ของ CM55 สำหรับคำถามยืนยันปัจจุบัน เป็น no-op เมื่อไม่มีคำถามค้างอยู่
bento_fw_emit_boot_complete
void bento_fw_emit_boot_complete(void)
ส่ง bento.fw.update.complete หนึ่งครั้งต่อการบูตหนึ่งรอบ ตอนเปลี่ยนสถานะเป็น CONNECTED ครั้งแรก
bento_fw_handle_update_begin
void bento_fw_handle_update_begin(const char *json, const jsmntok_t *toks, int n_toks)
handler ของ bento.fw.update.begin: เปิดคำถามยืนยัน Y/N บนจอ LCD และเลื่อน ack ไปจนกว่าจะมีการตัดสินใจ
bento_fw_handle_query
void bento_fw_handle_query(const char *json, const jsmntok_t *toks, int n_toks)
handler ของ bento.fw.query: เป็น probe อ่านอย่างเดียวที่ต้นทุนต่ำสำหรับ metadata เรียกจาก dispatcher ...
dist
ble_nus
include
bento_fw.h
Generated by
1.18.0