-
Notifications
You must be signed in to change notification settings - Fork 2
/
frugal-iot.ino
122 lines (111 loc) · 3.02 KB
/
frugal-iot.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
* This is a test harness for the Frugal IoT project
*/
#include "_settings.h" // Settings for what to include etc
#ifdef SYSTEM_WIFI_WANT
#include "system_wifi.h"
#endif
#ifdef SYSTEM_MQTT_WANT
#include "system_mqtt.h"
#endif
//TO_ADD_ACTUATOR - follow the pattern below and add any variables and search for other places tagged TO_ADD_ACTUATOR
#ifdef ACTUATOR_LEDBUILTIN_WANT
#include "actuator_ledbuiltin.h"
#endif
#ifdef ACTUATOR_RELAY_WANT
#include "actuator_relay.h"
#endif
//TO_ADD_SENSOR - follow the pattern below and add any variables and search for other places tagged TO_ADD_SENSOR
#ifdef SENSOR_ANALOG_WANT
#include "sensor_analog.h"
#endif
#ifdef SENSOR_SHT85_WANT
#include "sensor_sht85.h"
#endif
#ifdef SENSOR_DHT_WANT
#include "sensor_dht.h"
#endif
#ifdef CONTROL_BLINKEN_WANT
#include "control_blinken.h"
#endif
#ifdef CONTROL_DEMO_MQTT_WANT
#include "control_demo_mqtt.h"
#endif
#ifdef SYSTEM_DISCOVERY_WANT
#include "system_discovery.h"
#endif
void setup() {
#ifdef ANY_DEBUG
Serial.begin(SERIAL_BAUD);
while (!Serial) {
; // wait for serial port to connect. Needed for Arduino Leonardo only
}
delay(SERIAL_DELAY); // If dont do this on D1 Mini and Arduino IDE then miss next debugging
//Serial.setDebugOutput(true); // Enable debug from wifi, also needed to enable output from printf
Serial.println(F("FrugalIoT Starting"));
#endif // ANY_DEBUG
// put setup code here, to run once:
#ifdef SYSTEM_WIFI_WANT
xWifi::setup();
#endif
#ifdef SYSTEM_MQTT_WANT
xMqtt::setup();
#endif
#ifdef SYSTEM_DISCOVERY_WANT
xDiscovery::setup(); // Must be after system mqtt and before ACTUATOR* or SENSOR* or CONTROL* that setup topics
#endif
//TO_ADD_ACTUATOR - follow the pattern below and add any variables and search for other places tagged TO_ADD_ACTUATOR
#ifdef ACTUATOR_LEDBUILTIN_WANT
aLedbuiltin::setup();
#endif
#ifdef ACTUATOR_RELAY_WANT
aRelay::setup();
#endif
//TO_ADD_SENSOR - follow the pattern below and add any variables and search for other places tagged TO_ADD_SENSOR
#ifdef SENSOR_ANALOG_WANT
sAnalog::setup();
#endif
#ifdef SENSOR_SHT85_WANT
sSHT85::setup();
#endif
#ifdef SENSOR_DHT_WANT
sDHT::setup();
#endif
#ifdef CONTROL_BLINKEN_WANT
cBlinken::setup();
#endif
#ifdef CONTROL_DEMO_MQTT_WANT
cDemoMqtt::setup(); // Must be after system_mqtt
#endif
#ifdef ANY_DEBUG
Serial.println(F("FrugalIoT Starting Loop"));
#endif // ANY_DEBUG
}
void loop() {
// Put code for each sensor etc here - call functions in those sections
#ifdef SYSTEM_MQTT_WANT
xMqtt::loop();
#endif
//TO_ADD_ACTUATOR - follow the pattern below and add any variables and search for other places tagged TO_ADD_ACTUATOR
/*
#ifdef ACTUATOR_XXX
aXXX::loop();
#endif
*/
//TO_ADD_SENSOR - follow the pattern below and add any variables and search for other places tagged TO_ADD_SENSOR
#ifdef SENSOR_ANALOG_WANT
sAnalog::loop();
#endif
#ifdef SENSOR_SHT85_WANT
sSHT85::loop();
#endif
#ifdef SENSOR_DHT_WANT
sDHT::loop();
#endif
#ifdef CONTROL_BLINKEN_WANT
cBlinken::loop();
#endif
#ifdef SYSTEM_DISCOVERY_WANT
xDiscovery::loop();
#endif
}