Net::poll alternative

15 Jan 2012

I'm using the EthernetNetIf library and have set up my program to display temperature and other data over http. I've added net::poll to my program loop and while this does actually work it can be slow to respond. Now I think this is because my main program loop takes around 10 seconds to run through.

Clearly I could optimise the main loop but is there any alternative to net::poll that works like an interrupt or could I make net::poll a ticker? Ideally I want the program to respond instantly to the http request regardless of what else it may be doing...

Thanks.

16 Jan 2012

The way forward depends on whether the server sends the data:

1. only when asked? 2. or does it send continually, without needing an HTTP GET request?

If 1. you can use raw lwIP commands to send a GET request. The function used to send the tcp_write can then include a pointer to a callback function which will generate an interrupt when the data response arrives.

See tcp_write, tcp_output, tcp_recv

http://lwip.wikia.com/wiki/Raw/TCP

If the data streams in without needing to be asked, then yes, set up a Ticker as an interrupt with net::poll() in there.