Sming icon indicating copy to clipboard operation
Sming copied to clipboard

Running web server on both Ap and Station

Open Matzz opened this issue 3 years ago • 1 comments

Hi, I'm trying to bind web server to both station and AP network. When I run Station and IP without setting an IP and station receive the same IP as AP then web server works on both.

However when I set different IP for station then only AP is accessible. My sample code is here: https://github.com/Matzz/Sming/blob/StationAndApHttpServer/samples/StationAndApHttpServer/app/application.cpp

I was thinking about a PR to enable correct behavior. My one idea was to replace IP_ADDR_ANY with provided IP in following line:

	err_t res = tcp_bind(tcp, IP_ADDR_ANY, port);

However, it will require running 2 web servers at the same time, which is inefficient. Another idea is to modify this line to bind to both networks regardless the IP. I saw this working when IP is the same for both Station and IP. However, due to lack of lwIP knowledge, I don't know how to enforce that for different ip.

I'm willing to make a PR for that but I would need some guidance / ideas first.

Regards, Matzz

Matzz avatar Apr 03 '21 22:04 Matzz

Related post - https://github.com/esp8266/Arduino/issues/2155

Matzz avatar Apr 03 '21 22:04 Matzz