Skip to content

Added a freeEntries method to Preferences library #1722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 14, 2018
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions libraries/Preferences/src/Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions libraries/Preferences/src/Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -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