Added first part of out own protocol

Mon, 23 Jun 2014 19:53:33 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 23 Jun 2014 19:53:33 +0200
changeset 68
6dba71439cd8
parent 67
4a26aaa34fa1
child 69
df5d983dab1b

Added first part of out own protocol

thermferm/server.c file | annotate | diff | comparison | revisions
--- a/thermferm/server.c	Sun Jun 22 22:11:33 2014 +0200
+++ b/thermferm/server.c	Mon Jun 23 19:53:33 2014 +0200
@@ -119,6 +119,9 @@
     int                 i, rc, rlen;
     socklen_t           fromlen;
     float		newtemp;
+#ifdef HAVE_WIRINGPI_H
+    int			j;
+#endif
 
 //    if (debug) {
 //	char *hostname = inet_ntoa(peeraddr_in.sin_addr);
@@ -147,7 +150,26 @@
 	    /*
 	     * Process commands from the client
 	     */
-	    if (strncmp(buf, "ack", 3) == 0) {
+	    if (strncmp(buf, "HELP", 4) == 0) {
+		srv_send((char *)"100 Help text follows");
+		srv_send((char *)"Recognized commands:");
+		srv_send((char *)"");
+		srv_send((char *)"LCD                       Get LCD screen (allways 4 rows of 20 characters)");
+		srv_send((char *)".");
+	    } else if (strncmp(buf, "LCD", 3) == 0) {
+#ifdef HAVE_WIRINGPI_H
+		srv_send((char *)"201 information follows");
+		for (j = 0; j < 4; j++) {
+		    sprintf(obuf, "                   ");
+		    for (i = 0; i < 20; i++)
+		    	obuf[i]  = lcdbuf[lcdHandle][i][j];
+		    srv_send(obuf);
+		}
+		srv_send((char *)".");
+#else
+		srv_send((char *)"403 LCD not available");
+#endif
+	    } else if (strncmp(buf, "ack", 3) == 0) {
 		srv_send((char *)"ack");
 	    } else if (strncmp(buf, "lcd", 3) == 0) {
 		sprintf(obuf, "[\"                    \", \"                    \", \"                    \", \"                    \"]");

mercurial