Browse Source

Merge branch 'master' into dev

fastled
Xose Pérez 7 years ago
parent
commit
0ce667fb8e
6 changed files with 13 additions and 7 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. +2
    -2
      code/espurna/emon.ino
  6. +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

@ -109,7 +109,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"

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

@ -160,14 +160,14 @@ void powerMonitorLoop() {
while ((unsigned char) *c == ' ') ++c;
// Calculate average apparent power from current and create C-string
_power = (int) (current_avgd * mainsVoltage);
_power = (int) (average * mainsVoltage);
char power[6];
snprintf(power, 6, "%d", _power);
// Calculate energy increment (ppower times time) and create C-string
double energy_inc = (double) _power * EMON_INTERVAL * EMON_MEASUREMENTS / 1000.0 / 3600.0;
char energy_buf[11];
dtostrf(energy_inc, 11, 3, energy_buf);
dtostrf(energy_inc, 10, 3, energy_buf);
char *e = energy_buf;
while ((unsigned char) *e == ' ') ++e;


+ 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