@Links2004 here is my function enum status { WL_DISCONNECTED = 0, WL_CONNECTED = 1, WL_NO_SSID_AVAIL = 2, WL_CONNECT_FAILED = 3 , WL_IDLE_STATUS =5 };
//void to_scan(void) { wifi_station_scan(&config,scan_done); }
uint8 status()
{
int status = wifi_station_get_connect_status();
if (status == STATION_GOT_IP)
return WL_CONNECTED;
else if (status == STATION_NO_AP_FOUND)
return WL_NO_SSID_AVAIL;
else if (status == STATION_CONNECT_FAIL || status == STATION_WRONG_PASSWORD)
return WL_CONNECT_FAILED;
else if (status == STATION_IDLE)
return WL_IDLE_STATUS;
else
return WL_DISCONNECTED;
} int x=status();
os_sprintf(info1,"state : %d \r\n", x);
putrsUART(info1);
while (status() != WL_CONNECTED) {
for(int i=0;i<10;i++)
os_delay_us(5000);
putrsUART(".");
}
putrsUART("wifi connected");
char kat[40];
wifi_get_ip_info(STATION_IF, &ipconfig);
os_sprintf(kat,"IPaddress: %u %u %u %u",IP2STR(&ipconfig.ip));
putrsUART(kat);
@Links2004 yes .But to the surprise the same code using extern "C" works in arduino ide extern "C" {
}
struct ip_info ipconfig,ip;
enum status { WL_DISCONNECTED = 0, WL_CONNECTED = 1, WL_NO_SSID_AVAIL = 2, WL_CONNECT_FAILED = 3 , WL_IDLE_STATUS =5 };
uint8 status()
{
int status = wifi_station_get_connect_status();
if (status == STATION_GOT_IP)
return WL_CONNECTED;
else if (status == STATION_NO_AP_FOUND)
return WL_NO_SSID_AVAIL;
else if (status == STATION_CONNECT_FAIL || status == STATION_WRONG_PASSWORD)
return WL_CONNECT_FAILED;
else if (status == STATION_IDLE)
return WL_IDLE_STATUS;
else
return WL_DISCONNECTED;
}
void ICACHE_FLASH_ATTR
user_init(void)
{
Serial.begin(115200);
Serial.print("wifi connecting\r\n");
os_printf("wifi connecting\r\n");
char ssid[32] = "Benjamin";
char password[64] ="4522641400abc";
struct station_config stationConf;
stationConf.bssid_set = 0; //need not check MAC address of AP
os_memcpy(&stationConf.ssid, ssid, 32);
os_memcpy(&stationConf.password, password, 64);
ETS_UART_INTR_DISABLE();
wifi_station_set_config(&stationConf);
wifi_station_connect();
ETS_UART_INTR_ENABLE();
wifi_station_dhcpc_start();
while (status() != WL_CONNECTED) {
//for(int i=0;i<10;i++)
delay(500);
Serial.printf(".");
}
os_printf("wifi connected\r\n");
Serial.print("wifi connected\r\n");
char kat[40];
wifi_get_ip_info(STATION_IF, &ipconfig);
sprintf(kat,"IPaddress: %u %u %u %u",IP2STR(ipconfig.ip.addr);
Serial.print(kat);
}
//Do nothing function
void setup() {
// put your setup code here, to run once:
user_init();
}
void loop() {
// put your main code here, to run repeatedly:
// user_init();
}
$ cmp -l map.png ~/Downloads/map.png
231425 145 144
372737 265 264
745473 135 134