Browse Source

Merge branch 'dev' into rfm69

rfm69
Xose Pérez 6 years ago
parent
commit
008abd619a
10 changed files with 91 additions and 41 deletions
  1. +4
    -0
      code/espurna/button.ino
  2. +12
    -0
      code/espurna/config/general.h
  3. +10
    -0
      code/espurna/config/hardware.h
  4. +6
    -2
      code/espurna/espurna.ino
  5. +4
    -0
      code/espurna/led.ino
  6. +3
    -1
      code/espurna/relay.ino
  7. +14
    -3
      code/espurna/settings.ino
  8. +8
    -5
      code/espurna/web.ino
  9. +7
    -7
      code/gulpfile.js
  10. +23
    -23
      code/platformio.ini

+ 4
- 0
code/espurna/button.ino View File

@ -10,6 +10,8 @@ Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
// BUTTON
// -----------------------------------------------------------------------------
#if BUTTON_SUPPORT
#include <DebounceEvent.h>
#include <vector>
@ -266,3 +268,5 @@ void buttonLoop() {
#endif
}
#endif // BUTTON_SUPPORT

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

@ -201,6 +201,10 @@
// BUTTON
//------------------------------------------------------------------------------
#ifndef BUTTON_SUPPORT
#define BUTTON_SUPPORT 1
#endif
#ifndef BUTTON_DEBOUNCE_DELAY
#define BUTTON_DEBOUNCE_DELAY 50 // Debounce delay (ms)
#endif
@ -217,6 +221,14 @@
#define BUTTON_LNGLNGCLICK_DELAY 10000 // Time in ms holding the button down to get a long-long click
#endif
//------------------------------------------------------------------------------
// LED
//------------------------------------------------------------------------------
#ifndef LED_SUPPORT
#define LED_SUPPORT 1
#endif
//------------------------------------------------------------------------------
// RELAY
//------------------------------------------------------------------------------


+ 10
- 0
code/espurna/config/hardware.h View File

@ -37,9 +37,11 @@
// Disable non-core modules
#define ALEXA_SUPPORT 0
#define BROKER_SUPPORT 0
#define BUTTON_SUPPORT 0
#define DOMOTICZ_SUPPORT 0
#define HOMEASSISTANT_SUPPORT 0
#define I2C_SUPPORT 0
#define MDNS_SERVER_SUPPORT 0
#define MQTT_SUPPORT 0
#define NTP_SUPPORT 0
#define SCHEDULER_SUPPORT 0
@ -47,6 +49,14 @@
#define THINGSPEAK_SUPPORT 0
#define WEB_SUPPORT 0
// Extra light-weight image
//#define DEBUG_SERIAL_SUPPORT 0
//#define DEBUG_TELNET_SUPPORT 0
//#define DEBUG_WEB_SUPPORT 0
//#define LED_SUPPORT 0
//#define TELNET_SUPPORT 0
//#define TERMINAL_SUPPORT 0
// -----------------------------------------------------------------------------
// Development boards
// -----------------------------------------------------------------------------


+ 6
- 2
code/espurna/espurna.ino View File

@ -99,8 +99,12 @@ void setup() {
#endif
relaySetup();
buttonSetup();
ledSetup();
#if BUTTON_SUPPORT
buttonSetup();
#endif
#if LED_SUPPORT
ledSetup();
#endif
#if MQTT_SUPPORT
mqttSetup();
#endif


+ 4
- 0
code/espurna/led.ino View File

@ -10,6 +10,8 @@ Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
// LED
// -----------------------------------------------------------------------------
#if LED_SUPPORT
typedef struct {
unsigned char pin;
bool reverse;
@ -290,3 +292,5 @@ void ledLoop() {
_led_update = false;
}
#endif LED_SUPPORT

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

@ -194,7 +194,9 @@ void _relayProcess(bool mode) {
#endif
// Flag relay-based LEDs to update status
ledUpdate(true);
#if LED_SUPPORT
ledUpdate(true);
#endif
_relays[id].report = false;
_relays[id].group_report = false;


+ 14
- 3
code/espurna/settings.ino View File

@ -375,19 +375,30 @@ size_t settingsMaxSize() {
bool settingsRestoreJson(JsonObject& data) {
// Check this is an ESPurna configuration file (must have "app":"ESPURNA")
const char* app = data["app"];
if (strcmp(app, APP_NAME) != 0) return false;
if (!app || strcmp(app, APP_NAME) != 0) {
DEBUG_MSG_P(PSTR("[SETTING] Wrong or missing 'app' key\n"));
return false;
}
for (unsigned int i = EEPROM_DATA_END; i < SPI_FLASH_SEC_SIZE; i++) {
EEPROMr.write(i, 0xFF);
// Clear settings
bool is_backup = data["backup"];
if (is_backup) {
for (unsigned int i = EEPROM_DATA_END; i < SPI_FLASH_SEC_SIZE; i++) {
EEPROMr.write(i, 0xFF);
}
}
// Dump settings to memory buffer
for (auto element : data) {
if (strcmp(element.key, "app") == 0) continue;
if (strcmp(element.key, "version") == 0) continue;
if (strcmp(element.key, "backup") == 0) continue;
setSetting(element.key, element.value.as<char*>());
}
// Persist to EEPROM
saveSettings();
DEBUG_MSG_P(PSTR("[SETTINGS] Settings restored successfully\n"));


+ 8
- 5
code/espurna/web.ino View File

@ -88,14 +88,17 @@ void _onGetConfig(AsyncWebServerRequest *request) {
response->addHeader("X-Content-Type-Options", "nosniff");
response->addHeader("X-Frame-Options", "deny");
response->printf("{\n \"app\": \"%s\",\n \"version\": \"%s\"", APP_NAME, APP_VERSION);
response->printf("{\n\"app\": \"%s\"", APP_NAME);
response->printf(",\n\"version\": \"%s\"", APP_VERSION);
response->printf(",\n\"backup\": \"1\"");
response->printf(",\n\"timestamp\": \"%s\"", ntpDateTime().c_str());
// Write the keys line by line (not sorted)
unsigned long count = settingsKeyCount();
for (unsigned int i=0; i<count; i++) {
String key = settingsKeyName(i);
String value = getSetting(key);
response->printf(",\n \"%s\": \"%s\"", key.c_str(), value.c_str());
response->printf(",\n\"%s\": \"%s\"", key.c_str(), value.c_str());
}
response->printf("\n}");
@ -196,9 +199,9 @@ void _onHome(AsyncWebServerRequest *request) {
response->addHeader("Content-Encoding", "gzip");
response->addHeader("Last-Modified", _last_modified);
response->addHeader("X-XSS-Protection", "1; mode=block");
response->addHeader("X-Content-Type-Options", "nosniff");
response->addHeader("X-Frame-Options", "deny");
response->addHeader("X-XSS-Protection", "1; mode=block");
response->addHeader("X-Content-Type-Options", "nosniff");
response->addHeader("X-Frame-Options", "deny");
request->send(response);
}


+ 7
- 7
code/gulpfile.js View File

@ -96,14 +96,14 @@ var buildHeaderFile = function() {
cb(0, destination);
});
});
}
var htmllintReporter = function(filepath, issues) {
if (issues.length > 0) {
issues.forEach(function (issue) {
console.info(
if (issues.length > 0) {
issues.forEach(function (issue) {
console.info(
'[gulp-htmllint] ' +
filepath + ' [' +
issue.line + ',' +
@ -111,9 +111,9 @@ var htmllintReporter = function(filepath, issues) {
'(' + issue.code + ') ' +
issue.msg
);
});
process.exitCode = 1;
}
});
process.exitCode = 1;
}
};
var buildWebUI = function(module) {


+ 23
- 23
code/platformio.ini View File

@ -1416,7 +1416,7 @@ board = ${common.board_4m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m0m} -DEXS_WIFI_RELAY_V31
build_flags = ${common.build_flags_4m1m} -DEXS_WIFI_RELAY_V31
monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts}
@ -1427,7 +1427,7 @@ board = ${common.board_4m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m0m} -DEXS_WIFI_RELAY_V31
build_flags = ${common.build_flags_4m1m} -DEXS_WIFI_RELAY_V31
upload_speed = ${common.upload_speed}
upload_port = ${common.upload_port}
upload_flags = ${common.upload_flags}
@ -1730,7 +1730,7 @@ board = ${common.board_1m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_4m1m} -DEUROMATE_WIFI_STECKER_SCHUKO
build_flags = ${common.build_flags_1m0m} -DEUROMATE_WIFI_STECKER_SCHUKO
monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts}
@ -1741,7 +1741,7 @@ board = ${common.board_1m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_4m1m} -DEUROMATE_WIFI_STECKER_SCHUKO
build_flags = ${common.build_flags_1m0m} -DEUROMATE_WIFI_STECKER_SCHUKO
upload_speed = ${common.upload_speed}
upload_port = ${common.upload_port}
upload_flags = ${common.upload_flags}
@ -1754,7 +1754,7 @@ board = ${common.board_1m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_4m1m} -DTONBUX_POWERSTRIP02
build_flags = ${common.build_flags_1m0m} -DTONBUX_POWERSTRIP02
monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts}
@ -1765,7 +1765,7 @@ board = ${common.board_1m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_4m1m} -DTONBUX_POWERSTRIP02
build_flags = ${common.build_flags_1m0m} -DTONBUX_POWERSTRIP02
upload_speed = ${common.upload_speed}
upload_port = ${common.upload_port}
upload_flags = ${common.upload_flags}
@ -1778,7 +1778,7 @@ board = ${common.board_1m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_4m1m} -DLINGAN_SWA1
build_flags = ${common.build_flags_1m0m} -DLINGAN_SWA1
monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts}
@ -1789,7 +1789,7 @@ board = ${common.board_1m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_4m1m} -DLINGAN_SWA1
build_flags = ${common.build_flags_1m0m} -DLINGAN_SWA1
upload_speed = ${common.upload_speed}
upload_port = ${common.upload_port}
upload_flags = ${common.upload_flags}
@ -1967,11 +1967,11 @@ extra_scripts = ${common.extra_scripts}
[env:arniex-swifitch]
platform = ${common.platform}
framework = ${common.framework}
board = ${common.board_1m}
board = ${common.board_4m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m0m} -DARNIEX_SWIFITCH
build_flags = ${common.build_flags_4m1m} -DARNIEX_SWIFITCH
extra_scripts = ${common.extra_scripts}
monitor_speed = ${common.monitor_speed}
@ -1982,7 +1982,7 @@ board = ${common.board_4m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m0m} -DARNIEX_SWIFITCH
build_flags = ${common.build_flags_4m1m} -DARNIEX_SWIFITCH
upload_speed = ${common.upload_speed}
upload_port = ${common.upload_port}
upload_flags = ${common.upload_flags}
@ -2020,7 +2020,7 @@ board = ${common.board_4m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m0m} -DLUANI_HVIO
build_flags = ${common.build_flags_4m1m} -DLUANI_HVIO
monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts}
@ -2031,7 +2031,7 @@ board = ${common.board_4m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m0m} -DZLUANI_HVIO
build_flags = ${common.build_flags_4m1m} -DLUANI_HVIO
upload_speed = ${common.upload_speed}
upload_port = ${common.upload_port}
upload_flags = ${common.upload_flags}
@ -2045,7 +2045,7 @@ board = ${common.board_1m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_4m1m} -DNEO_COOLCAM_NAS_WR01W
build_flags = ${common.build_flags_1m0m} -DNEO_COOLCAM_NAS_WR01W
monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts}
@ -2056,7 +2056,7 @@ board = ${common.board_1m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_4m1m} -DNEO_COOLCAM_NAS_WR01W
build_flags = ${common.build_flags_1m0m} -DNEO_COOLCAM_NAS_WR01W
upload_speed = ${common.upload_speed}
upload_port = ${common.upload_port}
upload_flags = ${common.upload_flags}
@ -2069,7 +2069,7 @@ board = ${common.board_1m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_4m1m} -DESTINK_WIFI_POWER_STRIP
build_flags = ${common.build_flags_1m0m} -DESTINK_WIFI_POWER_STRIP
monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts}
@ -2080,7 +2080,7 @@ board = ${common.board_1m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_4m1m} -DESTINK_WIFI_POWER_STRIP
build_flags = ${common.build_flags_1m0m} -DESTINK_WIFI_POWER_STRIP
upload_speed = ${common.upload_speed}
upload_port = ${common.upload_port}
upload_flags = ${common.upload_flags}
@ -2217,7 +2217,7 @@ board = ${common.board_4m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m0m} -DALLNET_4DUINO_IOT_WLAN_RELAIS
build_flags = ${common.build_flags_4m1m} -DALLNET_4DUINO_IOT_WLAN_RELAIS
monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts}
@ -2228,7 +2228,7 @@ board = ${common.board_4m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m0m} -DALLNET_4DUINO_IOT_WLAN_RELAIS
build_flags = ${common.build_flags_4m1m} -DALLNET_4DUINO_IOT_WLAN_RELAIS
upload_speed = ${common.upload_speed}
upload_port = ${common.upload_port}
upload_flags = ${common.upload_flags}
@ -2289,7 +2289,7 @@ board = ${common.board_4m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m0m} -DNODEMCU_BASIC -DGEIGER_SUPPORT=1 -DEVENTS_SUPPORT=0 -DINFLUXDB_SUPPORT=1 -DALEXA_SUPPORT=0 -DALEXA_ENABLED=0
build_flags = ${common.build_flags_4m1m} -DNODEMCU_BASIC -DGEIGER_SUPPORT=1 -DEVENTS_SUPPORT=0 -DINFLUXDB_SUPPORT=1 -DALEXA_SUPPORT=0 -DALEXA_ENABLED=0
upload_speed = ${common.upload_speed_fast}
monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts}
@ -2301,7 +2301,7 @@ board = ${common.board_4m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m0m} -DNODEMCU_BASIC -DGEIGER_SUPPORT=1 -DEVENTS_SUPPORT=0 -DINFLUXDB_SUPPORT=1 -DALEXA_SUPPORT=0 -DALEXA_ENABLED=0
build_flags = ${common.build_flags_4m1m} -DNODEMCU_BASIC -DGEIGER_SUPPORT=1 -DEVENTS_SUPPORT=0 -DINFLUXDB_SUPPORT=1 -DALEXA_SUPPORT=0 -DALEXA_ENABLED=0
upload_speed = ${common.upload_speed_fast}
monitor_speed = ${common.monitor_speed}
upload_port = ${common.upload_port}
@ -2341,7 +2341,7 @@ board = ${common.board_4m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m0m} -DBH_ONOFRE
build_flags = ${common.build_flags_4m1m} -DBH_ONOFRE
upload_speed = ${common.upload_speed_fast}
monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts}
@ -2353,7 +2353,7 @@ board = ${common.board_4m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m0m} -DBH_ONOFRE
build_flags = ${common.build_flags_4m1m} -DBH_ONOFRE
upload_speed = ${common.upload_speed_fast}
monitor_speed = ${common.monitor_speed}
upload_port = ${common.upload_port}


Loading…
Cancel
Save