How to run AP + TCP-server?

walt22
Posts: 9
Joined: Fri Oct 16, 2015 3:00 am

How to run AP + TCP-server?

Postby walt22 » Fri May 19, 2017 5:37 pm

Hello,
I am developing an outdoor remote control system, with a dedicated WLAN from an ESP8266 AP. A tablet with a TCP-client should connect to it in order to set some GPIOs on the ESP. According to my understanding, a TCP-server on the ESP should take the commands from the tablet client for further processing. There is no additional router involved.
Right now, the AP works fine and the tablet can log into the WLAN and gets a proper IP address. But a connection of the client to the server will be refused. So my questions are:
Which mode the ESP should have SOFTAP or STATIONAP?
Is a TCP-server necessary or are other solutions possible?
Which IP address the TCP-server should have, I tried with the address of the AP and a different one, but no success?

I work with None-OS SDK 2.0.

Many thanks for any help
Walter

pratik

Re: How to run AP + TCP-server?

Postby pratik » Fri May 19, 2017 5:42 pm

By default, the server IP of ESP8266 in AP mode is 192.168.4.1
When you start your server in the ESP, make sure the port is 80.
Seems like you are doing everything right. You can ping the ESP server IP to make sure your ESP setup is good.

Staion + AP mode is not required in your project.

walt22
Posts: 9
Joined: Fri Oct 16, 2015 3:00 am

Re: How to run AP + TCP-server?

Postby walt22 » Sat May 20, 2017 3:01 am

Hello Pratik,

Many thanks for your quick reply.
I have started the AP and am able to ping his IP address successfully.
But I don´t understand your recommendation regarding port 80, because my client is able to address any port.

What should happen after the AP has started, should I start a TCP-server with the local address of the AP?
A code snippet of this would be very helpful.

Best regards
Walter

pratik

Re: How to run AP + TCP-server?

Postby pratik » Sun May 21, 2017 12:15 am

Ohh, I suggested port 80 because that is the default port in all browsers.

Refer to sample code section here, it works with all SDK versions (nonOS SDK):
http://www.espressif.com/en/products/ha ... /resources

walt22
Posts: 9
Joined: Fri Oct 16, 2015 3:00 am

Re: How to run AP + TCP-server?

Postby walt22 » Sun May 21, 2017 6:53 pm

Hello Pratik,

Many thanks for your helpful support!

My test program is now running. What I did:
Start an AP with a given IP address, eg. 10.10.10.1
Start of a TCP-server with a given port, eg. 3333, which fetched the a.m. IP address.

My TCP-client gets from AP the address 10.10.10.2 and is able to commicate with the AP (10.10.10.1).

Now I can continue the development of my remote control.

Best regards
Walter

yuryhor
Posts: 1
Joined: Wed May 06, 2020 6:53 pm

Re: How to run AP + TCP-server?

Postby yuryhor » Wed May 06, 2020 7:53 pm

Hello Valter.
Can I see your TCP server code in AP mode.
I am trying to solve a similar problem until I know where to start.
Thanks.

Who is online

Users browsing this forum: No registered users and 258 guests