Non-blocking readSubscription()?

Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Locked
User avatar
jecottrell
 
Posts: 249
Joined: Sat Jan 02, 2016 1:47 am

Non-blocking readSubscription()?

Post by jecottrell »

Is there a way to implement non-blocking code to read subscriptions?

What is the optimal "timeout" value for the readSubscription function?

Code: Select all

while ((subscription = mqtt.readSubscription(2000)))
Thanks,

John

User avatar
pellico
 
Posts: 31
Joined: Thu Aug 15, 2013 6:20 pm

Re: Non-blocking readSubscription()?

Post by pellico »

if the readSubscription() timeout value is not working(how did you test it) you could wrap that in a while(true) loop and put a sleep after the while( readSubscription() ) loop.

I didn't see the readSubscription() function as part of the python code so it might be just for embedded controllers. Maybe look at the source code for that function and see what it's doing, or not doing and what the single 'time' parameter is used for.

Doug

User avatar
jecottrell
 
Posts: 249
Joined: Sat Jan 02, 2016 1:47 am

Re: Non-blocking readSubscription()?

Post by jecottrell »

I'm sorry, I missed the important info that this code is on an ESP8266.

I guess the better forum is the Other Supported products. I'll post there, thanks!

User avatar
pellico
 
Posts: 31
Joined: Thu Aug 15, 2013 6:20 pm

Re: Non-blocking readSubscription()?

Post by pellico »

jecottrell wrote:I'm sorry, I missed the important info that this code is on an ESP8266.

I guess the better forum is the Other Supported products. I'll post there, thanks!
if it's an Adafruit IO API then I believe your question does belong here. I only stated I didn't see it in my Python code because I'm only using the Python API but the same rules apply to seeking the answer yourself. Ie look at the code since it's all posted on git and public.

It is possible you found a bug in the readSubscription(t) API the work-around I posted should work too as long as the readSubscription is correctly returning the proper data/value.

Locked
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.

Return to “Internet of Things: Adafruit IO and Wippersnapper”