Added a freeEntries method to Preferences library (#1722)
This commit is contained in:
parent
b05430cfd9
commit
d057e544e0
@ -468,3 +468,13 @@ size_t Preferences::getBytes(const char* key, void * buf, size_t maxLen){
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ class Preferences {
|
||||
size_t getString(const char* key, char* value, size_t maxLen);
|
||||
String getString(const char* key, String defaultValue = String());
|
||||
size_t getBytes(const char* key, void * buf, size_t maxLen);
|
||||
size_t freeEntries();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user