From 2f13c51ac44a1753f1fe59c71fac13c616e42d7a Mon Sep 17 00:00:00 2001 From: anschrammh Date: Mon, 13 Jun 2022 08:08:21 +0200 Subject: [PATCH] Added wifi get state command --- app/nano_shell_command.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/app/nano_shell_command.c b/app/nano_shell_command.c index 39afca2..937d902 100644 --- a/app/nano_shell_command.c +++ b/app/nano_shell_command.c @@ -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) { - 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); if(buf == NULL) { @@ -36,7 +36,16 @@ void wifi_scan_result_cb(void) for(u8 i = 0; i < scan_result->count; i++) { 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); @@ -139,6 +148,27 @@ int _station(const shell_cmd_t *pcmd, int argc, char *const argv[]) 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 { shell_printf("Unknown station action\n"); @@ -146,7 +176,7 @@ int _station(const shell_cmd_t *pcmd, int argc, char *const argv[]) } else { - shell_printf("List of station actions :\nscan\n"); + shell_printf("List of station actions :\nscan\nstate\nconnect \ndisconnect\n"); } return 0; }