Skip to content

Commit

Permalink
Merge pull request #7231 from ascillato/patch-2
Browse files Browse the repository at this point in the history
PubSubClient: Allow clean disconnection as optional.
  • Loading branch information
arendst authored Dec 28, 2019
2 parents a4749ec + 0803294 commit 8369467
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/PubSubClient-EspEasy-2.7.12/src/PubSubClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,11 +610,13 @@ boolean PubSubClient::unsubscribe(const char* topic) {
return false;
}

void PubSubClient::disconnect() {
void PubSubClient::disconnect(bool disconnect_package) {
buffer[0] = MQTTDISCONNECT;
buffer[1] = 0;
if (_client != nullptr) {
_client->write(buffer,2);
if (disconnect_package) {
_client->write(buffer,2);
}
_client->flush();
_client->stop();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/PubSubClient-EspEasy-2.7.12/src/PubSubClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class PubSubClient : public Print {
boolean connect(const char* id, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage);
boolean connect(const char* id, const char* user, const char* pass, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage);
boolean connect(const char* id, const char* user, const char* pass, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage, boolean cleanSession);
void disconnect();
void disconnect(bool disconnect_package = false);
boolean publish(const char* topic, const char* payload);
boolean publish(const char* topic, const char* payload, boolean retained);
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength);
Expand Down

0 comments on commit 8369467

Please sign in to comment.