Statistics: Posted by wenhui_1 — Mon Jun 27, 2016 5:02 pm
Code:
void wifiEventHandler(System_Event_t * event)
{
switch (event->event_id)
{
case EVENT_STAMODE_CONNECTED:
{
printf("WIFI Connected\n");
break;
}
case EVENT_STAMODE_GOT_IP:
{
struct ip_info hostInfo;
wifi_get_ip_info(STATION_IF, &hostInfo);
// IP Success
os_printf("Ip Addr: " IPSTR "\n", IP2STR(&hostInfo.ip));
os_printf("Netmask: " IPSTR "\n", IP2STR(&hostInfo.netmask));
os_printf("Gateway: " IPSTR "\n", IP2STR(&hostInfo.gw));
break;
}
case EVENT_STAMODE_DISCONNECTED:
{
printf("WIFI Disconnected\n");
break;
}
case EVENT_STAMODE_SCAN_DONE:
{
printf("WIFI Scan Done\n");
// TODO: Send Notification to Scanning Task
break;
}
case EVENT_STAMODE_DHCP_TIMEOUT:
{
printf("WIFI Error Retrieving IP\n");
// TODO: Send Notification to error handling task
break;
}
case EVENT_SOFTAPMODE_STACONNECTED:
{
// Send Station Discovery Packet
printf("AP Device Connected\n");
// TODO: Send notification to connected station task with station's IP
break;
}
}
}
void startWifiClient(void)
{
wifi_set_opmode(STATION_MODE);
struct station_config stationConfig =
{
.ssid = "SSID",
.password = "password"
};
wifi_station_set_config(&stationConfig);
}
/**
* Main Startup
*/
void ICACHE_FLASH_ATTR user_init(void)
{
// Serial Configuration
UART_SetBaudrate(0, BIT_RATE_115200);
// WIFI Configuration
wifi_set_event_handler_cb(wifiEventHandler);
// Start Client
startWifiClient();
}
Statistics: Posted by ESP_Faye — Mon Jan 11, 2016 4:30 pm
Statistics: Posted by Nicholas3388 — Sun Jan 10, 2016 10:53 am
Statistics: Posted by ESP_Faye — Fri Jan 08, 2016 11:53 am
Statistics: Posted by Nicholas3388 — Wed Jan 06, 2016 10:58 pm
Statistics: Posted by Nicholas3388 — Wed Jan 06, 2016 10:41 pm
Statistics: Posted by ESP_Faye — Mon Jan 04, 2016 10:27 am