Skip to content

Commit 4f61d3a

Browse files
committed
Option to remove API_SUPPORT at build time
1 parent b497cc8 commit 4f61d3a

24 files changed

+15063
-15017
lines changed

code/espurna/api.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
66
77
*/
88

9-
#if WEB_SUPPORT
9+
#if API_SUPPORT
1010

1111
#include <ESPAsyncTCP.h>
1212
#include <ESPAsyncWebServer.h>
@@ -27,6 +27,7 @@ bool _apiWebSocketOnReceive(const char * key, JsonVariant& value) {
2727
}
2828

2929
void _apiWebSocketOnSend(JsonObject& root) {
30+
root["apiVisible"] = 1;
3031
root["apiEnabled"] = getSetting("apiEnabled", API_ENABLED).toInt() == 1;
3132
root["apiKey"] = getSetting("apiKey");
3233
root["apiRealTime"] = getSetting("apiRealTime", API_REAL_TIME_VALUES).toInt() == 1;
@@ -216,4 +217,4 @@ void apiSetup() {
216217
webRequestRegister(_apiRequestCallback);
217218
}
218219

219-
#endif // WEB_SUPPORT
220+
#endif // API_SUPPORT

code/espurna/config/arduino.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@
9797
//--------------------------------------------------------------------------------
9898

9999
//#define ALEXA_SUPPORT 0
100+
//#define API_SUPPORT 0
100101
//#define BROKER_SUPPORT 0
102+
//#define BUTTON_SUPPORT 0
101103
//#define DEBUG_SERIAL_SUPPORT 0
102104
//#define DEBUG_TELNET_SUPPORT 0
103105
//#define DEBUG_UDP_SUPPORT 1
@@ -107,15 +109,18 @@
107109
//#define I2C_SUPPORT 1
108110
//#define INFLUXDB_SUPPORT 1
109111
//#define IR_SUPPORT 1
112+
//#define LED_SUPPORT 0
110113
//#define LLMNR_SUPPORT 1 // Only with Arduino Core 2.4.0
111-
//#define MDNS_SERVER_SUPPORT 0
112114
//#define MDNS_CLIENT_SUPPORT 1
115+
//#define MDNS_SERVER_SUPPORT 0
113116
//#define MQTT_SUPPORT 0
114117
//#define NETBIOS_SUPPORT 1 // Only with Arduino Core 2.4.0
115118
//#define NOFUSS_SUPPORT 1
116119
//#define NTP_SUPPORT 0
120+
//#define RFM69_SUPPORT 1
117121
//#define RF_SUPPORT 1
118122
//#define SCHEDULER_SUPPORT 0
123+
//#define SENSOR_SUPPORT 1
119124
//#define SPIFFS_SUPPORT 1
120125
//#define SSDP_SUPPORT 1
121126
//#define TELNET_SUPPORT 0
@@ -141,6 +146,7 @@
141146
//#define EMON_ADS1X15_SUPPORT 1
142147
//#define EMON_ANALOG_SUPPORT 1
143148
//#define EVENTS_SUPPORT 1
149+
//#define GEIGER_SUPPORT 1
144150
//#define GUVAS12SD_SUPPORT 1
145151
//#define HLW8012_SUPPORT 1
146152
//#define MHZ19_SUPPORT 1
@@ -152,4 +158,3 @@
152158
//#define SONAR_SUPPORT 1
153159
//#define TMP3X_SUPPORT 1
154160
//#define V9261F_SUPPORT 1
155-
//#define GEIGER_SUPPORT 1

code/espurna/config/dependencies.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
#define DEBUG_WEB_SUPPORT 0
1616
#endif
1717

18+
#if not WEB_SUPPORT
19+
#undef API_SUPPORT
20+
#define API_SUPPORT 0 // API support requires web support
21+
#endif
22+
1823
#if not WEB_SUPPORT
1924
#undef SSDP_SUPPORT
2025
#define SSDP_SUPPORT 0 // SSDP support requires web support

code/espurna/config/general.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,10 @@
431431
// API
432432
// -----------------------------------------------------------------------------
433433

434+
#ifndef API_SUPPORT
435+
#define API_SUPPORT 1 // API (REST & RPC) support built in
436+
#endif
437+
434438
// This will only be enabled if WEB_SUPPORT is 1 (this is the default value)
435439
#ifndef API_ENABLED
436440
#define API_ENABLED 0 // Do not enable API by default

code/espurna/config/hardware.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@
721721
// the port and remove UART noise on serial line
722722
#if not RFB_DIRECT
723723
#define SERIAL_BAUDRATE 19200
724-
#define DEBUG_SERIAL_SUPPORT 0
724+
//#define DEBUG_SERIAL_SUPPORT 0
725725
#endif
726726

727727
#elif defined(ITEAD_SONOFF_B1)

code/espurna/config/progmem.h

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,15 @@ PROGMEM const char espurna_modules[] =
3131
#if ALEXA_SUPPORT
3232
"ALEXA "
3333
#endif
34+
#if API_SUPPORT
35+
"API "
36+
#endif
3437
#if BROKER_SUPPORT
3538
"BROKER "
3639
#endif
40+
#if BUTTON_SUPPORT
41+
"BUTTON "
42+
#endif
3743
#if DEBUG_SERIAL_SUPPORT
3844
"DEBUG_SERIAL "
3945
#endif
@@ -61,15 +67,18 @@ PROGMEM const char espurna_modules[] =
6167
#if IR_SUPPORT
6268
"IR "
6369
#endif
70+
#if LED_SUPPORT
71+
"LED "
72+
#endif
6473
#if LLMNR_SUPPORT
6574
"LLMNR "
6675
#endif
67-
#if MDNS_SERVER_SUPPORT
68-
"MDNS_SERVER "
69-
#endif
7076
#if MDNS_CLIENT_SUPPORT
7177
"MDNS_CLIENT "
7278
#endif
79+
#if MDNS_SERVER_SUPPORT
80+
"MDNS_SERVER "
81+
#endif
7382
#if MQTT_SUPPORT
7483
"MQTT "
7584
#endif
@@ -82,12 +91,12 @@ PROGMEM const char espurna_modules[] =
8291
#if NTP_SUPPORT
8392
"NTP "
8493
#endif
85-
#if RF_SUPPORT
86-
"RF "
87-
#endif
8894
#if RFM69_SUPPORT
8995
"RFM69 "
9096
#endif
97+
#if RF_SUPPORT
98+
"RF "
99+
#endif
91100
#if SCHEDULER_SUPPORT
92101
"SCHEDULER "
93102
#endif
@@ -169,9 +178,6 @@ PROGMEM const char espurna_sensors[] =
169178
#if GUVAS12SD_SUPPORT
170179
"GUVAS12SD "
171180
#endif
172-
#if SONAR_SUPPORT
173-
"SONAR "
174-
#endif
175181
#if HLW8012_SUPPORT
176182
"HLW8012 "
177183
#endif
@@ -196,6 +202,9 @@ PROGMEM const char espurna_sensors[] =
196202
#if SI7021_SUPPORT
197203
"SI7021 "
198204
#endif
205+
#if SONAR_SUPPORT
206+
"SONAR "
207+
#endif
199208
#if TMP3X_SUPPORT
200209
"TMP3X "
201210
#endif

code/espurna/config/sensors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@
534534

535535
//------------------------------------------------------------------------------
536536
// SHT3X I2C (Wemos) temperature & humidity sensor
537-
// Enable support by passing SHT3X_SUPPORT=1 build flag
537+
// Enable support by passing SHT3X_I2C_SUPPORT=1 build flag
538538
//------------------------------------------------------------------------------
539539

540540
#ifndef SHT3X_I2C_SUPPORT

code/espurna/data/index.all.html.gz

7 Bytes
Binary file not shown.

code/espurna/data/index.light.html.gz

15 Bytes
Binary file not shown.
12 Bytes
Binary file not shown.

code/espurna/data/index.rfm69.html.gz

9 Bytes
Binary file not shown.
10 Bytes
Binary file not shown.

code/espurna/data/index.small.html.gz

14 Bytes
Binary file not shown.

code/espurna/espurna.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,13 @@ void setup() {
8787
#if WEB_SUPPORT
8888
webSetup();
8989
wsSetup();
90-
apiSetup();
9190
#if DEBUG_WEB_SUPPORT
9291
debugWebSetup();
9392
#endif
9493
#endif
94+
#if API_SUPPORT
95+
apiSetup();
96+
#endif
9597

9698
// lightSetup must be called before relaySetup
9799
#if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE

code/espurna/light.ino

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ void _fromHSV(const char * hsv) {
282282
void _fromKelvin(unsigned long kelvin) {
283283

284284
if (!_light_has_color) return;
285-
285+
286286
_light_mireds = constrain(round(1000000UL / kelvin), LIGHT_MIN_MIREDS, LIGHT_MAX_MIREDS);
287287

288288
if (_light_use_cct) {
@@ -826,6 +826,10 @@ void _lightWebSocketOnAction(uint32_t client_id, const char * action, JsonObject
826826
}
827827
}
828828

829+
#endif
830+
831+
#if API_SUPPORT
832+
829833
void _lightAPISetup() {
830834
// API entry points (protected with apikey)
831835
if (_light_has_color) {
@@ -896,7 +900,7 @@ void _lightAPISetup() {
896900
}
897901
}
898902

899-
#endif // WEB_SUPPORT
903+
#endif // API_SUPPORT
900904

901905
#if TERMINAL_SUPPORT
902906

@@ -1069,7 +1073,6 @@ void lightSetup() {
10691073
_lightColorRestore();
10701074

10711075
#if WEB_SUPPORT
1072-
_lightAPISetup();
10731076
wsOnSendRegister(_lightWebSocketOnSend);
10741077
wsOnActionRegister(_lightWebSocketOnAction);
10751078
wsOnReceiveRegister(_lightWebSocketOnReceive);
@@ -1081,6 +1084,10 @@ void lightSetup() {
10811084
});
10821085
#endif
10831086

1087+
#if API_SUPPORT
1088+
_lightAPISetup();
1089+
#endif
1090+
10841091
#if MQTT_SUPPORT
10851092
mqttRegister(_lightMQTTCallback);
10861093
#endif

code/espurna/relay.ino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ void relaySetupWS() {
628628
// REST API
629629
//------------------------------------------------------------------------------
630630

631-
#if WEB_SUPPORT
631+
#if API_SUPPORT
632632

633633
void relaySetupAPI() {
634634

@@ -700,7 +700,7 @@ void relaySetupAPI() {
700700

701701
}
702702

703-
#endif // WEB_SUPPORT
703+
#endif // API_SUPPORT
704704

705705
//------------------------------------------------------------------------------
706706
// MQTT
@@ -1007,9 +1007,11 @@ void relaySetup() {
10071007
espurnaRegisterLoop(_relayLoop);
10081008

10091009
#if WEB_SUPPORT
1010-
relaySetupAPI();
10111010
relaySetupWS();
10121011
#endif
1012+
#if API_SUPPORT
1013+
relaySetupAPI();
1014+
#endif
10131015
#if MQTT_SUPPORT
10141016
relaySetupMQTT();
10151017
#endif

code/espurna/sensor.ino

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ void _sensorWebSocketStart(JsonObject& root) {
223223

224224
}
225225

226+
#endif // WEB_SUPPORT
227+
228+
#if API_SUPPORT
229+
226230
void _sensorAPISetup() {
227231

228232
for (unsigned char magnitude_id=0; magnitude_id<_magnitudes.size(); magnitude_id++) {
@@ -242,7 +246,8 @@ void _sensorAPISetup() {
242246
}
243247

244248
}
245-
#endif
249+
250+
#endif // API_SUPPORT
246251

247252
#if TERMINAL_SUPPORT
248253

@@ -1027,19 +1032,20 @@ void sensorSetup() {
10271032
// Configure stored values
10281033
_sensorConfigure();
10291034

1035+
// Websockets
10301036
#if WEB_SUPPORT
1031-
1032-
// Websockets
10331037
wsOnSendRegister(_sensorWebSocketStart);
10341038
wsOnReceiveRegister(_sensorWebSocketOnReceive);
10351039
wsOnSendRegister(_sensorWebSocketSendData);
10361040
wsOnAfterParseRegister(_sensorConfigure);
1041+
#endif
10371042

1038-
// API
1043+
// API
1044+
#if API_SUPPORT
10391045
_sensorAPISetup();
1040-
10411046
#endif
10421047

1048+
// Terminal
10431049
#if TERMINAL_SUPPORT
10441050
_sensorInitCommands();
10451051
#endif

0 commit comments

Comments
 (0)