thermferm/server.c

changeset 170
3cb99272b84b
parent 167
56b008563db8
child 174
244de612c572
equal deleted inserted replaced
169:47358c2cc285 170:3cb99272b84b
278 278
279 279
280 /* 280 /*
281 * GET AIR uuid 281 * GET AIR uuid
282 * GET BEER uuid 282 * GET BEER uuid
283 * GET LED1 uuid
284 * GET LED2 uuid
285 * GET LED3 uuid
286 * GET MODE uuid
283 * GET TARGET uuid 287 * GET TARGET uuid
284 */ 288 */
285 int cmd_get(char *buf) 289 int cmd_get(char *buf)
286 { 290 {
287 char *opt, *uuid; 291 char *opt, *uuid;
303 if (unit->air_state == 0) 307 if (unit->air_state == 0)
304 srv_send((char *)"215 AIR,%.3f", unit->air_temperature / 1000.0); 308 srv_send((char *)"215 AIR,%.3f", unit->air_temperature / 1000.0);
305 else 309 else
306 srv_send((char *)"215 AIR,NA"); 310 srv_send((char *)"215 AIR,NA");
307 return 0; 311 return 0;
312
308 } else if (strcmp(opt, (char *)"BEER") == 0) { 313 } else if (strcmp(opt, (char *)"BEER") == 0) {
309 if (unit->beer_state == 0) 314 if (unit->beer_state == 0)
310 srv_send((char *)"215 BEER,%.3f", unit->beer_temperature / 1000.0); 315 srv_send((char *)"215 BEER,%.3f", unit->beer_temperature / 1000.0);
311 else 316 else
312 srv_send((char *)"215 BEER,NA"); 317 srv_send((char *)"215 BEER,NA");
313 return 0; 318 return 0;
319
320 } else if (strcmp(opt, (char *)"LED1") == 0) {
321 srv_send((char *)"215 HEATER,%d", (unit->heater_available && unit->heater_state) ? 1:0);
322 return 0;
323
324 } else if (strcmp(opt, (char *)"LED2") == 0) {
325 srv_send((char *)"215 COOLER,%d", (unit->cooler_available && unit->cooler_state) ? 1:0);
326 return 0;
327
328 } else if (strcmp(opt, (char *)"LED3") == 0) {
329 srv_send((char *)"215 FAN,%d", (unit->fan_available && unit->fan_state) ? 1:0);
330 return 0;
331
332 } else if (strcmp(opt, (char *)"MODE") == 0) {
333 srv_send((char *)"215 MODE,%s", UNITMODE[unit->mode]);
334 return 0;
335
314 } else if (strcmp(opt, (char *)"TARGET") == 0) { 336 } else if (strcmp(opt, (char *)"TARGET") == 0) {
315 if (unit->mode == UNITMODE_BEER) { 337 if (unit->mode == UNITMODE_BEER) {
316 srv_send((char *)"215 TARGET,%.3f", unit->beer_set); 338 srv_send((char *)"215 TARGET,%.3f", unit->beer_set);
317 } else if (unit->mode == UNITMODE_FRIDGE) { 339 } else if (unit->mode == UNITMODE_FRIDGE) {
318 srv_send((char *)"215 TARGET,%.3f", unit->fridge_set); 340 srv_send((char *)"215 TARGET,%.3f", unit->fridge_set);
463 if (unit->io2_address) { 485 if (unit->io2_address) {
464 srv_send((char *)"IO2_ADDRESS,%s", unit->io2_address); 486 srv_send((char *)"IO2_ADDRESS,%s", unit->io2_address);
465 } 487 }
466 if (unit->heater_available) { 488 if (unit->heater_available) {
467 srv_send((char *)"HEATER_AVAILABLE,%s", unit->heater_available); 489 srv_send((char *)"HEATER_AVAILABLE,%s", unit->heater_available);
490 srv_send((char *)"HEATER_STATE,%d", unit->heater_state);
468 } 491 }
469 if (unit->cooler_available) { 492 if (unit->cooler_available) {
470 srv_send((char *)"COOLER_AVAILABLE,%s", unit->cooler_available); 493 srv_send((char *)"COOLER_AVAILABLE,%s", unit->cooler_available);
494 srv_send((char *)"COOLER_STATE,%d", unit->cooler_state);
471 } 495 }
472 if (unit->fan_available) { 496 if (unit->fan_available) {
473 srv_send((char *)"FAN_AVAILABLE,%s", unit->fan_available); 497 srv_send((char *)"FAN_AVAILABLE,%s", unit->fan_available);
498 srv_send((char *)"FAN_STATE,%d", unit->fan_state);
474 } 499 }
475 srv_send((char *)"MODE,%s", UNITMODE[unit->mode]); 500 srv_send((char *)"MODE,%s", UNITMODE[unit->mode]);
476 srv_send((char *)"FRIDGE_SET,%.1f", unit->fridge_set); 501 srv_send((char *)"FRIDGE_SET,%.1f", unit->fridge_set);
477 srv_send((char *)"BEER_SET,%.1f", unit->beer_set); 502 srv_send((char *)"BEER_SET,%.1f", unit->beer_set);
478 if (unit->profile) { 503 if (unit->profile) {
993 srv_send((char *)"ADD UNIT name Add a new unit with \"name\""); 1018 srv_send((char *)"ADD UNIT name Add a new unit with \"name\"");
994 srv_send((char *)"DEL PROFILE uuid Delete profile with uuid"); 1019 srv_send((char *)"DEL PROFILE uuid Delete profile with uuid");
995 // srv_send((char *)"DEL UNIT uuid Delete unit with uuid"); 1020 // srv_send((char *)"DEL UNIT uuid Delete unit with uuid");
996 srv_send((char *)"GET AIR uuid Get Air temperature with uuid"); 1021 srv_send((char *)"GET AIR uuid Get Air temperature with uuid");
997 srv_send((char *)"GET BEER uuid Get Beer temperature with uuid"); 1022 srv_send((char *)"GET BEER uuid Get Beer temperature with uuid");
998 // srv_send((char *)"GET LED1 uuid Get LED 1 (cooler) state"); 1023 srv_send((char *)"GET LED1 uuid Get LED 1 (cooler) state");
999 // srv_send((char *)"GET LED2 uuid Get LED 2 (heater) state"); 1024 srv_send((char *)"GET LED2 uuid Get LED 2 (heater) state");
1000 // srv_send((char *)"GET LED3 uuid Get LED 3 (fan) state"); 1025 srv_send((char *)"GET LED3 uuid Get LED 3 (fan) state");
1001 // srv_send((char *)"GET DOOR uuid Get Door state"); 1026 srv_send((char *)"GET MODE uuid Get Unit Mode");
1027 // srv_send((char *)"GET SW1 uuid Get Switch 1 (cooler) state");
1028 // srv_send((char *)"GET SW2 uuid Get Switch 2 (heater) state");
1029 // srv_send((char *)"GET SW3 uuid Get Switch 3 (fan) state");
1002 srv_send((char *)"GET TARGET uuid Get Target temperature with uuid"); 1030 srv_send((char *)"GET TARGET uuid Get Target temperature with uuid");
1003 srv_send((char *)"LCD Get LCD screen (allways 4 rows of 20 characters)"); 1031 srv_send((char *)"LCD Get LCD screen (allways 4 rows of 20 characters)");
1004 srv_send((char *)"LIST List all fermenter units"); 1032 srv_send((char *)"LIST List all fermenter units");
1005 srv_send((char *)"LIST BUS List 1-wire bus"); 1033 srv_send((char *)"LIST BUS List 1-wire bus");
1006 srv_send((char *)"LIST LOG List logfile data in 1 hour lines"); 1034 srv_send((char *)"LIST LOG List logfile data in 1 hour lines");

mercurial