
Q: Why could not ESP8266 find my router and connect to it?
A:
There is a parameter "stationConf.bssid_set" maybe you missed.
"stationConf.bssid_set" needs to be 0 , if you are setting ssid, otherwise it will check bssid which is the mac address..
More details on Espressif BBS http://bbs.espressif.com/viewtopic.php?f=5&t=53
Please refer to the source code below.
问:为什么我设置了路由信息,ESP8266 却找不到路由,无法连上?
答:
可能是您漏掉了一个参数 "stationConf.bssid_set",
当您根据 ssid 查找路由时,请将 "stationConf.bssid_set"设置为 0,否则,它查找时会参考 bssid,也就是路由的 MAC 地址。。
详情参见 Espressif BBS http://bbs.espressif.com/viewtopic.php?f=5&t=53
请参考如下示例代码:
void wifi_config()
{
// Wifi configuration
char ssid[32] = SSID;
char password[64] = PASSWORD;
struct station_config stationConf;
//Set station mode
wifi_set_opmode( 0x1 );
stationConf.bssid_set = 0;
//Set ap settings
os_memcpy(&stationConf.ssid, ssid, 32);
os_memcpy(&stationConf.password, password, 64);
wifi_station_set_config(&stationConf);
}
//Init function
void user_init()
{
wifi_config();
}