Final steps removing rc-switch from thermferm

Mon, 23 Jun 2014 22:41:09 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 23 Jun 2014 22:41:09 +0200
changeset 72
f7cb53c50ee1
parent 71
a09c5cdc4022
child 73
4a28de5b9b47

Final steps removing rc-switch from thermferm

thermferm/rdconfig.c file | annotate | diff | comparison | revisions
thermferm/thermferm.c file | annotate | diff | comparison | revisions
thermferm/thermferm.h file | annotate | diff | comparison | revisions
--- a/thermferm/rdconfig.c	Mon Jun 23 22:16:29 2014 +0200
+++ b/thermferm/rdconfig.c	Mon Jun 23 22:41:09 2014 +0200
@@ -35,7 +35,6 @@
 static int getw1(char **);
 #ifdef HAVE_WIRINGPI_H
 static int getint(char **);
-static int getrcs(char **);
 #endif
 static int getuch(char **);
 static int getfloat(char **);
@@ -53,8 +52,6 @@
 #ifdef HAVE_WIRINGPI_H
     {(char *)"lcd_cols",		getint,		(char **)&Config.lcd_cols},
     {(char *)"lcd_rows",		getint,		(char **)&Config.lcd_rows},
-    {(char *)"tx433",			getint,		(char **)&Config.tx433},
-    {(char *)"rcswitch",		getrcs,		(char **)&Config.rcswitch},
 #endif
     {(char *)"cs_mode",			getuch,		(char **)&Config.cs_mode},
     {(char *)"cs_beerSet",		getfloat,	(char **)&Config.cs_beerSet},
@@ -74,9 +71,6 @@
 void killconfig(void)
 {
     w1_therm	*tmp1, *old1;
-#ifdef HAVE_WIRINGPI_H
-    rc_switch	*tmp2, *old2;
-#endif
 
     if (Config.name)
 	free(Config.name);
@@ -98,19 +92,6 @@
 #ifdef HAVE_WIRINGPI_H
     Config.lcd_cols = 16;
     Config.lcd_rows = 2;
-    Config.tx433 = -1;
-
-    for (tmp2 = Config.rcswitch; tmp2; tmp2 = old2) {
-	old2 = tmp2->next;
-	if (tmp2->address)
-	    free(tmp2->address);
-	tmp2->address = NULL;
-	if (tmp2->alias)
-	    free(tmp2->alias);
-	tmp2->alias = NULL;
-	free(tmp2);
-    }
-    Config.rcswitch = NULL;
 #endif
 
     defaultControlSettings();
@@ -388,48 +369,6 @@
 
 
 
-#ifdef HAVE_WIRINGPI_H
-static int getrcs(char **dest)
-{
-    char        *p, *q = NULL, *r = NULL;
-    rc_switch   **tmpm;
-
-    for (p = v; *p && !isspace(*p); p++);
-	if (*p)
-	    *p++ = '\0';
-    while (*p && isspace(*p))
-	p++;
-    if (*p == '\0') {
-	syslog(LOG_NOTICE, "rdconfig: %s(%d): less then two tokens", mypath, linecnt);
-	return 1;
-    }
-
-    for (q = p; *q && !isspace(*q); q++);
-    if (*q && isspace(*q)) {
-	if (*q)
-	    *q++ = '\0';
-	while (*q && isspace(*q))
-	    q++;
-
-	for (r = q; *r && !isspace(*r); r++);
-	if (*r)
-	    *r++ = '\0';
-	if (debug)
-	    syslog(LOG_NOTICE, "rdconfig: getrcs: %s(%d): %s %s", mypath, linecnt, v, p);
-    }
-
-    for (tmpm = (rc_switch**)dest; *tmpm; tmpm=&((*tmpm)->next));
-    (*tmpm) = (rc_switch *) xmalloc(sizeof(rc_switch));
-    (*tmpm)->next = NULL;
-    (*tmpm)->address = xstrcpy(v);
-    (*tmpm)->alias = xstrcpy(p);
-
-    return 0;
-}
-#endif
-
-
-
 static int getuch(char **dest)
 {
     if (debug)
--- a/thermferm/thermferm.c	Mon Jun 23 22:16:29 2014 +0200
+++ b/thermferm/thermferm.c	Mon Jun 23 22:41:09 2014 +0200
@@ -26,8 +26,6 @@
 int			current_unit = -1;
 int			tempA = 80;
 int			tempB = 80;
-int			coolerA = 0;
-int			coolerB = 0;
 
 key_t			key = 5680;		/* key to be passed to shmget()		*/
 int			shmid;
@@ -83,52 +81,11 @@
 
 
 #ifdef HAVE_WIRINGPI_H
-void sendRCswitch(char *address, int state)
-{
-    char    *cmd = NULL;
-    int     rc;
-
-    cmd = xstrcpy(address);
-    if (state)
-	cmd = xstrcat(cmd, (char *)",1");
-    else
-	cmd = xstrcat(cmd, (char *)",0");
-    rc = toggleSwitch(cmd);
-    if (debug)
-	fprintf(stdout, "Switch %s rc=%d\n", cmd, rc);
-    syslog(LOG_NOTICE, "Switch %s rc=%d", cmd, rc);
-    free(cmd);
-}
-#endif
-
-
-#ifdef HAVE_WIRINGPI_H
 void stopLCD(void)
 {
     mb_lcdClear(lcdHandle);
     setBacklight(0);
 }
-
-
-
-void stopRCswitch(void)
-{
-    rc_switch   *tmp, *old;
-    char	*cmd = NULL;
-    int		rc;
-
-    for (tmp = Config.rcswitch; tmp; tmp = old) {
-	old = tmp->next;
-	cmd = xstrcpy(tmp->address);
-	cmd = xstrcat(cmd, (char *)",0");
-	rc = toggleSwitch(cmd);
-	if (debug)
-	    fprintf(stdout, "Switch %s rc=%d\n", cmd, rc);
-	syslog(LOG_NOTICE, "Switch %s rc=%d", cmd, rc);
-	free(cmd);
-	cmd = NULL;
-    }
-}
 #endif
 
 
@@ -197,13 +154,6 @@
     lcdPosition(lcdHandle, 0, 1);
     sprintf(buf, "  Version %s", VERSION);
     mb_lcdPuts(lcdHandle, buf);
-
-    if (Config.tx433 != -1) {
-	if (debug)
-	    fprintf(stdout, "Using 433 MHz transmitter on pin %d\n", Config.tx433);
-	syslog(LOG_NOTICE, "Using 433 MHz transmitter on pin %d", Config.tx433);
-    	enableTransmit(Config.tx433);
-    }
 #endif
 
     if (debug) {
@@ -278,7 +228,6 @@
     time_t		now, last = (time_t)0;
     w1_therm		*tmp1;
 #ifdef HAVE_WIRINGPI_H
-    rc_switch		*tmp2;
     int			rc;
 #endif
     int			run = 1, temp;
@@ -302,7 +251,7 @@
     }
 #endif
 
-    snprintf(buf, 1023, "tempA,coolerA,tempB,coolerB");
+    snprintf(buf, 1023, "tempA,tempB");
     logger((char *)"thermferm.log", (char *)"thermferm", buf);
 
     do {
@@ -312,49 +261,11 @@
 	    run = 0;
 
 	tmp1 = Config.w1therms;
-#ifdef HAVE_WIRINGPI_H
-	tmp2 = Config.rcswitch;
-#endif
-	if (((tmp1->lastval / 100) < (tempA - 5)) && (coolerA == 1)) {
-	    coolerA = 0;
-	    syslog(LOG_NOTICE, "Temperature A is %.1f, switched cooler off", (tmp1->lastval / 1000.0));
-#ifdef HAVE_WIRINGPI_H
-	    sendRCswitch(tmp2->address, 0);
-#endif
-	    lcdupdate = TRUE;
-	}
-	if (((tmp1->lastval / 100) > (tempA + 5)) && (coolerA == 0)) {
-	    coolerA = 1;
-	    syslog(LOG_NOTICE, "Temperature A is %.1f, switched cooler on", (tmp1->lastval / 1000.0));
-#ifdef HAVE_WIRINGPI_H
-	    sendRCswitch(tmp2->address, 1);
-#endif
-	    lcdupdate = TRUE;
-	}
 	if (tmp1->update) {
 	    tmp1->update = FALSE;
 	    lcdupdate = TRUE;
 	}
 	tmp1 = tmp1->next;
-#ifdef HAVE_WIRINGPI_H
-	tmp2 = tmp2->next;
-#endif
-	if (((tmp1->lastval / 100) < (tempB - 5)) && (coolerB == 1)) {
-	    coolerB = 0;
-	    syslog(LOG_NOTICE, "Temperature B is %.1f, switched cooler off", (tmp1->lastval / 1000.0));
-#ifdef HAVE_WIRINGPI_H
-	    sendRCswitch(tmp2->address, 0);
-#endif
-	    lcdupdate = TRUE;
-	}
-	if (((tmp1->lastval / 100) > (tempB + 5)) && (coolerB == 0)) {
-	    coolerB = 1;
-	    syslog(LOG_NOTICE, "Temperature B is %.1f, switched cooler on", (tmp1->lastval / 1000.0));
-#ifdef HAVE_WIRINGPI_H
-	    sendRCswitch(tmp2->address, 1);
-#endif
-	    lcdupdate = TRUE;
-	}
 	if (tmp1->update) {
 	    tmp1->update = FALSE;
 	    lcdupdate = TRUE;
@@ -364,12 +275,12 @@
 	if (run && lcdupdate) {
 	    lcdPosition(lcdHandle, 0, 0);
 	    tmp1 = Config.w1therms;
-	    snprintf(buf, 16, "%5.2f %cC %c %s            ", tmp1->lastval / 1000.0, 0xdf, coolerA ? '-' : ' ', tmp1->alias);
+	    snprintf(buf, 16, "%5.2f %cC %s              ", tmp1->lastval / 1000.0, 0xdf, tmp1->alias);
 	    mb_lcdPuts(lcdHandle, buf);
 	    temp = tmp1->lastval;
 	    tmp1 = tmp1->next;
 	    lcdPosition(lcdHandle, 0, 1);
-	    snprintf(buf, 16, "%5.2f %cC %c %s            ", tmp1->lastval / 1000.0, 0xdf, coolerB ? '-' : ' ', tmp1->alias);
+	    snprintf(buf, 16, "%5.2f %cC %s              ", tmp1->lastval / 1000.0, 0xdf, tmp1->alias);
 	    mb_lcdPuts(lcdHandle, buf);
 	}
 #endif
@@ -381,8 +292,7 @@
 	    temp = tmp1->lastval;
 	    tmp1 = tmp1->next;
 	    if (temp && tmp1->lastval && run) {
-	    	snprintf(buf, 1023, "%.2f,%s,%.2f,%s", temp / 1000.0, coolerA ? (char *)"on" : (char *)"off",
-			    			 tmp1->lastval / 1000.0, coolerB ? (char *)"on" : (char *)"off");
+	    	snprintf(buf, 1023, "%.2f,%.2f", temp / 1000.0, tmp1->lastval / 1000.0);
 	    	logger((char *)"thermferm.log", (char *)"thermferm", buf);
 	    }
 	}
@@ -399,12 +309,7 @@
     usleep(1500000);
 
 #ifdef HAVE_WIRINGPI_H
-    if (Config.tx433 != -1) {
-	stopRCswitch();
-    }
-
     stopLCD();
-    disableTransmit();
 #endif
 
     wrconfig((char *)"thermferm.conf");
--- a/thermferm/thermferm.h	Mon Jun 23 22:16:29 2014 +0200
+++ b/thermferm/thermferm.h	Mon Jun 23 22:41:09 2014 +0200
@@ -108,14 +108,6 @@
     int			update;			/* Value updated		*/
 } w1_therm;
 
-#ifdef HAVE_WIRINGPI_H
-typedef struct _rc_switch {
-    struct _rc_switch	*next;
-    char		*address;		/* Address code			*/
-    char		*alias;			/* Friendly name		*/
-} rc_switch;
-#endif
-
 typedef struct _sys_config {
     char		*name;			/* Configuration name		*/
     int			my_port;		/* my client/server port	*/
@@ -123,8 +115,6 @@
 #ifdef HAVE_WIRINGPI_H
     int			lcd_cols;		/* LCD display columns		*/
     int			lcd_rows;		/* LCD display rows		*/
-    int			tx433;			/* 433 MHz transmitter pin	*/
-    rc_switch		*rcswitch;		/* 433 MHz RC Power switches	*/
 #endif
     units_list		*units;			/* Fermenter units		*/
     						/* ControlSettings:		*/
@@ -184,37 +174,6 @@
 /* logger.c */
 void logger(char *, char *, char *);
 
-
-/* rc-switch.c */
-#ifdef HAVE_WIRINGPI_H
-int  toggleSwitch(char *);
-int  toggleTypeA(char *, char *, bool);
-int  toggleTypeB(int, int, bool);
-int  toggleTypeC(char, int, int, bool);
-int  toggleTypeE(char, int, bool);
-
-void enableReceiveIRQ(int interrupt);
-void enableReceive(void);
-void disableReceive(void);
-bool available(void);
-void resetAvailable(void);
-
-unsigned long getReceivedValue(void);
-unsigned int getReceivedBitlength(void);
-unsigned int getReceivedDelay(void);
-unsigned int getReceivedProtocol(void);
-unsigned int *getReceivedRawdata(void);
-
-void enableTransmit(int);
-void disableTransmit(void);
-
-char *dec2binWzerofill(unsigned long, unsigned int);
-#endif
-
-/* dht11.c */
-void dht11Read(void);
-void dht11Init(int, int, int);
-
 #ifdef HAVE_WIRINGPI_H
 PI_THREAD (my_sensors_loop);
 #else

mercurial