Unable to set keep alive to over 32 seconds (signed int vs unsigned long)

This commit is contained in:
Nicholas O'Leary 2012-10-27 22:10:38 +01:00
parent 6f23967ee1
commit 97e9614780

View File

@ -94,7 +94,7 @@ boolean PubSubClient::connect(char *id, char *user, char *pass, char* willTopic,
lastInActivity = millis();
while (!_client->available()) {
unsigned long t= millis();
if (t-lastInActivity > MQTT_KEEPALIVE*1000) {
if (t-lastInActivity > MQTT_KEEPALIVE*1000UL) {
_client->stop();
return false;
}
@ -146,7 +146,7 @@ uint16_t PubSubClient::readPacket() {
boolean PubSubClient::loop() {
if (connected()) {
unsigned long t = millis();
if ((t - lastInActivity > MQTT_KEEPALIVE*1000) || (t - lastOutActivity > MQTT_KEEPALIVE*1000)) {
if ((t - lastInActivity > MQTT_KEEPALIVE*1000UL) || (t - lastOutActivity > MQTT_KEEPALIVE*1000UL)) {
if (pingOutstanding) {
_client->stop();
return false;