Added a freeEntries method to Preferences library (#1722)

This commit is contained in:
lbernstone 2018-08-14 02:52:01 -07:00 committed by Me No Dev
parent b05430cfd9
commit d057e544e0
2 changed files with 11 additions and 0 deletions

View File

@ -468,3 +468,13 @@ size_t Preferences::getBytes(const char* key, void * buf, size_t maxLen){
} }
return len; return len;
} }
size_t Preferences::freeEntries() {
nvs_stats_t nvs_stats;
esp_err_t err = nvs_get_stats(NULL, &nvs_stats);
if(err){
log_e("Failed to get nvs statistics");
return 0;
}
return nvs_stats.free_entries;
}

View File

@ -64,6 +64,7 @@ class Preferences {
size_t getString(const char* key, char* value, size_t maxLen); size_t getString(const char* key, char* value, size_t maxLen);
String getString(const char* key, String defaultValue = String()); String getString(const char* key, String defaultValue = String());
size_t getBytes(const char* key, void * buf, size_t maxLen); size_t getBytes(const char* key, void * buf, size_t maxLen);
size_t freeEntries();
}; };
#endif #endif