Added wifi get state command
This commit is contained in:
parent
0f27eaa1be
commit
2f13c51ac4
@ -17,7 +17,7 @@ void tls_wifi_client_event_cb(u8 *mac, enum tls_wifi_client_event_type event)
|
|||||||
|
|
||||||
void wifi_scan_result_cb(void)
|
void wifi_scan_result_cb(void)
|
||||||
{
|
{
|
||||||
u16 buffer_size = sizeof(struct tls_scan_bss_t) + sizeof(struct tls_bss_info_t) * 10;
|
u16 buffer_size = sizeof(struct tls_scan_bss_t) + sizeof(struct tls_bss_info_t) * 20;
|
||||||
u8 *buf = tls_mem_alloc(buffer_size);
|
u8 *buf = tls_mem_alloc(buffer_size);
|
||||||
if(buf == NULL)
|
if(buf == NULL)
|
||||||
{
|
{
|
||||||
@ -36,7 +36,16 @@ void wifi_scan_result_cb(void)
|
|||||||
for(u8 i = 0; i < scan_result->count; i++)
|
for(u8 i = 0; i < scan_result->count; i++)
|
||||||
{
|
{
|
||||||
station_list[i].ssid[station_list[i].ssid_len] = '\0';
|
station_list[i].ssid[station_list[i].ssid_len] = '\0';
|
||||||
shell_printf("station %u :\nSSID : %s\n", i, (char *)station_list[i].ssid);
|
shell_printf("station %u :\nSSID : %s\nBSSID : %02X:%02X:%02X:%02X:%02X:%02X\nRSSI : %d dB\nChannel : %u\nMax DR : %u Mbps\nMode %u\nAuth :%u\nWPS supported : %u\n\n",
|
||||||
|
i,
|
||||||
|
(char *)station_list[i].ssid,
|
||||||
|
station_list[i].bssid[0], station_list[i].bssid[1], station_list[i].bssid[2], station_list[i].bssid[3], station_list[i].bssid[4], station_list[i].bssid[5],
|
||||||
|
(s8)station_list[i].rssi,
|
||||||
|
station_list[i].channel,
|
||||||
|
station_list[i].max_data_rate,
|
||||||
|
station_list[i].mode,
|
||||||
|
station_list[i].privacy,
|
||||||
|
station_list[i].wps_support);
|
||||||
}
|
}
|
||||||
|
|
||||||
tls_mem_free(buf);
|
tls_mem_free(buf);
|
||||||
@ -139,6 +148,27 @@ int _station(const shell_cmd_t *pcmd, int argc, char *const argv[])
|
|||||||
shell_printf("Failed to start wifi scan\n");
|
shell_printf("Failed to start wifi scan\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(strcmp(argv[1], "state") == 0)
|
||||||
|
{
|
||||||
|
shell_printf("Station state : %u\n", tls_wifi_get_state());
|
||||||
|
}
|
||||||
|
else if(strcmp(argv[1], "connect") == 0)
|
||||||
|
{
|
||||||
|
shell_printf("Connecting to %s with pwd : %s\n", argv[2], argv[3]);
|
||||||
|
if(tls_wifi_connect((u8 *)argv[2], strlen(argv[2]), (u8 *)argv[3], strlen(argv[3])) == WM_SUCCESS)
|
||||||
|
{
|
||||||
|
shell_printf("Connected\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shell_printf("Failed to connect !\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(strcmp(argv[1], "disconnect") == 0)
|
||||||
|
{
|
||||||
|
shell_printf("Disconnecting from current station\n");
|
||||||
|
tls_wifi_disconnect();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
shell_printf("Unknown station action\n");
|
shell_printf("Unknown station action\n");
|
||||||
@ -146,7 +176,7 @@ int _station(const shell_cmd_t *pcmd, int argc, char *const argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
shell_printf("List of station actions :\nscan\n");
|
shell_printf("List of station actions :\nscan\nstate\nconnect <SSID> <PWD>\ndisconnect\n");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user