Skip to content

Commit

Permalink
Merge pull request #163 from LaCoolCo/fix/online-mode
Browse files Browse the repository at this point in the history
Fix MQTT onlinemode bug
  • Loading branch information
3rwww1 authored Jun 28, 2018
2 parents ebb2509 + ad23270 commit 0ea852c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/core/CoolBoard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,12 +516,18 @@ void CoolBoard::mqttConnect() {
if (this->coolPubSubClient->connect(this->mqttId.c_str())) {
this->coolPubSubClient->subscribe(this->mqttInTopic.c_str());
INFO_LOG("Subscribed to MQTT input topic");
mqttRetries = 0;
} else {
WARN_LOG("MQTT connection failed, retrying");
mqttRetries++;
}
delay(5);
i++;
}
if (mqttRetries >= MAX_MQTT_RETRIES) {
SPIFFS.end();
ESP.restart();
}
}

void CoolBoard::mqttLog(String data) {
Expand Down
4 changes: 3 additions & 1 deletion src/core/CoolBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@

#define ENABLE_I2C_PIN 5
#define BOOTSTRAP_PIN 0
#define MQTT_RETRIES 5
#define MIN_BAT_VOLTAGE 3.5
#define NOT_IN_CHARGING 1.8
#define LOW_POWER_SLEEP 300
#define MQTT_RETRIES 5
#define MAX_MQTT_RETRIES 15

class CoolBoard {

Expand Down Expand Up @@ -86,6 +87,7 @@ class CoolBoard {
void mqttLog(String data);

private:
uint8_t mqttRetries = 0;
CoolBoardSensors coolBoardSensors;
CoolBoardLed coolBoardLed;
CoolWifi *coolWifi = new CoolWifi;
Expand Down

0 comments on commit 0ea852c

Please sign in to comment.