SDK สำหรับ TESAIoT Dev Kit
คู่มืออ้างอิง API และ Tutorial (MTB & µPython)
Loading...
Searching...
No Matches
lfs_wifi_creds.h
Go to the documentation of this file.
1/*******************************************************************************
2 * File: lfs_wifi_creds.h
3 *
4 * Description:
5 * LittleFS-based persistent storage for WiFi credentials.
6 * Primary credential store — survives firmware reflash.
7 *
8 * Stores up to 6 WiFi network entries in /.wifi_creds file on the
9 * MicroPython LittleFS2 filesystem (55MB QSPI partition at 0x900000).
10 *
11 * Uses the same binary format and entry type as qspi_wifi_creds.h
12 * for seamless migration from raw QSPI sector storage.
13 *
14 * Uses MicroPython's exec_python_str() for file I/O instead of
15 * direct LFS2 C API (avoids blockdev callback + LFS2_NO_MALLOC issues).
16 * MUST be called from MicroPython task context only.
17 *
18 ******************************************************************************/
19
20#ifndef LFS_WIFI_CREDS_H
21#define LFS_WIFI_CREDS_H
22
23#include "wifi_creds_types.h" /* qspi_wifi_entry_t type + constants */
24
30
36
41
52int lfs_wifi_creds_read(qspi_wifi_entry_t *entries, int max_entries);
53
63bool lfs_wifi_creds_write(const qspi_wifi_entry_t *entries, int count);
64
70
71#endif /* LFS_WIFI_CREDS_H */
bool lfs_wifi_creds_write(const qspi_wifi_entry_t *entries, int count)
เขียนทับ /.wifi_creds ด้วย CRC32; ทำ snapshot ภายใต้ lock แล้วเขียนนอก lock
int lfs_wifi_creds_read(qspi_wifi_entry_t *entries, int max_entries)
เติมอาร์เรย์ของผู้เรียก; คืนค่าจำนวนรายการ และคืน 0 เมื่อการตรวจความถูกต้องล้มเหลวไม่ว่ากรณีใด
void lfs_wifi_creds_init(void)
บน variant นี้เป็น no-op — bento_storage_init() เป็นเจ้าของการเริ่มต้นใช้งาน
bool lfs_wifi_creds_ready(void)
ส่งต่อไปยัง bento_storage_ready(); ตรวจก่อนการอ่านและการเขียนทุกครั้ง
void lfs_wifi_creds_deinit(void)
บน variant นี้เป็น no-op; ลำดับการ teardown ของ mtb-mpy ไม่นำมาใช้ที่นี่
bool lfs_wifi_creds_needs_resave(void)
บน variant นี้เป็น false เสมอ — ที่เก็บฝั่ง C เขียนเฉพาะรูปแบบปัจจุบันเท่านั้น
qspi_wifi_entry_t
Definition wifi_creds_types.h:31