diff -r 87b86d16b1d6 -r e84200edc852 main/config.c --- a/main/config.c Sun Oct 21 23:12:08 2018 +0200 +++ b/main/config.c Mon Oct 22 21:43:45 2018 +0200 @@ -267,7 +267,6 @@ if (strcmp(wifiStation.SSID, (char *)SSID) == 0) { // Fount it fclose(f); -// ESP_LOGI(TAG, "read_station %s record %d", (char *)SSID, rc); return rc; } rc++; @@ -336,7 +335,7 @@ size_t bytes = fwrite(dst, 1, sizeof(runtime), f); fclose(f); - ESP_LOGI(TAG, "/spiffs/etc/runtime.conf written %d bytes", bytes); + ESP_LOGD(TAG, "/spiffs/etc/runtime.conf written %d bytes", bytes); } @@ -420,11 +419,10 @@ FILE *f = fopen("/spiffs/etc/recipe.conf", "r"); if (f == NULL) { - // No runtime yet, create it. + // No recipe yet, create it. dst = (uint8_t*)&recipe; memset(dst, 0, sizeof(recipe)); recipe.Version = 1; - recipe.Record = 1; sprintf(recipe.Name, "Recipe 1"); sprintf(recipe.Code, "001"); sprintf(recipe.MashStep[0].Name, "Mash-in"); @@ -464,7 +462,7 @@ void delete_recipe(int RecNo) { - int RecNow = 1; + int RecRead = 1, RecWrite = 1; FILE *n, *o; uint8_t *dst; size_t bytes; @@ -487,20 +485,17 @@ if (bytes == 0) break; - if (recipe.Record == RecNo) { - // Record to delete, don't copy - printf("Ditch %d\n", RecNo); - } else { - if ((config.RecipeRec == recipe.Record) && (config.RecipeRec != RecNow)) { + if (RecRead != RecNo) { + // Record to copy + if ((config.RecipeRec == RecRead) && (config.RecipeRec != RecWrite)) { // We need to change the default record. - config.RecipeRec = RecNow; + config.RecipeRec = RecWrite; write_config(); } - printf("Copy %d to %d\n", recipe.Record, RecNow); - recipe.Record = RecNow; fwrite(dst, 1, sizeof(recipe), n); - RecNow++; + RecWrite++; } + RecRead++; } fclose(o); fclose(n); @@ -508,6 +503,7 @@ rename("/spiffs/etc/recipe.conf", "/spiffs/etc/recipe.old"); rename("/spiffs/etc/recipe.new", "/spiffs/etc/recipe.conf"); unlink("/spiffs/etc/recipe.old"); + ESP_LOGI(TAG, "Deleted recipe %d", RecNo); }