1 #ifndef _THERMOMETERS_H |
|
2 #define _THERMOMETERS_H |
|
3 |
|
4 |
|
5 #define TRUE 1 |
|
6 #define FALSE 0 |
|
7 |
|
8 #include "../config.h" |
|
9 |
|
10 #include <stdlib.h> |
|
11 #include <stdio.h> |
|
12 #include <stdint.h> |
|
13 #include <stdarg.h> |
|
14 #include <string.h> |
|
15 #include <ctype.h> |
|
16 #include <sys/types.h> |
|
17 #include <sys/stat.h> |
|
18 #include <sys/time.h> |
|
19 #include <time.h> |
|
20 #include <fcntl.h> |
|
21 #include <syslog.h> |
|
22 #include <unistd.h> |
|
23 #include <errno.h> |
|
24 #include <signal.h> |
|
25 #include <getopt.h> |
|
26 #include <limits.h> |
|
27 #include <sys/socket.h> |
|
28 #include <arpa/inet.h> |
|
29 #include <netdb.h> |
|
30 #include <poll.h> |
|
31 |
|
32 |
|
33 /* mosquitto */ |
|
34 //#include <mosquitto.h> |
|
35 |
|
36 #ifdef HAVE_WIRINGPI_H |
|
37 /* wiringPi */ |
|
38 #include <wiringPi.h> |
|
39 #include <pcf8574.h> |
|
40 #include <lcd.h> |
|
41 |
|
42 #endif |
|
43 |
|
44 #define TRUE 1 |
|
45 #define FALSE 0 |
|
46 |
|
47 #define MBSE_SS(x) (x)?(x):"(null)" |
|
48 |
|
49 /* rdconfig.c */ |
|
50 typedef struct _key_list { |
|
51 char *key; |
|
52 int (*prc)(char **); |
|
53 char **dest; |
|
54 } key_list; |
|
55 |
|
56 typedef struct _w1_therm { |
|
57 struct _w1_therm *next; |
|
58 char *master; /* Master for this device */ |
|
59 int bus; /* Reserved for ds2482-800 */ |
|
60 char *name; /* Name of this device */ |
|
61 char *alias; /* Friendly name */ |
|
62 int present; /* 1=present, 0=absent */ |
|
63 int lastval; /* Last valid value */ |
|
64 int update; /* Value updated */ |
|
65 } w1_therm; |
|
66 |
|
67 typedef struct _rc_switch { |
|
68 struct _rc_switch *next; |
|
69 char *address; /* Address code */ |
|
70 char *alias; /* Friendly name */ |
|
71 } rc_switch; |
|
72 |
|
73 typedef struct _sys_config { |
|
74 char *name; /* Configuration name */ |
|
75 int my_port; /* my client/server port */ |
|
76 w1_therm *w1therms; /* 1-wire temp sensors */ |
|
77 #ifdef HAVE_WIRINGPI_H |
|
78 int lcd_cols; /* LCD display columns */ |
|
79 int lcd_rows; /* LCD display rows */ |
|
80 int rx433; /* 433 MHz receiver pin */ |
|
81 int tx433; /* 433 MHz transmitter pin */ |
|
82 rc_switch *rcswitch; /* 433 MHz RC Power switches */ |
|
83 #endif |
|
84 } sys_config; |
|
85 |
|
86 |
|
87 void killconfig(void); |
|
88 int rdconfig(char *); |
|
89 |
|
90 |
|
91 /* xutil.c */ |
|
92 char *xmalloc(size_t); |
|
93 char *xstrcpy(char *); |
|
94 char *xstrcat(char *, char *); |
|
95 |
|
96 |
|
97 #ifdef HAVE_WIRINGPI_H |
|
98 |
|
99 /* lcd-pcf8574.c */ |
|
100 // Defines for the pcf8574 Pi LCD interface board |
|
101 #define AF_BASE 100 |
|
102 |
|
103 #define AF_RS (AF_BASE + 0) |
|
104 #define AF_RW (AF_BASE + 1) |
|
105 #define AF_E (AF_BASE + 2) |
|
106 #define AF_BACKLIGHT (AF_BASE + 3) |
|
107 #define AF_DB4 (AF_BASE + 4) |
|
108 #define AF_DB5 (AF_BASE + 5) |
|
109 #define AF_DB6 (AF_BASE + 6) |
|
110 #define AF_DB7 (AF_BASE + 7) |
|
111 |
|
112 void setBacklight (int); |
|
113 int initLCD (int, int); |
|
114 void mb_lcdPutchar(const int, unsigned char); |
|
115 void mb_lcdPuts(const int, const char *); |
|
116 void mb_lcdClear(const int); |
|
117 |
|
118 |
|
119 |
|
120 #endif |
|
121 |
|
122 |
|
123 #endif |
|
124 |
|