How to run AP + TCP-server?

walt22
Posts: 3
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

User avatar
pratik
Posts: 349
Joined: Wed Jun 29, 2016 7:17 pm
Location: India
Contact:

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.
Regards,
Pratik Panda
Website: http://www.PratikPanda.com

Custom firmware, Knowledge base and freelancing (ESP8266/ESP32):
http://www.iot-bits.com

walt22
Posts: 3
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

User avatar
pratik
Posts: 349
Joined: Wed Jun 29, 2016 7:17 pm
Location: India
Contact:

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
Regards,
Pratik Panda
Website: http://www.PratikPanda.com

Custom firmware, Knowledge base and freelancing (ESP8266/ESP32):
http://www.iot-bits.com

walt22
Posts: 3
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

Who is online

Users browsing this forum: Google [Bot] and 5 guests