Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By martinayotte
#44575 As answered in the other thread, viewtopic.php?f=27&t=4080&start=16#p44573, simply use TCPServer on the AP side and the TCPClient on the STA side. On STA side, a simple client.connect("192.168.4.1", 23) would initiate a Telnet connection with the AP.
User avatar
By msk basha
#53267
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 all if (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
User avatar
By Nanosi
#77697 You can use
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);