Update PubSubClient.cpp
Make sure all data is flushed to the other end when doing a disconnect(): that way we know for sure that it is there when we disconnect the wifi or maybe even reboot. This change was made after I noticed that I did not get any mqtt messages. I verified that it indeed solves the problem. Example code on request.
This commit is contained in:
parent
54be6e87db
commit
0e2d6c322b
@ -524,6 +524,7 @@ void PubSubClient::disconnect() {
|
|||||||
buffer[1] = 0;
|
buffer[1] = 0;
|
||||||
_client->write(buffer,2);
|
_client->write(buffer,2);
|
||||||
_state = MQTT_DISCONNECTED;
|
_state = MQTT_DISCONNECTED;
|
||||||
|
_client->flush();
|
||||||
_client->stop();
|
_client->stop();
|
||||||
lastInActivity = lastOutActivity = millis();
|
lastInActivity = lastOutActivity = millis();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user