Skip to content

Commit 0f39931

Browse files
sveljkovveljko
authored andcommitted
Don't wait for disconnect in a tight loop (#27)
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.
1 parent 143ef60 commit 0f39931

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

PubNubDefs.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -670,13 +670,13 @@ inline PubNonSubClient* PubNub::publish(const char* channel,
670670
DBGprintln("publish() BH_ERROR");
671671
client.stop();
672672
while (client.connected())
673-
;
673+
delay(10);
674674
return 0;
675675
case PubNub_BH_TIMEOUT:
676676
DBGprintln("publish() BH_TIMEOUT");
677677
client.stop();
678678
while (client.connected())
679-
;
679+
delay(10);
680680
return 0;
681681
}
682682
}
@@ -727,14 +727,14 @@ inline PubSubClient* PubNub::subscribe(const char* channel, int timeout)
727727
DBGprintln("No data received!");
728728
client.stop();
729729
while (client.connected())
730-
;
730+
delay(10);
731731
return 0;
732732
}
733733
if (client.read() != '[') {
734734
DBGprintln("Unexpected body in subscribe response");
735735
client.stop();
736736
while (client.connected())
737-
;
737+
delay(10);
738738
return 0;
739739
}
740740
/* Now return handle to the client for further perusal.
@@ -748,15 +748,15 @@ inline PubSubClient* PubNub::subscribe(const char* channel, int timeout)
748748
DBGprintln("subscribe() BH_ERROR");
749749
client.stop();
750750
while (client.connected())
751-
;
751+
delay(10);
752752
return 0;
753753

754754
case PubNub_BH_TIMEOUT:
755755
DBGprintln("subscribe() BH_TIMEOUT");
756756
client.stop();
757757
DBGprintln("subscribe() BH_TIMEOUT stopped");
758758
while (client.connected())
759-
;
759+
delay(10);
760760
DBGprintln("subscribe() BH_TIMEOUT disconnected");
761761
return 0;
762762
}
@@ -791,13 +791,13 @@ inline PubNonSubClient* PubNub::history(const char* channel, int limit, int time
791791
DBGprintln("history() BH_ERROR");
792792
client.stop();
793793
while (client.connected())
794-
;
794+
delay(10);
795795
return 0;
796796
case PubNub_BH_TIMEOUT:
797797
DBGprintln("history() BH_TIMEOUT");
798798
client.stop();
799799
while (client.connected())
800-
;
800+
delay(10);
801801
return 0;
802802
}
803803
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Pubnub
2-
version=3.1.0
2+
version=3.1.1
33
author=Vladimir Veljkovic <[email protected]>
44
maintainer=Vladimir Veljkovic <[email protected]>
55
sentence=Pubnub SDK for Arduino.

0 commit comments

Comments
 (0)