Skip to content

Commit

Permalink
Fix firmware update
Browse files Browse the repository at this point in the history
  • Loading branch information
SergiuToporjinschi committed Jun 14, 2019
1 parent 133196a commit 12f8167
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ESPManager
version=3.0.1
version=3.0.2
author=Sergiu Toporjinschi
maintainer=Sergiu Toporjinschi
sentence=ESP manager
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env_default = nodemcuv2


[common]
version = "3.0.1"
version = "3.0.2"
name = "EspManager"
monitor_speed = 115200
examples_folder = examples/ESPManager
Expand Down
14 changes: 9 additions & 5 deletions src/ESPManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ void ESPManager::setupMQTT() {
DBG(mqttServer);
DBG("; port: ");
DBGLN(mqttPort);
mqttCli.begin(mqttServer, mqttPort, net);

mqttCli.begin(mqttServer, mqttPort, mqttNetClient);

mqttCli.onMessage(cbBind->callback); //TODO de implementat

Expand Down Expand Up @@ -470,8 +471,8 @@ void ESPManager::cmdUpdate(const char *respTopic, JsonVariant params) {
return;

const char *type = params[F("type")].as<const char *>();
const char *ver = params[F("version")].as<const char *>();
const char *url = params[F("url")].as<const char *>();
String ver = params[F("version")].as<String>();
String url = params[F("url")].as<String>();

DBG("type: ");
DBGLN(type);
Expand All @@ -480,14 +481,17 @@ void ESPManager::cmdUpdate(const char *respTopic, JsonVariant params) {
DBG("url: ");
DBGLN(url);

ESPhttpUpdate.rebootOnUpdate(true);
ESPhttpUpdate.setLedPin(LED_BUILTIN, HIGH);
t_httpUpdate_return ret = HTTP_UPDATE_OK;
if (strcmp_P(type, UPDATE_SKETCH_P) == 0) {
DBGLN("updateTYPE");
ret = ESPhttpUpdate.update(net, url, ver);
WiFiClient updateNetCli;
ret = ESPhttpUpdate.update(updateNetCli, url, ver);
} else if (strcmp_P(type, UPDATE_SPIFFS_P) == 0) {
DBGLN("updateSPIFFS");
ret = ESPhttpUpdate.updateSpiffs(net, url, ver);
WiFiClient updateNetCli;
ret = ESPhttpUpdate.updateSpiffs(updateNetCli, url, ver);
}
switch (ret) {
case HTTP_UPDATE_FAILED:
Expand Down
10 changes: 5 additions & 5 deletions src/ESPManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ class ESPManager {
std::function<void()> waitingMQTTCon;
std::function<void()> afterWaitingMQTTCon;

WiFiClient net;
JsonObject _wlanConf; //WLAN settings
JsonObject _mqttConf; //MQTT settings
MQTTClient mqttCli; //MQTT client engine
WiFiMode wifiMode; //WiFi Engine
WiFiClient mqttNetClient; //TCP client for MQTT
JsonObject _wlanConf; //WLAN settings
JsonObject _mqttConf; //MQTT settings
MQTTClient mqttCli; //MQTT client engine
WiFiMode wifiMode; //WiFi Engine

bool sendOfflineStatus; //Sends a retain message for registering stauts
const char *cmdTopic = nullptr; //topic for receving commands
Expand Down

0 comments on commit 12f8167

Please sign in to comment.