thermferm/server.c

changeset 223
14700edd2a67
parent 219
ae720212accc
child 235
885ad8d52126
equal deleted inserted replaced
222:6519fc50f543 223:14700edd2a67
28 #include "xutil.h" 28 #include "xutil.h"
29 29
30 30
31 extern int my_shutdown; 31 extern int my_shutdown;
32 extern int debug; 32 extern int debug;
33 #ifdef HAVE_WIRINGPI_H
34 extern int lcdHandle;
35 extern unsigned char lcdbuf[MAX_LCDS][20][4];
36 #endif
37 extern sys_config Config; 33 extern sys_config Config;
38 extern const char UNITMODE[5][8]; 34 extern const char UNITMODE[5][8];
39 extern const char UNITmode[5]; 35 extern const char UNITmode[5];
40 extern const char TEMPSTATE[3][8]; 36 extern const char TEMPSTATE[3][8];
41 extern const char DEVTYPE[7][6]; 37 extern const char DEVTYPE[7][6];
1330 void cmd_server(void) 1326 void cmd_server(void)
1331 { 1327 {
1332 char buf[SS_BUFSIZE]; 1328 char buf[SS_BUFSIZE];
1333 int i, rlen; 1329 int i, rlen;
1334 socklen_t fromlen; 1330 socklen_t fromlen;
1335 #ifdef HAVE_WIRINGPI_H
1336 int j;
1337 char obuf[SS_BUFSIZE];
1338 #endif
1339 1331
1340 memset((char *)&buf, 0, SS_BUFSIZE); 1332 memset((char *)&buf, 0, SS_BUFSIZE);
1341 fromlen = sizeof(peeraddr_in); 1333 fromlen = sizeof(peeraddr_in);
1342 rlen = recvfrom(s, buf, sizeof(buf) -1, 0, (struct sockaddr *)&peeraddr_in, &fromlen); 1334 rlen = recvfrom(s, buf, sizeof(buf) -1, 0, (struct sockaddr *)&peeraddr_in, &fromlen);
1343 if (rlen == -1) { 1335 if (rlen == -1) {
1380 srv_send((char *)"DEVICE LIST List Devices"); 1372 srv_send((char *)"DEVICE LIST List Devices");
1381 srv_send((char *)"DEVICE GET uuid Get Device record by uuid"); 1373 srv_send((char *)"DEVICE GET uuid Get Device record by uuid");
1382 srv_send((char *)"DEVICE PUT uuid Put Device record by uuid"); 1374 srv_send((char *)"DEVICE PUT uuid Put Device record by uuid");
1383 srv_send((char *)"GLOBAL GET Get global settings"); 1375 srv_send((char *)"GLOBAL GET Get global settings");
1384 srv_send((char *)"GLOBAL PUT Put global settings"); 1376 srv_send((char *)"GLOBAL PUT Put global settings");
1385 srv_send((char *)"LCD Get LCD screen (allways 4 rows of 20 characters)");
1386 srv_send((char *)"LIST List all fermenter units"); 1377 srv_send((char *)"LIST List all fermenter units");
1387 srv_send((char *)"LIST LOG uuid List logfile data in 1 hour lines"); 1378 srv_send((char *)"LIST LOG uuid List logfile data in 1 hour lines");
1388 srv_send((char *)"PROFILE uuid,name Profile rename"); 1379 srv_send((char *)"PROFILE uuid,name Profile rename");
1389 srv_send((char *)"PROFILE ADD name Add new profile with name"); 1380 srv_send((char *)"PROFILE ADD name Add new profile with name");
1390 srv_send((char *)"PROFILE DEL uuid Delete profile by uuid"); 1381 srv_send((char *)"PROFILE DEL uuid Delete profile by uuid");
1397 srv_send((char *)"UNIT DEL uuid Delete Unit by uuid"); 1388 srv_send((char *)"UNIT DEL uuid Delete Unit by uuid");
1398 srv_send((char *)"UNIT LIST List all Units"); 1389 srv_send((char *)"UNIT LIST List all Units");
1399 srv_send((char *)"UNIT GET uuid Get Unit record by uuid"); 1390 srv_send((char *)"UNIT GET uuid Get Unit record by uuid");
1400 srv_send((char *)"UNIT PUT uuid Put Unit record by uuid"); 1391 srv_send((char *)"UNIT PUT uuid Put Unit record by uuid");
1401 srv_send((char *)"."); 1392 srv_send((char *)".");
1402 } else if (strncmp(buf, "LCD", 3) == 0) {
1403 #ifdef HAVE_WIRINGPI_H
1404 srv_send((char *)"201 Information follows");
1405 for (j = 0; j < 4; j++) {
1406 sprintf(obuf, " ");
1407 obuf[20] = '\0';
1408 for (i = 0; i < 20; i++)
1409 obuf[i] = lcdbuf[lcdHandle][i][j];
1410 srv_send(obuf);
1411 }
1412 srv_send((char *)".");
1413 #else
1414 srv_send((char *)"403 LCD not available");
1415 #endif
1416 } else if (strncmp(buf, "LIST", 4) == 0) { 1393 } else if (strncmp(buf, "LIST", 4) == 0) {
1417 cmd_list(buf); 1394 cmd_list(buf);
1418 } else if (strncmp(buf, "PROFILE", 7) == 0) { 1395 } else if (strncmp(buf, "PROFILE", 7) == 0) {
1419 if (cmd_profile(buf) == 0) 1396 if (cmd_profile(buf) == 0)
1420 wrconfig(); 1397 wrconfig();

mercurial