mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-12 00:16:42 +02:00
add method entry debug statements
This commit is contained in:
parent
ae1272ccf0
commit
b1906f0f31
8 changed files with 90 additions and 0 deletions
|
@ -21,6 +21,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"));
|
||||
mAddressSet = true;
|
||||
mClient->setServer(broker, port);
|
||||
|
||||
|
@ -30,6 +31,7 @@ class mqtt {
|
|||
}
|
||||
|
||||
void sendMsg(const char *topic, const char *msg) {
|
||||
DPRINTLN(F("mqtt.h:sendMsg"));
|
||||
if(mAddressSet) {
|
||||
char top[64];
|
||||
snprintf(top, 64, "%s/%s", mTopic, topic);
|
||||
|
@ -41,24 +43,29 @@ class mqtt {
|
|||
}
|
||||
|
||||
bool isConnected(bool doRecon = false) {
|
||||
DPRINTLN(F("mqtt.h:isConnected"));
|
||||
if(doRecon)
|
||||
reconnect();
|
||||
return mClient->connected();
|
||||
}
|
||||
|
||||
char *getUser(void) {
|
||||
DPRINTLN(F("mqtt.h:getUser"));
|
||||
return mUser;
|
||||
}
|
||||
|
||||
char *getPwd(void) {
|
||||
DPRINTLN(F("mqtt.h:getPwd"));
|
||||
return mPwd;
|
||||
}
|
||||
|
||||
char *getTopic(void) {
|
||||
DPRINTLN(F("mqtt.h:getTopic"));
|
||||
return mTopic;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
//DPRINT(F("m"));
|
||||
//if(!mClient->connected())
|
||||
// reconnect();
|
||||
mClient->loop();
|
||||
|
@ -66,6 +73,7 @@ class mqtt {
|
|||
|
||||
private:
|
||||
void reconnect(void) {
|
||||
DPRINTLN(F("mqtt.h:reconnect"));
|
||||
if(!mClient->connected()) {
|
||||
String mqttId = "ESP-" + String(random(0xffff), HEX);
|
||||
if((strlen(mUser) > 0) && (strlen(mPwd) > 0))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue