Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 5 additions & 33 deletions examples/companion_radio/DataStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,7 @@ void DataStore::loadPrefs(NodePrefs& prefs, double& node_lat, double& node_lon)
}

void DataStore::loadPrefsInt(const char *filename, NodePrefs& _prefs, double& node_lat, double& node_lon) {
#if defined(RP2040_PLATFORM)
File file = _fs->open(filename, "r");
#else
File file = _fs->open(filename);
#endif
File file = openRead(_fs, filename);
if (file) {
uint8_t pad[8];

Expand Down Expand Up @@ -262,16 +258,7 @@ void DataStore::savePrefs(const NodePrefs& _prefs, double node_lat, double node_
}

void DataStore::loadContacts(DataStoreHost* host) {
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
if (_getContactsChannelsFS()->exists("/contacts3")) {
File file = _getContactsChannelsFS()->open("/contacts3");
#elif defined(RP2040_PLATFORM)
if (_fs->exists("/contacts3")) {
File file = _fs->open("/contacts3", "r");
#else
if (_fs->exists("/contacts3")) {
File file = _fs->open("/contacts3", "r", false);
#endif
File file = openRead(_getContactsChannelsFS(), "/contacts3");
if (file) {
bool full = false;
while (!full) {
Expand Down Expand Up @@ -299,7 +286,6 @@ void DataStore::loadContacts(DataStoreHost* host) {
}
file.close();
}
}
}

void DataStore::saveContacts(DataStoreHost* host) {
Expand Down Expand Up @@ -332,16 +318,7 @@ void DataStore::saveContacts(DataStoreHost* host) {
}

void DataStore::loadChannels(DataStoreHost* host) {
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
if (_getContactsChannelsFS()->exists("/channels2")) {
File file = _getContactsChannelsFS()->open("/channels2");
#elif defined(RP2040_PLATFORM)
if (_fs->exists("/channels2")) {
File file = _fs->open("/channels2", "r");
#else
if (_fs->exists("/channels2")) {
File file = _fs->open("/channels2", "r", false);
#endif
File file = openRead(_getContactsChannelsFS(), "/channels2");
if (file) {
bool full = false;
uint8_t channel_idx = 0;
Expand All @@ -363,7 +340,6 @@ void DataStore::loadChannels(DataStoreHost* host) {
}
file.close();
}
}
}

void DataStore::saveChannels(DataStoreHost* host) {
Expand Down Expand Up @@ -520,7 +496,7 @@ void DataStore::migrateToSecondaryFS() {
}

uint8_t DataStore::getBlobByKey(const uint8_t key[], int key_len, uint8_t dest_buf[]) {
File file = _getContactsChannelsFS()->open("/adv_blobs");
File file = openRead(_getContactsChannelsFS(), "/adv_blobs");
uint8_t len = 0; // 0 = not found
if (file) {
BlobRec tmp;
Expand Down Expand Up @@ -583,11 +559,7 @@ uint8_t DataStore::getBlobByKey(const uint8_t key[], int key_len, uint8_t dest_b
sprintf(path, "/bl/%s", fname);

if (_fs->exists(path)) {
#if defined(RP2040_PLATFORM)
File f = _fs->open(path, "r");
#else
File f = _fs->open(path);
#endif
File f = openRead(_fs, path);
if (f) {
int len = f.read(dest_buf, 255); // currently MAX 255 byte blob len supported!!
f.close();
Expand Down