B4R Question ESP8266 AP mode, dhcp ip sometime not run in properly.

tzfpg

Active Member
Licensed User
Longtime User
Hi,

I facing a problem about esp8266 wifi ap mode. I use esp8266 as wifi access point and i set dhcp ip range 192.168.4.100 to 192.168.4.120.
At the same time, i use 4 android devices to connect to wifi ap, sometime all android device show correct ip ( rangew from 192.168.4.100 to 192.168.4.120) and communicate smooth with esp8266.
after few minute and test again, some device get the range ip from 192.168.4.2 and can't communicate with esp8266, if try connect again and get start from 192.168.4.100 and problem gone.

i already stuck this problem a week, until now stil can't solve the problem.

Please help me solve this problem. thanks.

B4R code here
B4X:
RunNative("user_init", Null)
wifi.StartAccessPoint2(ssid,pwd)

B4X:
#if C
void dhcps_lease_test(void)
{
   struct dhcps_lease dhcp_lease;
   IP4_ADDR(&dhcp_lease.start_ip, 192, 168, 4, 100);
   IP4_ADDR(&dhcp_lease.end_ip, 192, 168, 4, 120);
   wifi_softap_set_dhcps_lease(&dhcp_lease);
}

void user_init(B4R::Object* unused)
{
   struct ip_info info;
   wifi_set_opmode( SOFTAP_MODE ); //Set softAP
   wifi_softap_dhcps_stop();
   IP4_ADDR(&info.ip, 192, 168, 4, 1);
   IP4_ADDR(&info.gw, 192, 168, 4, 1);
   IP4_ADDR(&info.netmask, 255, 255, 255, 0);
   wifi_set_ip_info(SOFTAP_IF, &info);
   dhcps_lease_test();
   wifi_softap_dhcps_start();
}
#end if
 

tzfpg

Active Member
Licensed User
Longtime User
Why do you need to do it? Why do you need to configure DHCP?

I didn't want to configure DHCP, previous i didn't configure DHCP, i facing same problem.
i thougth is DHCP problem, because first device get 192.168.4.2 , second get 192.168.4.3 ....
when first device connect again then get 192.168.4.5, the device can't communicate with esp8266.

ESP8266 is a UDP server, android devices communicate with esp to transfer data.

devices first time connect to esp and get the ip, if disconnect and connect again didnt get the same ip will not communicate with esp.
 
Upvote 0
Top