


Sample code below is based on ESP8266_NONOS_SDK.
Set SSID, password and other information about ESP8266 soft-AP.
Download blank.bin to flash for initialization.
Please notice that wifi_softap_get_config(&softap_config); // Get config first is recommended to be called first.
Or you have to set value for every parameter in softap_config, for example, softap_config.beacon_interval and softap_config.ssid_len, otherwise they will be random value which may make ESP8266 softAP hardly to be connected.
Code: Select all
/******************************************************************************
* FunctionName : user_set_softap_config
* Description : set SSID and password of ESP8266 softAP
* Parameters : none
* Returns : none
*******************************************************************************/
void ICACHE_FLASH_ATTR
user_set_softap_config(void)
{
struct softap_config config;
wifi_softap_get_config(&config); // Get config first.
os_memset(config.ssid, 0, 32);
os_memset(config.password, 0, 64);
os_memcpy(config.ssid, "ESP8266", 7);
os_memcpy(config.password, "12345678", 8);
config.authmode = AUTH_WPA_WPA2_PSK;
config.ssid_len = 0;// or its actual length
config.beacon_interval = 100;
config.max_connection = 4; // how many stations can connect to ESP8266 softAP at most.
wifi_softap_set_config(&config);// Set ESP8266 softap config .
}
/******************************************************************************
* FunctionName : user_init
* Description : entry of user application, init user function here
* Parameters : none
* Returns : none
*******************************************************************************/
void user_init(void)
{
os_printf("SDK version:%s\n", system_get_sdk_version());
wifi_set_opmode(SOFTAP_MODE);
// ESP8266 softAP set config.
user_set_softap_config();
}