MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / loadFromFile

Method loadFromFile

src/WifiCredentialStore.cpp:37–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37bool WifiCredentialStore::loadFromFile() {
38 // Try JSON first
39 if (Storage.exists(WIFI_FILE_JSON)) {
40 String json = Storage.readFile(WIFI_FILE_JSON);
41 if (!json.isEmpty()) {
42 bool resave = false;
43 bool result = JsonSettingsIO::loadWifi(*this, json.c_str(), &resave);
44 if (result && resave) {
45 LOG_DBG("WCS", "Resaving JSON with obfuscated passwords");
46 saveToFile();
47 }
48 return result;
49 }
50 }
51
52 // Fall back to binary migration
53 if (Storage.exists(WIFI_FILE_BIN)) {
54 if (loadFromBinaryFile()) {
55 if (saveToFile()) {
56 Storage.rename(WIFI_FILE_BIN, WIFI_FILE_BAK);
57 LOG_DBG("WCS", "Migrated wifi.bin to wifi.json");
58 return true;
59 } else {
60 LOG_ERR("WCS", "Failed to save wifi during migration");
61 return false;
62 }
63 }
64 }
65
66 return false;
67}
68
69bool WifiCredentialStore::loadFromBinaryFile() {
70 HalFile file;

Callers

nothing calls this directly

Calls 4

existsMethod · 0.80
readFileMethod · 0.80
renameMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected