lib/mbselib.h

changeset 51
a03b6dac5398
parent 50
8b5e8f1e172d
child 52
4387a6b11eb3
equal deleted inserted replaced
50:8b5e8f1e172d 51:a03b6dac5398
1 #ifndef _MBSELIB_H
2 #define _MBSELIB_H
3
4 #include "../config.h"
5
6 #include <stdlib.h>
7 #include <stdio.h>
8 #include <stdint.h>
9 #include <stdarg.h>
10 #include <string.h>
11 #include <ctype.h>
12 #include <sys/types.h>
13 #include <sys/stat.h>
14 #include <sys/time.h>
15 #include <time.h>
16 #include <fcntl.h>
17 #include <syslog.h>
18 #include <unistd.h>
19 #include <errno.h>
20 #include <signal.h>
21 #include <getopt.h>
22 #include <limits.h>
23 #include <sys/socket.h>
24 #include <arpa/inet.h>
25 #include <netdb.h>
26 #include <poll.h>
27
28
29 /* mosquitto */
30 #include <mosquitto.h>
31
32 #ifdef HAVE_WIRINGPI_H
33 /* wiringPi */
34 #include <wiringPi.h>
35 #include <pcf8574.h>
36 #include <lcd.h>
37
38 #endif
39
40 #define TRUE 1
41 #define FALSE 0
42
43 #define MBSE_SS(x) (x)?(x):"(null)"
44
45 /* rdconfig.c */
46 typedef struct _key_list {
47 char *key;
48 int (*prc)(char **);
49 char **dest;
50 } key_list;
51
52 typedef struct _w1_therm {
53 struct _w1_therm *next;
54 char *master; /* Master for this device */
55 int bus; /* Reserved for ds2482-800 */
56 char *name; /* Name of this device */
57 char *alias; /* Friendly name */
58 int present; /* 1=present, 0=absent */
59 int lastval; /* Last valid value */
60 int update; /* Value updated */
61 } w1_therm;
62
63 typedef struct _rc_switch {
64 struct _rc_switch *next;
65 char *address; /* Address code */
66 char *alias; /* Friendly name */
67 } rc_switch;
68
69 typedef struct _sys_config {
70 char *name; /* Configuration name */
71 char *mosq_host; /* mosquitto server hostname */
72 int mosq_port; /* mosquitto server port */
73 int my_port; /* my client/server port */
74 w1_therm *w1therms; /* 1-wire temp sensors */
75 #ifdef HAVE_WIRINGPI_H
76 int lcd_cols; /* LCD display columns */
77 int lcd_rows; /* LCD display rows */
78 int rx433; /* 433 MHz receiver pin */
79 int tx433; /* 433 MHz transmitter pin */
80 rc_switch *rcswitch; /* 433 MHz RC Power switches */
81 #endif
82 } sys_config;
83
84
85 void killconfig(void);
86 int rdconfig(char *);
87
88
89 /* lock.c */
90 int lockprog(char *);
91 void ulockprog(char *);
92
93
94 /* xutil.c */
95 char *xmalloc(size_t);
96 char *xstrcpy(char *);
97 char *xstrcat(char *, char *);
98
99
100 #ifdef HAVE_WIRINGPI_H
101
102 /* lcd-pcf8574.c */
103 // Defines for the pcf8574 Pi LCD interface board
104 #define AF_BASE 100
105
106 #define AF_RS (AF_BASE + 0)
107 #define AF_RW (AF_BASE + 1)
108 #define AF_E (AF_BASE + 2)
109 #define AF_BACKLIGHT (AF_BASE + 3)
110 #define AF_DB4 (AF_BASE + 4)
111 #define AF_DB5 (AF_BASE + 5)
112 #define AF_DB6 (AF_BASE + 6)
113 #define AF_DB7 (AF_BASE + 7)
114
115 void setBacklight (int);
116 int initLCD (int, int);
117 void mb_lcdPutchar(const int, unsigned char);
118 void mb_lcdPuts(const int, const char *);
119 void mb_lcdClear(const int);
120
121
122 /* logger.c */
123 void logger(char *, char *, char *);
124
125
126 /* rc-switch.c */
127 int toggleSwitch(char *);
128 int toggleTypeA(char *, char *, bool);
129 int toggleTypeB(int, int, bool);
130 int toggleTypeC(char, int, int, bool);
131 int toggleTypeE(char, int, bool);
132
133 void enableReceiveIRQ(int interrupt);
134 void enableReceive(void);
135 void disableReceive(void);
136 bool available(void);
137 void resetAvailable(void);
138
139 unsigned long getReceivedValue(void);
140 unsigned int getReceivedBitlength(void);
141 unsigned int getReceivedDelay(void);
142 unsigned int getReceivedProtocol(void);
143 unsigned int *getReceivedRawdata(void);
144
145 void enableTransmit(int);
146 void disableTransmit(void);
147
148 char *dec2binWzerofill(unsigned long, unsigned int);
149
150
151 /* dht11.c */
152 void dht11Read(void);
153 void dht11Init(int, int, int);
154
155
156 #endif
157
158
159 #endif
160

mercurial