Skip to content

Commit

Permalink
bugfix mqtt
Browse files Browse the repository at this point in the history
  • Loading branch information
DmytroKorniienko committed Oct 31, 2020
1 parent cdaf07c commit da552d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions EmbUI/EmbUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
#include "MemoryInfo.h"
#endif

#ifndef MAX_WS_CLIENTS
#define MAX_WS_CLIENTS 4
#endif
#ifndef PUB_PERIOD
#define PUB_PERIOD 10000 // Publication period, ms
#endif
#define SECONDARY_PERIOD 300U // second handler timer, ms

EmbUI embui;
Expand Down Expand Up @@ -392,8 +396,8 @@ void EmbUI::handle(){
MDNS.update();
#endif
//_connected();
//mqtt_handle();
//udpLoop();
mqtt_handle();
udpLoop();

static unsigned long timer = 0;
if (timer + SECONDARY_PERIOD > millis()) return;
Expand Down
6 changes: 3 additions & 3 deletions EmbUI/mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ void emptyFunction(const String &, const String &){}

void EmbUI::mqtt(const String &pref, const String &host, int port, const String &user, const String &pass, void (*mqttFunction) (const String &topic, const String &payload), bool remotecontrol){
if (host.length()==0){
Serial.println(F("MQTT host is empty - disabled!"));
return; // выходим если host не задан
LOG(println, PSTR("UI: MQTT host is empty - disabled!"));
return; // выходим если host не задан
}
String m_pref=param(FPSTR(P_m_pref));
String m_host=param(FPSTR(P_m_host));
Expand All @@ -56,7 +56,7 @@ void EmbUI::mqtt(const String &pref, const String &host, int port, const String
if(m_user == FPSTR(P_null)) var(FPSTR(P_m_user), user);
if(m_pass == FPSTR(P_null)) var(FPSTR(P_m_pass), pass);

//Serial.println(F("MQTT Init completed"));
LOG(println, PSTR("UI: MQTT Init completed"));

if (remotecontrol) embui.sysData.mqtt_remotecontrol = true;
mqt = mqttFunction;
Expand Down

0 comments on commit da552d7

Please sign in to comment.