thermferm/server.c

changeset 100
012576d7386d
parent 95
2c28afc329a5
child 101
1302abe92eb1
equal deleted inserted replaced
99:5dccd1d8d817 100:012576d7386d
207 */ 207 */
208 srv_send((char *)"212 Fermenter list follows:"); 208 srv_send((char *)"212 Fermenter list follows:");
209 i = 0; 209 i = 0;
210 for (unit = Config.units; unit; unit = unit->next) { 210 for (unit = Config.units; unit; unit = unit->next) {
211 i++; 211 i++;
212 srv_send((char *)"%02d %s %-20s %-7s", i, unit->uuid, unit->name, UNITMODE[unit->mode]); 212 srv_send((char *)"%d,%s,%s,%s", i, unit->uuid, unit->name, UNITMODE[unit->mode]);
213 } 213 }
214 srv_send((char *)"."); 214 srv_send((char *)".");
215 return 0; 215 return 0;
216 216
217 } else if (strcmp(opt, (char *)"BUS") == 0) { 217 } else if (strcmp(opt, (char *)"BUS") == 0) {
221 if ((fd = opendir((char *)"/sys/bus/w1/devices"))) { 221 if ((fd = opendir((char *)"/sys/bus/w1/devices"))) {
222 srv_send((char *)"212 1-wire bus devices:"); 222 srv_send((char *)"212 1-wire bus devices:");
223 while ((de = readdir(fd))) { 223 while ((de = readdir(fd))) {
224 if (de->d_name[0] != '.') { 224 if (de->d_name[0] != '.') {
225 if (strncmp(de->d_name, (char *)"w1", 2) == 0) { 225 if (strncmp(de->d_name, (char *)"w1", 2) == 0) {
226 srv_send((char *)"%-15s system device", de->d_name); 226 srv_send((char *)"%s,N/A,System device", de->d_name);
227 } else if (strncmp(de->d_name, (char *)"10", 2) == 0) { 227 } else if (strncmp(de->d_name, (char *)"10", 2) == 0) {
228 srv_send((char *)"%-15s 18S20 digital thermometer", de->d_name); 228 srv_send((char *)"%s,18S20,Digital thermometer", de->d_name);
229 } else if (strncmp(de->d_name, (char *)"28", 2) == 0) { 229 } else if (strncmp(de->d_name, (char *)"28", 2) == 0) {
230 srv_send((char *)"%-15s 18B20 digital thermometer", de->d_name); 230 srv_send((char *)"%s,18B20,Digital thermometer", de->d_name);
231 } else if (strncmp(de->d_name, (char *)"29", 2) == 0) { 231 } else if (strncmp(de->d_name, (char *)"29", 2) == 0) {
232 srv_send((char *)"%-15s 2408 8-channel addressable switch/LCD", de->d_name); 232 srv_send((char *)"%s,2408,8 Channel addressable switch/LCD", de->d_name);
233 } else if (strncmp(de->d_name, (char *)"3a", 2) == 0) { 233 } else if (strncmp(de->d_name, (char *)"3a", 2) == 0) {
234 srv_send((char *)"%-15s 2413 dual channel addressable switchs", de->d_name); 234 srv_send((char *)"%s,2413,Dual channel addressable switchs", de->d_name);
235 } else { 235 } else {
236 srv_send((char *)"%-15s unknown device", de->d_name); 236 srv_send((char *)"%s,N/A,Unknown device", de->d_name);
237 } 237 }
238 } 238 }
239 } 239 }
240 srv_send((char *)"."); 240 srv_send((char *)".");
241 closedir(fd); 241 closedir(fd);
251 */ 251 */
252 srv_send((char *)"212 profiles:"); 252 srv_send((char *)"212 profiles:");
253 i = 0; 253 i = 0;
254 for (profile = Config.profiles; profile; profile = profile->next) { 254 for (profile = Config.profiles; profile; profile = profile->next) {
255 i++; 255 i++;
256 srv_send((char *)"%02d %s %s", i, profile->uuid, profile->name); 256 srv_send((char *)"%d,%s,%s", i, profile->uuid, profile->name);
257 } 257 }
258 srv_send((char *)"."); 258 srv_send((char *)".");
259 return 0; 259 return 0;
260 260
261 } else if (strcmp(opt, (char *)"UNIT") == 0) { 261 } else if (strcmp(opt, (char *)"UNIT") == 0) {
270 srv_send((char *)"213 Unit %d listing follows:", current_unit); 270 srv_send((char *)"213 Unit %d listing follows:", current_unit);
271 i = 0; 271 i = 0;
272 for (unit = Config.units; unit; unit = unit->next) { 272 for (unit = Config.units; unit; unit = unit->next) {
273 i++; 273 i++;
274 if (i == current_unit) { 274 if (i == current_unit) {
275 srv_send((char *)"Name of the unit/beer %s", unit->name); 275 srv_send((char *)"NAME,%s", unit->name);
276 srv_send((char *)"UUID of this unit %s", unit->uuid); 276 srv_send((char *)"UUID,%s", unit->uuid);
277 if (unit->air_address) { 277 if (unit->air_address) {
278 srv_send((char *)"1-wire address air sensor %s", unit->air_address); 278 srv_send((char *)"AIR_ADDRESS,%s", unit->air_address);
279 srv_send((char *)"Air temperature %.1f", unit->air_temp); 279 srv_send((char *)"AIR_TEMP,%.1f", unit->air_temp);
280 } 280 }
281 if (unit->beer_address) { 281 if (unit->beer_address) {
282 srv_send((char *)"1-wire address beer sensor %s", unit->air_address); 282 srv_send((char *)"BEER_ADDRESS,%s", unit->beer_address);
283 srv_send((char *)"Beer temperature %.1f", unit->air_temp); 283 srv_send((char *)"BEER_TEMP,%.1f", unit->beer_temp);
284 } 284 }
285 if (unit->io1_address) { 285 if (unit->io1_address) {
286 srv_send((char *)"1-wire address cool/heat %s", unit->io1_address); 286 srv_send((char *)"IO1_ADDRESS,%s", unit->io1_address);
287 } 287 }
288 if (unit->io2_address) { 288 if (unit->io2_address) {
289 srv_send((char *)"1-wire address fan/door %s", unit->io2_address); 289 srv_send((char *)"IO2_ADDRESS,%s", unit->io2_address);
290 } 290 }
291 if (unit->heater_available) { 291 if (unit->heater_available) {
292 srv_send((char *)"Heater available %s", unit->heater_available); 292 srv_send((char *)"HEATER_AVAILABLE,%s", unit->heater_available);
293 } 293 }
294 if (unit->cooler_available) { 294 if (unit->cooler_available) {
295 srv_send((char *)"Cooler available %s", unit->cooler_available); 295 srv_send((char *)"COOLER_AVAILABLE,%s", unit->cooler_available);
296 } 296 }
297 if (unit->fan_available) { 297 if (unit->fan_available) {
298 srv_send((char *)"Fan available %s", unit->fan_available); 298 srv_send((char *)"FAN_AVAILABLE,%s", unit->fan_available);
299 } 299 }
300 srv_send((char *)"Unit mode %s", UNITMODE[unit->mode]); 300 srv_send((char *)"MODE,%s", UNITMODE[unit->mode]);
301 srv_send((char *)"Fridge temperature set to %.1f", unit->fridge_set); 301 srv_send((char *)"FRIDGE_SET,%.1f", unit->fridge_set);
302 srv_send((char *)"Beer temperature set to %.1f", unit->beer_set); 302 srv_send((char *)"BEER_SET,%.1f", unit->beer_set);
303 if (unit->profile) { 303 if (unit->profile) {
304 srv_send((char *)"Profile name %s", unit->profile); 304 srv_send((char *)"PROFILE,%s", unit->profile);
305 } 305 }
306 srv_send((char *)"Temperature range %.1f .. %.1f", unit->temp_set_min, unit->temp_set_max); 306 srv_send((char *)"TEMP_SET_MIN,%.1f", unit->temp_set_min);
307 srv_send((char *)"Idle temperature range %.1f .. %.1f", unit->idle_rangeL, unit->idle_rangeH); 307 srv_send((char *)"TEMP_SET_MAX,%.1f", unit->temp_set_max);
308 srv_send((char *)"IDLE_RANGE_L,%.1f", unit->idle_rangeL);
309 srv_send((char *)"IDLE_RANGE_H,%.1f", unit->idle_rangeH);
308 } 310 }
309 } 311 }
310 srv_send((char *)"."); 312 srv_send((char *)".");
311 return 0; 313 return 0;
312 } 314 }

mercurial