Browse Source

Check if there is an MQTT broker defined before the MQTT_MAX_TRIES check

fastled 1.6.2
Xose Pérez 7 years ago
parent
commit
b14f5cf6e6
5 changed files with 11 additions and 5 deletions
  1. +4
    -0
      CHANGELOG.md
  2. +1
    -1
      README.md
  3. +1
    -1
      code/espurna/config/general.h
  4. +1
    -1
      code/espurna/config/version.h
  5. +4
    -2
      code/espurna/mqtt.ino

+ 4
- 0
CHANGELOG.md View File

@ -3,6 +3,10 @@
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [1.6.2] 2017-02-10
### Fix
- Check if there is an MQTT broker defined before the MQTT_MAX_TRIES check
## [1.6.1] 2017-02-10
### Added
- Added support for [Jorge Garcia's Wifi+Relay Board Kit](https://www.tindie.com/products/jorgegarciadev/wifi--relays-board-kit/)


+ 1
- 1
README.md View File

@ -4,7 +4,7 @@ ESPurna ("spark" in Catalan) is a custom firmware for ESP8266 based smart switch
It was originally developed with the **[IteadStudio Sonoff](https://www.itead.cc/sonoff-wifi-wireless-switch.html)** in mind but now it supports a growing number of ESP8266-based boards.
It uses the Arduino Core for ESP8266 framework and a number of 3rd party libraries.
**Current Release Version is 1.6.1**, read the [changelog](https://bitbucket.org/xoseperez/espurna/src/master/CHANGELOG.md).
**Current Release Version is 1.6.2**, read the [changelog](https://bitbucket.org/xoseperez/espurna/src/master/CHANGELOG.md).
## Features


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

@ -103,7 +103,7 @@
#define MQTT_KEEPALIVE 30
#define MQTT_RECONNECT_DELAY 10000
#define MQTT_TRY_INTERVAL 30000
#define MQTT_MAX_TRIES 5
#define MQTT_MAX_TRIES 12
#define MQTT_SKIP_RETAINED 1
#define MQTT_SKIP_TIME 1000
#define MQTT_ACTION_TOPIC "/action"


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

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

+ 4
- 2
code/espurna/mqtt.ino View File

@ -139,12 +139,16 @@ void mqttConnect() {
if (!mqtt.connected()) {
char * host = strdup(getSetting("mqttServer", MQTT_SERVER).c_str());
if (strlen(host) == 0) return;
// Last option: reconnect to wifi after MQTT_MAX_TRIES attemps in a row
#if MQTT_MAX_TRIES > 0
static unsigned int tries = 0;
static unsigned long last_try = millis();
if (millis() - last_try < MQTT_TRY_INTERVAL) {
if (++tries > MQTT_MAX_TRIES) {
DEBUG_MSG("[MQTT] MQTT_MAX_TRIES met, disconnecting from WiFi\n");
wifiDisconnect();
tries = 0;
return;
@ -157,8 +161,6 @@ void mqttConnect() {
mqtt.disconnect();
char * host = strdup(getSetting("mqttServer", MQTT_SERVER).c_str());
if (strlen(host) == 0) return;
unsigned int port = getSetting("mqttPort", MQTT_PORT).toInt();
char * user = strdup(getSetting("mqttUser").c_str());
char * pass = strdup(getSetting("mqttPassword").c_str());


Loading…
Cancel
Save