Sat, 27 Oct 2018 15:55:16 +0200
Boot now checks got IP status before installing the http and vnc servers.
0 | 1 | /** |
2 | * @file config.c | |
3 | * @brief BrewBoard configuration files. | |
4 | */ | |
5 | ||
6 | #include "config.h" | |
7 | ||
8 | static const char *TAG = "config"; | |
9 | ||
10 | ||
11 | void write_config() { | |
12 | uint8_t *dst = (uint8_t *)&config; | |
13 | FILE *f = fopen("/spiffs/etc/config.conf", "w+"); | |
14 | ||
15 | if (f == NULL) { | |
16 | ESP_LOGE(TAG, "write /spiffs/etc/config.conf failed"); | |
17 | return; | |
18 | } | |
19 | ||
20 | size_t bytes = fwrite(dst, 1, sizeof(config), f); | |
21 | fclose(f); | |
22 | ESP_LOGI(TAG, "/spiffs/etc/config.conf written %d bytes", bytes); | |
23 | } | |
24 | ||
25 | ||
26 | ||
27 | void read_config() { | |
28 | uint8_t *dst; | |
29 | uint8_t mac_addr[8] = {0}; | |
30 | FILE *f = fopen("/spiffs/etc/config.conf", "r"); | |
31 | ||
32 | if (f == NULL) { | |
33 | // No configuration yet, create it. | |
34 | esp_efuse_mac_get_default(mac_addr); | |
35 | config.Version = 1; | |
36 | config.Unit = 'C'; | |
37 | config.BoilTemperature = 99.0; | |
38 | config.AskAdd = true; | |
39 | config.AskRemove = true; | |
40 | config.AskIodine = true; | |
41 | config.IodineTime = 30; | |
42 | config.EquipmentRec = 1; | |
43 | sprintf(config.hostname, "brewboard-%02x%02x%02x", mac_addr[3], mac_addr[4], mac_addr[5]); | |
44 | sprintf(config.ap_ssid, "brewboardAP-%02x%02x%02x", mac_addr[3], mac_addr[4], mac_addr[5]); | |
45 | sprintf(config.ap_pwd, "%s", "triplehop"); | |
46 | config.ap_channel = 5; | |
47 | config.ap_ssid_hidden = 0; | |
48 | config.ap_bandwidth = WIFI_BW_HT20; | |
49 | config.ts_xleft = 0; | |
50 | config.ts_xright = 3600; | |
51 | config.ts_ytop = 3600; | |
52 | config.ts_ybottom = 0; | |
53 | config.RecipeRec = 1; | |
54 | sprintf(config.uuid, "c0ffeeee-dead-beef-cafe-%02x%02x%02x%02x%02x%02x", | |
55 | mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]); | |
56 | write_config(); | |
57 | } else { | |
58 | dst = (uint8_t*)&config; | |
59 | size_t bytes = fread(dst, 1, sizeof(config), f); | |
60 | fclose(f); | |
61 | ESP_LOGI(TAG, "/spiffs/etc/config.conf read %d bytes", bytes); | |
62 | if (config.AskIodine && ! config.IodineTime) { | |
63 | config.IodineTime = 30; | |
64 | write_config(); | |
65 | } | |
66 | if (strlen(config.uuid) !=36) { | |
67 | esp_efuse_mac_get_default(mac_addr); | |
68 | sprintf(config.uuid, "c0ffeeee-dead-beef-cafe-%02x%02x%02x%02x%02x%02x", | |
69 | mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]); | |
70 | write_config(); | |
71 | } | |
72 | } | |
73 | } | |
74 | ||
75 | ||
76 | ||
77 | void append_equipment() { | |
78 | uint8_t *dst = (uint8_t *)&equipment; | |
79 | FILE *f = fopen("/spiffs/etc/equipments.conf", "a"); | |
80 | ||
81 | if (f == NULL) { | |
82 | ESP_LOGE(TAG, "append /spiffs/etc/equipments.conf failed"); | |
83 | return; | |
84 | } | |
85 | ||
86 | size_t bytes = fwrite(dst, 1, sizeof(equipment), f); | |
87 | fclose(f); | |
88 | ESP_LOGI(TAG, "/spiffs/etc/equipments.conf appended %d bytes", bytes); | |
89 | } | |
90 | ||
91 | ||
92 | ||
93 | void read_equipment(int RecNo) { | |
94 | uint8_t *dst; | |
95 | FILE *f = fopen("/spiffs/etc/equipments.conf", "r"); | |
96 | ||
97 | if (f == NULL) { | |
98 | // No configuration yet, create it. | |
99 | equipment.Version = 1; | |
100 | equipment.Record = 1; | |
101 | sprintf(equipment.Name, "default"); | |
102 | equipment.BoilPower = 80; | |
103 | equipment.MashPower = 100; | |
104 | equipment.PumpCycle = 8; | |
105 | equipment.PumpRest = 2; | |
106 | equipment.PumpPreMash = true; | |
107 | equipment.PumpOnMash = true; | |
108 | equipment.PumpMashOut = true; | |
109 | equipment.PumpOnBoil = false; | |
110 | equipment.PumpMaxTemp = 80; | |
111 | equipment.PIDPipe = true; | |
112 | equipment.SSR2 = 0; | |
113 | equipment.TempHLT = 85.0; | |
114 | equipment.PID_kP = 150.0; | |
115 | equipment.PID_kI = 1.5; | |
116 | equipment.PID_kD = 15000.0; | |
117 | equipment.PID_POn = PID_P_ON_E; | |
118 | equipment.SampleTime = 5000; | |
119 | append_equipment(); | |
120 | } else { | |
121 | dst = (uint8_t*)&equipment; | |
122 | while (1) { | |
123 | size_t bytes = fread(dst, 1, sizeof(equipment), f); | |
124 | if (bytes && equipment.Record == RecNo) { | |
125 | fclose(f); | |
126 | ESP_LOGI(TAG, "/spiffs/etc/equipments.conf read %d bytes, record %d: %s", bytes, RecNo, equipment.Name); | |
127 | return; | |
128 | } | |
129 | if (bytes == 0) | |
130 | break; | |
131 | } | |
132 | fclose(f); | |
133 | ESP_LOGI(TAG, "/spiffs/etc/equipments.conf read error, record %d not found", RecNo); | |
134 | } | |
135 | } | |
136 | ||
137 | ||
138 | ||
139 | void write_equipment(int RecNo) | |
140 | { | |
141 | uint8_t *dst = (uint8_t *)&equipment; | |
142 | FILE *f; | |
143 | ||
144 | f = fopen("/spiffs/etc/equipments.conf", "r+"); | |
145 | if (f == NULL) { | |
146 | ESP_LOGE(TAG, "write /spiffs/etc/equipments.conf failed"); | |
147 | return; | |
148 | } | |
149 | fseek(f, (RecNo - 1) * sizeof(equipment), SEEK_SET); | |
150 | size_t bytes = fwrite(dst, 1, sizeof(equipment), f); | |
151 | fclose(f); | |
152 | ESP_LOGI(TAG, "/spiffs/etc/equipments.conf update record %d, %d bytes", RecNo, bytes); | |
153 | } | |
154 | ||
155 | ||
156 | ||
157 | void delete_equipment(int RecNo) | |
158 | { | |
159 | int RecNow = 1; | |
160 | FILE *n, *o; | |
161 | uint8_t *dst; | |
162 | size_t bytes; | |
163 | ||
164 | n = fopen("/spiffs/etc/equipments.new", "a"); | |
165 | if (n == NULL) { | |
166 | ESP_LOGE(TAG, "cannot create /spiffs/etc/equipments.new"); | |
167 | return; | |
168 | } | |
169 | o = fopen("/spiffs/etc/equipments.conf", "r"); | |
170 | if (o == NULL) { | |
171 | ESP_LOGE(TAG, "cannot open spiffs/etc/equipments.conf for reading"); | |
172 | fclose(n); | |
173 | return; | |
174 | } | |
175 | ||
176 | dst = (uint8_t*)&equipment; | |
177 | while (true) { | |
178 | bytes = fread(dst, 1, sizeof(equipment), o); | |
179 | if (bytes == 0) | |
180 | break; | |
181 | ||
182 | if (equipment.Record == RecNo) { | |
183 | // Record to delete, don't copy | |
184 | printf("Ditch %d\n", RecNo); | |
185 | } else { | |
186 | if ((config.EquipmentRec == equipment.Record) && (config.EquipmentRec != RecNow)) { | |
187 | // We need to change the default record. | |
188 | config.EquipmentRec = RecNow; | |
189 | write_config(); | |
190 | } | |
191 | printf("Copy %d to %d\n", equipment.Record, RecNow); | |
192 | equipment.Record = RecNow; | |
193 | fwrite(dst, 1, sizeof(equipment), n); | |
194 | RecNow++; | |
195 | } | |
196 | } | |
197 | fclose(o); | |
198 | fclose(n); | |
199 | ||
200 | rename("/spiffs/etc/equipments.conf", "/spiffs/etc/equipments.old"); | |
201 | rename("/spiffs/etc/equipments.new", "/spiffs/etc/equipments.conf"); | |
202 | unlink("/spiffs/etc/equipments.old"); | |
203 | } | |
204 | ||
205 | ||
206 | ||
207 | int add_station(uint8_t *SSID, uint8_t *Password) | |
208 | { | |
209 | FILE *f; | |
210 | uint8_t *dst = (uint8_t *)&wifiStation; | |
211 | ||
212 | if (read_station(SSID) >= 0) { | |
213 | ESP_LOGE(TAG, "add_station %s already excists", SSID); | |
214 | return -1; | |
215 | } | |
216 | ||
217 | f = fopen("/spiffs/etc/stations.conf", "a+"); | |
218 | if (f == NULL) { | |
219 | ESP_LOGE(TAG, "write /spiffs/etc/stations.conf failed"); | |
220 | return -1; | |
221 | } | |
222 | memset(dst, 0, sizeof(wifiStation)); | |
223 | sprintf(wifiStation.SSID, "%s", (char *)SSID); | |
224 | sprintf(wifiStation.Password, "%s", (char *)Password); | |
225 | wifiStation.hide = false; | |
226 | fwrite(dst, 1, sizeof(wifiStation), f); | |
227 | fclose(f); | |
228 | ||
229 | ESP_LOGI(TAG, "add_station %s record: %d", (char *)SSID, read_station(SSID)); | |
230 | /* Return the record number */ | |
231 | return read_station(SSID); | |
232 | } | |
233 | ||
234 | ||
235 | ||
236 | int read_station(uint8_t *SSID) | |
237 | { | |
238 | uint8_t *dst = (uint8_t *)&wifiStation; | |
239 | static int rc; | |
240 | FILE *f; | |
241 | size_t bytes; | |
242 | ||
243 | if ((SSID == NULL) || (strlen((char *)SSID) == 0)) { | |
244 | ESP_LOGI(TAG, "read_station(NULL)"); | |
245 | return -1; | |
246 | } | |
247 | ||
248 | memset(dst, 0, sizeof(wifiStation)); | |
249 | f = fopen("/spiffs/etc/stations.conf", "r+"); | |
250 | if (f == NULL) { | |
251 | f = fopen("/spiffs/etc/stations.conf", "w+"); | |
252 | fclose(f); | |
253 | ESP_LOGI(TAG, "/spiffs/etc/stations.conf created, return -1"); | |
254 | return -1; | |
255 | } | |
256 | ||
257 | rc = 0; | |
258 | fseek(f, 0, SEEK_SET); | |
259 | ||
260 | while (1) { | |
261 | bytes = fread(dst, 1, sizeof(wifiStation), f); | |
262 | if (bytes < sizeof(wifiStation)) { | |
263 | fclose(f); | |
264 | memset(dst, 0, sizeof(wifiStation)); | |
265 | return -1; | |
266 | } | |
267 | if (strcmp(wifiStation.SSID, (char *)SSID) == 0) { | |
268 | // Fount it | |
269 | fclose(f); | |
270 | return rc; | |
271 | } | |
272 | rc++; | |
273 | } | |
274 | return -1; | |
275 | } | |
276 | ||
277 | ||
278 | ||
279 | void remove_station(uint8_t *SSID) | |
280 | { | |
281 | FILE *n, *o; | |
282 | uint8_t *dst; | |
283 | size_t bytes; | |
284 | ||
285 | n = fopen("/spiffs/etc/stations.new", "a"); | |
286 | if (n == NULL) { | |
287 | ESP_LOGE(TAG, "cannot create /spiffs/etc/stations.new"); | |
288 | return; | |
289 | } | |
290 | o = fopen("/spiffs/etc/stations.conf", "r"); | |
291 | if (o == NULL) { | |
292 | ESP_LOGE(TAG, "cannot open spiffs/etc/stations.conf for reading"); | |
293 | fclose(n); | |
294 | return; | |
295 | } | |
296 | ||
297 | dst = (uint8_t*)&wifiStation; | |
298 | while (true) { | |
299 | bytes = fread(dst, 1, sizeof(wifiStation), o); | |
300 | if (bytes == 0) | |
301 | break; | |
302 | ||
303 | if ((strcmp((char *)SSID, wifiStation.SSID) == 0) || (strlen(wifiStation.SSID) == 0)) { | |
304 | // Record to delete, don't copy | |
305 | } else { | |
306 | fwrite(dst, 1, sizeof(wifiStation), n); | |
307 | } | |
308 | } | |
309 | fclose(o); | |
310 | fclose(n); | |
311 | ||
312 | rename("/spiffs/etc/stations.conf", "/spiffs/etc/stations.old"); | |
313 | rename("/spiffs/etc/stations.new", "/spiffs/etc/stations.conf"); | |
314 | unlink("/spiffs/etc/stations.old"); | |
315 | } | |
316 | ||
317 | ||
318 | ||
319 | int blacklist_station(uint8_t *SSID) | |
320 | { | |
321 | return -1; | |
322 | } | |
323 | ||
324 | ||
325 | ||
326 | void write_runtime() | |
327 | { | |
328 | uint8_t *dst = (uint8_t *)&runtime; | |
329 | FILE *f = fopen("/spiffs/etc/runtime.conf", "w+"); | |
330 | ||
331 | if (f == NULL) { | |
332 | ESP_LOGE(TAG, "write /spiffs/etc/runtime.conf failed"); | |
333 | return; | |
334 | } | |
335 | ||
336 | size_t bytes = fwrite(dst, 1, sizeof(runtime), f); | |
337 | fclose(f); | |
6
e84200edc852
Updated esp-ide. Removed VNC server corre encoding because no clients would use it. Enabled WiFi error logmessages. Write runtime record is now debug logging. Removed recipe.Record number, not usefull and was wrong too. Removed console print of json log data.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
338 | ESP_LOGD(TAG, "/spiffs/etc/runtime.conf written %d bytes", bytes); |
0 | 339 | } |
340 | ||
341 | ||
342 | ||
343 | void read_runtime() | |
344 | { | |
345 | uint8_t *dst; | |
346 | FILE *f = fopen("/spiffs/etc/runtime.conf", "r"); | |
347 | ||
348 | if (f == NULL) { | |
349 | // No runtime yet, create it. | |
350 | runtime.Version = 1; | |
351 | runtime.AutoModeStarted = false; | |
352 | runtime.StageResume = 0; | |
353 | runtime.StageTimeLeft = 0; | |
354 | runtime.HopAddition = 0; | |
355 | runtime.ManualMLT = 45.0; | |
356 | runtime.ManualHLT = 45.0; | |
357 | runtime.BrewStart = (time_t)0; | |
358 | runtime.Logfile[0] = '\0'; | |
359 | runtime.PumpCooling = false; | |
360 | runtime.TimeBrewing = 0; | |
361 | write_runtime(); | |
362 | } else { | |
363 | dst = (uint8_t*)&runtime; | |
364 | size_t bytes = fread(dst, 1, sizeof(runtime), f); | |
365 | fclose(f); | |
366 | ESP_LOGI(TAG, "/spiffs/etc/runtime.conf read %d bytes", bytes); | |
367 | #if 0 | |
368 | printf("Auto started %s\n", runtime.AutoModeStarted ? "yes":"no"); | |
369 | printf("Stage resume %d\n", runtime.StageResume); | |
370 | printf("Stage time left %d\n", runtime.StageTimeLeft); | |
371 | printf("Hop addition %d\n", runtime.HopAddition); | |
372 | printf("Brew start %d\n", (int)runtime.BrewStart); | |
373 | printf("Log file %s\n", runtime.Logfile); | |
374 | printf("Pump cooling %s\n", runtime.PumpCooling ? "yes":"no"); | |
375 | printf("Time brewing %d\n", runtime.TimeBrewing); | |
376 | #endif | |
377 | } | |
378 | } | |
379 | ||
380 | ||
381 | ||
382 | void append_recipe() { | |
383 | uint8_t *dst = (uint8_t *)&recipe; | |
384 | FILE *f = fopen("/spiffs/etc/recipe.conf", "a"); | |
385 | ||
386 | if (f == NULL) { | |
387 | ESP_LOGE(TAG, "append /spiffs/etc/recipe.conf failed"); | |
388 | return; | |
389 | } | |
390 | ||
391 | size_t bytes = fwrite(dst, 1, sizeof(recipe), f); | |
392 | fclose(f); | |
393 | ESP_LOGI(TAG, "/spiffs/etc/recipe.conf appended %d bytes", bytes); | |
394 | } | |
395 | ||
396 | ||
397 | ||
398 | void write_recipe(int RecNo) | |
399 | { | |
400 | uint8_t *dst = (uint8_t *)&recipe; | |
401 | FILE *f = fopen("/spiffs/etc/recipe.conf", "r+"); | |
402 | ||
403 | if (f == NULL) { | |
404 | ESP_LOGE(TAG, "write /spiffs/etc/recipe.conf failed"); | |
405 | return; | |
406 | } | |
407 | ||
408 | fseek(f, (RecNo - 1) * sizeof(recipe), SEEK_SET); | |
409 | size_t bytes = fwrite(dst, 1, sizeof(recipe), f); | |
410 | fclose(f); | |
411 | ESP_LOGI(TAG, "/spiffs/etc/recipe.conf written record %d, %d bytes", RecNo, bytes); | |
412 | } | |
413 | ||
414 | ||
415 | ||
416 | void read_recipe(int RecNo) | |
417 | { | |
418 | uint8_t *dst; | |
419 | FILE *f = fopen("/spiffs/etc/recipe.conf", "r"); | |
420 | ||
421 | if (f == NULL) { | |
6
e84200edc852
Updated esp-ide. Removed VNC server corre encoding because no clients would use it. Enabled WiFi error logmessages. Write runtime record is now debug logging. Removed recipe.Record number, not usefull and was wrong too. Removed console print of json log data.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
422 | // No recipe yet, create it. |
0 | 423 | dst = (uint8_t*)&recipe; |
424 | memset(dst, 0, sizeof(recipe)); | |
425 | recipe.Version = 1; | |
426 | sprintf(recipe.Name, "Recipe 1"); | |
427 | sprintf(recipe.Code, "001"); | |
428 | sprintf(recipe.MashStep[0].Name, "Mash-in"); | |
15
34b1eb93e71a
Added extra mash step fields for infusion steps. Added these fields in recipe import too.
Michiel Broek <mbroek@mbse.eu>
parents:
6
diff
changeset
|
429 | recipe.MashStep[0].Type = MASHTYPE_INFUSION; |
34b1eb93e71a
Added extra mash step fields for infusion steps. Added these fields in recipe import too.
Michiel Broek <mbroek@mbse.eu>
parents:
6
diff
changeset
|
430 | recipe.MashStep[0].Temperature = recipe.MashStep[0].Infusion_temp = 67.5; |
34b1eb93e71a
Added extra mash step fields for infusion steps. Added these fields in recipe import too.
Michiel Broek <mbroek@mbse.eu>
parents:
6
diff
changeset
|
431 | recipe.MashStep[0].Infusion_amount = 15.0; |
0 | 432 | recipe.MashStep[0].Resttime = 1; |
15
34b1eb93e71a
Added extra mash step fields for infusion steps. Added these fields in recipe import too.
Michiel Broek <mbroek@mbse.eu>
parents:
6
diff
changeset
|
433 | recipe.MashStep[0].Ramptime = 1; |
19 | 434 | for (int i = 1; i < 8; i++) |
435 | recipe.MashStep[i].Type = MASHTYPE_TEMPERATURE; | |
0 | 436 | sprintf(recipe.MashStep[1].Name, "Mash"); |
437 | recipe.MashStep[1].Temperature = 67.0; | |
438 | recipe.MashStep[1].Resttime = 75; | |
15
34b1eb93e71a
Added extra mash step fields for infusion steps. Added these fields in recipe import too.
Michiel Broek <mbroek@mbse.eu>
parents:
6
diff
changeset
|
439 | recipe.MashStep[1].Ramptime = 1; |
0 | 440 | sprintf(recipe.MashStep[7].Name, "Mash-out"); |
441 | recipe.MashStep[7].Temperature = 78.0; | |
442 | recipe.MashStep[7].Resttime = 5; | |
15
34b1eb93e71a
Added extra mash step fields for infusion steps. Added these fields in recipe import too.
Michiel Broek <mbroek@mbse.eu>
parents:
6
diff
changeset
|
443 | recipe.MashStep[7].Ramptime = 11; |
0 | 444 | recipe.BoilTime = 60; |
445 | recipe.Additions = 2; | |
446 | sprintf(recipe.Addition[0].Name, "Hop"); | |
447 | recipe.Addition[0].Time = 60; | |
448 | recipe.Addition[0].Type = ADDITION_HOP; | |
449 | sprintf(recipe.Addition[1].Name, "Hop"); | |
450 | recipe.Addition[1].Time = 10; | |
451 | recipe.Addition[1].Type = ADDITION_HOP; | |
452 | recipe.CoolTemp = 20.0; | |
453 | recipe.Whirlpool9 = 0; | |
454 | recipe.Whirlpool7 = 0; | |
455 | recipe.Whirlpool6 = 0; | |
456 | recipe.Whirlpool2 = 0; | |
457 | recipe.SpargeTemp = 85.0; | |
458 | append_recipe(); | |
459 | } else { | |
460 | dst = (uint8_t*)&recipe; | |
461 | fseek(f, (RecNo - 1) * sizeof(recipe), SEEK_SET); | |
462 | size_t bytes = fread(dst, 1, sizeof(recipe), f); | |
463 | fclose(f); | |
464 | ESP_LOGI(TAG, "/spiffs/etc/recipe.conf read record %d, %d bytes", RecNo, bytes); | |
465 | } | |
466 | } | |
467 | ||
468 | ||
469 | ||
470 | void delete_recipe(int RecNo) | |
471 | { | |
6
e84200edc852
Updated esp-ide. Removed VNC server corre encoding because no clients would use it. Enabled WiFi error logmessages. Write runtime record is now debug logging. Removed recipe.Record number, not usefull and was wrong too. Removed console print of json log data.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
472 | int RecRead = 1, RecWrite = 1; |
0 | 473 | FILE *n, *o; |
474 | uint8_t *dst; | |
475 | size_t bytes; | |
476 | ||
477 | n = fopen("/spiffs/etc/recipe.new", "a"); | |
478 | if (n == NULL) { | |
479 | ESP_LOGE(TAG, "cannot create /spiffs/etc/recipe.new"); | |
480 | return; | |
481 | } | |
482 | o = fopen("/spiffs/etc/recipe.conf", "r"); | |
483 | if (o == NULL) { | |
484 | ESP_LOGE(TAG, "cannot open spiffs/etc/recipe.conf for reading"); | |
485 | fclose(n); | |
486 | return; | |
487 | } | |
488 | ||
489 | dst = (uint8_t*)&recipe; | |
490 | while (true) { | |
491 | bytes = fread(dst, 1, sizeof(recipe), o); | |
492 | if (bytes == 0) | |
493 | break; | |
494 | ||
6
e84200edc852
Updated esp-ide. Removed VNC server corre encoding because no clients would use it. Enabled WiFi error logmessages. Write runtime record is now debug logging. Removed recipe.Record number, not usefull and was wrong too. Removed console print of json log data.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
495 | if (RecRead != RecNo) { |
e84200edc852
Updated esp-ide. Removed VNC server corre encoding because no clients would use it. Enabled WiFi error logmessages. Write runtime record is now debug logging. Removed recipe.Record number, not usefull and was wrong too. Removed console print of json log data.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
496 | // Record to copy |
e84200edc852
Updated esp-ide. Removed VNC server corre encoding because no clients would use it. Enabled WiFi error logmessages. Write runtime record is now debug logging. Removed recipe.Record number, not usefull and was wrong too. Removed console print of json log data.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
497 | if ((config.RecipeRec == RecRead) && (config.RecipeRec != RecWrite)) { |
0 | 498 | // We need to change the default record. |
6
e84200edc852
Updated esp-ide. Removed VNC server corre encoding because no clients would use it. Enabled WiFi error logmessages. Write runtime record is now debug logging. Removed recipe.Record number, not usefull and was wrong too. Removed console print of json log data.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
499 | config.RecipeRec = RecWrite; |
0 | 500 | write_config(); |
501 | } | |
502 | fwrite(dst, 1, sizeof(recipe), n); | |
6
e84200edc852
Updated esp-ide. Removed VNC server corre encoding because no clients would use it. Enabled WiFi error logmessages. Write runtime record is now debug logging. Removed recipe.Record number, not usefull and was wrong too. Removed console print of json log data.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
503 | RecWrite++; |
0 | 504 | } |
6
e84200edc852
Updated esp-ide. Removed VNC server corre encoding because no clients would use it. Enabled WiFi error logmessages. Write runtime record is now debug logging. Removed recipe.Record number, not usefull and was wrong too. Removed console print of json log data.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
505 | RecRead++; |
0 | 506 | } |
507 | fclose(o); | |
508 | fclose(n); | |
509 | ||
510 | rename("/spiffs/etc/recipe.conf", "/spiffs/etc/recipe.old"); | |
511 | rename("/spiffs/etc/recipe.new", "/spiffs/etc/recipe.conf"); | |
512 | unlink("/spiffs/etc/recipe.old"); | |
6
e84200edc852
Updated esp-ide. Removed VNC server corre encoding because no clients would use it. Enabled WiFi error logmessages. Write runtime record is now debug logging. Removed recipe.Record number, not usefull and was wrong too. Removed console print of json log data.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
513 | ESP_LOGI(TAG, "Deleted recipe %d", RecNo); |
0 | 514 | } |
515 | ||
516 |