mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-18 03:16:12 +02:00
* PR #76 updated debug messages: now 5 different levels are available
* fixed CRC loop issue
This commit is contained in:
parent
7e2df351d9
commit
0347a3df44
10 changed files with 245 additions and 196 deletions
|
@ -26,7 +26,7 @@ class mqtt {
|
|||
}
|
||||
|
||||
void setup(const char *broker, const char *topic, const char *user, const char *pwd, uint16_t port) {
|
||||
DPRINTLN(F("mqtt.h:setup"));
|
||||
DPRINTLN(DBG_VERBOSE, F("mqtt.h:setup"));
|
||||
mAddressSet = true;
|
||||
mClient->setServer(broker, port);
|
||||
|
||||
|
@ -37,7 +37,7 @@ class mqtt {
|
|||
}
|
||||
|
||||
void sendMsg(const char *topic, const char *msg) {
|
||||
//DPRINTLN(F("mqtt.h:sendMsg"));
|
||||
//DPRINTLN(DBG_VERBOSE, F("mqtt.h:sendMsg"));
|
||||
if(mAddressSet) {
|
||||
char top[64];
|
||||
snprintf(top, 64, "%s/%s", mTopic, topic);
|
||||
|
@ -50,24 +50,24 @@ class mqtt {
|
|||
}
|
||||
|
||||
bool isConnected(bool doRecon = false) {
|
||||
//DPRINTLN(F("mqtt.h:isConnected"));
|
||||
//DPRINTLN(DBG_VERBOSE, F("mqtt.h:isConnected"));
|
||||
if(doRecon)
|
||||
reconnect();
|
||||
return mClient->connected();
|
||||
}
|
||||
|
||||
char *getUser(void) {
|
||||
//DPRINTLN(F("mqtt.h:getUser"));
|
||||
//DPRINTLN(DBG_VERBOSE, F("mqtt.h:getUser"));
|
||||
return mUser;
|
||||
}
|
||||
|
||||
char *getPwd(void) {
|
||||
//DPRINTLN(F("mqtt.h:getPwd"));
|
||||
//DPRINTLN(DBG_VERBOSE, F("mqtt.h:getPwd"));
|
||||
return mPwd;
|
||||
}
|
||||
|
||||
char *getTopic(void) {
|
||||
//DPRINTLN(F("mqtt.h:getTopic"));
|
||||
//DPRINTLN(DBG_VERBOSE, F("mqtt.h:getTopic"));
|
||||
return mTopic;
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ class mqtt {
|
|||
|
||||
private:
|
||||
void reconnect(void) {
|
||||
//DPRINTLN(F("mqtt.h:reconnect"));
|
||||
//DPRINTLN(DBG_VERBOSE, F("mqtt.h:reconnect"));
|
||||
if(!mClient->connected()) {
|
||||
if((strlen(mUser) > 0) && (strlen(mPwd) > 0))
|
||||
mClient->connect(DEF_DEVICE_NAME, mUser, mPwd);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue