Skip to content

Commit

Permalink
Blocking mqtt option
Browse files Browse the repository at this point in the history
  • Loading branch information
sblantipodi committed Jan 26, 2025
1 parent 01f822e commit 54839bd
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "git",
"url": "https://github.com/sblantipodi/arduino_bootstrapper.git"
},
"version": "1.18.2",
"version": "1.18.3",
"examples": "examples/*.cpp",
"exclude": "tests",
"frameworks": "arduino",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Bootstrapper
version=1.18.2
version=1.18.3
author=Davide Perini <perini.davide@dpsoftware.org>
maintainer=Davide Perini <perini.davide@dpsoftware.org>
sentence=A client library for MQTT messaging.
Expand Down
6 changes: 4 additions & 2 deletions src/Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ String mqttpass = "XXX";
String mqttWillTopic = "0";
String mqttWillPayload = "0";
int mqttWillQOS = 1;
bool mqttWillRetain = 0;
bool mqttCleanSession = 1;
bool mqttWillRetain = false;
bool mqttCleanSession = true;
bool blockingMqtt = true;
bool mqttConnected = false;
String additionalParam = "XXX";
bool ethConnected = false;

Expand Down
2 changes: 2 additions & 0 deletions src/Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ extern String mqttWillPayload;
extern int mqttWillQOS;
extern bool mqttWillRetain;
extern bool mqttCleanSession;
extern bool mqttConnected;
extern bool blockingMqtt;
extern String additionalParam;
extern bool ethConnected;

Expand Down
6 changes: 6 additions & 0 deletions src/QueueManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,19 @@ void QueueManager::mqttReconnect(void (*manageDisconnections)(), void (*manageQu
// Wait 500 millis before retrying
delay(DELAY_500);
}
if (!blockingMqtt) {
break;
}
}
}

void QueueManager::queueLoop(void (*manageDisconnections)(), void (*manageQueueSubscription)(),
void (*manageHardwareButton)()) {
if (!mqttClient.connected()) {
mqttConnected = false;
mqttReconnect(manageDisconnections, manageQueueSubscription, manageHardwareButton);
} else {
mqttConnected = true;
}
mqttClient.loop();
}
Expand Down

0 comments on commit 54839bd

Please sign in to comment.