internet unavailable when connected to AP(Wi-Fi) of ESP32 DevKit,

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: internet unavailable when connected to AP(Wi-Fi) of ESP32 DevKit,

Postby WiFive » Thu Feb 28, 2019 8:52 am

Code: Select all

IP4_ADDR(&info.gw, 192, 168, 1, 1);//ESP acts as router, so gw addr will be its own addr
Set this to 0 otherwise your phone will try to send internet traffic there

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: internet unavailable when connected to AP(Wi-Fi) of ESP32 DevKit,

Postby Ritesh » Thu Feb 28, 2019 11:42 am

WiFive wrote:
Thu Feb 28, 2019 8:52 am

Code: Select all

IP4_ADDR(&info.gw, 192, 168, 1, 1);//ESP acts as router, so gw addr will be its own addr
Set this to 0 otherwise your phone will try to send internet traffic there
Hi WiFive,

I have one query like iOS device can get internet connection from ESP32 when it is connected with ESP32 device into AP mode?

Let me correct what I understood is like below

1) iOS device doesn't has any internet connection
2) ESP32 Device is working as AP mode
3) iOS Device is trying to connect with ESP32 device and trying to get internet connection with that

or let me correct if I understood something wrong?
Regards,
Ritesh Prajapati

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: internet unavailable when connected to AP(Wi-Fi) of ESP32 DevKit,

Postby WiFive » Thu Feb 28, 2019 12:23 pm

No it is like

1) iOS device has cellular internet connection
2) ESP32 Device is working as AP mode
3) iOS Device is trying to connect with ESP32 device and trying to keep internet connection from cellular

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: internet unavailable when connected to AP(Wi-Fi) of ESP32 DevKit,

Postby Ritesh » Thu Feb 28, 2019 1:01 pm

WiFive wrote:
Thu Feb 28, 2019 12:23 pm
No it is like

1) iOS device has cellular internet connection
2) ESP32 Device is working as AP mode
3) iOS Device is trying to connect with ESP32 device and trying to keep internet connection from cellular
Ok. Understood.

Then Internet connection should be remained as it is into iOS phone even if after connecting that iOS device with ESP32 into AP mode.
Regards,
Ritesh Prajapati

jcsbanks
Posts: 305
Joined: Tue Mar 28, 2017 8:03 pm

Re: internet unavailable when connected to AP(Wi-Fi) of ESP32 DevKit,

Postby jcsbanks » Wed Feb 10, 2021 4:21 pm

phatpaul wrote:
Tue Feb 26, 2019 4:34 pm
Interesting about the Garmin device. What device is it? Does it prevent hijacking the internet connection on both iOS and Android?

Here's what I have after struggling with this as well. It seems to work for iOS, but not always working in Android.

this is in main() before initializing WiFi:

Code: Select all

	tcpip_adapter_init();
	{
		tcpip_adapter_ip_info_t info = {0};
		tcpip_adapter_dns_info_t dns_info = {0};
		IP_ADDR4(&dns_info.ip, 0, 0, 0, 0);
		IP4_ADDR(&info.ip, 192, 168, 4, 1);
		IP4_ADDR(&info.gw, 0, 0, 0, 0);
		IP4_ADDR(&info.netmask, 255, 255, 255, 0);

		ESP_ERROR_CHECK(tcpip_adapter_dhcps_stop(TCPIP_ADAPTER_IF_AP));
		ESP_ERROR_CHECK(tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_AP, &info));
		dhcps_dns_setserver(&(dns_info.ip));
		uint8_t opt_val = 0; // don't supply a dns server via dhcps
		//ESP_ERROR_CHECK(tcpip_adapter_dhcps_option(TCPIP_ADAPTER_OP_SET, TCPIP_ADAPTER_DOMAIN_NAME_SERVER, &opt_val, 1));  // don't supply a dns server via dhcps
		ESP_ERROR_CHECK(tcpip_adapter_dhcps_option(TCPIP_ADAPTER_OP_SET, TCPIP_ADAPTER_ROUTER_SOLICITATION_ADDRESS, &opt_val, 1));  // don't supply a gateway (router) via dhcps option 3
		ESP_ERROR_CHECK(tcpip_adapter_dhcps_start(TCPIP_ADAPTER_IF_AP));
	}
Hope it helps.
Trying either option on ESP IDF 3.3 still results in there being a DNS server on 192.168.4.1, but the gateway on 192.168.4.1 disappears. Android still doesn't use cellular in this case.

jcsbanks
Posts: 305
Joined: Tue Mar 28, 2017 8:03 pm

Re: internet unavailable when connected to AP(Wi-Fi) of ESP32 DevKit,

Postby jcsbanks » Wed Feb 10, 2021 8:54 pm

https://github.com/espressif/esp-idf/bl ... er.c?#L355

Since I could only set DNS to 0.0.0.0 and that didn't work for Android I also commented out the 13 lines from the link and then in Windows no IPV4 DNS servers are shown. Gateway also not shown. Not sure it makes any difference though as Android 9 still doesn't want to use cellular when connected to ESP32 WiFi though. Developer options set include "Mobile data always active".

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: internet unavailable when connected to AP(Wi-Fi) of ESP32 DevKit,

Postby WiFive » Wed Feb 10, 2021 10:06 pm

You may want to register your support for this https://github.com/espressif/esp-idf/issues/6522

dynek=
Posts: 7
Joined: Thu Aug 27, 2020 11:28 am

Re: internet unavailable when connected to AP(Wi-Fi) of ESP32 DevKit,

Postby dynek= » Tue Jun 06, 2023 6:12 am

Hey,

Has anyone every succeeded in having both mobile/cellular internet connectivity + ESP32 in AP mode (without Internet) on Android devices?

Looks like the following make it so I can at least access the ESP32, but mobile connectivity is not working anymore:

Code: Select all

 uint8_t opt_val = 0; // don't supply a dns server via dhcps
ESP_ERROR_CHECK(tcpip_adapter_dhcps_option(TCPIP_ADAPTER_OP_SET, TCPIP_ADAPTER_DOMAIN_NAME_SERVER, &opt_val, 1));
Cheers

MicroController
Posts: 1725
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: internet unavailable when connected to AP(Wi-Fi) of ESP32 DevKit,

Postby MicroController » Tue Jun 06, 2023 9:04 pm

This Q/A suggest that you may be able to do it by disabling DHCP for the respective SSID and removing the gateway IP address in Android's WiFi config. Or by "skipping" Android's prompt when first connecting to the internet-less WiFi. Might give that a try.

Who is online

Users browsing this forum: No registered users and 396 guests