Browse Source

Issue #190. Race condition inside a ticker callback caused a crash loop on boot

fastled
Xose Pérez 7 years ago
parent
commit
385bba7d0e
4 changed files with 25 additions and 13 deletions
  1. +9
    -1
      code/espurna/config/general.h
  2. +1
    -1
      code/espurna/config/version.h
  3. +1
    -3
      code/espurna/espurna.ino
  4. +14
    -8
      code/espurna/settings.ino

+ 9
- 1
code/espurna/config/general.h View File

@ -402,12 +402,20 @@ PROGMEM const char* const custom_reset_string[] = {
#define MQTT_USE_GETTER "" #define MQTT_USE_GETTER ""
#define MQTT_USE_SETTER "/set" #define MQTT_USE_SETTER "/set"
// -----------------------------------------------------------------------------
// SETTINGS
// -----------------------------------------------------------------------------
#ifndef SETTINGS_AUTOSAVE
#define SETTINGS_AUTOSAVE 1 // Autosave settings o force manual commit
#endif
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// I2C // I2C
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#ifndef I2C_SUPPORT #ifndef I2C_SUPPORT
#define I2C_SUPPORT 0 // I2C enabled
#define I2C_SUPPORT 0 // I2C enabled
#endif #endif
#define I2C_SDA_PIN 4 // SDA GPIO #define I2C_SDA_PIN 4 // SDA GPIO


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

@ -1,4 +1,4 @@
#define APP_NAME "ESPurna" #define APP_NAME "ESPurna"
#define APP_VERSION "1.9.1"
#define APP_VERSION "1.9.2b"
#define APP_AUTHOR "xose.perez@gmail.com" #define APP_AUTHOR "xose.perez@gmail.com"
#define APP_WEBSITE "http://tinkerman.cat" #define APP_WEBSITE "http://tinkerman.cat"

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

@ -210,6 +210,7 @@ void loop() {
wifiLoop(); wifiLoop();
otaLoop(); otaLoop();
mqttLoop(); mqttLoop();
settingsLoop();
#ifdef ITEAD_SONOFF_RFBRIDGE #ifdef ITEAD_SONOFF_RFBRIDGE
rfbLoop(); rfbLoop();
@ -218,9 +219,6 @@ void loop() {
#if NTP_SUPPORT #if NTP_SUPPORT
ntpLoop(); ntpLoop();
#endif #endif
#if TERMINAL_SUPPORT
settingsLoop();
#endif
#if ALEXA_SUPPORT #if ALEXA_SUPPORT
alexaLoop(); alexaLoop();
#endif #endif


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

@ -11,14 +11,14 @@ Copyright (C) 2016-2017 by Xose Pérez <xose dot perez at gmail dot com>
#include "spi_flash.h" #include "spi_flash.h"
#include <StreamString.h> #include <StreamString.h>
#define AUTO_SAVE 1
#ifdef DEBUG_PORT #ifdef DEBUG_PORT
Embedis embedis(DEBUG_PORT); Embedis embedis(DEBUG_PORT);
#else #else
Embedis embedis(Serial); Embedis embedis(Serial);
#endif #endif
bool _settings_save = false;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Settings // Settings
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -86,8 +86,8 @@ void settingsSetup() {
SPI_FLASH_SEC_SIZE, SPI_FLASH_SEC_SIZE,
[](size_t pos) -> char { return EEPROM.read(pos); }, [](size_t pos) -> char { return EEPROM.read(pos); },
[](size_t pos, char value) { EEPROM.write(pos, value); }, [](size_t pos, char value) { EEPROM.write(pos, value); },
#if AUTO_SAVE
[]() { EEPROM.commit(); }
#if SETTINGS_AUTOSAVE
[]() { _settings_save = true; }
#else #else
[]() {} []() {}
#endif #endif
@ -246,7 +246,14 @@ void settingsDump() {
} }
void settingsLoop() { void settingsLoop() {
embedis.process();
if (_settings_save) {
DEBUG_MSG_P(PSTR("[SETTINGS] Saving\n"));
EEPROM.commit();
_settings_save = false;
}
#if TERMINAL_SUPPORT
embedis.process();
#endif
} }
void moveSetting(const char * from, const char * to) { void moveSetting(const char * from, const char * to) {
@ -302,9 +309,8 @@ bool hasSetting(const String& key, unsigned int index) {
} }
void saveSettings() { void saveSettings() {
DEBUG_MSG_P(PSTR("[SETTINGS] Saving\n"));
#if not AUTO_SAVE
EEPROM.commit();
#if not SETTINGS_AUTOSAVE
_settings_save = true;
#endif #endif
//settingsDump(); //settingsDump();
} }

Loading…
Cancel
Save