Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By cyborgmax
#2326 I'm trying to setup Soft AP, I can see the ssid in my phone but can't connect to it.
//config.h
#define SSID "espwifi"
#define SSID_PASSWORD "testesp"

//main.c
#include "ets_sys.h"
#include "osapi.h"
#include "gpio.h"
#include "os_type.h"
#include "user_config.h"
#include "user_interface.h"

//Init function
void ICACHE_FLASH_ATTR
user_init()
{
char ssid[32] = SSID;
char password[64] = SSID_PASSWORD;
struct softap_config apConfig;

//Set AP mode
wifi_set_opmode(2);

//Set ap settings
os_memcpy(&apConfig.ssid, ssid, 32);
os_memcpy(&apConfig.password, password, 64);
apConfig.channel = 1;
apConfig.authmode = 4;
wifi_softap_set_config (&apConfig);
}

Anyone had any luck with this?? Am I missing something??
Can someone help me with this??? Thanks.
User avatar
By elektronika_ba
#2328 Did you try with different auth mode, like AUTH_WPA_PSK (2)?
I remember that I couldn't connect to my module when using auth mode AUTH_WPA_WPA2_PSK (4).
Also, maybe your .max_connection is somehow set to 0 in config already...

This is how it works for me:
Code: Select all      char macaddr[6];
      wifi_get_macaddr(SOFTAP_IF, macaddr);

      struct softap_config apConfig;
      os_memset(apConfig.ssid, 0, sizeof(apConfig.ssid));
      os_sprintf(apConfig.ssid, "CTRL_%02x%02x%02x%02x%02x%02x", MAC2STR(macaddr));
      os_memset(apConfig.password, 0, sizeof(apConfig.password));
      os_sprintf(apConfig.password, "%02x%02x%02x%02x%02x%02x", MAC2STR(macaddr));
      apConfig.authmode = AUTH_WPA_PSK;
      apConfig.channel = 7;
      apConfig.max_connection = 255; // 1?
      apConfig.ssid_hidden = 0;

      wifi_softap_set_config(&apConfig);
User avatar
By cyborgmax
#2349 Thank a lot for your help. It looks like it was the max_connection parameter. I had try with all Auth modes. It seems to me that whenever we're using a function, every parameter have to be specified.
By the way, I could use Auth_mode WPA_WPA2_PSK (4) without issues.

Thanks again.
User avatar
By barone_f
#15342 Hello,

same problem for me, I would change the SSID on my ESP01 running in SOFTAP mode with this portion of code:

struct softap_config cfgESP;
while(!wifi_softap_get_config(&cfgESP));

/****** Change SSID ******/
memset(cfgESP.ssid, 0, 32);
os_memcpy(&cfgESP.ssid, ssid, strlen(ssid));

cfgESP.authmode=AUTH_OPEN;
cfgESP.max_connection=255;
cfgESP.ssid_hidden=0;

wifi_softap_set_config(&cfgESP);

It works, when ESP starts I was able to discover the SSID but I was not able to connect to it.

Have you same experience?

Thanks for help :geek: