2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <glib-object.h>
26 #include "wifi_mgr_tool.h"
27 #include "wifi_mgr_menu.h"
28 #include "wifi_mgr_public.h"
29 #include "wifi_mgr_extension.h"
31 wifi_manager_h g_wifi_h = NULL;
32 wifi_manager_device_state_e g_device_state = WIFI_MANAGER_DEVICE_STATE_DEACTIVATED;
33 static wifi_manager_h g_wifi2_h = NULL;
34 static int cs_tid = 0;
36 static char g_ifname[MENU_DATA_SIZE] = "wlan1";
38 extern struct menu_data menu_public[];
39 extern struct menu_data menu_extension[];
41 static struct menu_data menu_main[] = {
42 { "1", LOG_LIGHTBLUE "[Public]" LOG_END, menu_public, NULL, NULL},
43 { "2", LOG_LIGHTMAGENTA "[Extension]" LOG_END, menu_extension, NULL, NULL},
44 { NULL, NULL, NULL, NULL, NULL },
47 static void __test_device_state_cb(wifi_manager_device_state_e state, void *user_data)
49 wifi_manager_h wifi_h = NULL;
52 g_device_state = state;
54 wifi_h = GPOINTER_TO_INT(user_data) == 1 ? g_wifi_h : g_wifi2_h;
55 wifi_manager_get_network_interface_name(wifi_h, &if_name);
57 msg("[%d:%s] Device state changed callback [%s]",
58 GPOINTER_TO_INT(user_data), if_name,
59 test_wifi_mgr_device_state_to_string(g_device_state));
64 static void __test_scan_changed_cb(wifi_manager_scan_state_e state, void* user_data)
66 wifi_manager_h wifi_h = NULL;
69 wifi_h = GPOINTER_TO_INT(user_data) == 1 ? g_wifi_h : g_wifi2_h;
70 wifi_manager_get_network_interface_name(wifi_h, &if_name);
72 msg("[%d:%s] Scan changed callback [%s]",
73 GPOINTER_TO_INT(user_data), if_name,
74 test_wifi_mgr_scan_state_to_string(state));
79 static void __test_connection_state_cb(wifi_manager_connection_state_e state,
80 wifi_manager_ap_h ap, void* user_data)
82 int ret = WIFI_MANAGER_ERROR_NONE;
83 wifi_manager_h wifi_h = NULL;
87 wifi_h = GPOINTER_TO_INT(user_data) == 1 ? g_wifi_h : g_wifi2_h;
88 wifi_manager_get_network_interface_name(wifi_h, &if_name);
90 ret = wifi_manager_ap_get_essid(ap, &ap_name);
91 if (ret != WIFI_MANAGER_ERROR_NONE) {
92 msg(LOG_RED "Failed to get AP name [%s]" LOG_END,
93 test_wifi_mgr_convert_error_to_string(ret));
98 msg("[%d:%s] Connection state changed callback " LOG_CYAN "[%s]" LOG_END "[%s]",
99 GPOINTER_TO_INT(user_data), if_name, ap_name,
100 test_wifi_mgr_conn_state_to_string(state));
106 static void __test_rssi_level_cb(wifi_manager_rssi_level_e rssi_level, void* user_data)
108 wifi_manager_h wifi_h = NULL;
109 char *if_name = NULL;
111 wifi_h = GPOINTER_TO_INT(user_data) == 1 ? g_wifi_h : g_wifi2_h;
112 wifi_manager_get_network_interface_name(wifi_h, &if_name);
114 msg("[%d:%s] RSSI level changed callback [%d]",
115 GPOINTER_TO_INT(user_data), if_name, rssi_level);
120 static void __test_bg_scan_completed_cb(wifi_manager_error_e error_code, void* user_data)
122 wifi_manager_h wifi_h = NULL;
123 char *if_name = NULL;
125 wifi_h = GPOINTER_TO_INT(user_data) == 1 ? g_wifi_h : g_wifi2_h;
126 wifi_manager_get_network_interface_name(wifi_h, &if_name);
128 msg("[%d:%s] Background scan completed [%s]",
129 GPOINTER_TO_INT(user_data), if_name,
130 test_wifi_mgr_convert_error_to_string(error_code));
135 static void __test_ip_conflict_cb(char *mac, wifi_manager_ip_conflict_state_e state, void *user_data)
137 wifi_manager_h wifi_h = NULL;
138 char *if_name = NULL;
140 wifi_h = GPOINTER_TO_INT(user_data) == 1 ? g_wifi_h : g_wifi2_h;
141 wifi_manager_get_network_interface_name(wifi_h, &if_name);
143 msgn("[%d:%s] Ip conflict", GPOINTER_TO_INT(user_data), if_name);
145 if (state == WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_DETECTED)
146 msg(" detected [%s]", mac);
147 else if (state == WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED)
150 msg(" state unknown");
155 static void __test_get_wifi_module_state_cb(wifi_manager_module_state_e state, void *user_data)
157 wifi_manager_h wifi_h = NULL;
158 char *if_name = NULL;
160 wifi_h = GPOINTER_TO_INT(user_data) == 1 ? g_wifi_h : g_wifi2_h;
161 wifi_manager_get_network_interface_name(wifi_h, &if_name);
163 msgn("[%d%s] Wi-Fi module state changed callback [%s]",
164 GPOINTER_TO_INT(user_data), if_name,
165 test_wifi_mgr_module_state_to_string(state));
170 static void __test_tdls_state_cb(wifi_manager_tdls_state_e state, char *peer_mac_add, void *user_data)
172 wifi_manager_h wifi_h = NULL;
173 char *if_name = NULL;
175 wifi_h = GPOINTER_TO_INT(user_data) == 1 ? g_wifi_h : g_wifi2_h;
176 wifi_manager_get_network_interface_name(wifi_h, &if_name);
178 msgn("[%d:%s] TDLS state changed callback", GPOINTER_TO_INT(user_data), if_name);
180 if (state == WIFI_MANAGER_TDLS_STATE_CONNECTED)
181 msg("TDLS [Connected] Peer MAC address [%s]", peer_mac_add);
183 msg("TDLS [Disconnected] Peer MAC address [%s]", peer_mac_add);
188 static void __test_tdls_discover_cb(wifi_manager_tdls_discovery_state_e state,
189 char *peer_mac_add, void *user_data)
191 wifi_manager_h wifi_h = NULL;
192 char *if_name = NULL;
194 wifi_h = GPOINTER_TO_INT(user_data) == 1 ? g_wifi_h : g_wifi2_h;
195 wifi_manager_get_network_interface_name(wifi_h, &if_name);
197 msgn("[%d:%s] TDLS discover callback ", GPOINTER_TO_INT(user_data), if_name);
199 msgn("Peer MAC address [%s] state [%d] ", peer_mac_add, state);
200 if (state == WIFI_MANAGER_TDLS_DISCOVERY_STATE_ONGOING)
201 msg("Discovery is ongoing");
203 msg("Discovery is finished");
208 static void __test_dpp_event_cb(wifi_manager_dpp_event_e event,
209 wifi_manager_dpp_state_e state, wifi_manager_dpp_h handle, void *user_data)
211 wifi_manager_h wifi_h = NULL;
212 char *if_name = NULL;
214 wifi_h = GPOINTER_TO_INT(user_data) == 1 ? g_wifi_h : g_wifi2_h;
215 wifi_manager_get_network_interface_name(wifi_h, &if_name);
217 msgn("[%d:%s] DPP event callback ", GPOINTER_TO_INT(user_data), if_name);
219 msg("event [%s] ", test_wifi_mgr_dpp_event_to_string(event));
220 if (event == WIFI_MANAGER_DPP_EVENT_STATE_CHANGED)
221 msg("state [%s]", test_wifi_mgr_dpp_state_to_string(state));
226 static int __test_init_cbs(wifi_manager_h g_wifi_h, int ret, int num)
228 char *if_name = NULL;
230 if (ret == WIFI_MANAGER_ERROR_NONE) {
231 wifi_manager_set_device_state_changed_cb(g_wifi_h, __test_device_state_cb, GINT_TO_POINTER(num));
232 wifi_manager_set_scan_state_changed_cb(g_wifi_h, __test_scan_changed_cb, GINT_TO_POINTER(num));
233 wifi_manager_set_connection_state_changed_cb(g_wifi_h, __test_connection_state_cb, GINT_TO_POINTER(num));
234 wifi_manager_set_rssi_level_changed_cb(g_wifi_h, __test_rssi_level_cb, GINT_TO_POINTER(num));
235 wifi_manager_set_background_scan_cb(g_wifi_h, __test_bg_scan_completed_cb, GINT_TO_POINTER(num));
236 wifi_manager_set_ip_conflict_cb(g_wifi_h, __test_ip_conflict_cb, GINT_TO_POINTER(num));
237 wifi_manager_set_module_state_changed_cb(g_wifi_h, __test_get_wifi_module_state_cb, GINT_TO_POINTER(num));
239 wifi_manager_tdls_set_state_changed_cb(g_wifi_h, __test_tdls_state_cb, GINT_TO_POINTER(num));
240 wifi_manager_tdls_set_discovered_cb(g_wifi_h, __test_tdls_discover_cb, GINT_TO_POINTER(num));
242 wifi_manager_dpp_set_event_cb(g_wifi_h, __test_dpp_event_cb, GINT_TO_POINTER(num));
244 wifi_manager_get_network_interface_name(g_wifi_h, &if_name);
245 msg(LOG_GREEN "[%d:%s] Success to initialize wifi handle [%p]" LOG_END, num, if_name, g_wifi_h);
250 msg("[%d] Failed to initialize wifi handle " LOG_RED "[%s]" LOG_END,
251 num, test_wifi_mgr_convert_error_to_string(ret));
257 static int __test_init_dev_state_out(void)
259 char *if_name = NULL;
260 int ret = WIFI_MANAGER_ERROR_NONE;
263 ret = wifi_manager_is_activated(g_wifi_h, &state);
264 wifi_manager_get_network_interface_name(g_wifi_h, &if_name);
265 if (ret == WIFI_MANAGER_ERROR_NONE) {
266 g_device_state = state;
267 msg("[1:%s] Wi-Fi device state " LOG_CYAN "[%s]" LOG_END, if_name,
268 test_wifi_mgr_device_state_to_string(g_device_state));
270 msg("[1] Failed to get Wi-Fi device state " LOG_RED "[%s]" LOG_END,
271 test_wifi_mgr_convert_error_to_string(ret));
279 static void __test_deinit_all(void)
282 wifi_manager_deinitialize(g_wifi_h);
287 wifi_manager_deinitialize(g_wifi2_h);
292 static int _test_wifi_mgr_initialize(MManager *mm, struct menu_data *menu)
294 int ret = WIFI_MANAGER_ERROR_NONE;
298 ret = wifi_manager_initialize(&g_wifi_h);
299 if (!__test_init_cbs(g_wifi_h, ret, 1))
302 ret = wifi_manager_initialize(&g_wifi2_h);
303 if (!__test_init_cbs(g_wifi2_h, ret, 2))
306 ret = __test_init_dev_state_out();
311 static int _test_wifi_mgr_initialize_cs(MManager *mm, struct menu_data *menu)
313 int ret = WIFI_MANAGER_ERROR_NONE;
319 ret = wifi_manager_initialize_cs(cs_tid, &g_wifi_h);
320 __test_init_cbs(g_wifi_h, ret, 1);
322 ret = wifi_manager_initialize_cs(cs_tid, &g_wifi2_h);
323 __test_init_cbs(g_wifi2_h, ret, 2);
325 if (ret == WIFI_MANAGER_ERROR_NONE)
326 ret = __test_init_dev_state_out();
331 static int _test_wifi_mgr_initialize_with_ifname(MManager *mm, struct menu_data *menu)
333 int ret = WIFI_MANAGER_ERROR_NONE;
337 ret = wifi_manager_initialize_with_interface_name(&g_wifi_h, g_ifname);
338 if (!__test_init_cbs(g_wifi_h, ret, 1))
341 ret = wifi_manager_initialize_with_interface_name(&g_wifi2_h, g_ifname);
342 if (!__test_init_cbs(g_wifi2_h, ret, 2))
345 ret = __test_init_dev_state_out();
350 static int _test_wifi_mgr_deinitialize(void)
352 int ret = WIFI_MANAGER_ERROR_NONE;
353 char *if_name = NULL;
357 ret = wifi_manager_deinitialize_cs(cs_tid, g_wifi_h);
359 ret = wifi_manager_deinitialize(g_wifi_h);
361 if (ret == WIFI_MANAGER_ERROR_NONE) {
362 wifi_manager_get_network_interface_name(g_wifi_h, &if_name);
363 msg(LOG_GREEN "[1:%s] Succeeded to deinitialize wifi handle" LOG_END, if_name);
366 msg("[1] Failed to deinitialize wifi handle " LOG_RED "[%s]" LOG_END,
367 test_wifi_mgr_convert_error_to_string(ret));
372 ret = wifi_manager_deinitialize_cs(cs_tid, g_wifi2_h);
374 ret = wifi_manager_deinitialize(g_wifi2_h);
376 if (ret == WIFI_MANAGER_ERROR_NONE) {
377 wifi_manager_get_network_interface_name(g_wifi2_h, &if_name);
378 msg(LOG_GREEN "[2:%s] Succeeded to deinitialize wifi handle" LOG_END, if_name);
381 msg("[2] Failed to deinitialize wifi handle " LOG_RED "[%s]" LOG_END,
382 test_wifi_mgr_convert_error_to_string(ret));
390 static gboolean _test_wifi_mgr_create_init_menu(struct menu_data init_menu[5])
392 init_menu[0].key = "0";
393 init_menu[0].title = LOG_LIGHTGREEN "[Interface Name]" LOG_END;
394 init_menu[0].sub_menu = NULL;
395 init_menu[0].callback = NULL;
396 init_menu[0].data = g_ifname;
398 init_menu[1].key = "1";
399 init_menu[1].title = LOG_YELLOW "Wifi Mgr Init" LOG_END;
400 init_menu[1].sub_menu = menu_main;
401 init_menu[1].callback = _test_wifi_mgr_initialize;
402 init_menu[1].data = NULL;
404 init_menu[2].key = "2";
405 init_menu[2].title = LOG_YELLOW "Wifi Mgr Init for C#" LOG_END;
406 init_menu[2].sub_menu = menu_main;
407 init_menu[2].callback = _test_wifi_mgr_initialize_cs;
408 init_menu[2].data = NULL;
410 init_menu[3].key = "3";
411 init_menu[3].title = LOG_YELLOW "Wifi Mgr Init with ifname" LOG_END;
412 init_menu[3].sub_menu = menu_main;
413 init_menu[3].callback = _test_wifi_mgr_initialize_with_ifname;
414 init_menu[3].data = NULL;
419 bool test_wifi_mgr_compare_string(const char *str, const char *part)
421 int str_len = strlen(str);
422 int part_len = strlen(part);
424 if (strncmp(str, part, MAX(str_len, part_len)) == 0)
430 const char *test_wifi_mgr_autoscan_mode_to_string(wifi_manager_autoscan_mode_e state)
433 case WIFI_MANAGER_AUTOSCAN_MODE_EXPONENTIAL:
434 return "Exponential";
435 case WIFI_MANAGER_AUTOSCAN_MODE_PERIODIC:
442 const char *test_wifi_mgr_ipconflict_state_to_string(wifi_manager_ip_conflict_state_e state)
445 case WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED:
447 case WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_DETECTED:
456 const char *test_wifi_mgr_device_state_to_string(wifi_manager_device_state_e state)
459 case WIFI_MANAGER_DEVICE_STATE_DEACTIVATED:
460 return "Deactivated";
461 case WIFI_MANAGER_DEVICE_STATE_ACTIVATED:
468 const char *test_wifi_mgr_module_state_to_string(wifi_manager_module_state_e state)
471 case WIFI_MANAGER_MODULE_STATE_DETACHED:
473 case WIFI_MANAGER_MODULE_STATE_ATTACHED:
480 const char *test_wifi_mgr_scan_state_to_string(wifi_manager_scan_state_e state)
483 case WIFI_MANAGER_SCAN_STATE_NOT_SCANNING:
484 return "Not scanning";
485 case WIFI_MANAGER_SCAN_STATE_SCANNING:
492 const char *test_wifi_mgr_eap_auth_type_to_string(wifi_manager_eap_auth_type_e type)
495 case WIFI_MANAGER_EAP_AUTH_TYPE_NONE:
497 case WIFI_MANAGER_EAP_AUTH_TYPE_PAP:
499 case WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAP:
501 case WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAPV2:
503 case WIFI_MANAGER_EAP_AUTH_TYPE_GTC:
505 case WIFI_MANAGER_EAP_AUTH_TYPE_MD5:
512 const char *test_wifi_mgr_eap_type_to_string(wifi_manager_eap_type_e type)
515 case WIFI_MANAGER_EAP_TYPE_PEAP:
517 case WIFI_MANAGER_EAP_TYPE_TLS:
519 case WIFI_MANAGER_EAP_TYPE_TTLS:
521 case WIFI_MANAGER_EAP_TYPE_SIM:
523 case WIFI_MANAGER_EAP_TYPE_AKA:
525 case WIFI_MANAGER_EAP_TYPE_AKA_PRIME:
527 case WIFI_MANAGER_EAP_TYPE_FAST:
529 case WIFI_MANAGER_EAP_TYPE_PWD:
536 const char *test_wifi_mgr_encryption_type_to_string(wifi_manager_encryption_type_e type)
539 case WIFI_MANAGER_ENCRYPTION_TYPE_NONE:
541 case WIFI_MANAGER_ENCRYPTION_TYPE_WEP:
543 case WIFI_MANAGER_ENCRYPTION_TYPE_TKIP:
545 case WIFI_MANAGER_ENCRYPTION_TYPE_AES:
547 case WIFI_MANAGER_ENCRYPTION_TYPE_TKIP_AES_MIXED:
548 return "TKIP AES MIXED";
554 const char *test_wifi_mgr_dns_config_type_to_string(wifi_manager_dns_config_type_e type)
557 case WIFI_MANAGER_DNS_CONFIG_TYPE_NONE:
559 case WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC:
561 case WIFI_MANAGER_DNS_CONFIG_TYPE_DYNAMIC:
568 const char *test_wifi_mgr_proxy_type_to_string(wifi_manager_proxy_type_e type)
571 case WIFI_MANAGER_PROXY_TYPE_DIRECT:
573 case WIFI_MANAGER_PROXY_TYPE_AUTO:
575 case WIFI_MANAGER_PROXY_TYPE_MANUAL:
582 const char *test_wifi_mgr_ip_config_type_to_string(wifi_manager_ip_config_type_e type)
585 case WIFI_MANAGER_IP_CONFIG_TYPE_NONE:
587 case WIFI_MANAGER_IP_CONFIG_TYPE_STATIC:
589 case WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC:
591 case WIFI_MANAGER_IP_CONFIG_TYPE_AUTO:
593 case WIFI_MANAGER_IP_CONFIG_TYPE_FIXED:
600 const char *test_wifi_mgr_sec_type_to_string(wifi_manager_security_type_e type)
603 case WIFI_MANAGER_SECURITY_TYPE_NONE:
605 case WIFI_MANAGER_SECURITY_TYPE_WEP:
607 case WIFI_MANAGER_SECURITY_TYPE_WPA_PSK:
609 case WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK:
611 case WIFI_MANAGER_SECURITY_TYPE_EAP:
613 case WIFI_MANAGER_SECURITY_TYPE_WPA_FT_PSK:
615 case WIFI_MANAGER_SECURITY_TYPE_SAE:
617 case WIFI_MANAGER_SECURITY_TYPE_OWE:
619 case WIFI_MANAGER_SECURITY_TYPE_DPP:
626 const char *test_wifi_mgr_conn_state_to_string(wifi_manager_connection_state_e state)
629 case WIFI_MANAGER_CONNECTION_STATE_FAILURE:
631 case WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED:
632 return "Disconnected";
633 case WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION:
634 return "Association";
635 case WIFI_MANAGER_CONNECTION_STATE_CONNECTED:
637 case WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION:
638 return "Configuration";
644 const char *test_wifi_mgr_convert_error_to_string(wifi_manager_error_e err_type)
647 case WIFI_MANAGER_ERROR_NONE:
649 case WIFI_MANAGER_ERROR_INVALID_PARAMETER:
650 return "INVALID_PARAMETER";
651 case WIFI_MANAGER_ERROR_OUT_OF_MEMORY:
652 return "OUT_OF_MEMORY";
653 case WIFI_MANAGER_ERROR_INVALID_OPERATION:
654 return "INVALID_OPERATION";
655 case WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
656 return "ADDRESS_FAMILY_NOT_SUPPORTED";
657 case WIFI_MANAGER_ERROR_OPERATION_FAILED:
658 return "OPERATION_FAILED";
659 case WIFI_MANAGER_ERROR_NO_CONNECTION:
660 return "NO_CONNECTION";
661 case WIFI_MANAGER_ERROR_NOW_IN_PROGRESS:
662 return "NOW_IN_PROGRESS";
663 case WIFI_MANAGER_ERROR_ALREADY_EXISTS:
664 return "ALREADY_EXISTS";
665 case WIFI_MANAGER_ERROR_OPERATION_ABORTED:
666 return "OPERATION_ABORTED";
667 case WIFI_MANAGER_ERROR_DHCP_FAILED:
668 return "DHCP_FAILED";
669 case WIFI_MANAGER_ERROR_INVALID_KEY:
670 return "INVALID_KEY";
671 case WIFI_MANAGER_ERROR_NO_REPLY:
673 case WIFI_MANAGER_ERROR_SECURITY_RESTRICTED:
674 return "SECURITY_RESTRICTED";
675 case WIFI_MANAGER_ERROR_ALREADY_INITIALIZED:
676 return "ALREADY_INITIALIZED";
677 case WIFI_MANAGER_ERROR_OUT_OF_RANGE:
678 return "OUT_OF_RANGE";
679 case WIFI_MANAGER_ERROR_CONNECT_FAILED:
680 return "CONNECT_FAILED";
681 case WIFI_MANAGER_ERROR_LOGIN_FAILED:
682 return "LOGIN_FAILED";
683 case WIFI_MANAGER_ERROR_AUTHENTICATION_FAILED:
684 return "AUTH_FAILED";
685 case WIFI_MANAGER_ERROR_ASSOCIATION_FAILED:
686 return "ASSOC_FAILED";
687 case WIFI_MANAGER_ERROR_PIN_MISSING:
688 return "PIN_MISSING";
689 case WIFI_MANAGER_ERROR_WPS_OVERLAP:
690 return "WPS_OVERLAP";
691 case WIFI_MANAGER_ERROR_WPS_TIMEOUT:
692 return "WPS_TIMEOUT";
693 case WIFI_MANAGER_ERROR_WPS_WEP_PROHIBITED:
694 return "WPS_WEP_PROHIBITED";
695 case WIFI_MANAGER_ERROR_PERMISSION_DENIED:
696 return "PERMISSION_DENIED";
697 case WIFI_MANAGER_ERROR_OFFLINE:
699 case WIFI_MANAGER_ERROR_INVALID_GATEWAY:
700 return "INVALID_GATEWAY";
701 case WIFI_MANAGER_ERROR_NOT_SUPPORTED:
702 return "NOT_SUPPORTED";
703 case WIFI_MANAGER_ERROR_NOT_INITIALIZED:
704 return "NOT_INITIALIZED";
710 const char *test_wifi_mgr_dpp_state_to_string(wifi_manager_dpp_state_e state)
713 case WIFI_MANAGER_DPP_STATE_NONE:
715 case WIFI_MANAGER_DPP_STATE_URI_REQUESTED:
716 return "URI_REQUESTED";
717 case WIFI_MANAGER_DPP_STATE_AWAITING:
719 case WIFI_MANAGER_DPP_STATE_BOOTSTRAPPED:
720 return "BOOTSTRAPPED";
721 case WIFI_MANAGER_DPP_STATE_AUTHENTICATING:
722 return "AUTHENTICATING";
723 case WIFI_MANAGER_DPP_STATE_AUTHENTICATED:
724 return "AUTHENTICATED";
725 case WIFI_MANAGER_DPP_STATE_CONFIGURING:
726 return "CONFIGURING";
727 case WIFI_MANAGER_DPP_STATE_CONFIGURED:
734 const char *test_wifi_mgr_dpp_event_to_string(wifi_manager_dpp_event_e event)
737 case WIFI_MANAGER_DPP_EVENT_REQUEST_FAILED:
738 return "REQUEST_FAILED";
739 case WIFI_MANAGER_DPP_EVENT_URI_GENERATED:
740 return "URI_GENERATED";
741 case WIFI_MANAGER_DPP_EVENT_SCAN_PEER_QR:
742 return "SCAN_PEER_QR";
743 case WIFI_MANAGER_DPP_EVENT_BUSY:
745 case WIFI_MANAGER_DPP_EVENT_AUTH_FAILED:
746 return "AUTH_FAILED";
747 case WIFI_MANAGER_DPP_EVENT_NOT_COMPATIBLE:
748 return "NOT_COMPATIBLE";
749 case WIFI_MANAGER_DPP_EVENT_CONF_FAILED:
750 return "CONF FAILED";
751 case WIFI_MANAGER_DPP_EVENT_TIMEOUT:
753 case WIFI_MANAGER_DPP_EVENT_STATE_CHANGED:
754 return "STATE_CHANGED";
760 const char *test_wifi_mgr_dpp_device_role_to_string(wifi_manager_dpp_role_e role)
763 case WIFI_MANAGER_DPP_ROLE_CONFIGURATOR:
764 return "CONFIGURATOR";
765 case WIFI_MANAGER_DPP_ROLE_ENROLLEE:
772 const char *test_wifi_mgr_dpp_network_role_to_string(wifi_manager_dpp_network_role_e role)
775 case WIFI_MANAGER_DPP_NETWORK_ROLE_AP:
777 case WIFI_MANAGER_DPP_NETWORK_ROLE_STA:
784 const char *test_wifi_mgr_dpp_akm_to_string(wifi_manager_dpp_akm_e akm)
787 case WIFI_MANAGER_DPP_AKM_PSK:
789 case WIFI_MANAGER_DPP_AKM_SAE:
791 case WIFI_MANAGER_DPP_AKM_DPP:
798 int main(int arg, char **argv)
800 GMainLoop *mainloop = NULL;
801 GIOChannel *channel = g_io_channel_unix_new(STDIN_FILENO);
803 struct menu_data init_menu[5] = { {NULL, NULL, NULL, NULL, NULL} };
805 #if !GLIB_CHECK_VERSION(2, 35, 0)
808 mainloop = g_main_loop_new(NULL, FALSE);
811 msg(LOG_GREEN "* Wifi Manager Tool " LOG_END);
812 msg("* Build On: %s %s", __DATE__, __TIME__);
814 if (_test_wifi_mgr_create_init_menu(init_menu) == FALSE)
817 manager = menu_manager_new(init_menu, mainloop);
821 menu_manager_run(manager);
823 g_io_add_watch(channel, (G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL),
824 on_menu_manager_keyboard, manager);
825 g_main_loop_run(mainloop);
828 _test_wifi_mgr_deinitialize();
829 g_main_loop_unref(mainloop);
830 msg("******* Bye bye *******");