Skip to content

Commit

Permalink
Don't wait for disconnect in a tight loop (#27)
Browse files Browse the repository at this point in the history
Instead, do a short `delay()` in each iteration. This should
allow the rest of the SW to "do its stuff", like, kicking the
WDT and such.
  • Loading branch information
sveljko authored and vveljko committed Feb 28, 2019
1 parent 143ef60 commit 0f39931
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions PubNubDefs.h
Expand Up @@ -670,13 +670,13 @@ inline PubNonSubClient* PubNub::publish(const char* channel,
DBGprintln("publish() BH_ERROR");
client.stop();
while (client.connected())
;
delay(10);
return 0;
case PubNub_BH_TIMEOUT:
DBGprintln("publish() BH_TIMEOUT");
client.stop();
while (client.connected())
;
delay(10);
return 0;
}
}
Expand Down Expand Up @@ -727,14 +727,14 @@ inline PubSubClient* PubNub::subscribe(const char* channel, int timeout)
DBGprintln("No data received!");
client.stop();
while (client.connected())
;
delay(10);
return 0;
}
if (client.read() != '[') {
DBGprintln("Unexpected body in subscribe response");
client.stop();
while (client.connected())
;
delay(10);
return 0;
}
/* Now return handle to the client for further perusal.
Expand All @@ -748,15 +748,15 @@ inline PubSubClient* PubNub::subscribe(const char* channel, int timeout)
DBGprintln("subscribe() BH_ERROR");
client.stop();
while (client.connected())
;
delay(10);
return 0;

case PubNub_BH_TIMEOUT:
DBGprintln("subscribe() BH_TIMEOUT");
client.stop();
DBGprintln("subscribe() BH_TIMEOUT stopped");
while (client.connected())
;
delay(10);
DBGprintln("subscribe() BH_TIMEOUT disconnected");
return 0;
}
Expand Down Expand Up @@ -791,13 +791,13 @@ inline PubNonSubClient* PubNub::history(const char* channel, int limit, int time
DBGprintln("history() BH_ERROR");
client.stop();
while (client.connected())
;
delay(10);
return 0;
case PubNub_BH_TIMEOUT:
DBGprintln("history() BH_TIMEOUT");
client.stop();
while (client.connected())
;
delay(10);
return 0;
}
}
Expand Down
2 changes: 1 addition & 1 deletion library.properties
@@ -1,5 +1,5 @@
name=Pubnub
version=3.1.0
version=3.1.1
author=Vladimir Veljkovic <vlada@pubnub.com>
maintainer=Vladimir Veljkovic <vlada@pubnub.com>
sentence=Pubnub SDK for Arduino.
Expand Down

0 comments on commit 0f39931

Please sign in to comment.