add makeBlobPath inline helper for esp32
This commit is contained in:
@@ -564,13 +564,16 @@ bool DataStore::deleteBlobByKey(const uint8_t key[], int key_len) {
|
|||||||
return true; // this is just a stub on NRF52/STM32 platforms
|
return true; // this is just a stub on NRF52/STM32 platforms
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
uint8_t DataStore::getBlobByKey(const uint8_t key[], int key_len, uint8_t dest_buf[]) {
|
inline void makeBlobPath(const uint8_t key[], int key_len, char* path, size_t path_size) {
|
||||||
char path[64];
|
|
||||||
char fname[18];
|
char fname[18];
|
||||||
|
|
||||||
if (key_len > 8) key_len = 8; // just use first 8 bytes (prefix)
|
if (key_len > 8) key_len = 8; // just use first 8 bytes (prefix)
|
||||||
mesh::Utils::toHex(fname, key, key_len);
|
mesh::Utils::toHex(fname, key, key_len);
|
||||||
sprintf(path, "/bl/%s", fname);
|
sprintf(path, "/bl/%s", fname);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t DataStore::getBlobByKey(const uint8_t key[], int key_len, uint8_t dest_buf[]) {
|
||||||
|
char path[64];
|
||||||
|
makeBlobPath(key, key_len, path, sizeof(path));
|
||||||
|
|
||||||
if (_fs->exists(path)) {
|
if (_fs->exists(path)) {
|
||||||
File f = openRead(_fs, path);
|
File f = openRead(_fs, path);
|
||||||
@@ -585,11 +588,7 @@ uint8_t DataStore::getBlobByKey(const uint8_t key[], int key_len, uint8_t dest_b
|
|||||||
|
|
||||||
bool DataStore::putBlobByKey(const uint8_t key[], int key_len, const uint8_t src_buf[], uint8_t len) {
|
bool DataStore::putBlobByKey(const uint8_t key[], int key_len, const uint8_t src_buf[], uint8_t len) {
|
||||||
char path[64];
|
char path[64];
|
||||||
char fname[18];
|
makeBlobPath(key, key_len, path, sizeof(path));
|
||||||
|
|
||||||
if (key_len > 8) key_len = 8; // just use first 8 bytes (prefix)
|
|
||||||
mesh::Utils::toHex(fname, key, key_len);
|
|
||||||
sprintf(path, "/bl/%s", fname);
|
|
||||||
|
|
||||||
File f = openWrite(_fs, path);
|
File f = openWrite(_fs, path);
|
||||||
if (f) {
|
if (f) {
|
||||||
@@ -604,11 +603,7 @@ bool DataStore::putBlobByKey(const uint8_t key[], int key_len, const uint8_t src
|
|||||||
|
|
||||||
bool DataStore::deleteBlobByKey(const uint8_t key[], int key_len) {
|
bool DataStore::deleteBlobByKey(const uint8_t key[], int key_len) {
|
||||||
char path[64];
|
char path[64];
|
||||||
char fname[18];
|
makeBlobPath(key, key_len, path, sizeof(path));
|
||||||
|
|
||||||
if (key_len > 8) key_len = 8; // just use first 8 bytes (prefix)
|
|
||||||
mesh::Utils::toHex(fname, key, key_len);
|
|
||||||
sprintf(path, "/bl/%s", fname);
|
|
||||||
|
|
||||||
_fs->remove(path);
|
_fs->remove(path);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user