600 j++; |
601 j++; |
601 srv_send((char *)"%s,%s,%d,%d", profile->uuid, profile->name, j, profile->busy); |
602 srv_send((char *)"%s,%s,%d,%d", profile->uuid, profile->name, j, profile->busy); |
602 } |
603 } |
603 srv_send((char *)"."); |
604 srv_send((char *)"."); |
604 return 0; |
605 return 0; |
605 } |
|
606 |
|
607 srv_send((char *)"502 Unknown command option"); |
|
608 return 1; |
|
609 } |
|
610 |
|
611 |
|
612 |
|
613 /* |
|
614 * Set new operating mode |
|
615 * MODE OFF|NONE|BEER|FRIDGE|PROFILE |
|
616 */ |
|
617 int cmd_mode(char *buf) |
|
618 { |
|
619 char *opt; |
|
620 units_list *unit; |
|
621 |
|
622 opt = strtok(buf, " \0"); |
|
623 opt = strtok(NULL, "\0"); |
|
624 |
|
625 if (opt == NULL) { |
|
626 srv_send((char *)"502 Missing command option"); |
|
627 return 1; |
|
628 } |
|
629 |
|
630 if (current_unit == NULL) { |
|
631 srv_send((char *)"401 No fermenter unit selected"); |
|
632 return 1; |
|
633 } |
|
634 for (unit = Config.units; unit; unit = unit->next) { |
|
635 if (strcmp(current_unit, unit->uuid) == 0) |
|
636 break; |
|
637 } |
|
638 |
|
639 if (strcmp(opt, (char *)"OFF") == 0) { |
|
640 if (unit->mode != UNITMODE_OFF) { |
|
641 unit->mode = UNITMODE_OFF; |
|
642 syslog(LOG_NOTICE, "Unit %s mode set to OFF", unit->name); |
|
643 } |
|
644 srv_send((char *)"218 Unit mode to OFF"); |
|
645 return 0; |
|
646 |
|
647 } else if (strcmp(opt, (char *)"NONE") == 0) { |
|
648 if (unit->mode != UNITMODE_NONE) { |
|
649 unit->mode = UNITMODE_NONE; |
|
650 syslog(LOG_NOTICE, "Unit %s mode set to NONE", unit->name); |
|
651 initlog(unit->name); |
|
652 } |
|
653 srv_send((char *)"218 Unit mode to NONE"); |
|
654 return 0; |
|
655 |
|
656 } else if (strcmp(opt, (char *)"FRIDGE") == 0) { |
|
657 |
|
658 } else if (strcmp(opt, (char *)"BEER") == 0) { |
|
659 |
|
660 } else if (strcmp(opt, (char *)"PROFILE") == 0) { |
|
661 |
|
662 } |
606 } |
663 |
607 |
664 srv_send((char *)"502 Unknown command option"); |
608 srv_send((char *)"502 Unknown command option"); |
665 return 1; |
609 return 1; |
666 } |
610 } |
1287 for (i = 0; i < 5; i++) { |
1231 for (i = 0; i < 5; i++) { |
1288 if (strcmp(val, UNITMODE[i]) == 0) { |
1232 if (strcmp(val, UNITMODE[i]) == 0) { |
1289 unit->mode = i; |
1233 unit->mode = i; |
1290 /* Allways turn everything off after a mode change */ |
1234 /* Allways turn everything off after a mode change */ |
1291 unit->heater_state = unit->cooler_state = unit->fan_state = 0; |
1235 unit->heater_state = unit->cooler_state = unit->fan_state = 0; |
|
1236 device_out(unit->heater_address, unit->heater_state); |
|
1237 device_out(unit->cooler_address, unit->cooler_state); |
|
1238 device_out(unit->fan_address, unit->fan_state); |
1292 break; |
1239 break; |
1293 } |
1240 } |
1294 } |
1241 } |
1295 |
1242 |
1296 } else if (val && (strcmp(kwd, (char *)"FRIDGE_SET") == 0)) { |
1243 } else if (val && (strcmp(kwd, (char *)"FRIDGE_SET") == 0)) { |
1410 srv_send((char *)"DEVICE PUT uuid Put Device record by uuid"); |
1357 srv_send((char *)"DEVICE PUT uuid Put Device record by uuid"); |
1411 srv_send((char *)"LCD Get LCD screen (allways 4 rows of 20 characters)"); |
1358 srv_send((char *)"LCD Get LCD screen (allways 4 rows of 20 characters)"); |
1412 srv_send((char *)"LIST List all fermenter units"); |
1359 srv_send((char *)"LIST List all fermenter units"); |
1413 srv_send((char *)"LIST LOG List logfile data in 1 hour lines"); |
1360 srv_send((char *)"LIST LOG List logfile data in 1 hour lines"); |
1414 srv_send((char *)"LIST PROFILES List available profiles"); |
1361 srv_send((char *)"LIST PROFILES List available profiles"); |
1415 srv_send((char *)"MODE OFF|NONE|BEER|FRIDGE|PROFILE"); |
|
1416 // srv_send((char *)"PROFILE Profile status of current unit"); |
1362 // srv_send((char *)"PROFILE Profile status of current unit"); |
1417 srv_send((char *)"PROFILE uuid,name Profile rename"); |
1363 srv_send((char *)"PROFILE uuid,name Profile rename"); |
1418 srv_send((char *)"PROFILE GETS uuid Profile get steps list"); |
1364 srv_send((char *)"PROFILE GETS uuid Profile get steps list"); |
1419 srv_send((char *)"PROFILE PUTS uuid Profile put steps list"); |
1365 srv_send((char *)"PROFILE PUTS uuid Profile put steps list"); |
1420 srv_send((char *)"SET PROFILE uuid Set unit profile"); |
1366 srv_send((char *)"SET PROFILE uuid Set unit profile"); |
1441 #else |
1387 #else |
1442 srv_send((char *)"403 LCD not available"); |
1388 srv_send((char *)"403 LCD not available"); |
1443 #endif |
1389 #endif |
1444 } else if (strncmp(buf, "LIST", 4) == 0) { |
1390 } else if (strncmp(buf, "LIST", 4) == 0) { |
1445 cmd_list(buf); |
1391 cmd_list(buf); |
1446 } else if (strncmp(buf, "MODE", 4) == 0) { |
|
1447 if (cmd_mode(buf) == 0) |
|
1448 wrconfig(); |
|
1449 } else if (strncmp(buf, "PROFILE", 7) == 0) { |
1392 } else if (strncmp(buf, "PROFILE", 7) == 0) { |
1450 if (cmd_profile(buf) == 0) |
1393 if (cmd_profile(buf) == 0) |
1451 wrconfig(); |
1394 wrconfig(); |
1452 } else if (strncmp(buf, "SET", 3) == 0) { |
1395 } else if (strncmp(buf, "SET", 3) == 0) { |
1453 if (cmd_set(buf) == 0) |
1396 if (cmd_set(buf) == 0) |