Skip to content

Commit dc85659

Browse files
committed
MKR mqtt pooling fix
1 parent 04f2e80 commit dc85659

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

src/Adafruit_MQTT.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
// If using something like Zero or Due, change the above to SerialUSB
4444

4545
// Define actual debug output functions when necessary.
46-
#define MQTT_DEBUG
46+
//#define MQTT_DEBUG
4747
#ifdef MQTT_DEBUG
4848
#define DEBUG_PRINT(...) \
4949
{ DEBUG_PRINTER.print(__VA_ARGS__); }
@@ -59,7 +59,7 @@
5959
#define DEBUG_PRINTBUFFER(buffer, len) \
6060
{}
6161
#endif
62-
62+
#define MQTT_DEBUG
6363
#ifdef MQTT_ERROR
6464
#define ERROR_PRINT(...) \
6565
{ DEBUG_PRINTER.print(__VA_ARGS__); }

src/LiveObjectsBase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "LiveObjectsBase.h"
33
LiveObjectsBase::LiveObjectsBase()
44
:
5-
lastKeepAliveNetwork(10000)
5+
lastKeepAliveNetwork(5000)
66
,m_sPayload()
77
,m_sDecoder()
88
,m_Security(NONE)

src/LiveObjectsESP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ void LiveObjectsESP::disconnectNetwork()
108108

109109
void LiveObjectsESP::checkMQTT()
110110
{
111+
m_pMqttclient->loop();
111112
if(!m_pMqttclient->connected())
112113
connectMQTT();
113-
m_pMqttclient->loop();
114114
}
115115

116116
void LiveObjectsESP::connectMQTT()

src/LiveObjectsFona.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ LiveObjectsFona::LiveObjectsFona()
44
:
55
m_Fona(FONA_RST)
66
,m_FonaSerial(FONA_TX,FONA_RX)
7-
,m_FonaMQTT(&m_Fona,MQTT_BROKER, 1883,"Fona", MQTT_USER, SECRET_LIVEOBJECTS_API_KEY)
7+
,m_FonaMQTT(&m_Fona,MQTT_BROKER, 1883,"Fona", MQTT_USER, SECRET_LIVEOBJECTS_API_KEY.c_str())
88
,m_sClientID()
99
,m_nPort(1883)
1010
,m_Security(NONE)
@@ -78,7 +78,7 @@ void LiveObjectsFona::sendData()
7878
{
7979
//Serial.print("[INFO] Publishing message: ");
8080
//Serial.println(m_BufferPayload);
81-
m_Fona.sendSMS(SECRET_SERVER_MSISDN,m_BufferPayload);
81+
m_Fona.sendSMS(SECRET_SERVER_MSISDN.c_str(),m_BufferPayload);
8282
}
8383
}
8484
clearPayload();

src/LiveObjectsFona.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/******************************************************************************
66
DEFAULT VALUES FOR LIVEOBJECTS
77
******************************************************************************/
8-
#define PAYLOAD_DATA_SIZE 256
8+
#define PAYLOAD_DATA_SIZE 200
99
#define KEEP_ALIVE_NETWORK 1000
1010
#define SW_REVISION "1.8.0"
1111
#define MAX_COMMANDS 10
@@ -159,13 +159,13 @@ struct LiveObjects_command
159159
void addNetworkInfo();
160160

161161
template<typename LOtA>
162-
void addParameter(const String name, LOtA &variable){Serial.print("[ERROR] This board doesn't support this function");};
162+
void addParameter(const String name, LOtA &variable){}//Serial.print("[ERROR] This board doesn't support this function");};
163163
template<typename LOtB>
164-
void addParameter(const String name, LOtB &variable, LiveObjects_parameterType type){Serial.print("[ERROR] This board doesn't support this function");};
164+
void addParameter(const String name, LOtB &variable, LiveObjects_parameterType type){}//Serial.print("[ERROR] This board doesn't support this function");};
165165
template<typename LOtC>
166-
void addParameter(const String name, LOtC &variable, onParameterUpdateCallback callback){Serial.print("[ERROR] This board doesn't support this function");};
166+
void addParameter(const String name, LOtC &variable, onParameterUpdateCallback callback){}//Serial.print("[ERROR] This board doesn't support this function");};
167167
template<typename LOtD>
168-
void addParameter(const String name, LOtD &variable, onParameterUpdateCallback callback, LiveObjects_parameterType type){Serial.print("[ERROR] This board doesn't support this function");};
168+
void addParameter(const String name, LOtD &variable, onParameterUpdateCallback callback, LiveObjects_parameterType type){}//Serial.print("[ERROR] This board doesn't support this function");};
169169

170170
private:
171171
bool FONAconnect();
@@ -203,8 +203,8 @@ void LiveObjectsFona::addToStringPayload(T val, Args ... args)
203203
addToStringPayload(args...);
204204
}
205205

206-
extern const char* SECRET_LIVEOBJECTS_API_KEY;
207-
extern const char* SECRET_SERVER_MSISDN;
206+
extern const String SECRET_LIVEOBJECTS_API_KEY;
207+
extern const String SECRET_SERVER_MSISDN;
208208
// extern const String SECRET_PINNUMBER;
209209
// extern const String SECRET_APN;
210210
// extern const String SECRET_APN_USER;

src/LiveObjectsMKR.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ void LiveObjectsMKR::sendMQTT(String& topic, String& doc)
3434

3535
void LiveObjectsMKR::checkMQTT()
3636
{
37+
m_pMqttclient->poll();
3738
if(!m_bSubCMD) if(commands.size()>0) m_pMqttclient->subscribe(MQTT_SUBCMD);
3839
if(!m_pMqttclient->connected())
3940
connectMQTT();

0 commit comments

Comments
 (0)