Moderator: igrr
freedom2000 wrote:Thank you again
You are right I am a bit lost with the syntax of arduino sketches...
My Android app is working well and I have even tested another one "Socket Protocol" (free on google Play)
Both are using classical sockets to communicate with tcp connection.
My code is blocking here on the client.read() instruction
and even worse, it never enters the client.available condition...Code: Select allif (client.available() > 0) {
// read the bytes incoming from the client:
char thisChar = client.read();
// echo the bytes to the serial
Serial.write(thisChar);
Finally my question is :
- once connected to client, how can I detect and read incoming data ?
- client is Android
- server is ESP8266
- ESP8266 being in AP mode
JP
which app are u using on android side
if (client.available())
insted of
if (client.available()>0)
to run this if.
and if you use following section insted of your command, it works:
while(client.connected()) {
while(client.available()) {
char thisChar = client.read();
Serial.write(thisChar);
// echo the bytes back to the client:
client.println(thisChar);
}
}
client.stop();
I use both Serial.write(thisChar); and client.println(thisChar); .the first of them must send data to all clients and second of them send data to specified client to ported socket.
but Serial.write(thisChar); dosent work in this example and you can remove it. The code works properly with client.println(thisChar);