Module ble_store

Module ble_store 

Source
Expand description

BLE security snapshot journal: shared machinery from umsh-journal-store, plus this firmware’s flash placement.

The record engine, snapshot codec, and their power-cut tests live in the crate; only the page addresses — a memory.x fact — are decided here.

Structs§

Snapshot
StoredBond

Enums§

BondUpsert
Outcome of upsert_bond.
CommitError

Constants§

COMMIT_OFFSET
MAX_BONDS
PAGE0
Flash pages owned by this journal, inside the NV storage region (0x000E_4000..0x000F_4000; see memory.x).
PAGE1
PAGE_SIZE
Flash page size shared by every backend the journals run on (nRF52840 NVMC and ESP32-S3 SPI flash are both 4 KiB-erase parts).
SLOT_SIZE

Traits§

PageEraser
RecordReader
Flash reader used by a journal mount and by the boot path’s walk-back scan.
RecordWriter
Flash writer used by the journal’s two-stage record commit.

Functions§

consider_snapshot
Consider one journal slot while mounting without retaining its flash buffer.
crc32
CRC32 (reflected, polynomial 0xEDB88320) over a record body; the journals store it immediately before the commit word.
erase_journal_page
generation_is_newer
Wraparound-safe generation comparison: a record numbered 0 supersedes one numbered u32::MAX.
touch_bond
Move the bond matching address_kind + address to the MRU end, if present and not already there. Returns true when the order changed (and the caller should persist), false when the bond was already MRU or is not stored at all.
upsert_bond
Insert or refresh bond in bonds, which is kept ordered least-recently-used-first / most-recently-used-last (index 0 is the eviction candidate). A bond matching by address_kind + address is refreshed in place and moved to the MRU end; a new bond is appended at the MRU end, evicting the current LRU entry first if the list is full.
write_committed_record
Write a record body first and its visibility marker last. The record’s last four bytes are the commit word (shared convention across every journal in this crate).