thermferm/thermferm.h

changeset 51
a03b6dac5398
parent 48
d8c64f81b192
child 53
37623517e0ef
--- a/thermferm/thermferm.h	Sun May 25 16:39:54 2014 +0200
+++ b/thermferm/thermferm.h	Sun May 25 22:06:56 2014 +0200
@@ -1,10 +1,166 @@
-#ifndef	_MAIN_H
-#define	_MAIN_H
+#ifndef	_MBSELIB_H
+#define	_MBSELIB_H
 
 
 #define TRUE 1
 #define FALSE 0
 
+#include "../config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdarg.h>
+#include <string.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <time.h>
+#include <fcntl.h>
+#include <syslog.h>
+#include <unistd.h>
+#include <errno.h>
+#include <signal.h>
+#include <getopt.h>
+#include <limits.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <poll.h>
+
+
+/* mosquitto */
+#include <mosquitto.h>
+
+#ifdef HAVE_WIRINGPI_H
+/* wiringPi */
+#include <wiringPi.h>
+#include <pcf8574.h>
+#include <lcd.h>
+
+#endif
+
+#define TRUE 1
+#define FALSE 0
+
+#define MBSE_SS(x) (x)?(x):"(null)"
+
+/* rdconfig.c */
+typedef struct _key_list {
+    char	*key;
+    int		(*prc)(char **);
+    char	**dest;
+} key_list;
+
+typedef struct _w1_therm {
+    struct _w1_therm    *next;
+    char                *master;                /* Master for this device       */
+    int                 bus;                    /* Reserved for ds2482-800      */
+    char                *name;                  /* Name of this device          */
+    char                *alias;                 /* Friendly name                */
+    int                 present;                /* 1=present, 0=absent          */
+    int                 lastval;                /* Last valid value             */
+    int			update;			/* Value updated		*/
+} w1_therm;
+
+typedef struct _rc_switch {
+    struct _rc_switch	*next;
+    char		*address;		/* Address code			*/
+    char		*alias;			/* Friendly name		*/
+} rc_switch;
+
+typedef struct _sys_config {
+    char		*name;			/* Configuration name		*/
+    char		*mosq_host;		/* mosquitto server hostname	*/
+    int			mosq_port;		/* mosquitto server port	*/
+    int			my_port;		/* my client/server port	*/
+    w1_therm		*w1therms;		/* 1-wire temp sensors		*/
+#ifdef HAVE_WIRINGPI_H
+    int			lcd_cols;		/* LCD display columns		*/
+    int			lcd_rows;		/* LCD display rows		*/
+    int			rx433;			/* 433 MHz receiver pin		*/
+    int			tx433;			/* 433 MHz transmitter pin	*/
+    rc_switch		*rcswitch;		/* 433 MHz RC Power switches	*/
+#endif
+} sys_config;
+
+
+void killconfig(void);
+int  rdconfig(char *);
+
+
+/* lock.c */
+int  lockprog(char *);
+void ulockprog(char *);
+
+
+/* xutil.c */
+char *xmalloc(size_t);
+char *xstrcpy(char *);
+char *xstrcat(char *, char *);
+
+
+#ifdef HAVE_WIRINGPI_H
+
+/* lcd-pcf8574.c */
+// Defines for the pcf8574 Pi LCD interface board
+#define AF_BASE         100
+
+#define AF_RS           (AF_BASE + 0)
+#define AF_RW           (AF_BASE + 1)
+#define AF_E            (AF_BASE + 2)
+#define AF_BACKLIGHT    (AF_BASE + 3)
+#define AF_DB4          (AF_BASE + 4)
+#define AF_DB5          (AF_BASE + 5)
+#define AF_DB6          (AF_BASE + 6)
+#define AF_DB7          (AF_BASE + 7)
+
+void setBacklight (int);
+int  initLCD (int, int);
+void mb_lcdPutchar(const int, unsigned char);
+void mb_lcdPuts(const int, const char *);
+void mb_lcdClear(const int);
+
+
+/* logger.c */
+void logger(char *, char *, char *);
+
+
+/* rc-switch.c */
+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);
+
+
+/* dht11.c */
+void dht11Read(void);
+void dht11Init(int, int, int);
+
+PI_THREAD (my_sensors_loop);
+PI_THREAD (my_server_loop);
+
+#endif
 
 
 #endif
+

mercurial