Chat freely about anything...

User avatar
By Cicero
#49173 Hi all,

I've been using these ESP's for about a year, and feel pretty comfortable with them.
But I've hit a weird snag, I can't for the life of me set a password for the softAP which actually allows me to connect to it.

ESP-12
SDK v1.5.0

This is my code:
Code: Select allstruct softap_config config;
int ret = 0;
os_memset(config.ssid, 0, 32);
    os_memset(config.password, 0, 64);
    os_memcpy(config.ssid, "ESP8266_AP", 10);
    os_memcpy(config.password, "mypassword", 10);
    config.authmode = AUTH_WPA_WPA2_PSK;
    //config.authmode = AUTH_OPEN;
    config.ssid_len = 0;// or its actual length
    config.beacon_interval = 100;
    config.channel = 9;
    config.max_connection = 4; // how many stations can connect to ESP8266 softAP at most.
    wifi_set_opmode(SOFTAP_MODE);
   
    ret = wifi_softap_set_config(&config);// Set ESP8266 softap config .
   
    CONFIG_DEBUG("AP config loaded (return %u): %s, %s\r\n", ret, config.ssid, config.password);

void user_init(void) {
  wifi_station_set_auto_connect(FALSE);
 
  uart_init(BIT_RATE_115200,BIT_RATE_115200);
 
  os_delay_us(2000000); 
 
   ioInit();   

  CFG_Load();
 
  return;
}


It comes up with ESP8266_AP just fine, but when I try to connect my phone complains the password is incorrect. Changing it to open works just fine. I dont know what else to do.

The debug output is "AP config loaded (return 1): ESP8266_AP, mypassword", which looks perfect to me.

Any help will be appreciated.
User avatar
By martinayotte
#49175 Looking at how the configs is done in Arduino framework, I saw that it is using "config.authmode = AUTH_WPA2_PSK;" instead.
Maybe you can try that ?
(I presume that AUTH_WPA_WPA2_PSK can only be used for STA not for AP)
User avatar
By Cicero
#49177 I've tried that, doesn't work either.

This is from my debug output, my phone shows up for a few seconds before its removed, and then I get an 'incorrect password' error.

Code: Select allAP config loaded (return 1): ESP8266_AP, mypassword
end config
mode : softAP(1a:fe:34:9d:6a:82)
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100
add 1
aid 1
station: 18:af:61:0e:ef:c1 join, AID = 1
station: 18:af:61:0e:ef:c1 leave, AID = 1
rm 1


At my wits' end here.