Browse Source

add feature-flags for libs, to fit 512k esp-01 version.

Thomas Buck 2 years ago
parent
commit
47716cc74b
9 changed files with 124 additions and 37 deletions
  1. 6
    6
      include/DebugLog.h
  2. 7
    3
      include/sensors.h
  3. 34
    0
      platformio.ini
  4. 4
    7
      src/DebugLog.cpp
  5. 8
    4
      src/html.cpp
  6. 4
    0
      src/influx.cpp
  7. 18
    6
      src/mqtt.cpp
  8. 33
    8
      src/sensors.cpp
  9. 10
    3
      src/servers.cpp

+ 6
- 6
include/DebugLog.h View File

16
 
16
 
17
 #include <Arduino.h>
17
 #include <Arduino.h>
18
 
18
 
19
-#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
19
+#ifdef ENABLE_DEBUGLOG
20
 #include <CircularBuffer.h>
20
 #include <CircularBuffer.h>
21
 #define DEBUG_LOG_HISTORY_SIZE 1024
21
 #define DEBUG_LOG_HISTORY_SIZE 1024
22
-#endif
22
+#endif // ENABLE_DEBUGLOG
23
 
23
 
24
 class DebugLog {
24
 class DebugLog {
25
 public:
25
 public:
26
-#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
26
+#ifdef ENABLE_DEBUGLOG
27
     String getBuffer(void);
27
     String getBuffer(void);
28
-#endif
28
+#endif // ENABLE_DEBUGLOG
29
     
29
     
30
     void write(char c);
30
     void write(char c);
31
     void print(String s);
31
     void print(String s);
38
 private:
38
 private:
39
     void sendToTargets(String s);
39
     void sendToTargets(String s);
40
     
40
     
41
-#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
41
+#ifdef ENABLE_DEBUGLOG
42
     void addToBuffer(String s);
42
     void addToBuffer(String s);
43
     
43
     
44
     CircularBuffer<char, DEBUG_LOG_HISTORY_SIZE> buffer;
44
     CircularBuffer<char, DEBUG_LOG_HISTORY_SIZE> buffer;
45
-#endif
45
+#endif // ENABLE_DEBUGLOG
46
 };
46
 };
47
 
47
 
48
 extern DebugLog debug;
48
 extern DebugLog debug;

+ 7
- 3
include/sensors.h View File

14
 #ifndef __SENSORS_H__
14
 #ifndef __SENSORS_H__
15
 #define __SENSORS_H__
15
 #define __SENSORS_H__
16
 
16
 
17
+float sht_temp(void);
18
+float sht_humid(void);
19
+extern bool found_sht;
20
+
21
+#ifdef ENABLE_BME280
17
 float bme1_temp(void);
22
 float bme1_temp(void);
18
 float bme2_temp(void);
23
 float bme2_temp(void);
19
 float bme1_humid(void);
24
 float bme1_humid(void);
20
 float bme2_humid(void);
25
 float bme2_humid(void);
21
 float bme1_pressure(void);
26
 float bme1_pressure(void);
22
 float bme2_pressure(void);
27
 float bme2_pressure(void);
23
-float sht_temp(void);
24
-float sht_humid(void);
25
-extern bool found_bme1, found_bme2, found_sht;
28
+extern bool found_bme1, found_bme2;
29
+#endif // ENABLE_BME280
26
 
30
 
27
 #ifdef ENABLE_CCS811
31
 #ifdef ENABLE_CCS811
28
 float ccs1_eco2(void);
32
 float ccs1_eco2(void);

+ 34
- 0
platformio.ini View File

14
 framework = arduino
14
 framework = arduino
15
 build_flags =
15
 build_flags =
16
   -DSENSOR_HOSTNAME_PREFIX=\"env-\"
16
   -DSENSOR_HOSTNAME_PREFIX=\"env-\"
17
+  -DENABLE_WEBSOCKETS
18
+  -DENABLE_DEBUGLOG
19
+  -DENABLE_BME280
17
   -DENABLE_CCS811
20
   -DENABLE_CCS811
18
   -DENABLE_INFLUXDB_LOGGING
21
   -DENABLE_INFLUXDB_LOGGING
19
   -DENABLE_MQTT
22
   -DENABLE_MQTT
27
     https://github.com/rlogiacco/CircularBuffer
30
     https://github.com/rlogiacco/CircularBuffer
28
     https://github.com/Links2004/arduinoWebSockets
31
     https://github.com/Links2004/arduinoWebSockets
29
 
32
 
33
+[env:esp8266smallrelais]
34
+platform = espressif8266
35
+board = esp01
36
+framework = arduino
37
+build_flags =
38
+  -DSENSOR_HOSTNAME_PREFIX=\"relais-\"
39
+  -DENABLE_WEBSOCKETS
40
+  -DENABLE_DEBUGLOG
41
+  -DENABLE_BME280
42
+  -DENABLE_CCS811
43
+  -DRELAIS_SERIAL
44
+  -DENABLE_MQTT
45
+lib_deps =
46
+    Wire
47
+    Adafruit Unified Sensor
48
+    Adafruit BME280 Library
49
+    https://github.com/adafruit/Adafruit_CCS811
50
+    https://github.com/knolleary/pubsubclient.git#2d228f2f862a95846c65a8518c79f48dfc8f188c
51
+    https://github.com/rlogiacco/CircularBuffer
52
+    https://github.com/Links2004/arduinoWebSockets
53
+
30
 [env:esp8266relais]
54
 [env:esp8266relais]
31
 platform = espressif8266
55
 platform = espressif8266
32
 board = esp01_1m
56
 board = esp01_1m
33
 framework = arduino
57
 framework = arduino
34
 build_flags =
58
 build_flags =
35
   -DSENSOR_HOSTNAME_PREFIX=\"relais-\"
59
   -DSENSOR_HOSTNAME_PREFIX=\"relais-\"
60
+  -DENABLE_WEBSOCKETS
61
+  -DENABLE_DEBUGLOG
62
+  -DENABLE_BME280
36
   -DRELAIS_SERIAL
63
   -DRELAIS_SERIAL
37
   -DENABLE_INFLUXDB_LOGGING
64
   -DENABLE_INFLUXDB_LOGGING
38
   -DENABLE_MQTT
65
   -DENABLE_MQTT
55
 monitor_speed = 115200
82
 monitor_speed = 115200
56
 build_flags =
83
 build_flags =
57
   -DSENSOR_HOSTNAME_PREFIX=\"env-\"
84
   -DSENSOR_HOSTNAME_PREFIX=\"env-\"
85
+  -DENABLE_WEBSOCKETS
86
+  -DENABLE_DEBUGLOG
87
+  -DENABLE_BME280
58
   -DENABLE_CCS811
88
   -DENABLE_CCS811
59
   -DENABLE_INFLUXDB_LOGGING
89
   -DENABLE_INFLUXDB_LOGGING
60
   -DENABLE_MQTT
90
   -DENABLE_MQTT
78
 monitor_speed = 115200
108
 monitor_speed = 115200
79
 build_flags =
109
 build_flags =
80
   -DSENSOR_HOSTNAME_PREFIX=\"env-\"
110
   -DSENSOR_HOSTNAME_PREFIX=\"env-\"
111
+  -DENABLE_WEBSOCKETS
112
+  -DENABLE_DEBUGLOG
81
   -DMOISTURE_ADC_ESP32
113
   -DMOISTURE_ADC_ESP32
114
+  -DENABLE_BME280
82
   -DENABLE_CCS811
115
   -DENABLE_CCS811
83
   -DENABLE_INFLUXDB_LOGGING
116
   -DENABLE_INFLUXDB_LOGGING
84
   -DENABLE_MQTT
117
   -DENABLE_MQTT
101
 monitor_speed = 115200
134
 monitor_speed = 115200
102
 build_flags =
135
 build_flags =
103
   -DSENSOR_HOSTNAME_PREFIX=\"env-\"
136
   -DSENSOR_HOSTNAME_PREFIX=\"env-\"
137
+  -DENABLE_BME280
104
   -DMOISTURE_ADC_ARDUINO
138
   -DMOISTURE_ADC_ARDUINO
105
   -DENABLE_INFLUXDB_LOGGING
139
   -DENABLE_INFLUXDB_LOGGING
106
 lib_deps =
140
 lib_deps =

+ 4
- 7
src/DebugLog.cpp View File

13
 
13
 
14
 #include <Arduino.h>
14
 #include <Arduino.h>
15
 
15
 
16
+#include "servers.h"
16
 #include "DebugLog.h"
17
 #include "DebugLog.h"
17
 
18
 
18
 DebugLog debug;
19
 DebugLog debug;
19
 
20
 
20
-#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
21
-
22
-void wifi_send_websocket(String s);
21
+#ifdef ENABLE_DEBUGLOG
23
 
22
 
24
 String DebugLog::getBuffer(void) {
23
 String DebugLog::getBuffer(void) {
25
     String r;
24
     String r;
40
 void DebugLog::sendToTargets(String s) {
39
 void DebugLog::sendToTargets(String s) {
41
     Serial.print(s);
40
     Serial.print(s);
42
     
41
     
43
-#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
44
     s = "log:" + s;
42
     s = "log:" + s;
45
     wifi_send_websocket(s);
43
     wifi_send_websocket(s);
46
-#endif
47
 }
44
 }
48
 
45
 
49
 void DebugLog::write(char c) {
46
 void DebugLog::write(char c) {
51
 }
48
 }
52
 
49
 
53
 void DebugLog::print(String s) {
50
 void DebugLog::print(String s) {
54
-#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
51
+#ifdef ENABLE_DEBUGLOG
55
     addToBuffer(s);
52
     addToBuffer(s);
56
-#endif
53
+#endif // ENABLE_DEBUGLOG
57
     
54
     
58
     sendToTargets(s);
55
     sendToTargets(s);
59
 }
56
 }

+ 8
- 4
src/html.cpp View File

163
     
163
     
164
 #endif
164
 #endif
165
 
165
 
166
+#ifdef ENABLE_BME280
167
+
166
     message += F("\n<p>\n");
168
     message += F("\n<p>\n");
167
     if (found_bme1) {
169
     if (found_bme1) {
168
         message += F("BME280 Low:");
170
         message += F("BME280 Low:");
213
     }
215
     }
214
     message += F("\n</p><hr>\n");
216
     message += F("\n</p><hr>\n");
215
 
217
 
218
+#endif // ENABLE_BME280
219
+
216
     ARDUINO_SEND_PARTIAL_PAGE();
220
     ARDUINO_SEND_PARTIAL_PAGE();
217
 
221
 
218
     message += F("\n<p>\n");
222
     message += F("\n<p>\n");
370
     message += String(millis() / 1000);
374
     message += String(millis() / 1000);
371
     message += F(" sec.</p>");
375
     message += F(" sec.</p>");
372
 
376
 
373
-#if ! defined(ARDUINO_ARCH_AVR)
377
+#ifdef ENABLE_DEBUGLOG
374
     message += F("<hr><p>Debug Log:</p>");
378
     message += F("<hr><p>Debug Log:</p>");
375
     message += F("<div class='log'><pre id='logbuf'>");
379
     message += F("<div class='log'><pre id='logbuf'>");
376
     message += debug.getBuffer();
380
     message += debug.getBuffer();
377
     message += F("</pre></div>");
381
     message += F("</pre></div>");
378
-#endif
382
+#endif // ENABLE_DEBUGLOG
379
 
383
 
380
     message += F("</body>");
384
     message += F("</body>");
381
 
385
 
382
-#if ! defined(ARDUINO_ARCH_AVR)
386
+#ifdef ENABLE_WEBSOCKETS
383
     message += F("<script type='text/javascript'>\n");
387
     message += F("<script type='text/javascript'>\n");
384
     message += F("var socket = new WebSocket('ws://' + window.location.hostname + ':81');\n");
388
     message += F("var socket = new WebSocket('ws://' + window.location.hostname + ':81');\n");
385
     message += F("socket.onmessage = function(e) {");
389
     message += F("socket.onmessage = function(e) {");
394
     message += F("var hist = document.getElementsByClassName('log')[0];\n");
398
     message += F("var hist = document.getElementsByClassName('log')[0];\n");
395
     message += F("hist.scrollTop = hist.scrollHeight;\n");
399
     message += F("hist.scrollTop = hist.scrollHeight;\n");
396
     message += F("</script>\n");
400
     message += F("</script>\n");
397
-#endif
401
+#endif // ENABLE_WEBSOCKETS
398
 
402
 
399
     message += F("</html>");
403
     message += F("</html>");
400
 
404
 

+ 4
- 0
src/influx.cpp View File

96
     InfluxData measurement("");
96
     InfluxData measurement("");
97
 #endif
97
 #endif
98
 
98
 
99
+#ifdef ENABLE_BME280
100
+
99
     if (found_bme1) {
101
     if (found_bme1) {
100
 #if defined(ARDUINO_ARCH_AVR)
102
 #if defined(ARDUINO_ARCH_AVR)
101
         measurement.clear();
103
         measurement.clear();
148
         debug.println(F("Done!"));
150
         debug.println(F("Done!"));
149
     }
151
     }
150
 
152
 
153
+#endif // ENABLE_BME280
154
+
151
     if (found_sht) {
155
     if (found_sht) {
152
 #if defined(ARDUINO_ARCH_AVR)
156
 #if defined(ARDUINO_ARCH_AVR)
153
         measurement.clear();
157
         measurement.clear();

+ 18
- 6
src/mqtt.cpp View File

53
         return;
53
         return;
54
     }
54
     }
55
 
55
 
56
-    if (found_bme1) {
56
+    if (found_sht) {
57
+        mqtt.publish(SENSOR_LOCATION "/temperature", String(sht_temp()).c_str(), true);
58
+        mqtt.publish(SENSOR_LOCATION "/humidity", String(sht_humid()).c_str(), true);
59
+#ifdef ENABLE_BME280
60
+    } else if (found_bme1) {
57
         mqtt.publish(SENSOR_LOCATION "/temperature", String(bme1_temp()).c_str(), true);
61
         mqtt.publish(SENSOR_LOCATION "/temperature", String(bme1_temp()).c_str(), true);
58
         mqtt.publish(SENSOR_LOCATION "/humidity", String(bme1_humid()).c_str(), true);
62
         mqtt.publish(SENSOR_LOCATION "/humidity", String(bme1_humid()).c_str(), true);
59
         mqtt.publish(SENSOR_LOCATION "/pressure", String(bme1_pressure()).c_str(), true);
63
         mqtt.publish(SENSOR_LOCATION "/pressure", String(bme1_pressure()).c_str(), true);
61
         mqtt.publish(SENSOR_LOCATION "/temperature", String(bme2_temp()).c_str(), true);
65
         mqtt.publish(SENSOR_LOCATION "/temperature", String(bme2_temp()).c_str(), true);
62
         mqtt.publish(SENSOR_LOCATION "/humidity", String(bme2_humid()).c_str(), true);
66
         mqtt.publish(SENSOR_LOCATION "/humidity", String(bme2_humid()).c_str(), true);
63
         mqtt.publish(SENSOR_LOCATION "/pressure", String(bme2_pressure()).c_str(), true);
67
         mqtt.publish(SENSOR_LOCATION "/pressure", String(bme2_pressure()).c_str(), true);
64
-    } else if (found_sht) {
65
-        mqtt.publish(SENSOR_LOCATION "/temperature", String(sht_temp()).c_str(), true);
66
-        mqtt.publish(SENSOR_LOCATION "/humidity", String(sht_humid()).c_str(), true);
68
+#endif // ENABLE_BME280
67
     }
69
     }
68
 
70
 
69
 #ifdef ENABLE_CCS811
71
 #ifdef ENABLE_CCS811
78
 }
80
 }
79
 
81
 
80
 static void mqttCallback(char* topic, byte* payload, unsigned int length) {
82
 static void mqttCallback(char* topic, byte* payload, unsigned int length) {
83
+    String ts(topic), ps;
84
+    for (unsigned int i = 0; i < length; i++) {
85
+        char c = payload[i];
86
+        ps += c;
87
+    }
88
+
89
+    debug.print(F("MQTT Rx @ \""));
90
+    debug.print(ts);
91
+    debug.print(F("\" = \""));
92
+    debug.print(ps);
93
+    debug.println(F("\""));
94
+
81
 #ifdef FEATURE_RELAIS
95
 #ifdef FEATURE_RELAIS
82
     int state = 0;
96
     int state = 0;
83
     int id = -1;
97
     int id = -1;
84
 
98
 
85
-    String ts(topic), ps((char *)payload);
86
-
87
     String our_topic(SENSOR_LOCATION);
99
     String our_topic(SENSOR_LOCATION);
88
     our_topic += "/";
100
     our_topic += "/";
89
 
101
 

+ 33
- 8
src/sensors.cpp View File

13
 
13
 
14
 #include <Arduino.h>
14
 #include <Arduino.h>
15
 
15
 
16
-#include <Adafruit_BME280.h>
17
 #include <SHT2x.h>
16
 #include <SHT2x.h>
18
 
17
 
18
+#ifdef ENABLE_BME280
19
+#include <Adafruit_BME280.h>
20
+#endif // ENABLE_BME280
21
+
19
 #ifdef ENABLE_CCS811
22
 #ifdef ENABLE_CCS811
20
 #include <Adafruit_CCS811.h>
23
 #include <Adafruit_CCS811.h>
21
 #endif // ENABLE_CCS811
24
 #endif // ENABLE_CCS811
51
 
54
 
52
 #endif
55
 #endif
53
 
56
 
57
+#ifdef ENABLE_BME280
54
 static Adafruit_BME280 bme1, bme2;
58
 static Adafruit_BME280 bme1, bme2;
55
-
56
 bool found_bme1 = false;
59
 bool found_bme1 = false;
57
 bool found_bme2 = false;
60
 bool found_bme2 = false;
61
+#endif // ENABLE_BME280
62
+
58
 bool found_sht = false;
63
 bool found_sht = false;
59
 
64
 
60
 #ifdef ENABLE_CCS811
65
 #ifdef ENABLE_CCS811
69
 
74
 
70
 static unsigned long last_sensor_handle_time = 0;
75
 static unsigned long last_sensor_handle_time = 0;
71
 
76
 
77
+#ifdef ENABLE_BME280
78
+
72
 float bme1_temp(void) {
79
 float bme1_temp(void) {
73
     while (1) {
80
     while (1) {
74
         float a = bme1.readTemperature();
81
         float a = bme1.readTemperature();
165
     return 0.0;
172
     return 0.0;
166
 }
173
 }
167
 
174
 
175
+#endif // ENABLE_BME280
176
+
168
 float sht_temp(void) {
177
 float sht_temp(void) {
169
     while (1) {
178
     while (1) {
170
         float a = sht.GetTemperature() + config.sht_temp_off;
179
         float a = sht.GetTemperature() + config.sht_temp_off;
218
 static void ccs_update() {
227
 static void ccs_update() {
219
     if (found_ccs1) {
228
     if (found_ccs1) {
220
         if (ccs1.available()) {
229
         if (ccs1.available()) {
221
-            if (found_bme1) {
230
+            if (found_sht) {
231
+                ccs1.setEnvironmentalData(sht_humid(), sht_temp());
232
+#ifdef ENABLE_BME280
233
+            } else if (found_bme1) {
222
                 ccs1.setEnvironmentalData(bme1_humid(), bme1_temp());
234
                 ccs1.setEnvironmentalData(bme1_humid(), bme1_temp());
223
             } else if (found_bme2) {
235
             } else if (found_bme2) {
224
                 ccs1.setEnvironmentalData(bme2_humid(), bme2_temp());
236
                 ccs1.setEnvironmentalData(bme2_humid(), bme2_temp());
225
-            } else if (found_sht) {
226
-                ccs1.setEnvironmentalData(sht_humid(), sht_temp());
237
+#endif // ENABLE_BME280
227
             }
238
             }
228
 
239
 
229
             ccs1_error_code = ccs1.readData();
240
             ccs1_error_code = ccs1.readData();
233
 
244
 
234
     if (found_ccs2) {
245
     if (found_ccs2) {
235
         if (ccs2.available()) {
246
         if (ccs2.available()) {
236
-            if (found_bme1) {
247
+            if (found_sht) {
248
+                ccs2.setEnvironmentalData(sht_humid(), sht_temp());
249
+#ifdef ENABLE_BME280
250
+            } else if (found_bme1) {
237
                 ccs2.setEnvironmentalData(bme1_humid(), bme1_temp());
251
                 ccs2.setEnvironmentalData(bme1_humid(), bme1_temp());
238
             } else if (found_bme2) {
252
             } else if (found_bme2) {
239
                 ccs2.setEnvironmentalData(bme2_humid(), bme2_temp());
253
                 ccs2.setEnvironmentalData(bme2_humid(), bme2_temp());
240
-            } else if (found_sht) {
241
-                ccs2.setEnvironmentalData(sht_humid(), sht_temp());
254
+#endif // ENABLE_BME280
242
             }
255
             }
243
 
256
 
244
             ccs2_error_code = ccs2.readData();
257
             ccs2_error_code = ccs2.readData();
253
 void handleCalibrate() {
266
 void handleCalibrate() {
254
     bool diff = false;
267
     bool diff = false;
255
 
268
 
269
+#ifdef ENABLE_BME280
270
+
256
     if (server.hasArg("bme1")) {
271
     if (server.hasArg("bme1")) {
257
         diff = true;
272
         diff = true;
258
         String off_string = server.arg("bme1");
273
         String off_string = server.arg("bme1");
269
         config.bme2_temp_off = real_temp - meas_temp;
284
         config.bme2_temp_off = real_temp - meas_temp;
270
     }
285
     }
271
 
286
 
287
+#endif // ENABLE_BME280
288
+
272
     if (server.hasArg("sht")) {
289
     if (server.hasArg("sht")) {
273
         diff = true;
290
         diff = true;
274
         String off_string = server.arg("sht");
291
         String off_string = server.arg("sht");
278
     }
295
     }
279
 
296
 
280
     if (diff) {
297
     if (diff) {
298
+#ifdef ENABLE_BME280
281
         if (found_bme1) {
299
         if (found_bme1) {
282
             bme1.setTemperatureCompensation(config.bme1_temp_off);
300
             bme1.setTemperatureCompensation(config.bme1_temp_off);
283
         }
301
         }
285
         if (found_bme2) {
303
         if (found_bme2) {
286
             bme2.setTemperatureCompensation(config.bme2_temp_off);
304
             bme2.setTemperatureCompensation(config.bme2_temp_off);
287
         }
305
         }
306
+#endif // ENABLE_BME280
288
 
307
 
289
         mem_write(config);
308
         mem_write(config);
290
         handlePage(42);
309
         handlePage(42);
301
     debug.println(F("Wire2"));
320
     debug.println(F("Wire2"));
302
     Wire2.begin(I2C_SDA_PIN, I2C_SCL_PIN);
321
     Wire2.begin(I2C_SDA_PIN, I2C_SCL_PIN);
303
 
322
 
323
+#ifdef ENABLE_BME280
304
     debug.println(F("BME"));
324
     debug.println(F("BME"));
305
     found_bme1 = (!bme1.begin(BME_I2C_ADDRESS_1, &Wire2)) ? false : true;
325
     found_bme1 = (!bme1.begin(BME_I2C_ADDRESS_1, &Wire2)) ? false : true;
306
     found_bme2 = (!bme2.begin(BME_I2C_ADDRESS_2, &Wire2)) ? false : true;
326
     found_bme2 = (!bme2.begin(BME_I2C_ADDRESS_2, &Wire2)) ? false : true;
327
+#endif // ENABLE_BME280
307
 
328
 
308
 #ifdef ENABLE_CCS811
329
 #ifdef ENABLE_CCS811
309
     debug.println(F("CCS"));
330
     debug.println(F("CCS"));
318
     Wire.begin();
339
     Wire.begin();
319
 #endif
340
 #endif
320
 
341
 
342
+#ifdef ENABLE_BME280
321
     debug.println(F("BME"));
343
     debug.println(F("BME"));
322
     found_bme1 = (!bme1.begin(BME_I2C_ADDRESS_1, &Wire)) ? false : true;
344
     found_bme1 = (!bme1.begin(BME_I2C_ADDRESS_1, &Wire)) ? false : true;
323
     found_bme2 = (!bme2.begin(BME_I2C_ADDRESS_2, &Wire)) ? false : true;
345
     found_bme2 = (!bme2.begin(BME_I2C_ADDRESS_2, &Wire)) ? false : true;
346
+#endif // ENABLE_BME280
324
 
347
 
325
 #ifdef ENABLE_CCS811
348
 #ifdef ENABLE_CCS811
326
     debug.println(F("CCS"));
349
     debug.println(F("CCS"));
333
     debug.println(F("SHT"));
356
     debug.println(F("SHT"));
334
     found_sht = sht.GetAlive();
357
     found_sht = sht.GetAlive();
335
 
358
 
359
+#ifdef ENABLE_BME280
336
     // initialize temperature offsets
360
     // initialize temperature offsets
337
     if (found_bme1) {
361
     if (found_bme1) {
338
         bme1.setTemperatureCompensation(config.bme1_temp_off);
362
         bme1.setTemperatureCompensation(config.bme1_temp_off);
340
     if (found_bme2) {
364
     if (found_bme2) {
341
         bme2.setTemperatureCompensation(config.bme2_temp_off);
365
         bme2.setTemperatureCompensation(config.bme2_temp_off);
342
     }
366
     }
367
+#endif // ENABLE_BME280
343
 }
368
 }
344
 
369
 
345
 void runSensors() {
370
 void runSensors() {

+ 10
- 3
src/servers.cpp View File

29
 
29
 
30
 #if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
30
 #if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
31
 
31
 
32
-#include <WebSocketsServer.h>
33
 #include "SimpleUpdater.h"
32
 #include "SimpleUpdater.h"
34
 
33
 
35
 UPDATE_WEB_SERVER server(80);
34
 UPDATE_WEB_SERVER server(80);
36
 SimpleUpdater updater;
35
 SimpleUpdater updater;
36
+
37
+#ifdef ENABLE_WEBSOCKETS
38
+#include <WebSocketsServer.h>
37
 WebSocketsServer socket(81);
39
 WebSocketsServer socket(81);
40
+#endif // ENABLE_WEBSOCKETS
38
 
41
 
39
 #elif defined(ARDUINO_ARCH_AVR)
42
 #elif defined(ARDUINO_ARCH_AVR)
40
 
43
 
57
 
60
 
58
 static unsigned long last_server_handle_time = 0;
61
 static unsigned long last_server_handle_time = 0;
59
 
62
 
60
-#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
61
 void wifi_send_websocket(String s) {
63
 void wifi_send_websocket(String s) {
64
+#ifdef ENABLE_WEBSOCKETS
62
     socket.broadcastTXT(s);
65
     socket.broadcastTXT(s);
66
+#endif // ENABLE_WEBSOCKETS
63
 }
67
 }
64
-#endif
65
 
68
 
66
 #ifdef FEATURE_RELAIS
69
 #ifdef FEATURE_RELAIS
67
 
70
 
143
 
146
 
144
     MDNS.addService("http", "tcp", 80);
147
     MDNS.addService("http", "tcp", 80);
145
 
148
 
149
+#ifdef ENABLE_WEBSOCKETS
146
     socket.begin();
150
     socket.begin();
151
+#endif // ENABLE_WEBSOCKETS
147
 #endif
152
 #endif
148
 
153
 
149
     server.begin();
154
     server.begin();
220
         handleServers();
225
         handleServers();
221
 
226
 
222
 #if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
227
 #if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
228
+#ifdef ENABLE_WEBSOCKETS
223
         socket.loop();
229
         socket.loop();
230
+#endif // ENABLE_WEBSOCKETS
224
 #endif
231
 #endif
225
     }
232
     }
226
     
233
     

Loading…
Cancel
Save