Void Sentry
An AI-driven, real-time Sentry Turret platform leveraging asynchronous I/O and computer vision to deliver high-precision autonomous motion tracking on resource-constrained embedded hardware.
Loading...
Searching...
No Matches
nvs_blob.h
Go to the documentation of this file.
1
6
#pragma once
7
8
#include <Preferences.h>
9
#include <cstddef>
10
#include <cstdint>
11
#include <span>
12
13
namespace
nvs_blob
14
{
16
enum class
ReadStatus
{
17
Absent
,
18
Mismatch
,
19
Ok
20
};
21
26
inline
ReadStatus
read
(Preferences& prefs,
const
char
* key, std::span<uint8_t> out)
27
{
28
const
size_t
stored = prefs.getBytesLength(key);
29
if
(stored == 0)
30
{
31
return
ReadStatus::Absent;
32
}
33
if
(stored != out.size() || prefs.getBytes(key, out.data(), out.size()) != out.size())
34
{
35
return
ReadStatus::Mismatch;
36
}
37
return
ReadStatus::Ok;
38
}
39
}
// namespace nvs_blob
nvs_blob::ReadStatus
ReadStatus
Outcome of read().
Definition
nvs_blob.h:16
nvs_blob::ReadStatus::Mismatch
@ Mismatch
stored with a different length than expected, or the read came back short
nvs_blob::ReadStatus::Ok
@ Ok
out holds exactly the stored bytes
nvs_blob::ReadStatus::Absent
@ Absent
the key does not exist (stored length 0)
nvs_blob::read
ReadStatus read(Preferences &prefs, const char *key, std::span< uint8_t > out)
Reads the blob under key into out, requiring the stored length to equal out.size().
Definition
nvs_blob.h:26
include
nvs_blob.h
Generated by
1.12.0