Black Lives Matter - Action and Equality. ... Adafruit is part of the Stop Hate for Profit campaign. Adafruit is open and shipping.
0

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.
Please be positive and constructive with your questions and comments.

Non-blocking readSubscription()?

by jecottrell on Mon Jan 11, 2016 1:46 pm

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 | TOGGLE FULL SIZE
while ((subscription = mqtt.readSubscription(2000)))


Thanks,

John

jecottrell
 
Posts: 247
Joined: Sat Jan 02, 2016 1:47 am

Re: Non-blocking readSubscription()?

by pellico on Mon Jan 11, 2016 3:03 pm

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

pellico
 
Posts: 28
Joined: Thu Aug 15, 2013 6:20 pm

Re: Non-blocking readSubscription()?

by jecottrell on Mon Jan 11, 2016 5:29 pm

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!

jecottrell
 
Posts: 247
Joined: Sat Jan 02, 2016 1:47 am

Re: Non-blocking readSubscription()?

by pellico on Mon Jan 11, 2016 6:15 pm

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.

pellico
 
Posts: 28
Joined: Thu Aug 15, 2013 6:20 pm

Please be positive and constructive with your questions and comments.