Code:
void scan_done(void *arg, STATUS status)
{
uint8 ssid[33];
char temp[128];
if (status == OK)
{
struct bss_info *bss_link = (struct bss_info *)arg;
bss_link = bss_link->next.stqe_next;//ignore the first one , it's invalid.
while (bss_link != NULL)
{
memset(ssid, 0, 33);
if (strlen(bss_link->ssid) <= 32)
{
memcpy(ssid, bss_link->ssid, strlen(bss_link->ssid));
}
else
{
memcpy(ssid, bss_link->ssid, 32);
}
printf("(%d,\"%s\",%d,\""MACSTR"\",%d)\r\n",
bss_link->authmode, ssid, bss_link->rssi,
MAC2STR(bss_link->bssid),bss_link->channel);
bss_link = bss_link->next.stqe_next;
}
}
else
{
printf("scan fail !!!\r\n");
}
}
void user_scan(void)
{
// wifi scan has to after system init done
if(wifi_get_opmode() == SOFTAP_MODE)
{
printf("ap mode can't scan !!!\r\n");
return;
}
wifi_station_scan(NULL,scan_done);
}
void scan_task(void *pvParameters)
{
printf("Hello, welcome to scan-task!\r\n");
user_scan();
while (1) {
…
}
}
void user_init(void)
{
//Set softAP + station mode
wifi_set_opmode(STATIONAP_MODE);
xTaskCreate(scan_task, "scantsk", 256, NULL, 2, NULL);
}
Statistics: Posted by ESP_Faye — Thu Aug 20, 2015 1:52 pm
Statistics: Posted by Lucifer3502 — Thu Aug 20, 2015 9:27 am