我正在测试新的 NON_OS_DSK 2.2.0,它似乎在 WIFI 站连接方面有问题。以下代码在 2.1.0 中工作正常,但在 2.2.0 中 WIFI 继续连接。但从来没有。
struct sta
tion_config stconfig;
/*if (!wifi_station_get_config(&stconfig)){
os_printf("unable to get STA Config n");
}*/
os_memset(&stconfig, 0x0, sizeof(stconfig));
os_memset(stconfig.ssid, 0, sizeof(stconfig.ssid));
stconfig.threshold.authmode = AUTH_WPA_WPA2_PSK;
stconfig.threshold.rssi = 84;
os_printf("connecting to %s with %s rssi %d auth %d n", sysCfg.wifi_ssid, wifi_dec_pass, stconfig.threshold.rssi, stconfig.threshold.authmode);
os_memset(stconfig.password, 0, sizeof(stconfig.password));
os_sprintf(stconfig.ssid, "%s", (char *) sysCfg.wifi_ssid);
os_memcpy(stconfig.password, wifi_dec_pass,
os_strlen(wifi_dec_pass));
//wifi_set_opmode(STATION_MODE);
if (iWifiMode == STATION_MODE){
wifi_set_opmode((wifi_get_opmode()|STATIONAP_MODE) & iWifiMode);
}else {
wifi_set_opmode((wifi_get_opmode()|STATIONAP_MODE) & sysCfg.wifi_mode);
}
if ((sensCfg.szHostName != NULL) && (strlen(sensCfg.szHostName) > 0)){
wifi_station_set_hostname(sensCfg.szHostName);
}
if (!wifi_station_set_config(&stconfig)) {
WIFI_DEBUG("ESP8266 not set station config!rn");
}
if (!dhcp || strcmp(dhcp, "dhcp") != 0) {
wifi_get_ip_info(STATION_IF, &info);
ip = (char *) sysCfg.net_ip;
mask = (char *) sysCfg.net_mask;
gw = (char *) sysCfg.net_gw;
if (ip)
info.ip.addr = ipaddr_addr(ip);
if (mask)
info.netmask.addr = ipaddr_addr(mask);
if (gw)
info.gw.addr = ipaddr_addr(gw);
if (wifi_station_dhcpc_status() == 1) {
wifi_station_dhcpc_stop();
}
wifi_set_ip_info(STATION_IF, &info);
} else {
if (wifi_station_dhcpc_status() == 0) {
wifi_station_dhcpc_start();
}
}
wifi_station_disconnect();
wifi_station_connect();
wifi_station_set_重新_policy(TRUE);
wifi_station_set_auto_connect(TRUE);
这是输出。它连接的次数很少,下面的大部分时间都会发生
系统初始化...
12345678
sensingp@ssw0rd
管理
使用 12345678 RSSI 84 身份验证 4 连接到 IOTLab
模式:STA(60:01:94:26:5B:6A)
添加 if0
扫描
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
加 0
援助 35
cnt
堆 32680
WiFi连接...
state: 5 -> 2 (7c0)
rm 0
重新
state: 2 -> 0 (0)
扫描
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
加 0
援助 35
cnt
堆 32680
WiFi连接...
state: 5 -> 2 (7c0)
rm 0
重新
state: 2 -> 0 (0)
扫描
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
加 0
援助 35
cnt
state: 5 -> 2 (7c0)
rm 0
堆 32680
WiFi连接...
重新
state: 2 -> 0 (0)
扫描
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
加 0
援助 35
cnt
state: 5 -> 2 (7c0)
rm 0
重新
state: 2 -> 0 (0)
扫描
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
加 0
援助 35
cnt
堆 32680
WiFi连接...
state: 5 -> 2 (7c0)
rm 0
重新
state: 2 -> 0 (0)
扫描
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
加 0
援助 35
cnt
堆 32680
WiFi连接...
state: 5 -> 2 (7c0)
rm 0
重新
state: 2 -> 0 (0)
扫描
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
加 0
援助 35
cnt
堆 32680
WiFi连接...
state: 5 -> 2 (7c0)
rm 0
重新
state: 2 -> 0 (0)
扫描
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
加 0
援助 32
cnt
state: 5 -> 2 (7c0)
rm 0
堆 32680
WiFi连接...
重新
state: 2 -> 0 (0)
扫描
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
加 0
援助 32
cnt
有人知道为什么吗?
0