Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handing out NO gateway via DHCP? #1372

Closed
schweini opened this issue May 2, 2018 · 14 comments
Closed

Handing out NO gateway via DHCP? #1372

schweini opened this issue May 2, 2018 · 14 comments
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@schweini
Copy link

schweini commented May 2, 2018

I am trying to get my Android phone connected to my ESP32, while at the same time maintaining my mobile connection.

The problem seems to be that Android simply routes all traffic over the mobile data connection, until it is sure that the wifi network provides internet connectivity.

(strange side node: the WebView inside the 'sign in to network' pop-up can see the ESP32 - no other browser can. Only if I disable mobile data, can I use a browser to visit the ESP32's IP)

I suspect (but am not sure) that Android doesn't trust an AP that defines a default gateway, but offers no internet connectivity.

I would like to, therefore, NOT hand out a default gateway address over DHCP when my phone connects.

Is there a way to do this? Or some line I could quickly comment out for testing if this actually works?

@lbernstone
Copy link
Contributor

This doesn't have anything to do with ESP32, but simple TCP/IP behavior. The stack will use whichever route it thinks will get it to the destination address. If your ESP is using a private address (eg, the default softAP address of 192.168.4.1), then your phone will route requests to that network through the softAP. All other traffic will go through the mobile network. Are you saying that if you have mobile on that you cannot get to a webserver running on the ESP, but as soon as you turn it off you can get there? The "sign in to network" captive portal from WiFiManager is just a redirect to that address.

@schweini
Copy link
Author

schweini commented May 2, 2018 via email

@schweini
Copy link
Author

schweini commented May 2, 2018

Here's someone with the same problem on ESP8266:

esp8266/Arduino#1956

And someone recommended trying
wifi_softap_set_dhcps_offer_option(OFFER_ROUTER, 0)
but google can't tell me if that function exists in ESP32/Arduino or how to set that.

@schweini
Copy link
Author

schweini commented May 2, 2018

I commented out
info.gw.addr = static_cast<uint32_t>(gateway);
in espressif\esp32\libraries\WiFi\src\WiFiAP.cpp (hoping that this would cause the gateway not to be set), but this causes my Android phone to take on a gateway address of 235.103.13.128, which is in the IANA multicast IP block,

@everslick
Copy link
Contributor

@schweini I use the ESP soft AP with Android and I cannot confirm your problem. when i connect to the softap, my phone tells me that, this AP does not seem to provide an internet connection and if you want to connect anyway. after clicking yes, everything works as expected. I have mobile data ON all the time. this is on a Nexus from LG with Android 8.0

@schweini
Copy link
Author

schweini commented May 3, 2018 via email

@everslick
Copy link
Contributor

A) you can browse to the ESP32's IP (while it is in AP mode)

yes.

B) at the same time navigate the general internet

no.

But I did not expect B) to work. I obviously misunderstood your issue. I read it as 'you cannot reach the ESP AP as long as you have mobile data enabled'. but you have a point. if the default gateway still points to the mobile data interface, it might be possible to have both.

@nevercast
Copy link

I'm looking for this functionality on a different downstream project from the ESP-IDF (Pycom), is this functionality already available in the IDF and this issue is regarding Arduino implementation?

@stale
Copy link

stale bot commented Aug 1, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Aug 1, 2019
@stale
Copy link

stale bot commented Aug 15, 2019

This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Aug 15, 2019
@no-trick-pony
Copy link

Did anyone ever find a solution to this. I am struggling with that too ATM. I can either connect to the ESP32 AP and access the webserver it provides but can NOT browse the internet on the phone or the the other way around. This seems to be an Android issue though.

@ammgws
Copy link

ammgws commented Jul 27, 2021

@no-trick-pony Did you figure anything out this past month?

@chrismerck
Copy link

FWIW, I was able to disable the offering of a gateway by changing tcpip_adapter_init() in esp-idf/components/tcpip_adapter/tcpip_adapter_lwip.c:

    IP4_ADDR(&esp_ip[TCPIP_ADAPTER_IF_AP].ip, 10, 7, 42, 1); // we override the default AP IP because Espressif's default conflicts with some customer networks. This IP is less likely to conflict unless the user is a big Douglas Adams fan.
    IP4_ADDR(&esp_ip[TCPIP_ADAPTER_IF_AP].gw, 0, 0, 0, 0);  // making this 0.0.0.0 disables gateway offer
    IP4_ADDR(&esp_ip[TCPIP_ADAPTER_IF_AP].netmask, 255, 255 , 255, 0);

I've only tested on iOS, but I find that it causes the phone to be able to communicate on the Config AP and on the internet via cellular. It does have the unfortunate side-effect of preventing the iOS app from viewing the current SSID (something Apple surprisingly allows the app to do), however the app can still attempt to communicate with the device via its IP address.

@tjunussov
Copy link

chrismerck

Hi! here you mentioned filepath to esp-idf/components/tcpip_adapter/tcpip_adapter_lwip.c but Arduino-ESP32 doen't have such folder ? is it refered to ESP-IDF not Arduino-ESP32?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

No branches or pull requests

8 participants