Browse Source

Option to remove API_SUPPORT at build time

ech1560
Xose Pérez 6 years ago
parent
commit
4f61d3aa7e
24 changed files with 15063 additions and 15017 deletions
  1. +3
    -2
      code/espurna/api.ino
  2. +7
    -2
      code/espurna/config/arduino.h
  3. +5
    -0
      code/espurna/config/dependencies.h
  4. +4
    -0
      code/espurna/config/general.h
  5. +1
    -1
      code/espurna/config/hardware.h
  6. +18
    -9
      code/espurna/config/progmem.h
  7. +1
    -1
      code/espurna/config/sensors.h
  8. BIN
      code/espurna/data/index.all.html.gz
  9. BIN
      code/espurna/data/index.light.html.gz
  10. BIN
      code/espurna/data/index.rfbridge.html.gz
  11. BIN
      code/espurna/data/index.rfm69.html.gz
  12. BIN
      code/espurna/data/index.sensor.html.gz
  13. BIN
      code/espurna/data/index.small.html.gz
  14. +3
    -1
      code/espurna/espurna.ino
  15. +10
    -3
      code/espurna/light.ino
  16. +5
    -3
      code/espurna/relay.ino
  17. +11
    -5
      code/espurna/sensor.ino
  18. +3046
    -3045
      code/espurna/static/index.all.html.gz.h
  19. +2386
    -2386
      code/espurna/static/index.light.html.gz.h
  20. +2051
    -2050
      code/espurna/static/index.rfbridge.html.gz.h
  21. +3411
    -3410
      code/espurna/static/index.rfm69.html.gz.h
  22. +2090
    -2089
      code/espurna/static/index.sensor.html.gz.h
  23. +2008
    -2007
      code/espurna/static/index.small.html.gz.h
  24. +3
    -3
      code/html/index.html

+ 3
- 2
code/espurna/api.ino View File

@ -6,7 +6,7 @@ Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
*/ */
#if WEB_SUPPORT
#if API_SUPPORT
#include <ESPAsyncTCP.h> #include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h> #include <ESPAsyncWebServer.h>
@ -27,6 +27,7 @@ bool _apiWebSocketOnReceive(const char * key, JsonVariant& value) {
} }
void _apiWebSocketOnSend(JsonObject& root) { void _apiWebSocketOnSend(JsonObject& root) {
root["apiVisible"] = 1;
root["apiEnabled"] = getSetting("apiEnabled", API_ENABLED).toInt() == 1; root["apiEnabled"] = getSetting("apiEnabled", API_ENABLED).toInt() == 1;
root["apiKey"] = getSetting("apiKey"); root["apiKey"] = getSetting("apiKey");
root["apiRealTime"] = getSetting("apiRealTime", API_REAL_TIME_VALUES).toInt() == 1; root["apiRealTime"] = getSetting("apiRealTime", API_REAL_TIME_VALUES).toInt() == 1;
@ -216,4 +217,4 @@ void apiSetup() {
webRequestRegister(_apiRequestCallback); webRequestRegister(_apiRequestCallback);
} }
#endif // WEB_SUPPORT
#endif // API_SUPPORT

+ 7
- 2
code/espurna/config/arduino.h View File

@ -97,7 +97,9 @@
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
//#define ALEXA_SUPPORT 0 //#define ALEXA_SUPPORT 0
//#define API_SUPPORT 0
//#define BROKER_SUPPORT 0 //#define BROKER_SUPPORT 0
//#define BUTTON_SUPPORT 0
//#define DEBUG_SERIAL_SUPPORT 0 //#define DEBUG_SERIAL_SUPPORT 0
//#define DEBUG_TELNET_SUPPORT 0 //#define DEBUG_TELNET_SUPPORT 0
//#define DEBUG_UDP_SUPPORT 1 //#define DEBUG_UDP_SUPPORT 1
@ -107,15 +109,18 @@
//#define I2C_SUPPORT 1 //#define I2C_SUPPORT 1
//#define INFLUXDB_SUPPORT 1 //#define INFLUXDB_SUPPORT 1
//#define IR_SUPPORT 1 //#define IR_SUPPORT 1
//#define LED_SUPPORT 0
//#define LLMNR_SUPPORT 1 // Only with Arduino Core 2.4.0 //#define LLMNR_SUPPORT 1 // Only with Arduino Core 2.4.0
//#define MDNS_SERVER_SUPPORT 0
//#define MDNS_CLIENT_SUPPORT 1 //#define MDNS_CLIENT_SUPPORT 1
//#define MDNS_SERVER_SUPPORT 0
//#define MQTT_SUPPORT 0 //#define MQTT_SUPPORT 0
//#define NETBIOS_SUPPORT 1 // Only with Arduino Core 2.4.0 //#define NETBIOS_SUPPORT 1 // Only with Arduino Core 2.4.0
//#define NOFUSS_SUPPORT 1 //#define NOFUSS_SUPPORT 1
//#define NTP_SUPPORT 0 //#define NTP_SUPPORT 0
//#define RFM69_SUPPORT 1
//#define RF_SUPPORT 1 //#define RF_SUPPORT 1
//#define SCHEDULER_SUPPORT 0 //#define SCHEDULER_SUPPORT 0
//#define SENSOR_SUPPORT 1
//#define SPIFFS_SUPPORT 1 //#define SPIFFS_SUPPORT 1
//#define SSDP_SUPPORT 1 //#define SSDP_SUPPORT 1
//#define TELNET_SUPPORT 0 //#define TELNET_SUPPORT 0
@ -141,6 +146,7 @@
//#define EMON_ADS1X15_SUPPORT 1 //#define EMON_ADS1X15_SUPPORT 1
//#define EMON_ANALOG_SUPPORT 1 //#define EMON_ANALOG_SUPPORT 1
//#define EVENTS_SUPPORT 1 //#define EVENTS_SUPPORT 1
//#define GEIGER_SUPPORT 1
//#define GUVAS12SD_SUPPORT 1 //#define GUVAS12SD_SUPPORT 1
//#define HLW8012_SUPPORT 1 //#define HLW8012_SUPPORT 1
//#define MHZ19_SUPPORT 1 //#define MHZ19_SUPPORT 1
@ -152,4 +158,3 @@
//#define SONAR_SUPPORT 1 //#define SONAR_SUPPORT 1
//#define TMP3X_SUPPORT 1 //#define TMP3X_SUPPORT 1
//#define V9261F_SUPPORT 1 //#define V9261F_SUPPORT 1
//#define GEIGER_SUPPORT 1

+ 5
- 0
code/espurna/config/dependencies.h View File

@ -15,6 +15,11 @@
#define DEBUG_WEB_SUPPORT 0 #define DEBUG_WEB_SUPPORT 0
#endif #endif
#if not WEB_SUPPORT
#undef API_SUPPORT
#define API_SUPPORT 0 // API support requires web support
#endif
#if not WEB_SUPPORT #if not WEB_SUPPORT
#undef SSDP_SUPPORT #undef SSDP_SUPPORT
#define SSDP_SUPPORT 0 // SSDP support requires web support #define SSDP_SUPPORT 0 // SSDP support requires web support


+ 4
- 0
code/espurna/config/general.h View File

@ -431,6 +431,10 @@
// API // API
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#ifndef API_SUPPORT
#define API_SUPPORT 1 // API (REST & RPC) support built in
#endif
// This will only be enabled if WEB_SUPPORT is 1 (this is the default value) // This will only be enabled if WEB_SUPPORT is 1 (this is the default value)
#ifndef API_ENABLED #ifndef API_ENABLED
#define API_ENABLED 0 // Do not enable API by default #define API_ENABLED 0 // Do not enable API by default


+ 1
- 1
code/espurna/config/hardware.h View File

@ -721,7 +721,7 @@
// the port and remove UART noise on serial line // the port and remove UART noise on serial line
#if not RFB_DIRECT #if not RFB_DIRECT
#define SERIAL_BAUDRATE 19200 #define SERIAL_BAUDRATE 19200
#define DEBUG_SERIAL_SUPPORT 0
//#define DEBUG_SERIAL_SUPPORT 0
#endif #endif
#elif defined(ITEAD_SONOFF_B1) #elif defined(ITEAD_SONOFF_B1)


+ 18
- 9
code/espurna/config/progmem.h View File

@ -31,9 +31,15 @@ PROGMEM const char espurna_modules[] =
#if ALEXA_SUPPORT #if ALEXA_SUPPORT
"ALEXA " "ALEXA "
#endif #endif
#if API_SUPPORT
"API "
#endif
#if BROKER_SUPPORT #if BROKER_SUPPORT
"BROKER " "BROKER "
#endif #endif
#if BUTTON_SUPPORT
"BUTTON "
#endif
#if DEBUG_SERIAL_SUPPORT #if DEBUG_SERIAL_SUPPORT
"DEBUG_SERIAL " "DEBUG_SERIAL "
#endif #endif
@ -61,15 +67,18 @@ PROGMEM const char espurna_modules[] =
#if IR_SUPPORT #if IR_SUPPORT
"IR " "IR "
#endif #endif
#if LED_SUPPORT
"LED "
#endif
#if LLMNR_SUPPORT #if LLMNR_SUPPORT
"LLMNR " "LLMNR "
#endif #endif
#if MDNS_SERVER_SUPPORT
"MDNS_SERVER "
#endif
#if MDNS_CLIENT_SUPPORT #if MDNS_CLIENT_SUPPORT
"MDNS_CLIENT " "MDNS_CLIENT "
#endif #endif
#if MDNS_SERVER_SUPPORT
"MDNS_SERVER "
#endif
#if MQTT_SUPPORT #if MQTT_SUPPORT
"MQTT " "MQTT "
#endif #endif
@ -82,12 +91,12 @@ PROGMEM const char espurna_modules[] =
#if NTP_SUPPORT #if NTP_SUPPORT
"NTP " "NTP "
#endif #endif
#if RF_SUPPORT
"RF "
#endif
#if RFM69_SUPPORT #if RFM69_SUPPORT
"RFM69 " "RFM69 "
#endif #endif
#if RF_SUPPORT
"RF "
#endif
#if SCHEDULER_SUPPORT #if SCHEDULER_SUPPORT
"SCHEDULER " "SCHEDULER "
#endif #endif
@ -169,9 +178,6 @@ PROGMEM const char espurna_sensors[] =
#if GUVAS12SD_SUPPORT #if GUVAS12SD_SUPPORT
"GUVAS12SD " "GUVAS12SD "
#endif #endif
#if SONAR_SUPPORT
"SONAR "
#endif
#if HLW8012_SUPPORT #if HLW8012_SUPPORT
"HLW8012 " "HLW8012 "
#endif #endif
@ -196,6 +202,9 @@ PROGMEM const char espurna_sensors[] =
#if SI7021_SUPPORT #if SI7021_SUPPORT
"SI7021 " "SI7021 "
#endif #endif
#if SONAR_SUPPORT
"SONAR "
#endif
#if TMP3X_SUPPORT #if TMP3X_SUPPORT
"TMP3X " "TMP3X "
#endif #endif


+ 1
- 1
code/espurna/config/sensors.h View File

@ -534,7 +534,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// SHT3X I2C (Wemos) temperature & humidity sensor // SHT3X I2C (Wemos) temperature & humidity sensor
// Enable support by passing SHT3X_SUPPORT=1 build flag
// Enable support by passing SHT3X_I2C_SUPPORT=1 build flag
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#ifndef SHT3X_I2C_SUPPORT #ifndef SHT3X_I2C_SUPPORT


BIN
code/espurna/data/index.all.html.gz View File


BIN
code/espurna/data/index.light.html.gz View File


BIN
code/espurna/data/index.rfbridge.html.gz View File


BIN
code/espurna/data/index.rfm69.html.gz View File


BIN
code/espurna/data/index.sensor.html.gz View File


BIN
code/espurna/data/index.small.html.gz View File


+ 3
- 1
code/espurna/espurna.ino View File

@ -87,11 +87,13 @@ void setup() {
#if WEB_SUPPORT #if WEB_SUPPORT
webSetup(); webSetup();
wsSetup(); wsSetup();
apiSetup();
#if DEBUG_WEB_SUPPORT #if DEBUG_WEB_SUPPORT
debugWebSetup(); debugWebSetup();
#endif #endif
#endif #endif
#if API_SUPPORT
apiSetup();
#endif
// lightSetup must be called before relaySetup // lightSetup must be called before relaySetup
#if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE #if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE


+ 10
- 3
code/espurna/light.ino View File

@ -282,7 +282,7 @@ void _fromHSV(const char * hsv) {
void _fromKelvin(unsigned long kelvin) { void _fromKelvin(unsigned long kelvin) {
if (!_light_has_color) return; if (!_light_has_color) return;
_light_mireds = constrain(round(1000000UL / kelvin), LIGHT_MIN_MIREDS, LIGHT_MAX_MIREDS); _light_mireds = constrain(round(1000000UL / kelvin), LIGHT_MIN_MIREDS, LIGHT_MAX_MIREDS);
if (_light_use_cct) { if (_light_use_cct) {
@ -826,6 +826,10 @@ void _lightWebSocketOnAction(uint32_t client_id, const char * action, JsonObject
} }
} }
#endif
#if API_SUPPORT
void _lightAPISetup() { void _lightAPISetup() {
// API entry points (protected with apikey) // API entry points (protected with apikey)
if (_light_has_color) { if (_light_has_color) {
@ -896,7 +900,7 @@ void _lightAPISetup() {
} }
} }
#endif // WEB_SUPPORT
#endif // API_SUPPORT
#if TERMINAL_SUPPORT #if TERMINAL_SUPPORT
@ -1069,7 +1073,6 @@ void lightSetup() {
_lightColorRestore(); _lightColorRestore();
#if WEB_SUPPORT #if WEB_SUPPORT
_lightAPISetup();
wsOnSendRegister(_lightWebSocketOnSend); wsOnSendRegister(_lightWebSocketOnSend);
wsOnActionRegister(_lightWebSocketOnAction); wsOnActionRegister(_lightWebSocketOnAction);
wsOnReceiveRegister(_lightWebSocketOnReceive); wsOnReceiveRegister(_lightWebSocketOnReceive);
@ -1081,6 +1084,10 @@ void lightSetup() {
}); });
#endif #endif
#if API_SUPPORT
_lightAPISetup();
#endif
#if MQTT_SUPPORT #if MQTT_SUPPORT
mqttRegister(_lightMQTTCallback); mqttRegister(_lightMQTTCallback);
#endif #endif


+ 5
- 3
code/espurna/relay.ino View File

@ -628,7 +628,7 @@ void relaySetupWS() {
// REST API // REST API
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#if WEB_SUPPORT
#if API_SUPPORT
void relaySetupAPI() { void relaySetupAPI() {
@ -700,7 +700,7 @@ void relaySetupAPI() {
} }
#endif // WEB_SUPPORT
#endif // API_SUPPORT
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// MQTT // MQTT
@ -1007,9 +1007,11 @@ void relaySetup() {
espurnaRegisterLoop(_relayLoop); espurnaRegisterLoop(_relayLoop);
#if WEB_SUPPORT #if WEB_SUPPORT
relaySetupAPI();
relaySetupWS(); relaySetupWS();
#endif #endif
#if API_SUPPORT
relaySetupAPI();
#endif
#if MQTT_SUPPORT #if MQTT_SUPPORT
relaySetupMQTT(); relaySetupMQTT();
#endif #endif


+ 11
- 5
code/espurna/sensor.ino View File

@ -223,6 +223,10 @@ void _sensorWebSocketStart(JsonObject& root) {
} }
#endif // WEB_SUPPORT
#if API_SUPPORT
void _sensorAPISetup() { void _sensorAPISetup() {
for (unsigned char magnitude_id=0; magnitude_id<_magnitudes.size(); magnitude_id++) { for (unsigned char magnitude_id=0; magnitude_id<_magnitudes.size(); magnitude_id++) {
@ -242,7 +246,8 @@ void _sensorAPISetup() {
} }
} }
#endif
#endif // API_SUPPORT
#if TERMINAL_SUPPORT #if TERMINAL_SUPPORT
@ -1027,19 +1032,20 @@ void sensorSetup() {
// Configure stored values // Configure stored values
_sensorConfigure(); _sensorConfigure();
// Websockets
#if WEB_SUPPORT #if WEB_SUPPORT
// Websockets
wsOnSendRegister(_sensorWebSocketStart); wsOnSendRegister(_sensorWebSocketStart);
wsOnReceiveRegister(_sensorWebSocketOnReceive); wsOnReceiveRegister(_sensorWebSocketOnReceive);
wsOnSendRegister(_sensorWebSocketSendData); wsOnSendRegister(_sensorWebSocketSendData);
wsOnAfterParseRegister(_sensorConfigure); wsOnAfterParseRegister(_sensorConfigure);
#endif
// API
// API
#if API_SUPPORT
_sensorAPISetup(); _sensorAPISetup();
#endif #endif
// Terminal
#if TERMINAL_SUPPORT #if TERMINAL_SUPPORT
_sensorInitCommands(); _sensorInitCommands();
#endif #endif


+ 3046
- 3045
code/espurna/static/index.all.html.gz.h
File diff suppressed because it is too large
View File


+ 2386
- 2386
code/espurna/static/index.light.html.gz.h
File diff suppressed because it is too large
View File


+ 2051
- 2050
code/espurna/static/index.rfbridge.html.gz.h
File diff suppressed because it is too large
View File


+ 3411
- 3410
code/espurna/static/index.rfm69.html.gz.h
File diff suppressed because it is too large
View File


+ 2090
- 2089
code/espurna/static/index.sensor.html.gz.h
File diff suppressed because it is too large
View File


+ 2008
- 2007
code/espurna/static/index.small.html.gz.h
File diff suppressed because it is too large
View File


+ 3
- 3
code/html/index.html View File

@ -550,12 +550,12 @@
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="wsAuth" /></div> <div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="wsAuth" /></div>
</div> </div>
<div class="pure-g">
<div class="pure-g module module-api">
<label class="pure-u-1 pure-u-lg-1-4">Enable HTTP API</label> <label class="pure-u-1 pure-u-lg-1-4">Enable HTTP API</label>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="apiEnabled" /></div> <div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="apiEnabled" /></div>
</div> </div>
<div class="pure-g">
<div class="pure-g module module-api">
<label class="pure-u-1 pure-u-lg-1-4">Real time API</label> <label class="pure-u-1 pure-u-lg-1-4">Real time API</label>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="apiRealTime" /></div> <div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="apiRealTime" /></div>
<div class="pure-u-0 pure-u-lg-1-2"></div> <div class="pure-u-0 pure-u-lg-1-2"></div>
@ -566,7 +566,7 @@
</div> </div>
</div> </div>
<div class="pure-g">
<div class="pure-g module module-api">
<label class="pure-u-1 pure-u-lg-1-4">HTTP API Key</label> <label class="pure-u-1 pure-u-lg-1-4">HTTP API Key</label>
<input name="apiKey" class="pure-u-3-4 pure-u-lg-1-2" type="text" tabindex="14" /> <input name="apiKey" class="pure-u-3-4 pure-u-lg-1-2" type="text" tabindex="14" />
<div class=" pure-u-1-4 pure-u-lg-1-4"><button class="pure-button button-apikey pure-u-23-24">Auto</button></div> <div class=" pure-u-1-4 pure-u-lg-1-4"><button class="pure-button button-apikey pure-u-23-24">Auto</button></div>


Loading…
Cancel
Save