Added error checking for NVS storage

Also added NVS storage diagnostic to 'm' command.
This commit is contained in:
Gregg 2023-11-12 21:37:33 -06:00
parent 1e62a038f1
commit 4ab7503a72
1 changed files with 8 additions and 0 deletions

View File

@ -855,6 +855,9 @@ void Span::processSerialCommand(const char *c){
case 'm': {
LOG0("Free Heap=%d bytes (low=%d)\n",heap_caps_get_free_size(MALLOC_CAP_DEFAULT),heap_caps_get_minimum_free_size(MALLOC_CAP_DEFAULT));
nvs_stats_t nvs_stats;
nvs_get_stats(NULL, &nvs_stats);
LOG0("NVS: %d of %d records used\n",nvs_stats.used_entries,nvs_stats.total_entries-126);
}
break;
@ -1611,6 +1614,11 @@ boolean Span::updateDatabase(boolean updateMDNS){
}
}
nvs_stats_t nvs_stats;
nvs_get_stats(NULL, &nvs_stats);
if(nvs_stats.free_entries<=130)
LOG0("\n*** WARNING: NVS is running low on space. Try erasing with 'E'. If that fails, increase size of NVS partition or reduce NVS usage.\n\n");
Loops.clear();
for(auto acc=Accessories.begin(); acc!=Accessories.end(); acc++){ // identify all services with over-ridden loop() methods