Chat freely about anything...

User avatar
By treii28
#66392 I have a program I'm working on that combines a configuration access point and a wifi scanner that will make client connections to some specific networks. However, one problem is that if a scan is on-going and/or a connection is trying to be made, the code is tied up waiting for the connection and/or sending/receiving the traffic.

I would like to be able to write a synchronous code base for each side (the server stuff already seems to be sufficient enough for the moment) where, if a connection is waiting to be made, I can go back again and check it's status after going back to the main loop to check for AP requests and so on.

I know how to write code that way, but now I'm wondering what, if anything, I would need to do in my various scopes to make sure I'm talking to the right connection or client or whatever. Most of the examples I see for making an outbound connection don't seem to tie anything to any kind of handle as they assume you are just doing the one thing until it's finished. So, for example, they will use a while loop that checks WiFi.status() until it equals WL_CONNECTED and/or possibly some maximum counter is reached. Then it creates a client (ok, that I could tie off somewhere as a handle in a global var or class property) then checks for client.connect.

I would like to be able to create a function that gets called from a loop and checks the status of that specific WiFi request, if it's not connected yet, increment a time-out counter, if it is, create a web-client and flag it's connected so the next loop pass I can skip the check-connection part and go straight to the check web-client connection and so on until it's finished. Then reset all the flags so it knows it's ready for another scan again.

I think I can bind the (web)client but I'm not sure how to identify and reference the WiFi connect request to check on a later pass.

SW