Code:
struct station_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!\r\n");
}
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_reconnect_policy(TRUE);
wifi_station_set_auto_connect(TRUE);
Code:
System init...
12345678
senSingP@ssw0rd
admin
connecting to IOTLab with 12345678 rssi 84 auth 4
mode : sta(60:01:94:26:5b:6a)
add if0
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 35
cnt
heap 32680
WiFi connecting...
state: 5 -> 2 (7c0)
rm 0
reconnect
state: 2 -> 0 (0)
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 35
cnt
heap 32680
WiFi connecting...
state: 5 -> 2 (7c0)
rm 0
reconnect
state: 2 -> 0 (0)
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 35
cnt
state: 5 -> 2 (7c0)
rm 0
heap 32680
WiFi connecting...
reconnect
state: 2 -> 0 (0)
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 35
cnt
state: 5 -> 2 (7c0)
rm 0
reconnect
state: 2 -> 0 (0)
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 35
cnt
heap 32680
WiFi connecting...
state: 5 -> 2 (7c0)
rm 0
reconnect
state: 2 -> 0 (0)
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 35
cnt
heap 32680
WiFi connecting...
state: 5 -> 2 (7c0)
rm 0
reconnect
state: 2 -> 0 (0)
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 35
cnt
heap 32680
WiFi connecting...
state: 5 -> 2 (7c0)
rm 0
reconnect
state: 2 -> 0 (0)
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 32
cnt
state: 5 -> 2 (7c0)
rm 0
heap 32680
WiFi connecting...
reconnect
state: 2 -> 0 (0)
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 32
cnt
Statistics: Posted by chinnaobi — Thu Mar 29, 2018 12:14 pm