`armor/` 是它的 Rust 改写版,这一份留着当参考:ADC 阈值的 2000 就是从它标定出来的 (`.env.example` 里那句 "same as the reference firmware" 指的就是它),而且它的 README 记着实测设备与 MAC,换硬件时是有用的现场记录。 只收了 20 个源文件。它自带的 `.gitignore` 已经排掉 `build/`(211 MB 的 ESP-IDF 构建产物) 与生成的 `sdkconfig`,所以仓库里不会多出这些东西。 两处顺带处理: - `reference/armor/.git` 是一个**空的**仓库壳(`git init` 过,零提交、零 remote、零 ref), 而外层 git 正因为它的存在而拒绝索引 `reference/` 下的任何文件 (`error: 'reference/armor/' does not have a commit checked out`)。它被挪到 `desktop/.dev/backup/reference-armor-git`(可逆,且该目录已被忽略),不是删除。 - 它的 README 指着 `../armor-platformio-backup/`,那份备份并不存在。改成明说"没有进仓库", 免得以后有人照着找一个不存在的目录。 另外把 `/docs/` 加进 .gitignore:那是工作区里另起的一个 Astro 文档站,与本仓库无关。
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
|
|
#include "esp_err.h"
|
|
|
|
/**
|
|
* @brief Small NVS wrapper standing in for the Arduino `Preferences` class.
|
|
*
|
|
* The original code used `preferences.begin("armor", false)`, `putUInt`,
|
|
* `getUInt`, `isKey`, `putBytes` and `getBytes`. Those map directly onto the
|
|
* ESP-IDF NVS API; the handle is kept open for the lifetime of the program
|
|
* exactly like `Preferences` did.
|
|
*/
|
|
namespace Storage {
|
|
|
|
/** Open (creating if needed) the NVS namespace used by this application. */
|
|
esp_err_t begin(const char *name_space);
|
|
|
|
/** True when @p key exists as either a u32 or a blob. */
|
|
bool hasKey(const char *key);
|
|
|
|
/** Read a u32, returning @p default_value when the key is absent. */
|
|
uint32_t getUInt(const char *key, uint32_t default_value);
|
|
|
|
/** Read a blob, returning the number of bytes read (0 when absent). */
|
|
size_t getBytes(const char *key, void *out, size_t max_len);
|
|
|
|
/** Store a u32 and commit it. */
|
|
esp_err_t putUInt(const char *key, uint32_t value);
|
|
|
|
/** Store a blob and commit it. */
|
|
esp_err_t putBytes(const char *key, const void *data, size_t len);
|
|
|
|
} // namespace Storage
|