-->
Page 1 of 1

Wifi Client - TCP connection - Exit function when new data!

PostPosted: Sun Dec 30, 2018 8:32 am
by Neil_Y
HI, I am new to the forum (first post) and relatively new to Arduino coding. I hope I am posting in the correct section.

I am trying to use a D1 MIni (clone) to control an RGB LED strip (non-addressable) using an android app https://play.google.com/store/apps/details?id=udpcontroller.nomal&hl=en_US via wifi, I have the D1 mini connected via a driver shield and can get basic functionality.

I had previously used Blynk, and also set up a local Blynk server which have had working.

I have now started looking at controlling the device directly from this new app removing the need for the Blynk server. In SAP mode I had connectivity issues, so have now got the D1 mini (ESP8266) running in STA and the D1 and phone App connected via wifi network, connectivity is good and I have my code working well as far as accepting commands from the TCP controller app on my phone and changing the LED colours. This all works well from within the mail LOOP.

My question is.. how if at all can I get the client.read(); to work inside a function called from the main loop?

Basically, when a particular command is received I call a 'fade' function which continuously loops, smoothly changing the colour of the LED strip, what I can't figure out is how to break out of the loop and return to the main loop.

I have seen a couple of posts where people talk of keeping the TCP connection outside the main loop, I have added debug and tried varies combinations, but have had no luck.

I have dabbled a bit with Visual Studio and Windows Apps, so have the idea of trying to create different threads, but I am not at all sure if this is even a concept I should be considering..

I am probably overthinking things, or trying to do something fundamentally wrong, so any advice or suggestions would be appreciated.

Re: Wifi Client - TCP connection - Exit function when new da

PostPosted: Sun Dec 30, 2018 6:00 pm
by Neil_Y
Sorry, looks as though I duplicated the question, it took a while for the original post to appear. I should have been more patient..