Hi,
with the ESP in AP mode, it acts as a DHCP server.
when doing that, it hands out IP addresses to any client and also it tells them network information like the DNS servers and gateways.
And thats exactly my problem. When a DHCP server hands out DNS server and default route-adresses, a mobile device like my android smartphone will try to use the ESP8266 as a router to get to the internet -- which will of course fail.
This could be prevented by not sending the DHCP options 3 and 6.
Screenshot: https://screenshot.tbspace.de/vetdnfuhizk.png
Is there anyway to disable or configure the DHCP payload which is sent by the ESP?
Thanks,
Tobias
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
In user_interface.h there is wifi_softap_set_dhcps_offer_option(), which, as far as I can tell, controls whether to send routing-information to clients or not. wifi_softap_set_dhcps_offer_option(OFFER_ROUTER, 0) should disable sending that.
I have not tried this, but after calling WiFi.begin() calling wifi_softap_set_dhcps_offer_option() might work.
@Manawyrm did this solution work for you?
I unfortunatly can't test it at the moment, because I have lent out the ESP with the electronics to another team member who is developing on the hardware side of things.
I will come back to you as soon as possible.
Sorry for the delay and keeping this open for so long!
The code to include various options is here:
https://github.com/esp8266/Arduino/blob/master/tools/sdk/lwip/src/app/dhcpserver.c#L129
Is there any clear method to customize the DHCP Configuration in ESP8266 Arduino?
I need to customize my DHCP range from 192.168.244.x to 192.168.43.x.
There is not enough documentation on how to setting NodeMCU/ESP8266 Arduino Language DHCP settings in AP Mode.
Thanks!
@NarinLab Take a look at http://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/soft-access-point-class.html#softapconfig -- if you specify the ESP8266's IP-address as e.g. 192.168.43.1, the function softAPConfig() sets the DHCP-range as 192.168.43.100 - 192.168.43.200.
If you want to customize the range further, I recommend taking a look at https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp and setting the DHCP-server up manually.
@WereCatf
Thankyou very much,
Problem solved by:
IPAddress ip(192, 168, 43, 1);
IPAddress gateway(192, 168, 43, 1);
IPAddress subnet(255, 255, 255, 0);
WiFi.softAPConfig(ip, gateway, subnet);
@Manawyrm did you get this to work? I'm also stuck on getting my Android phone to simultaneously connect to the network 192.168.4.1/24 via wifi, and the rest of the internet via mobile data.
extern "C" {
}
const char *ssid = "NightVisionAP";
const char *password = "";
void setup() {
Serial.begin(115200);
delay(10);
Serial.println('\n');
uint8 mode = 0;
wifi_softap_set_dhcps_offer_option(OFFER_ROUTER, &mode);
WiFi.softAP(ssid, password); // Start the access point
Serial.print("Access Point "");
Serial.print(ssid);
Serial.println("\" started");
Serial.print("IP address:\t");
Serial.println(WiFi.softAPIP()); // Send the IP address of the ESP8266 to the computer
}
void loop() { }
Most helpful comment
extern "C" {
include "user_interface.h"
}
include // Include the Wi-Fi library
const char *ssid = "NightVisionAP";
const char *password = "";
void setup() {
Serial.begin(115200);
delay(10);
Serial.println('\n');
uint8 mode = 0;
wifi_softap_set_dhcps_offer_option(OFFER_ROUTER, &mode);
WiFi.softAP(ssid, password); // Start the access point
Serial.print("Access Point "");
Serial.print(ssid);
Serial.println("\" started");
Serial.print("IP address:\t");
Serial.println(WiFi.softAPIP()); // Send the IP address of the ESP8266 to the computer
}
void loop() { }