Tue, 02 Nov 2021 14:47:43 +0100
Version 0.3.20 fix for equipment records create and delete.
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); | |
57
6c5211c0120b
Version 0.3.3. Added favicon.ico to the web server. Fixed text position in the http client for the power percentage. Silenced a lot of log messages. Moved the pump led on the display to the left just as on the web page.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
22 | if (bytes != sizeof(config)) { |
6c5211c0120b
Version 0.3.3. Added favicon.ico to the web server. Fixed text position in the http client for the power percentage. Silenced a lot of log messages. Moved the pump led on the display to the left just as on the web page.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
23 | ESP_LOGE(TAG, "/spiffs/etc/config.conf written %d/%d bytes", bytes, sizeof(config)); |
6c5211c0120b
Version 0.3.3. Added favicon.ico to the web server. Fixed text position in the http client for the power percentage. Silenced a lot of log messages. Moved the pump led on the display to the left just as on the web page.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
24 | } |
0 | 25 | } |
26 | ||
27 | ||
28 | ||
29 | void read_config() { | |
30 | uint8_t *dst; | |
31 | uint8_t mac_addr[8] = {0}; | |
32 | FILE *f = fopen("/spiffs/etc/config.conf", "r"); | |
33 | ||
34 | if (f == NULL) { | |
35 | // No configuration yet, create it. | |
36 | esp_efuse_mac_get_default(mac_addr); | |
37 | config.Version = 1; | |
38 | config.Unit = 'C'; | |
39 | config.BoilTemperature = 99.0; | |
40 | config.AskAdd = true; | |
41 | config.AskRemove = true; | |
42 | config.AskIodine = true; | |
43 | config.IodineTime = 30; | |
44 | config.EquipmentRec = 1; | |
45 | sprintf(config.hostname, "brewboard-%02x%02x%02x", mac_addr[3], mac_addr[4], mac_addr[5]); | |
95
c02e12e9c884
Removed AP configuration settings.
Michiel Broek <mbroek@mbse.eu>
parents:
87
diff
changeset
|
46 | config.xap_ssid[0] = '\0'; |
c02e12e9c884
Removed AP configuration settings.
Michiel Broek <mbroek@mbse.eu>
parents:
87
diff
changeset
|
47 | config.xap_pwd[0] = '\0'; |
c02e12e9c884
Removed AP configuration settings.
Michiel Broek <mbroek@mbse.eu>
parents:
87
diff
changeset
|
48 | config.xap_channel = 0; |
c02e12e9c884
Removed AP configuration settings.
Michiel Broek <mbroek@mbse.eu>
parents:
87
diff
changeset
|
49 | config.xap_ssid_hidden = 0; |
c02e12e9c884
Removed AP configuration settings.
Michiel Broek <mbroek@mbse.eu>
parents:
87
diff
changeset
|
50 | config.xap_bandwidth = 0; |
0 | 51 | config.ts_xleft = 0; |
52 | config.ts_xright = 3600; | |
53 | config.ts_ytop = 3600; | |
54 | config.ts_ybottom = 0; | |
55 | config.RecipeRec = 1; | |
56 | sprintf(config.uuid, "c0ffeeee-dead-beef-cafe-%02x%02x%02x%02x%02x%02x", | |
57 | mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]); | |
58 | write_config(); | |
59 | } else { | |
60 | dst = (uint8_t*)&config; | |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
61 | fread(dst, 1, sizeof(config), f); |
0 | 62 | fclose(f); |
63 | } | |
64 | } | |
65 | ||
66 | ||
67 | ||
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
68 | void append_equipment() |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
69 | { |
0 | 70 | uint8_t *dst = (uint8_t *)&equipment; |
71 | FILE *f = fopen("/spiffs/etc/equipments.conf", "a"); | |
72 | ||
73 | if (f == NULL) { | |
120
afd58d4c7b5b
Version 0.3.20 fix for equipment records create and delete.
Michiel Broek <mbroek@mbse.eu>
parents:
119
diff
changeset
|
74 | ESP_LOGE(TAG, "/spiffs/etc/equipments.conf append failed"); |
0 | 75 | return; |
76 | } | |
120
afd58d4c7b5b
Version 0.3.20 fix for equipment records create and delete.
Michiel Broek <mbroek@mbse.eu>
parents:
119
diff
changeset
|
77 | |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
78 | size_t bytes = fwrite(dst, 1, equipment_hdr.recsize, f); |
0 | 79 | fclose(f); |
80 | ESP_LOGI(TAG, "/spiffs/etc/equipments.conf appended %d bytes", bytes); | |
81 | } | |
82 | ||
83 | ||
84 | ||
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
85 | void read_equipment(int RecNo) |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
86 | { |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
87 | size_t bytes; |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
88 | uint8_t *dst; |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
89 | FILE *f = fopen("/spiffs/etc/equipments.conf", "r"); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
90 | |
0 | 91 | if (f == NULL) { |
92 | // No configuration yet, create it. | |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
93 | dst = (uint8_t*)&equipment_hdr; |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
94 | memset(dst, 0, sizeof(equipment_hdr)); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
95 | equipment_hdr.version = EQUIPMENT_VERSION; |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
96 | equipment_hdr.hdrsize = sizeof(equipment_hdr); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
97 | equipment_hdr.recsize = sizeof(equipment); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
98 | f = fopen("/spiffs/etc/equipments.conf", "w"); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
99 | bytes = fwrite(dst, 1, sizeof(equipment_hdr), f); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
100 | if (bytes != sizeof(equipment_hdr)) { |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
101 | ESP_LOGE(TAG, "/spiffs/etc/equipment.conf write header, %d/%d bytes", bytes, sizeof(equipment_hdr)); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
102 | } |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
103 | dst = (uint8_t*)&equipment; |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
104 | memset(dst, 0, sizeof(equipment)); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
105 | equipment.MLT_watt = 2000; |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
106 | equipment.HLT_watt = 2000; |
0 | 107 | sprintf(equipment.Name, "default"); |
108 | equipment.BoilPower = 80; | |
109 | equipment.MashPower = 100; | |
110 | equipment.PumpCycle = 8; | |
111 | equipment.PumpRest = 2; | |
112 | equipment.PumpPreMash = true; | |
113 | equipment.PumpOnMash = true; | |
114 | equipment.PumpMashOut = true; | |
115 | equipment.PumpOnBoil = false; | |
116 | equipment.PumpMaxTemp = 80; | |
117 | equipment.PIDPipe = true; | |
118 | equipment.SSR2 = 0; | |
119 | equipment.TempHLT = 85.0; | |
82 | 120 | equipment.PID_kP = 200.0; |
121 | equipment.PID_kI = 2.0; | |
122 | equipment.PID_kD = 1.5; | |
123 | equipment.SampleTime = 3000; | |
101
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
124 | equipment.Hendi = false; |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
125 | equipment.RampPower = 100; |
103
1885d0c75c48
Default equipment max_watt set to 2750. Added defaults for new equipment record. Switched PWM timer to high-speed. Implemented the safety timer to prevent the MLT + HLT will draw too much power in shared mode. Removed some code ideas that were not used. The fake heater now uses the faked PWM power.
Michiel Broek <mbroek@mbse.eu>
parents:
101
diff
changeset
|
126 | equipment.Max_watt = 2750; |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
127 | bytes = fwrite(dst, 1, sizeof(equipment), f); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
128 | fclose(f); |
0 | 129 | } else { |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
130 | /* |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
131 | * Try to read the new header |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
132 | */ |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
133 | dst = (uint8_t*)&equipment_hdr; |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
134 | fseek(f, 0, SEEK_SET); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
135 | bytes = fread(dst, 1, sizeof(equipment_hdr), f); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
136 | if (bytes != sizeof(equipment_hdr)) { |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
137 | ESP_LOGE(TAG, "/spiffs/etc/equipments.conf read header, %d/%d bytes", bytes, sizeof(equipment_hdr)); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
138 | fclose(f); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
139 | return; |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
140 | } |
101
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
141 | #if 1 |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
142 | if (equipment_hdr.version < EQUIPMENT_VERSION) { |
101
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
143 | uint32_t oldsize = equipment_hdr.recsize; |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
144 | FILE *nf = fopen("/spiffs/etc/equipments.new", "w"); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
145 | |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
146 | ESP_LOGW(TAG, "/spiffs/etc/equipments.conf version %d, new %d", equipment_hdr.version, EQUIPMENT_VERSION); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
147 | dst = (uint8_t*)&equipment_hdr; |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
148 | memset(dst, 0, sizeof(equipment_hdr)); |
101
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
149 | // Update the header with new sizes |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
150 | equipment_hdr.version = EQUIPMENT_VERSION; |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
151 | equipment_hdr.hdrsize = sizeof(equipment_hdr); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
152 | equipment_hdr.recsize = sizeof(equipment); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
153 | bytes = fwrite(dst, 1, sizeof(equipment_hdr), nf); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
154 | |
101
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
155 | dst = (uint8_t*)&equipment; |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
156 | while ((bytes = fread(dst, 1, oldsize, f))) { |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
157 | // Upgrade data here |
101
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
158 | equipment.Hendi = false; |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
159 | equipment.RampPower = equipment.BoilPower; |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
160 | equipment.Max_watt = 3000; |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
161 | bytes = fwrite(dst, 1, sizeof(equipment), nf); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
162 | if (bytes != sizeof(equipment)) { |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
163 | ESP_LOGE(TAG, "/spiffs/etc/equipments.new write data, %d/%d bytes", bytes, sizeof(equipment)); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
164 | } |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
165 | } |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
166 | fclose(nf); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
167 | fclose(f); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
168 | rename("/spiffs/etc/equipments.conf", "/spiffs/etc/equipments.old"); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
169 | rename("/spiffs/etc/equipments.new", "/spiffs/etc/equipments.conf"); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
170 | unlink("/spiffs/etc/equipments.old"); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
171 | f = fopen("/spiffs/etc/equipments.conf", "r"); |
101
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
172 | dst = (uint8_t*)&equipment_hdr; |
1bc6e9263ada
Fixed HendiControl interface connecter to match the board input. Tested the new circuit.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
173 | fread(dst, 1, sizeof(equipment_hdr), f); |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
174 | } |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
175 | #endif |
0 | 176 | dst = (uint8_t*)&equipment; |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
177 | fseek(f, (RecNo - 1) * equipment_hdr.recsize + equipment_hdr.hdrsize, SEEK_SET); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
178 | bytes = fread(dst, 1, equipment_hdr.recsize, f); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
179 | fclose(f); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
180 | if (bytes != equipment_hdr.recsize) { |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
181 | ESP_LOGE(TAG, "/spiffs/etc/equipments.conf read record %d, %d/%d bytes", RecNo, bytes, equipment_hdr.recsize); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
182 | } else { |
120
afd58d4c7b5b
Version 0.3.20 fix for equipment records create and delete.
Michiel Broek <mbroek@mbse.eu>
parents:
119
diff
changeset
|
183 | ESP_LOGI(TAG, "/spiffs/etc/equipments.conf read %d bytes, record %d: %s", bytes, RecNo, equipment.Name); |
0 | 184 | } |
185 | } | |
186 | } | |
187 | ||
188 | ||
189 | ||
190 | void write_equipment(int RecNo) | |
191 | { | |
192 | uint8_t *dst = (uint8_t *)&equipment; | |
193 | FILE *f; | |
194 | ||
195 | f = fopen("/spiffs/etc/equipments.conf", "r+"); | |
196 | if (f == NULL) { | |
120
afd58d4c7b5b
Version 0.3.20 fix for equipment records create and delete.
Michiel Broek <mbroek@mbse.eu>
parents:
119
diff
changeset
|
197 | ESP_LOGE(TAG, "/spiffs/etc/equipments.conf write failed"); |
0 | 198 | return; |
199 | } | |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
200 | fseek(f, (RecNo - 1) * equipment_hdr.recsize + equipment_hdr.hdrsize, SEEK_SET); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
201 | size_t bytes = fwrite(dst, 1, equipment_hdr.recsize, f); |
0 | 202 | fclose(f); |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
203 | if (bytes != equipment_hdr.recsize) |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
204 | ESP_LOGE(TAG, "/spiffs/etc/equipments.conf write record %d, %d/%d bytes", RecNo, bytes, equipment_hdr.recsize); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
205 | else |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
206 | ESP_LOGI(TAG, "/spiffs/etc/equipments.conf update record %d, %d bytes", RecNo, bytes); |
0 | 207 | } |
208 | ||
209 | ||
210 | ||
211 | void delete_equipment(int RecNo) | |
212 | { | |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
213 | int RecRead = 1, RecWrite = 1; |
0 | 214 | FILE *n, *o; |
215 | uint8_t *dst; | |
216 | size_t bytes; | |
217 | ||
218 | n = fopen("/spiffs/etc/equipments.new", "a"); | |
219 | if (n == NULL) { | |
120
afd58d4c7b5b
Version 0.3.20 fix for equipment records create and delete.
Michiel Broek <mbroek@mbse.eu>
parents:
119
diff
changeset
|
220 | ESP_LOGE(TAG, "/spiffs/etc/equipments.new create error"); |
0 | 221 | return; |
222 | } | |
223 | o = fopen("/spiffs/etc/equipments.conf", "r"); | |
224 | if (o == NULL) { | |
120
afd58d4c7b5b
Version 0.3.20 fix for equipment records create and delete.
Michiel Broek <mbroek@mbse.eu>
parents:
119
diff
changeset
|
225 | ESP_LOGE(TAG, "/spiffs/etc/equipments.conf open error"); |
0 | 226 | fclose(n); |
120
afd58d4c7b5b
Version 0.3.20 fix for equipment records create and delete.
Michiel Broek <mbroek@mbse.eu>
parents:
119
diff
changeset
|
227 | unlink("/spiffs/etc/equipments.new"); |
0 | 228 | return; |
229 | } | |
230 | ||
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
231 | dst = (uint8_t*)&equipment_hdr; |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
232 | fread(dst, 1, equipment_hdr.hdrsize, o); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
233 | fwrite(dst, 1, equipment_hdr.hdrsize, n); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
234 | |
0 | 235 | dst = (uint8_t*)&equipment; |
236 | while (true) { | |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
237 | bytes = fread(dst, 1, equipment_hdr.recsize, o); |
0 | 238 | if (bytes == 0) |
239 | break; | |
240 | ||
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
241 | if (RecRead != RecNo) { |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
242 | // Record to copy |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
243 | if ((config.EquipmentRec == RecRead) && (config.EquipmentRec != RecWrite)) { |
0 | 244 | // We need to change the default record. |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
245 | config.EquipmentRec = RecWrite; |
0 | 246 | write_config(); |
247 | } | |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
248 | fwrite(dst, 1, equipment_hdr.recsize, n); |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
249 | RecWrite++; |
0 | 250 | } |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
251 | RecRead++; |
0 | 252 | } |
253 | fclose(o); | |
254 | fclose(n); | |
255 | ||
256 | rename("/spiffs/etc/equipments.conf", "/spiffs/etc/equipments.old"); | |
257 | rename("/spiffs/etc/equipments.new", "/spiffs/etc/equipments.conf"); | |
258 | unlink("/spiffs/etc/equipments.old"); | |
120
afd58d4c7b5b
Version 0.3.20 fix for equipment records create and delete.
Michiel Broek <mbroek@mbse.eu>
parents:
119
diff
changeset
|
259 | ESP_LOGI(TAG, "Deleted equipment %d, %d left", RecNo, RecWrite - 1); |
0 | 260 | } |
261 | ||
262 | ||
263 | ||
264 | int add_station(uint8_t *SSID, uint8_t *Password) | |
265 | { | |
266 | FILE *f; | |
267 | uint8_t *dst = (uint8_t *)&wifiStation; | |
268 | ||
269 | if (read_station(SSID) >= 0) { | |
270 | ESP_LOGE(TAG, "add_station %s already excists", SSID); | |
271 | return -1; | |
272 | } | |
273 | ||
274 | f = fopen("/spiffs/etc/stations.conf", "a+"); | |
275 | if (f == NULL) { | |
276 | ESP_LOGE(TAG, "write /spiffs/etc/stations.conf failed"); | |
277 | return -1; | |
278 | } | |
279 | memset(dst, 0, sizeof(wifiStation)); | |
280 | sprintf(wifiStation.SSID, "%s", (char *)SSID); | |
281 | sprintf(wifiStation.Password, "%s", (char *)Password); | |
282 | wifiStation.hide = false; | |
283 | fwrite(dst, 1, sizeof(wifiStation), f); | |
284 | fclose(f); | |
285 | ||
286 | ESP_LOGI(TAG, "add_station %s record: %d", (char *)SSID, read_station(SSID)); | |
287 | /* Return the record number */ | |
288 | return read_station(SSID); | |
289 | } | |
290 | ||
291 | ||
292 | ||
293 | int read_station(uint8_t *SSID) | |
294 | { | |
295 | uint8_t *dst = (uint8_t *)&wifiStation; | |
296 | static int rc; | |
297 | FILE *f; | |
298 | size_t bytes; | |
299 | ||
300 | if ((SSID == NULL) || (strlen((char *)SSID) == 0)) { | |
301 | ESP_LOGI(TAG, "read_station(NULL)"); | |
302 | return -1; | |
303 | } | |
304 | ||
305 | memset(dst, 0, sizeof(wifiStation)); | |
306 | f = fopen("/spiffs/etc/stations.conf", "r+"); | |
307 | if (f == NULL) { | |
308 | f = fopen("/spiffs/etc/stations.conf", "w+"); | |
309 | fclose(f); | |
310 | ESP_LOGI(TAG, "/spiffs/etc/stations.conf created, return -1"); | |
311 | return -1; | |
312 | } | |
313 | ||
314 | rc = 0; | |
315 | fseek(f, 0, SEEK_SET); | |
316 | ||
317 | while (1) { | |
318 | bytes = fread(dst, 1, sizeof(wifiStation), f); | |
319 | if (bytes < sizeof(wifiStation)) { | |
320 | fclose(f); | |
321 | memset(dst, 0, sizeof(wifiStation)); | |
322 | return -1; | |
323 | } | |
324 | if (strcmp(wifiStation.SSID, (char *)SSID) == 0) { | |
325 | // Fount it | |
326 | fclose(f); | |
327 | return rc; | |
328 | } | |
329 | rc++; | |
330 | } | |
331 | return -1; | |
332 | } | |
333 | ||
334 | ||
335 | ||
336 | void remove_station(uint8_t *SSID) | |
337 | { | |
338 | FILE *n, *o; | |
339 | uint8_t *dst; | |
340 | size_t bytes; | |
341 | ||
342 | n = fopen("/spiffs/etc/stations.new", "a"); | |
343 | if (n == NULL) { | |
344 | ESP_LOGE(TAG, "cannot create /spiffs/etc/stations.new"); | |
345 | return; | |
346 | } | |
347 | o = fopen("/spiffs/etc/stations.conf", "r"); | |
348 | if (o == NULL) { | |
349 | ESP_LOGE(TAG, "cannot open spiffs/etc/stations.conf for reading"); | |
350 | fclose(n); | |
351 | return; | |
352 | } | |
353 | ||
354 | dst = (uint8_t*)&wifiStation; | |
355 | while (true) { | |
356 | bytes = fread(dst, 1, sizeof(wifiStation), o); | |
357 | if (bytes == 0) | |
358 | break; | |
359 | ||
360 | if ((strcmp((char *)SSID, wifiStation.SSID) == 0) || (strlen(wifiStation.SSID) == 0)) { | |
361 | // Record to delete, don't copy | |
362 | } else { | |
363 | fwrite(dst, 1, sizeof(wifiStation), n); | |
364 | } | |
365 | } | |
366 | fclose(o); | |
367 | fclose(n); | |
368 | ||
369 | rename("/spiffs/etc/stations.conf", "/spiffs/etc/stations.old"); | |
370 | rename("/spiffs/etc/stations.new", "/spiffs/etc/stations.conf"); | |
371 | unlink("/spiffs/etc/stations.old"); | |
372 | } | |
373 | ||
374 | ||
375 | ||
376 | void write_runtime() | |
377 | { | |
378 | uint8_t *dst = (uint8_t *)&runtime; | |
379 | FILE *f = fopen("/spiffs/etc/runtime.conf", "w+"); | |
380 | ||
381 | if (f == NULL) { | |
382 | ESP_LOGE(TAG, "write /spiffs/etc/runtime.conf failed"); | |
383 | return; | |
384 | } | |
385 | ||
386 | size_t bytes = fwrite(dst, 1, sizeof(runtime), f); | |
387 | fclose(f); | |
57
6c5211c0120b
Version 0.3.3. Added favicon.ico to the web server. Fixed text position in the http client for the power percentage. Silenced a lot of log messages. Moved the pump led on the display to the left just as on the web page.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
388 | if (bytes != sizeof(runtime)) { |
6c5211c0120b
Version 0.3.3. Added favicon.ico to the web server. Fixed text position in the http client for the power percentage. Silenced a lot of log messages. Moved the pump led on the display to the left just as on the web page.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
389 | ESP_LOGE(TAG, "/spiffs/etc/runtime.conf written %d/%d bytes", bytes, sizeof(runtime)); |
6c5211c0120b
Version 0.3.3. Added favicon.ico to the web server. Fixed text position in the http client for the power percentage. Silenced a lot of log messages. Moved the pump led on the display to the left just as on the web page.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
390 | } |
0 | 391 | } |
392 | ||
393 | ||
394 | ||
395 | void read_runtime() | |
396 | { | |
397 | uint8_t *dst; | |
398 | FILE *f = fopen("/spiffs/etc/runtime.conf", "r"); | |
399 | ||
400 | if (f == NULL) { | |
401 | // No runtime yet, create it. | |
402 | runtime.Version = 1; | |
403 | runtime.AutoModeStarted = false; | |
404 | runtime.StageResume = 0; | |
405 | runtime.StageTimeLeft = 0; | |
406 | runtime.HopAddition = 0; | |
407 | runtime.ManualMLT = 45.0; | |
408 | runtime.ManualHLT = 45.0; | |
409 | runtime.BrewStart = (time_t)0; | |
410 | runtime.Logfile[0] = '\0'; | |
411 | runtime.PumpCooling = false; | |
412 | runtime.TimeBrewing = 0; | |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
413 | runtime.MashStep = 0; |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
414 | runtime.MLT_usage = 0; |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
415 | runtime.HLT_usage = 0; |
0 | 416 | write_runtime(); |
417 | } else { | |
418 | dst = (uint8_t*)&runtime; | |
419 | size_t bytes = fread(dst, 1, sizeof(runtime), f); | |
420 | fclose(f); | |
57
6c5211c0120b
Version 0.3.3. Added favicon.ico to the web server. Fixed text position in the http client for the power percentage. Silenced a lot of log messages. Moved the pump led on the display to the left just as on the web page.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
421 | if (bytes != sizeof(runtime)) { |
6c5211c0120b
Version 0.3.3. Added favicon.ico to the web server. Fixed text position in the http client for the power percentage. Silenced a lot of log messages. Moved the pump led on the display to the left just as on the web page.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
422 | ESP_LOGE(TAG, "/spiffs/etc/runtime.conf read %d/%d bytes", bytes, sizeof(runtime)); |
87
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
423 | runtime.MLT_usage = 0; |
47253f294a9f
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
424 | runtime.HLT_usage = 0; |
57
6c5211c0120b
Version 0.3.3. Added favicon.ico to the web server. Fixed text position in the http client for the power percentage. Silenced a lot of log messages. Moved the pump led on the display to the left just as on the web page.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
425 | } |
0 | 426 | #if 0 |
427 | printf("Auto started %s\n", runtime.AutoModeStarted ? "yes":"no"); | |
428 | printf("Stage resume %d\n", runtime.StageResume); | |
429 | printf("Stage time left %d\n", runtime.StageTimeLeft); | |
430 | printf("Hop addition %d\n", runtime.HopAddition); | |
431 | printf("Brew start %d\n", (int)runtime.BrewStart); | |
432 | printf("Log file %s\n", runtime.Logfile); | |
433 | printf("Pump cooling %s\n", runtime.PumpCooling ? "yes":"no"); | |
434 | printf("Time brewing %d\n", runtime.TimeBrewing); | |
435 | #endif | |
436 | } | |
437 | } | |
438 | ||
439 | ||
440 | ||
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
441 | void append_recipe() |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
442 | { |
0 | 443 | uint8_t *dst = (uint8_t *)&recipe; |
444 | FILE *f = fopen("/spiffs/etc/recipe.conf", "a"); | |
445 | ||
446 | if (f == NULL) { | |
447 | ESP_LOGE(TAG, "append /spiffs/etc/recipe.conf failed"); | |
448 | return; | |
449 | } | |
450 | ||
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
451 | size_t bytes = fwrite(dst, 1, recipe_hdr.recsize, f); |
0 | 452 | fclose(f); |
453 | ESP_LOGI(TAG, "/spiffs/etc/recipe.conf appended %d bytes", bytes); | |
454 | } | |
455 | ||
456 | ||
457 | ||
458 | void write_recipe(int RecNo) | |
459 | { | |
460 | uint8_t *dst = (uint8_t *)&recipe; | |
461 | FILE *f = fopen("/spiffs/etc/recipe.conf", "r+"); | |
462 | ||
463 | if (f == NULL) { | |
464 | ESP_LOGE(TAG, "write /spiffs/etc/recipe.conf failed"); | |
465 | return; | |
466 | } | |
467 | ||
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
468 | fseek(f, (RecNo - 1) * recipe_hdr.recsize + recipe_hdr.hdrsize, SEEK_SET); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
469 | size_t bytes = fwrite(dst, 1, recipe_hdr.recsize, f); |
0 | 470 | fclose(f); |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
471 | if (bytes != recipe_hdr.recsize) { |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
472 | ESP_LOGE(TAG, "/spiffs/etc/recipe.conf write record %d, %d/%d bytes", RecNo, bytes, recipe_hdr.recsize); |
57
6c5211c0120b
Version 0.3.3. Added favicon.ico to the web server. Fixed text position in the http client for the power percentage. Silenced a lot of log messages. Moved the pump led on the display to the left just as on the web page.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
473 | } |
0 | 474 | } |
475 | ||
476 | ||
477 | ||
478 | void read_recipe(int RecNo) | |
479 | { | |
480 | uint8_t *dst; | |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
481 | size_t bytes; |
0 | 482 | FILE *f = fopen("/spiffs/etc/recipe.conf", "r"); |
483 | ||
484 | 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
|
485 | // No recipe yet, create it. |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
486 | dst = (uint8_t*)&recipe_hdr; |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
487 | memset(dst, 0, sizeof(recipe_hdr)); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
488 | recipe_hdr.version = RECIPE_VERSION; |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
489 | recipe_hdr.hdrsize = sizeof(recipe_hdr); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
490 | recipe_hdr.recsize = sizeof(recipe); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
491 | recipe_hdr.mashmax = MASH_MAX; |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
492 | recipe_hdr.additionmax = ADDITION_MAX; |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
493 | f = fopen("/spiffs/etc/recipe.conf", "w"); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
494 | bytes = fwrite(dst, 1, sizeof(recipe_hdr), f); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
495 | if (bytes != sizeof(recipe_hdr)) { |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
496 | ESP_LOGE(TAG, "/spiffs/etc/recipe.conf write header, %d/%d bytes", bytes, sizeof(recipe_hdr)); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
497 | } |
0 | 498 | dst = (uint8_t*)&recipe; |
499 | memset(dst, 0, sizeof(recipe)); | |
500 | sprintf(recipe.Name, "Recipe 1"); | |
501 | sprintf(recipe.Code, "001"); | |
502 | 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
|
503 | recipe.MashStep[0].Type = MASHTYPE_INFUSION; |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
504 | recipe.MashStep[0].Step_temp = recipe.MashStep[0].End_temp = recipe.MashStep[0].Infuse_temp = 67.5; |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
505 | recipe.MashStep[0].Infuse_amount = 15.0; |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
506 | recipe.MashStep[0].Step_time = 1; |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
507 | recipe.MashStep[0].Ramp_time = 1; |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
508 | for (int i = 1; i < MASH_MAX; i++) |
19 | 509 | recipe.MashStep[i].Type = MASHTYPE_TEMPERATURE; |
0 | 510 | sprintf(recipe.MashStep[1].Name, "Mash"); |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
511 | recipe.MashStep[1].Step_temp = recipe.MashStep[1].End_temp = 67.0; |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
512 | recipe.MashStep[1].Step_time = 75; |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
513 | recipe.MashStep[1].Ramp_time = 1; |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
514 | sprintf(recipe.MashStep[2].Name, "Mash-out"); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
515 | recipe.MashStep[2].Step_temp = recipe.MashStep[2].End_temp = 78.0; |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
516 | recipe.MashStep[2].Step_time = 5; |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
517 | recipe.MashStep[2].Ramp_time = 11; |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
518 | recipe.Mashsteps = 3; |
0 | 519 | recipe.BoilTime = 60; |
520 | recipe.Additions = 2; | |
521 | sprintf(recipe.Addition[0].Name, "Hop"); | |
522 | recipe.Addition[0].Time = 60; | |
523 | recipe.Addition[0].Type = ADDITION_HOP; | |
524 | sprintf(recipe.Addition[1].Name, "Hop"); | |
525 | recipe.Addition[1].Time = 10; | |
526 | recipe.Addition[1].Type = ADDITION_HOP; | |
527 | recipe.CoolTemp = 20.0; | |
528 | recipe.Whirlpool9 = 0; | |
529 | recipe.Whirlpool7 = 0; | |
530 | recipe.Whirlpool6 = 0; | |
531 | recipe.Whirlpool2 = 0; | |
532 | recipe.SpargeTemp = 85.0; | |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
533 | bytes = fwrite(dst, 1, sizeof(recipe), f); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
534 | fclose(f); |
0 | 535 | } else { |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
536 | /* |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
537 | * Try to read the new file header |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
538 | */ |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
539 | dst = (uint8_t*)&recipe_hdr; |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
540 | fseek(f, 0, SEEK_SET); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
541 | bytes = fread(dst, 1, sizeof(recipe_hdr), f); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
542 | if (bytes != sizeof(recipe_hdr)) { |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
543 | ESP_LOGE(TAG, "/spiffs/etc/recipe.conf read header, %d/%d bytes", bytes, sizeof(recipe_hdr)); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
544 | fclose(f); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
545 | return; |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
546 | } |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
547 | /* |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
548 | if (recipe_hdr.version < RECIPE_VERSION) { |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
549 | FILE *nf = fopen("/spiffs/etc/recipe.new", "w"); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
550 | |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
551 | ESP_LOGI(TAG, "/spiffs/etc/recipe.conf version %d, new %d", recipe_hdr.version, RECIPE_VERSION); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
552 | |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
553 | fseek(f, recipe_hdr.hdrsize, SEEK_SET); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
554 | dst = (uint8_t*)&recipe; |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
555 | while ((bytes = fread(dst, 1, recipe_hdr.recsize, f))) { |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
556 | |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
557 | // Upgrade data here |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
558 | bytes = fwrite(dst, 1, sizeof(recipe), nf); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
559 | if (bytes != sizeof(recipe)) { |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
560 | ESP_LOGE(TAG, "/spiffs/etc/recipe.new write data, %d/%d bytes", bytes, sizeof(recipe)); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
561 | } |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
562 | } |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
563 | // Update the header with new sizes |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
564 | fclose(nf); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
565 | fclose(f); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
566 | rename("/spiffs/etc/recipe.conf", "/spiffs/etc/recipe.old"); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
567 | rename("/spiffs/etc/recipe.new", "/spiffs/etc/recipe.conf"); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
568 | unlink("/spiffs/etc/recipe.old"); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
569 | f = fopen("/spiffs/etc/recipe.conf", "r"); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
570 | } |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
571 | */ |
0 | 572 | dst = (uint8_t*)&recipe; |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
573 | fseek(f, (RecNo - 1) * recipe_hdr.recsize + recipe_hdr.hdrsize, SEEK_SET); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
574 | bytes = fread(dst, 1, sizeof(recipe), f); |
0 | 575 | fclose(f); |
57
6c5211c0120b
Version 0.3.3. Added favicon.ico to the web server. Fixed text position in the http client for the power percentage. Silenced a lot of log messages. Moved the pump led on the display to the left just as on the web page.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
576 | if (bytes != sizeof(recipe)) { |
6c5211c0120b
Version 0.3.3. Added favicon.ico to the web server. Fixed text position in the http client for the power percentage. Silenced a lot of log messages. Moved the pump led on the display to the left just as on the web page.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
577 | ESP_LOGE(TAG, "/spiffs/etc/recipe.conf read record %d, %d/%d bytes", RecNo, bytes, sizeof(recipe)); |
6c5211c0120b
Version 0.3.3. Added favicon.ico to the web server. Fixed text position in the http client for the power percentage. Silenced a lot of log messages. Moved the pump led on the display to the left just as on the web page.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
578 | } |
0 | 579 | } |
580 | } | |
581 | ||
582 | ||
583 | ||
584 | void delete_recipe(int RecNo) | |
585 | { | |
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
|
586 | int RecRead = 1, RecWrite = 1; |
0 | 587 | FILE *n, *o; |
588 | uint8_t *dst; | |
589 | size_t bytes; | |
590 | ||
591 | n = fopen("/spiffs/etc/recipe.new", "a"); | |
592 | if (n == NULL) { | |
593 | ESP_LOGE(TAG, "cannot create /spiffs/etc/recipe.new"); | |
594 | return; | |
595 | } | |
596 | o = fopen("/spiffs/etc/recipe.conf", "r"); | |
597 | if (o == NULL) { | |
598 | ESP_LOGE(TAG, "cannot open spiffs/etc/recipe.conf for reading"); | |
599 | fclose(n); | |
600 | return; | |
601 | } | |
602 | ||
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
603 | dst = (uint8_t*)&recipe_hdr; |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
604 | fread(dst, 1, recipe_hdr.hdrsize, o); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
605 | fwrite(dst, 1, recipe_hdr.hdrsize, n); |
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
606 | |
0 | 607 | dst = (uint8_t*)&recipe; |
608 | while (true) { | |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
609 | bytes = fread(dst, 1, recipe_hdr.recsize, o); |
0 | 610 | if (bytes == 0) |
611 | break; | |
612 | ||
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
|
613 | 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
|
614 | // 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
|
615 | if ((config.RecipeRec == RecRead) && (config.RecipeRec != RecWrite)) { |
0 | 616 | // 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
|
617 | config.RecipeRec = RecWrite; |
0 | 618 | write_config(); |
619 | } | |
77
66c77497d86d
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
620 | fwrite(dst, 1, recipe_hdr.recsize, 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
|
621 | RecWrite++; |
0 | 622 | } |
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
|
623 | RecRead++; |
0 | 624 | } |
625 | fclose(o); | |
626 | fclose(n); | |
627 | ||
628 | rename("/spiffs/etc/recipe.conf", "/spiffs/etc/recipe.old"); | |
629 | rename("/spiffs/etc/recipe.new", "/spiffs/etc/recipe.conf"); | |
630 | 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
|
631 | ESP_LOGI(TAG, "Deleted recipe %d", RecNo); |
0 | 632 | } |
633 | ||
634 |