Browse Source

Do not compile with fauxmo support by default

fastled
Xose Pérez 8 years ago
parent
commit
6770194287
7 changed files with 41 additions and 6 deletions
  1. +5
    -0
      code/html/index.html
  2. +1
    -1
      code/lib/fauxmoESP
  3. +1
    -1
      code/platformio.ini
  4. +2
    -1
      code/src/defaults.h
  5. +6
    -2
      code/src/fauxmo.ino
  6. +3
    -1
      code/src/main.ino
  7. +23
    -0
      code/src/web.ino

+ 5
- 0
code/html/index.html View File

@ -178,6 +178,11 @@
<div class="pure-u-1 pure-u-md-3-4 hint">The administrator password is used to access this web interface (user 'admin'), but also to connect to the device when in AP mode or to flash a new firmware over-the-air (OTA).</div> <div class="pure-u-1 pure-u-md-3-4 hint">The administrator password is used to access this web interface (user 'admin'), but also to connect to the device when in AP mode or to flash a new firmware over-the-air (OTA).</div>
</div> </div>
<div class="pure-g module module-fauxmo">
<div class="pure-u-1 pure-u-sm-1-4"><label for="fauxmoEnabled">Enable WeMo emulation</label></div>
<div class="pure-u-1 pure-u-sm-1-4"><input type="checkbox" name="fauxmoEnabled" /></div>
</div>
<div class="pure-g"> <div class="pure-g">
<div class="pure-u-1 pure-u-sm-1-4"><label for="apiEnabled">Enable HTTP API</label></div> <div class="pure-u-1 pure-u-sm-1-4"><label for="apiEnabled">Enable HTTP API</label></div>
<div class="pure-u-1 pure-u-sm-1-4"><input type="checkbox" name="apiEnabled" /></div> <div class="pure-u-1 pure-u-sm-1-4"><input type="checkbox" name="apiEnabled" /></div>


+ 1
- 1
code/lib/fauxmoESP

@ -1 +1 @@
Subproject commit a04b0f77b59e19698fdeb087aeb60e18a5adf858
Subproject commit bce66aba0ec2707e0139f859f1dd3dff0c06ef14

+ 1
- 1
code/platformio.ini View File

@ -86,7 +86,7 @@ framework = arduino
lib_install = ${common.lib_install} lib_install = ${common.lib_install}
extra_script = pio_hooks.py extra_script = pio_hooks.py
board = nodemcuv2 board = nodemcuv2
build_flags = -DNODEMCUV2 -DDEBUG_PORT=Serial -DDEBUG_FAUXMO=Serial
build_flags = -DNODEMCUV2 -DDEBUG_PORT=Serial -DENABLE_FAUXMO=1
[env:node-debug-ota] [env:node-debug-ota]
platform = espressif8266 platform = espressif8266


+ 2
- 1
code/src/defaults.h View File

@ -10,6 +10,7 @@
//#define S20 //#define S20
//#define NODEMCUV2 //#define NODEMCUV2
//#define ENABLE_FAUXMO 1
//#define ENABLE_NOFUSS 1 //#define ENABLE_NOFUSS 1
//#define ENABLE_EMON 1 //#define ENABLE_EMON 1
//#define ENABLE_DHT 1 //#define ENABLE_DHT 1
@ -153,4 +154,4 @@
#define POW_UPDATE_INTERVAL 10000 #define POW_UPDATE_INTERVAL 10000
#define POW_REPORT_EVERY 6 #define POW_REPORT_EVERY 6
#define FAUXMO_ENABLED 1
#define FAUXMO_ENABLED 0

+ 6
- 2
code/src/fauxmo.ino View File

@ -7,6 +7,8 @@ Copyright (C) 2016 by Xose Pérez <xose dot perez at gmail dot com>
*/ */
#if ENABLE_FAUXMO
#include <fauxmoESP.h> #include <fauxmoESP.h>
fauxmoESP fauxmo; fauxmoESP fauxmo;
@ -17,13 +19,15 @@ fauxmoESP fauxmo;
void fauxmoConfigure() { void fauxmoConfigure() {
fauxmo.setDeviceName(getSetting("hostname", HOSTNAME).c_str()); fauxmo.setDeviceName(getSetting("hostname", HOSTNAME).c_str());
fauxmo.enable(getSetting('fauxmoEnabled', String(FAUXMO_ENABLED)).toInt() == 1);
fauxmo.enable(getSetting("fauxmoEnabled", String(FAUXMO_ENABLED)).toInt() == 1);
} }
void fauxmoSetup() { void fauxmoSetup() {
fauxmoConfigure(); fauxmoConfigure();
fauxmo.onMessage([](const char * state) { fauxmo.onMessage([](const char * state) {
DEBUG_MSG("[FAUXMO] State: %s\n", state); DEBUG_MSG("[FAUXMO] State: %s\n", state);
(state[0] == '1') ? switchRelayOn() : switchRelayOff();
relayStatus(0, state[0] == '1');
}); });
} }
#endif

+ 3
- 1
code/src/main.ino View File

@ -147,8 +147,10 @@ void setup() {
mqttSetup(); mqttSetup();
webSetup(); webSetup();
ntpSetup(); ntpSetup();
fauxmoSetup();
#if ENABLE_FAUXMO
fauxmoSetup();
#endif
#if ENABLE_NOFUSS #if ENABLE_NOFUSS
nofussSetup(); nofussSetup();
#endif #endif


+ 23
- 0
code/src/web.ino View File

@ -72,6 +72,9 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) {
bool dirty = false; bool dirty = false;
bool dirtyMQTT = false; bool dirtyMQTT = false;
bool apiEnabled = false; bool apiEnabled = false;
#if ENABLE_FAUXMO
bool fauxmoEnabled = false;
#endif
unsigned int network = 0; unsigned int network = 0;
for (unsigned int i=0; i<config.size(); i++) { for (unsigned int i=0; i<config.size(); i++) {
@ -98,6 +101,12 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) {
apiEnabled = true; apiEnabled = true;
continue; continue;
} }
#if ENABLE_FAUXMO
if (key == "fauxmoEnabled") {
fauxmoEnabled = true;
continue;
}
#endif
if (key == "ssid") { if (key == "ssid") {
key = key + String(network); key = key + String(network);
@ -120,6 +129,12 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) {
setSetting("apiEnabled", String() + (apiEnabled ? 1 : 0)); setSetting("apiEnabled", String() + (apiEnabled ? 1 : 0));
dirty = true; dirty = true;
} }
#if ENABLE_FAUXMO
if (fauxmoEnabled != (getSetting("fauxmoEnabled").toInt() == 1)) {
setSetting("fauxmoEnabled", String() + (fauxmoEnabled ? 1 : 0));
dirty = true;
}
#endif
// Save settings // Save settings
if (dirty) { if (dirty) {
@ -127,6 +142,9 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) {
saveSettings(); saveSettings();
wifiConfigure(); wifiConfigure();
otaConfigure(); otaConfigure();
#if ENABLE_FAUXMO
fauxmoConfigure();
#endif
buildTopics(); buildTopics();
#if ENABLE_RF #if ENABLE_RF
@ -184,6 +202,11 @@ void _wsStart(uint32_t client_id) {
root["apiEnabled"] = getSetting("apiEnabled").toInt() == 1; root["apiEnabled"] = getSetting("apiEnabled").toInt() == 1;
root["apiKey"] = getSetting("apiKey"); root["apiKey"] = getSetting("apiKey");
#if ENABLE_FAUXMO
root["fauxmoVisible"] = 1;
root["fauxmoEnabled"] = getSetting("fauxmoEnabled", String(FAUXMO_ENABLED)).toInt() == 1;
#endif
#if ENABLE_DHT #if ENABLE_DHT
root["dhtVisible"] = 1; root["dhtVisible"] = 1;
root["dhtTmp"] = getTemperature(); root["dhtTmp"] = getTemperature();


Loading…
Cancel
Save