SDK สำหรับ TESAIoT Dev Kit
คู่มืออ้างอิง API และ Tutorial (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.
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: 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: 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
******************************************************************************/
24
25
#ifndef BENTO_FW_H
26
#define BENTO_FW_H
27
28
#include <stddef.h>
29
#include <stdint.h>
30
31
/* jsmn tokens — forward decl so this header stays light. */
32
struct
jsmntok;
33
typedef
struct
jsmntok
jsmntok_t
;
34
35
#ifdef __cplusplus
36
extern
"C"
{
37
#endif
38
39
/* Firmware version string reported to the desktop in the bento.fw.query
40
* reply and the boot-complete event. That reply also carries a `_diag`
41
* block (firmware hash, BLE counters, uptime) so a connectivity report can
42
* be diagnosed in one round trip. */
43
/* A build that defines BENTO_FW_VERSION (for example with
44
* DEFINES+=BENTO_FW_VERSION=\"x.y.z\" in its makefile) gets that number here;
45
* the constant below applies only when the build supplies none. This changes
46
* only code compiled against this header: the prebuilt libbento_secure.a was
47
* built with its own value and is not affected. */
48
#ifdef BENTO_FW_VERSION
49
#undef BENTO_BUDDY_FW_VERSION
50
#define BENTO_BUDDY_FW_VERSION BENTO_FW_VERSION
51
#endif
52
#ifndef BENTO_BUDDY_FW_VERSION
53
#define BENTO_BUDDY_FW_VERSION "1.4.0"
54
#endif
55
56
/* Handler for bento.fw.query. Emits the JSON ack on the NUS link. */
57
void
bento_fw_handle_query
(
const
char
*json,
const
jsmntok_t
*toks,
int
n_toks);
58
59
/* Handler for bento.fw.update.begin. Launches the LCD Y/N prompt and emits
60
* the final ack (approve → ok:true + sensor streams stopped; decline → error;
61
* timeout → error). Rate-limits duplicate prompts within 5 seconds. */
62
void
bento_fw_handle_update_begin
(
const
char
*json,
const
jsmntok_t
*toks,
int
n_toks);
63
64
/* Called from the BLE state-change hook the moment the link transitions to
65
* CONNECTED. Emits bento.fw.update.complete ONCE per boot so the desktop can
66
* reconcile whatever hash it cached against what's actually running.
67
* Idempotent — subsequent calls within the same boot are no-ops. */
68
void
bento_fw_emit_boot_complete
(
void
);
69
70
/* Called by the CM55 bridge inside libbento_secure.a when the CM55 LCD
71
* returns a Y/N decision for the current firmware-update prompt. `approve` is non-zero for
72
* Y (proceed with flash), zero for N (decline). No-op when there is no
73
* pending prompt. */
74
void
bento_fw_on_user_decision
(
int
approve);
75
76
#ifdef __cplusplus
77
}
78
#endif
79
80
#endif
/* BENTO_FW_H */
jsmntok_t
struct jsmntok jsmntok_t
Definition
bento_fw.h:33
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