Chat freely about anything...

User avatar
By Dave S
#19462 I don't get it. Hopefully, someone knows the secret sauce.

Here's the problem:
  • ESP8266 WIFI is set to AP mode using the SDK 1.0.1 24 April 2015
  • Callback installed to send a serial port message (for testing) when a device joins and leaves the AP
  • My laptop joins and leaves the AP as expected.
  • My iPhone also joins and leaves the AP as expected.
  • My Android smartphone running 4.4.2 will not connect to the AP. The ssid is visible, but no connection made when attempted.
  • My Android tablet also will not connect to the ESP8266 AP.
  • But....if I run an ESP8266 sketch compiled with Arduino IDE 1.6.1 with the ESP8266 in AP, I can join and leave the AP with my Android devices

Does anyone know what the Android IDE for ESP8266 do to satisfy Android devices that is missing from the SDK compiled code? Very strange that it is only a problem with Android devices. :o
User avatar
By Dave S
#19478 I set the ssid (WIFI_AP_NAME) to "ESP8266_4" as this is my 4th module in service.

No encryption (AUTH_OPEN). Also tested each encryption type and they all worked with my Windows7 laptop and iPhone but not the Android devices.

Here is the function used to setup the AP mode. Also printed via serial port the wifi_get_opmode() to confirm it was 0x2 (SOFTAP_MODE)
Code: Select allvoid setup_wifi_ap_mode(void)

   struct softap_config apconfig;
      os_memset(apconfig.ssid, 0, sizeof(apconfig.ssid));
      os_memset(apconfig.password, 0, sizeof(apconfig.password));
      os_sprintf(apconfig.ssid, "%s", WIFI_AP_NAME);
      os_sprintf(apconfig.password, "%s", WIFI_AP_PASSWORD);
      apconfig.authmode = AUTH_OPEN;
      apconfig.ssid_hidden = 0;
      apconfig.max_connection = 4;;
         #ifdef PLATFORM_DEBUG
         ets_uart_printf("ESP8266 not set ap config!\r\n");


    LOCAL struct ip_info info;
    IP4_ADDR(&info.ip, 192, 168, 22, 1);
    IP4_ADDR(&, 192, 168, 22, 1);
    IP4_ADDR(&info.netmask, 255, 255, 255, 0);
    wifi_set_ip_info(SOFTAP_IF, &info);

    struct dhcps_lease dhcp_lease;
    IP4_ADDR(&dhcp_lease.start_ip, 192, 168, 22, 2);
    IP4_ADDR(&dhcp_lease.end_ip, 192, 168, 22, 5);

    ets_uart_printf("SOFTAP Status:%d\r\n",wifi_softap_dhcps_status());


And here is the WIFI event callback

Code: Select allvoid wifi_event_cb(System_Event_t *evt) {
   static int serverinit=0;
   switch (evt->event) {
         ets_uart_printf("station: " MACSTR " join, AID = %d\n",
         //Start Web Server
         if(!serverinit) {
         //Start periodic loop
         os_timer_setfn(&loop_timer, (os_timer_func_t *)loop_cb, (void *)0);
         os_timer_arm(&loop_timer, DELAY, 10);
         ets_uart_printf("station: " MACSTR " leave, AID = %d\n",
         //Stop Web Server
         //Stop periodic loop

After connection was made, I further confirmed the webserver was functional on my laptop by sending a request to the ESP8266 AP IP ( My server was set to listen on port 9703(SERVER_PORT). The correct JSON string was returned from this request, as programmed in the web server.

But no connection with the Android device?? :cry:

Thanks for any light you might shine on this...
User avatar
By hdrut
#19487 HI,

i have had issues with sizeof() in the past. Try printing the value from sizeof(<yourSSID>) and compare it with the actual length of your SSID (which is 9 i believe).

Also, try CHAR casting in accessing your structure elements (this works for me on android ):

os_sprintf((char *)softApConf.ssid, "%s%02X%02X%02X", sysCfg.softap_ssid, macaddr[3], macaddr[4], macaddr[5] );
os_sprintf((char *)softApConf.password, "%s", sysCfg.softap_pass);

Good luck!