summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhyunuk.tak <hyunuk.tak@samsung.com>2019-11-15 11:04:20 +0900
committerhyunuk.tak <hyunuk.tak@samsung.com>2020-02-20 14:05:25 +0900
commit48bf8b40595f24633df326a3d23db251ec8eb8ff (patch)
tree99968953a96e964c9bed97c18a770205bca935c1
parent0165bd6550c2284c3b5796483a3fedea3628b5df (diff)
downloadwifi-tizen_7.0.tar.gz
wifi-tizen_7.0.tar.bz2
wifi-tizen_7.0.zip
Change-Id: I6ca941ba44e00b99de635a15245c32df38a84b2d Signed-off-by: hyunuk.tak <hyunuk.tak@samsung.com>
-rwxr-xr-xCMakeLists.txt4
-rwxr-xr-xinclude/net_wifi_private.h5
-rwxr-xr-xpackaging/capi-network-wifi.spec3
-rwxr-xr-xsrc/net_wifi.c297
-rwxr-xr-xsrc/net_wifi_ap.c242
-rwxr-xr-xsrc/net_wifi_config.c104
-rwxr-xr-xsrc/net_wifi_private.c94
-rwxr-xr-xtest/CMakeLists.txt25
-rwxr-xr-xtest/wifi_test.c1904
9 files changed, 2505 insertions, 173 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 922f1a6..f5c9087 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,7 +11,7 @@ SET(LIBDIR ${PREFIX}/${LIB_PATH})
SET(INC_DIR include)
INCLUDE_DIRECTORIES(${INC_DIR})
-SET(dependents "dlog ")
+SET(dependents "dlog capi-network-wifi-manager")
SET(pc_dependents "capi-base-common")
IF(TIZEN_DUALSIM_ENABLE)
@@ -68,6 +68,8 @@ CONFIGURE_FILE(
)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB}/pkgconfig)
+ADD_SUBDIRECTORY(test)
+
IF(UNIX)
ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
diff --git a/include/net_wifi_private.h b/include/net_wifi_private.h
index ad65002..560995e 100755
--- a/include/net_wifi_private.h
+++ b/include/net_wifi_private.h
@@ -22,6 +22,7 @@
#include <string.h>
#include <stdlib.h>
+#include <wifi-manager.h>
#include "wifi.h"
#ifdef __cplusplus
@@ -69,6 +70,10 @@ extern "C" {
} \
} while (0)
+wifi_error_e convert_to_wifi_error(wifi_manager_error_e error);
+wifi_security_type_e convert_to_wifi_security_type(wifi_manager_security_type_e type);
+wifi_eap_type_e convert_to_wifi_eap_type(wifi_manager_eap_type_e type);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/packaging/capi-network-wifi.spec b/packaging/capi-network-wifi.spec
index e4179ce..7bf5816 100755
--- a/packaging/capi-network-wifi.spec
+++ b/packaging/capi-network-wifi.spec
@@ -7,6 +7,8 @@ License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
BuildRequires: cmake
BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(capi-network-wifi-manager)
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
@@ -50,6 +52,7 @@ make %{?_smp_mflags}
%manifest capi-network-wifi.manifest
%attr(644,-,-) %{_libdir}/libcapi-network-wifi.so.*
%license LICENSE
+%{_bindir}/wifi_test
%files devel
%{_includedir}/network/*.h
diff --git a/src/net_wifi.c b/src/net_wifi.c
index 9c139e3..0e1799d 100755
--- a/src/net_wifi.c
+++ b/src/net_wifi.c
@@ -16,197 +16,390 @@
#include "net_wifi_private.h"
+typedef struct {
+ wifi_activated_cb activated_cb;
+ void *activated_ud;
+ wifi_deactivated_cb deactivated_cb;
+ void *deactivated_ud;
+ wifi_scan_finished_cb scan_finished_cb;
+ void *scan_finished_ud;
+ wifi_scan_finished_cb specific_scan_finished_cb;
+ void *specific_scan_finished_ud;
+ wifi_connected_cb connected_cb;
+ void *connected_ud;
+ wifi_connected_cb specific_connected_cb;
+ void *specific_connected_ud;
+ wifi_disconnected_cb disconnected_cb;
+ void *disconnected_ud;
+ wifi_connected_cb wps_pbc_connected_cb;
+ void *wps_pbc_connected_ud;
+ wifi_connected_cb wps_pin_connected_cb;
+ void *wps_pin_connected_ud;
+ wifi_scan_finished_cb background_scan_finished_cb;
+ void *background_scan_finished_ud;
+} wifi_user_callback_s;
+
+wifi_user_callback_s g_user_callback = { 0, };
+wifi_manager_h g_wifi_manager_handle = NULL;
+
+static void __activated_callback(wifi_manager_error_e result, void *user_data)
+{
+ if (g_user_callback.activated_cb) {
+ g_user_callback.activated_cb(convert_to_wifi_error(result), g_user_callback.activated_ud);
+ g_user_callback.activated_cb = NULL;
+ g_user_callback.activated_ud = NULL;
+ }
+}
+
+static void __deactivated_callback(wifi_manager_error_e result, void *user_data)
+{
+ if (g_user_callback.deactivated_cb) {
+ g_user_callback.deactivated_cb(convert_to_wifi_error(result), g_user_callback.deactivated_ud);
+ g_user_callback.deactivated_cb = NULL;
+ g_user_callback.deactivated_ud = NULL;
+ }
+}
+
+static void __scan_finished_callback(wifi_manager_error_e error_code, void* user_data)
+{
+ if (g_user_callback.scan_finished_cb) {
+ g_user_callback.scan_finished_cb(convert_to_wifi_error(error_code), g_user_callback.scan_finished_ud);
+ g_user_callback.scan_finished_cb = NULL;
+ g_user_callback.scan_finished_ud = NULL;
+ }
+}
+
+static void __specific_scan_finished_callback(wifi_manager_error_e error_code, void *user_data)
+{
+ if (g_user_callback.specific_scan_finished_cb) {
+ g_user_callback.specific_scan_finished_cb(convert_to_wifi_error(error_code), g_user_callback.specific_scan_finished_ud);
+ g_user_callback.specific_scan_finished_cb = NULL;
+ g_user_callback.specific_scan_finished_ud = NULL;
+ }
+}
+
+static void __connected_callback(wifi_manager_error_e result, void *user_data)
+{
+ if (g_user_callback.connected_cb) {
+ g_user_callback.connected_cb(convert_to_wifi_error(result), g_user_callback.connected_ud);
+ g_user_callback.connected_cb = NULL;
+ g_user_callback.connected_ud = NULL;
+ }
+}
+
+static void __specific_connected_callback(wifi_manager_error_e result, void *user_data)
+{
+ if (g_user_callback.specific_connected_cb) {
+ g_user_callback.specific_connected_cb(convert_to_wifi_error(result), g_user_callback.specific_connected_ud);
+ g_user_callback.specific_connected_cb = NULL;
+ g_user_callback.specific_connected_ud = NULL;
+ }
+}
+
+static void __disconnected_callback(wifi_manager_error_e result, void *user_data)
+{
+ if (g_user_callback.disconnected_cb) {
+ g_user_callback.disconnected_cb(convert_to_wifi_error(result), g_user_callback.disconnected_ud);
+ g_user_callback.disconnected_cb = NULL;
+ g_user_callback.disconnected_ud = NULL;
+ }
+}
+
+static void __wps_pbc_connected_callback(wifi_manager_error_e result, void *user_data)
+{
+ if (g_user_callback.wps_pbc_connected_cb) {
+ g_user_callback.wps_pbc_connected_cb(convert_to_wifi_error(result), g_user_callback.wps_pbc_connected_ud);
+ g_user_callback.wps_pbc_connected_cb = NULL;
+ g_user_callback.wps_pbc_connected_ud = NULL;
+ }
+}
+
+static void __wps_pin_connected_callback(wifi_manager_error_e result, void *user_data)
+{
+ if (g_user_callback.wps_pin_connected_cb) {
+ g_user_callback.wps_pin_connected_cb(convert_to_wifi_error(result), g_user_callback.wps_pin_connected_ud);
+ g_user_callback.wps_pin_connected_cb = NULL;
+ g_user_callback.wps_pin_connected_ud = NULL;
+ }
+}
+
+static void __background_scan_completed_callback(wifi_manager_error_e error_code, void *user_data)
+{
+ if (g_user_callback.background_scan_finished_cb)
+ g_user_callback.background_scan_finished_cb(convert_to_wifi_error(error_code), g_user_callback.background_scan_finished_ud);
+}
+
EXPORT_API int wifi_initialize(void)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_initialize");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_initialize(&g_wifi_manager_handle));
}
EXPORT_API int wifi_deinitialize(void)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_deinitialize");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_deinitialize(g_wifi_manager_handle));
}
-EXPORT_API int wifi_activate(wifi_activated_cb callback, void* user_data)
+EXPORT_API int wifi_activate(wifi_activated_cb callback, void *user_data)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_activate");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ g_user_callback.activated_cb = callback;
+ g_user_callback.activated_ud = user_data;
+
+ return convert_to_wifi_error(wifi_manager_activate(g_wifi_manager_handle, __activated_callback, NULL));
}
EXPORT_API int wifi_activate_with_wifi_picker_tested(
- wifi_activated_cb callback, void* user_data)
+ wifi_activated_cb callback, void *user_data)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_activate_with_wifi_picker_tested");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ g_user_callback.activated_cb = callback;
+ g_user_callback.activated_ud = user_data;
+
+ return convert_to_wifi_error(wifi_manager_activate_with_wifi_picker_tested(g_wifi_manager_handle, __activated_callback, NULL));
}
-EXPORT_API int wifi_deactivate(wifi_deactivated_cb callback, void* user_data)
+EXPORT_API int wifi_deactivate(wifi_deactivated_cb callback, void *user_data)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_deactivate");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ g_user_callback.deactivated_cb = callback;
+ g_user_callback.deactivated_ud = user_data;
+
+ return convert_to_wifi_error(wifi_manager_deactivate(g_wifi_manager_handle, __deactivated_callback, NULL));
}
-EXPORT_API int wifi_is_activated(bool* activated)
+EXPORT_API int wifi_is_activated(bool *activated)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_is_activated");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_is_activated(g_wifi_manager_handle, activated));
}
-EXPORT_API int wifi_get_mac_address(char** mac_address)
+EXPORT_API int wifi_get_mac_address(char **mac_address)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_get_mac_address");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_get_mac_address(g_wifi_manager_handle, mac_address));
}
-EXPORT_API int wifi_get_network_interface_name(char** name)
+EXPORT_API int wifi_get_network_interface_name(char **name)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_get_network_interface_name");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_get_network_interface_name(g_wifi_manager_handle, name));
}
-EXPORT_API int wifi_scan(wifi_scan_finished_cb callback, void* user_data)
+EXPORT_API int wifi_scan(wifi_scan_finished_cb callback, void *user_data)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_scan");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ g_user_callback.scan_finished_cb = callback;
+ g_user_callback.scan_finished_ud = user_data;
+
+ return convert_to_wifi_error(wifi_manager_scan(g_wifi_manager_handle, __scan_finished_callback, NULL));
}
-EXPORT_API int wifi_scan_specific_ap(const char* essid, wifi_scan_finished_cb callback, void* user_data)
+EXPORT_API int wifi_scan_specific_ap(const char *essid, wifi_scan_finished_cb callback, void *user_data)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_scan_specific_ap");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ g_user_callback.specific_scan_finished_cb = callback;
+ g_user_callback.specific_scan_finished_ud = user_data;
+
+ return convert_to_wifi_error(wifi_manager_scan_specific_ap(g_wifi_manager_handle, essid, __specific_scan_finished_callback, NULL));
}
EXPORT_API int wifi_get_connected_ap(wifi_ap_h *ap)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_get_connected_ap");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_get_connected_ap(g_wifi_manager_handle, (wifi_manager_ap_h *)ap));
}
-EXPORT_API int wifi_foreach_found_aps(wifi_found_ap_cb callback, void* user_data)
+EXPORT_API int wifi_foreach_found_aps(wifi_found_ap_cb callback, void *user_data)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_foreach_found_ap");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_foreach_found_ap(g_wifi_manager_handle,
+ (wifi_manager_found_ap_cb)callback, user_data));
}
-EXPORT_API int wifi_foreach_found_specific_aps(wifi_found_ap_cb callback, void* user_data)
+EXPORT_API int wifi_foreach_found_specific_aps(wifi_found_ap_cb callback, void *user_data)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_foreach_found_specific_ap");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_foreach_found_specific_ap(g_wifi_manager_handle,
+ (wifi_manager_found_ap_cb)callback, user_data));
}
-EXPORT_API int wifi_connect(wifi_ap_h ap, wifi_connected_cb callback, void* user_data)
+EXPORT_API int wifi_connect(wifi_ap_h ap, wifi_connected_cb callback, void *user_data)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_connect");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ g_user_callback.connected_cb = callback;
+ g_user_callback.connected_ud = user_data;
+
+ return convert_to_wifi_error(wifi_manager_connect(g_wifi_manager_handle,
+ (wifi_manager_ap_h)ap, __connected_callback, NULL));
}
-EXPORT_API int wifi_connect_specific_ap(const char* essid,
+EXPORT_API int wifi_connect_specific_ap(const char *essid,
wifi_security_type_e sec_type, const char *passphrase,
wifi_connected_cb callback, void* user_data)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_connect_hidden_ap");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ g_user_callback.specific_connected_cb = callback;
+ g_user_callback.specific_connected_ud = user_data;
+
+ return convert_to_wifi_error(wifi_manager_connect_hidden_ap(g_wifi_manager_handle,
+ essid, (wifi_manager_security_type_e)sec_type,
+ passphrase, __specific_connected_callback, NULL));
}
-EXPORT_API int wifi_disconnect(wifi_ap_h ap, wifi_disconnected_cb callback, void* user_data)
+EXPORT_API int wifi_disconnect(wifi_ap_h ap, wifi_disconnected_cb callback, void *user_data)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_disconnect");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ g_user_callback.disconnected_cb = callback;
+ g_user_callback.disconnected_ud = user_data;
+
+ return convert_to_wifi_error(wifi_manager_disconnect(g_wifi_manager_handle,
+ (wifi_manager_ap_h)ap, __disconnected_callback, NULL));
}
-EXPORT_API int wifi_connect_by_wps_pbc(wifi_ap_h ap, wifi_connected_cb callback, void* user_data)
+EXPORT_API int wifi_connect_by_wps_pbc(wifi_ap_h ap, wifi_connected_cb callback, void *user_data)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_connect_by_wps_pbc");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ g_user_callback.wps_pbc_connected_cb = callback;
+ g_user_callback.wps_pbc_connected_ud = user_data;
+
+ return convert_to_wifi_error(wifi_manager_connect_by_wps_pbc(g_wifi_manager_handle,
+ (wifi_manager_ap_h)ap, __wps_pbc_connected_callback, NULL));
}
EXPORT_API int wifi_connect_by_wps_pin(wifi_ap_h ap, const char *pin, wifi_connected_cb callback, void* user_data)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_connect_by_wps_pin");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ g_user_callback.wps_pin_connected_cb = callback;
+ g_user_callback.wps_pin_connected_ud = user_data;
+
+ return convert_to_wifi_error(wifi_manager_connect_by_wps_pin(g_wifi_manager_handle,
+ (wifi_manager_ap_h)ap, pin, __wps_pin_connected_callback, NULL));
}
EXPORT_API int wifi_forget_ap(wifi_ap_h ap)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_forget_ap");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_forget_ap(g_wifi_manager_handle, (wifi_manager_ap_h)ap));
}
EXPORT_API int wifi_get_connection_state(wifi_connection_state_e *connection_state)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_get_connection_state");
- return WIFI_ERROR_NOT_SUPPORTED;
+ return convert_to_wifi_error(wifi_manager_get_connection_state(g_wifi_manager_handle,
+ (wifi_manager_connection_state_e *)connection_state));
}
-EXPORT_API int wifi_set_device_state_changed_cb(wifi_device_state_changed_cb callback, void* user_data)
+EXPORT_API int wifi_set_device_state_changed_cb(wifi_device_state_changed_cb callback, void *user_data)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_set_device_state_changed_cb");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_set_device_state_changed_cb(g_wifi_manager_handle,
+ (wifi_manager_device_state_changed_cb)callback, user_data));
}
EXPORT_API int wifi_unset_device_state_changed_cb(void)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_unset_device_state_changed_cb");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_unset_device_state_changed_cb(g_wifi_manager_handle));
}
-EXPORT_API int wifi_set_background_scan_cb(wifi_scan_finished_cb callback, void* user_data)
+EXPORT_API int wifi_set_background_scan_cb(wifi_scan_finished_cb callback, void *user_data)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_set_background_scan_cb");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ g_user_callback.background_scan_finished_cb = callback;
+ g_user_callback.background_scan_finished_ud = user_data;
+
+ return convert_to_wifi_error(wifi_manager_set_background_scan_cb(g_wifi_manager_handle, __background_scan_completed_callback, NULL));
}
EXPORT_API int wifi_unset_background_scan_cb(void)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_unset_background_scan_cb");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ g_user_callback.background_scan_finished_cb = NULL;
+ g_user_callback.background_scan_finished_ud = NULL;
+
+ return convert_to_wifi_error(wifi_manager_unset_background_scan_cb(g_wifi_manager_handle));
}
-EXPORT_API int wifi_set_connection_state_changed_cb(wifi_connection_state_changed_cb callback, void* user_data)
+EXPORT_API int wifi_set_connection_state_changed_cb(wifi_connection_state_changed_cb callback, void *user_data)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_set_connection_state_changed_cb");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_set_connection_state_changed_cb(g_wifi_manager_handle,
+ (wifi_manager_connection_state_changed_cb)callback, user_data));
}
EXPORT_API int wifi_unset_connection_state_changed_cb(void)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_unset_connection_state_changed_cb");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_unset_connection_state_changed_cb(g_wifi_manager_handle));
}
EXPORT_API int wifi_set_rssi_level_changed_cb(wifi_rssi_level_changed_cb callback, void* user_data)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_set_rssi_level_changed_cb");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_set_rssi_level_changed_cb(g_wifi_manager_handle,
+ (wifi_manager_rssi_level_changed_cb)callback, user_data));
}
EXPORT_API int wifi_unset_rssi_level_changed_cb(void)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_unset_rssi_level_changed_cb");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_unset_rssi_level_changed_cb(g_wifi_manager_handle));
}
-EXPORT_API int wifi_tdls_disconnect(const char* peer_mac_addr)
+EXPORT_API int wifi_tdls_disconnect(const char *peer_mac_addr)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_tdls_disconnect");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_tdls_disconnect(g_wifi_manager_handle, peer_mac_addr));
}
-EXPORT_API int wifi_tdls_get_connected_peer(char** peer_mac_addr)
+EXPORT_API int wifi_tdls_get_connected_peer(char **peer_mac_addr)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_tdls_get_connected_peer");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_tdls_get_connected_peer(g_wifi_manager_handle, peer_mac_addr));
}
-EXPORT_API int wifi_tdls_set_state_changed_cb(wifi_tdls_state_changed_cb callback, void* user_data)
+EXPORT_API int wifi_tdls_set_state_changed_cb(wifi_tdls_state_changed_cb callback, void *user_data)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_tdls_set_state_changed_cb");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_tdls_set_state_changed_cb(g_wifi_manager_handle,
+ (wifi_manager_tdls_state_changed_cb)callback, user_data));
}
EXPORT_API int wifi_tdls_unset_state_changed_cb(void)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_tdls_unset_state_changed_cb");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_tdls_unset_state_changed_cb(g_wifi_manager_handle));
}
diff --git a/src/net_wifi_ap.c b/src/net_wifi_ap.c
index bda88bf..491e59e 100755
--- a/src/net_wifi_ap.c
+++ b/src/net_wifi_ap.c
@@ -15,283 +15,359 @@
*/
#include "net_wifi_private.h"
+extern wifi_manager_h g_wifi_manager_handle;
/* Wi-Fi AP ******************************************************************/
-EXPORT_API int wifi_ap_create(const char* essid, wifi_ap_h* ap)
+EXPORT_API int wifi_ap_create(const char *essid, wifi_ap_h *ap)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_create");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_create(g_wifi_manager_handle, essid, ap));
}
-EXPORT_API int wifi_ap_hidden_create(const char* essid, wifi_ap_h* ap)
+EXPORT_API int wifi_ap_hidden_create(const char *essid, wifi_ap_h *ap)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_hidden_create");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_hidden_create(g_wifi_manager_handle, essid, ap));
}
EXPORT_API int wifi_ap_destroy(wifi_ap_h ap)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_destroy");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_destroy(ap));
}
-EXPORT_API int wifi_ap_clone(wifi_ap_h* cloned_ap, wifi_ap_h origin)
+EXPORT_API int wifi_ap_clone(wifi_ap_h *cloned_ap, wifi_ap_h origin)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_clone");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_clone(cloned_ap, origin));
}
EXPORT_API int wifi_ap_refresh(wifi_ap_h ap)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_refresh");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_refresh(ap));
}
/* Wi-Fi network information *************************************************/
-EXPORT_API int wifi_ap_get_essid(wifi_ap_h ap, char** essid)
+EXPORT_API int wifi_ap_get_essid(wifi_ap_h ap, char **essid)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_essid");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_get_essid(ap, essid));
}
-EXPORT_API int wifi_ap_get_bssid(wifi_ap_h ap, char** bssid)
+EXPORT_API int wifi_ap_get_bssid(wifi_ap_h ap, char **bssid)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_bssid");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_get_bssid(ap, bssid));
}
-EXPORT_API int wifi_ap_get_rssi(wifi_ap_h ap, int* rssi)
+EXPORT_API int wifi_ap_get_rssi(wifi_ap_h ap, int *rssi)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_rssi");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_get_rssi(ap, rssi));
}
-EXPORT_API int wifi_ap_get_frequency(wifi_ap_h ap, int* frequency)
+EXPORT_API int wifi_ap_get_frequency(wifi_ap_h ap, int *frequency)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_frequency");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_get_frequency(ap, frequency));
}
-EXPORT_API int wifi_ap_get_max_speed(wifi_ap_h ap, int* max_speed)
+EXPORT_API int wifi_ap_get_max_speed(wifi_ap_h ap, int *max_speed)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_max_speed");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_get_max_speed(ap, max_speed));
}
-EXPORT_API int wifi_ap_is_favorite(wifi_ap_h ap, bool* favorite)
+EXPORT_API int wifi_ap_is_favorite(wifi_ap_h ap, bool *favorite)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_is_favorite");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_is_favorite(ap, favorite));
}
-EXPORT_API int wifi_ap_is_passpoint(wifi_ap_h ap, bool* passpoint)
+EXPORT_API int wifi_ap_is_passpoint(wifi_ap_h ap, bool *passpoint)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_is_passpoint");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_is_passpoint(ap, passpoint));
}
-EXPORT_API int wifi_ap_get_connection_state(wifi_ap_h ap, wifi_connection_state_e* state)
+EXPORT_API int wifi_ap_get_connection_state(wifi_ap_h ap, wifi_connection_state_e *state)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_connection_state");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_get_connection_state(ap, (wifi_manager_connection_state_e *)state));
}
-EXPORT_API int wifi_ap_get_ip_config_type(wifi_ap_h ap, wifi_address_family_e address_family, wifi_ip_config_type_e* type)
+EXPORT_API int wifi_ap_get_ip_config_type(wifi_ap_h ap, wifi_address_family_e address_family, wifi_ip_config_type_e *type)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_ip_config_type");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_get_ip_config_type(ap,
+ (wifi_manager_address_family_e)address_family,
+ (wifi_manager_ip_config_type_e *)type));
}
EXPORT_API int wifi_ap_set_ip_config_type(wifi_ap_h ap, wifi_address_family_e address_family, wifi_ip_config_type_e type)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_ip_config_type");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_set_ip_config_type(ap,
+ (wifi_manager_address_family_e)address_family,
+ (wifi_manager_ip_config_type_e)type));
}
-EXPORT_API int wifi_ap_get_ip_address(wifi_ap_h ap, wifi_address_family_e address_family, char** ip_address)
+EXPORT_API int wifi_ap_get_ip_address(wifi_ap_h ap, wifi_address_family_e address_family, char **ip_address)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_ip_address");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_get_ip_address(ap,
+ (wifi_manager_address_family_e)address_family,
+ ip_address));
}
-EXPORT_API int wifi_ap_set_ip_address(wifi_ap_h ap, wifi_address_family_e address_family, const char* ip_address)
+EXPORT_API int wifi_ap_set_ip_address(wifi_ap_h ap, wifi_address_family_e address_family, const char *ip_address)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_ip_address");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_set_ip_address(ap,
+ (wifi_manager_address_family_e)address_family,
+ ip_address));
}
-EXPORT_API int wifi_ap_get_subnet_mask(wifi_ap_h ap, wifi_address_family_e address_family, char** subnet_mask)
+EXPORT_API int wifi_ap_get_subnet_mask(wifi_ap_h ap, wifi_address_family_e address_family, char **subnet_mask)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_subnet_mask");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_get_subnet_mask(ap,
+ (wifi_manager_address_family_e)address_family,
+ subnet_mask));
}
-EXPORT_API int wifi_ap_set_subnet_mask(wifi_ap_h ap, wifi_address_family_e address_family, const char* subnet_mask)
+EXPORT_API int wifi_ap_set_subnet_mask(wifi_ap_h ap, wifi_address_family_e address_family, const char *subnet_mask)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_subnet_mask");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_set_subnet_mask(ap,
+ (wifi_manager_address_family_e)address_family,
+ subnet_mask));
}
-EXPORT_API int wifi_ap_get_gateway_address(wifi_ap_h ap, wifi_address_family_e address_family, char** gateway_address)
+EXPORT_API int wifi_ap_get_gateway_address(wifi_ap_h ap, wifi_address_family_e address_family, char **gateway_address)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_gateway_address");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_get_gateway_address(ap,
+ (wifi_manager_address_family_e)address_family,
+ gateway_address));
}
-EXPORT_API int wifi_ap_set_gateway_address(wifi_ap_h ap, wifi_address_family_e address_family, const char* gateway_address)
+EXPORT_API int wifi_ap_set_gateway_address(wifi_ap_h ap, wifi_address_family_e address_family, const char *gateway_address)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_gateway_address");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_set_gateway_address(ap,
+ (wifi_manager_address_family_e)address_family,
+ gateway_address));
}
-EXPORT_API int wifi_ap_get_proxy_address(wifi_ap_h ap, wifi_address_family_e address_family, char** proxy_address)
+EXPORT_API int wifi_ap_get_proxy_address(wifi_ap_h ap, wifi_address_family_e address_family, char **proxy_address)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_proxy_address");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_get_proxy_address(ap,
+ (wifi_manager_address_family_e)address_family,
+ proxy_address));
}
-EXPORT_API int wifi_ap_set_proxy_address(wifi_ap_h ap, wifi_address_family_e address_family, const char* proxy_address)
+EXPORT_API int wifi_ap_set_proxy_address(wifi_ap_h ap, wifi_address_family_e address_family, const char *proxy_address)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_proxy_address");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_set_proxy_address(ap,
+ (wifi_manager_address_family_e)address_family,
+ proxy_address));
}
-EXPORT_API int wifi_ap_get_proxy_type(wifi_ap_h ap, wifi_proxy_type_e* type)
+EXPORT_API int wifi_ap_get_proxy_type(wifi_ap_h ap, wifi_proxy_type_e *type)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_proxy_type");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_get_proxy_type(ap, (wifi_manager_proxy_type_e *)type));
}
EXPORT_API int wifi_ap_set_proxy_type(wifi_ap_h ap, wifi_proxy_type_e proxy_type)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_proxy_type");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_set_proxy_type(ap, (wifi_manager_proxy_type_e)proxy_type));
}
-EXPORT_API int wifi_ap_get_dns_address(wifi_ap_h ap, int order, wifi_address_family_e address_family, char** dns_address)
+EXPORT_API int wifi_ap_get_dns_address(wifi_ap_h ap, int order, wifi_address_family_e address_family, char **dns_address)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_dns_address");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_get_dns_address(ap, order,
+ (wifi_manager_address_family_e)address_family, dns_address));
}
EXPORT_API int wifi_ap_set_dns_address(wifi_ap_h ap, int order, wifi_address_family_e address_family, const char* dns_address)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_dns_address");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_set_dns_address(ap, order,
+ (wifi_manager_address_family_e)address_family, dns_address));
}
/* Wi-Fi security information ************************************************/
-EXPORT_API int wifi_ap_get_security_type(wifi_ap_h ap, wifi_security_type_e* type)
+EXPORT_API int wifi_ap_get_security_type(wifi_ap_h ap, wifi_security_type_e *type)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_security_type");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ wifi_manager_security_type_e manager_type;
+ int ret = wifi_manager_ap_get_security_type(ap, &manager_type);
+
+ *type = convert_to_wifi_security_type(manager_type);
+ return convert_to_wifi_error(ret);
}
EXPORT_API int wifi_ap_set_security_type(wifi_ap_h ap, wifi_security_type_e type)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_security_type");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_set_security_type(ap, (wifi_manager_security_type_e)type));
}
-EXPORT_API int wifi_ap_get_encryption_type(wifi_ap_h ap, wifi_encryption_type_e* type)
+EXPORT_API int wifi_ap_get_encryption_type(wifi_ap_h ap, wifi_encryption_type_e *type)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_encryption_type");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_get_encryption_type(ap, (wifi_manager_encryption_type_e *)type));
}
EXPORT_API int wifi_ap_set_encryption_type(wifi_ap_h ap, wifi_encryption_type_e type)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_encryption_type");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_set_encryption_type(ap, (wifi_manager_encryption_type_e)type));
}
-EXPORT_API int wifi_ap_is_passphrase_required(wifi_ap_h ap, bool* required)
+EXPORT_API int wifi_ap_is_passphrase_required(wifi_ap_h ap, bool *required)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_is_passphrase_required");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_is_passphrase_required(ap, required));
}
-EXPORT_API int wifi_ap_set_passphrase(wifi_ap_h ap, const char* passphrase)
+EXPORT_API int wifi_ap_set_passphrase(wifi_ap_h ap, const char *passphrase)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_passphrase");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_set_passphrase(ap, passphrase));
}
-EXPORT_API int wifi_ap_is_wps_supported(wifi_ap_h ap, bool* supported)
+EXPORT_API int wifi_ap_is_wps_supported(wifi_ap_h ap, bool *supported)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_is_wps_supported");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_is_wps_supported(ap, supported));
}
/* Wi-Fi EAP *****************************************************************/
-EXPORT_API int wifi_ap_set_eap_passphrase(wifi_ap_h ap, const char* user_name, const char* password)
+EXPORT_API int wifi_ap_set_eap_passphrase(wifi_ap_h ap, const char *user_name, const char *password)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_eap_passphrase");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_set_eap_passphrase(ap, user_name, password));
}
-EXPORT_API int wifi_ap_get_eap_passphrase(wifi_ap_h ap, char** user_name, bool* is_password_set)
+EXPORT_API int wifi_ap_get_eap_passphrase(wifi_ap_h ap, char **user_name, bool *is_password_set)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_eap_passphrase");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_get_eap_passphrase(ap, user_name, is_password_set));
}
-EXPORT_API int wifi_ap_get_eap_ca_cert_file(wifi_ap_h ap, char** file)
+EXPORT_API int wifi_ap_get_eap_ca_cert_file(wifi_ap_h ap, char **file)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_eap_ca_cert_file");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_get_eap_ca_cert_file(ap, file));
}
-EXPORT_API int wifi_ap_set_eap_ca_cert_file(wifi_ap_h ap, const char* file)
+EXPORT_API int wifi_ap_set_eap_ca_cert_file(wifi_ap_h ap, const char *file)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_eap_ca_cert_file");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_set_eap_ca_cert_file(ap, file));
}
-EXPORT_API int wifi_ap_get_eap_client_cert_file(wifi_ap_h ap, char** file)
+EXPORT_API int wifi_ap_get_eap_client_cert_file(wifi_ap_h ap, char **file)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_eap_client_cert_file");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_get_eap_client_cert_file(ap, file));
}
-EXPORT_API int wifi_ap_set_eap_client_cert_file(wifi_ap_h ap, const char* file)
+EXPORT_API int wifi_ap_set_eap_client_cert_file(wifi_ap_h ap, const char *file)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_eap_client_cert_file");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_set_eap_client_cert_file(ap, file));
}
-EXPORT_API int wifi_ap_get_eap_private_key_file(wifi_ap_h ap, char** file)
+EXPORT_API int wifi_ap_get_eap_private_key_file(wifi_ap_h ap, char **file)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_eap_private_key_file");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_get_eap_private_key_file(ap, file));
}
-EXPORT_API int wifi_ap_set_eap_private_key_info(wifi_ap_h ap, const char* file, const char* password)
+EXPORT_API int wifi_ap_set_eap_private_key_info(wifi_ap_h ap, const char *file, const char *password)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_eap_private_key_info");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_set_eap_private_key_info(ap, file, password));
}
-EXPORT_API int wifi_ap_get_eap_type(wifi_ap_h ap, wifi_eap_type_e* type)
+EXPORT_API int wifi_ap_get_eap_type(wifi_ap_h ap, wifi_eap_type_e *type)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_eap_type");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ wifi_manager_eap_type_e manager_type;
+ int ret = wifi_manager_ap_get_eap_type(ap, &manager_type);
+
+ *type = convert_to_wifi_eap_type(manager_type);
+ return convert_to_wifi_error(ret);
}
EXPORT_API int wifi_ap_set_eap_type(wifi_ap_h ap, wifi_eap_type_e type)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_eap_type");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_set_eap_type(ap, type));
}
-EXPORT_API int wifi_ap_get_eap_auth_type(wifi_ap_h ap, wifi_eap_auth_type_e* type)
+EXPORT_API int wifi_ap_get_eap_auth_type(wifi_ap_h ap, wifi_eap_auth_type_e *type)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_get_eap_auth_type");
- return WIFI_ERROR_NOT_SUPPORTED;
+ return convert_to_wifi_error(wifi_manager_ap_get_eap_auth_type(ap, (wifi_manager_eap_auth_type_e *)type));
}
EXPORT_API int wifi_ap_set_eap_auth_type(wifi_ap_h ap, wifi_eap_auth_type_e type)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_ap_set_eap_auth_type");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_ap_set_eap_auth_type(ap, (wifi_manager_eap_auth_type_e)type));
}
diff --git a/src/net_wifi_config.c b/src/net_wifi_config.c
index 03f9c76..d741890 100755
--- a/src/net_wifi_config.c
+++ b/src/net_wifi_config.c
@@ -15,6 +15,7 @@
*/
#include "net_wifi_private.h"
+extern wifi_manager_h g_wifi_manager_handle;
/**
* wifi configuration
@@ -22,49 +23,58 @@
EXPORT_API int wifi_config_create(const char *name, const char *passphrase, wifi_security_type_e security_type, wifi_config_h *config)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_create");
- return WIFI_ERROR_NOT_SUPPORTED;
+ return convert_to_wifi_error(wifi_manager_config_create(g_wifi_manager_handle, name, passphrase,
+ (wifi_manager_security_type_e)security_type, config));
}
EXPORT_API int wifi_config_clone(wifi_config_h origin, wifi_config_h *cloned_config)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_clone");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_clone(origin, cloned_config));
}
EXPORT_API int wifi_config_destroy(wifi_config_h config)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_destroy");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_destroy(config));
}
EXPORT_API int wifi_config_save_configuration(wifi_config_h config)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_save");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_save(g_wifi_manager_handle, config));
}
EXPORT_API int wifi_config_remove(wifi_config_h config)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_remove");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_remove(g_wifi_manager_handle, config));
}
EXPORT_API int wifi_config_foreach_configuration(wifi_config_list_cb callback, void *user_data)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_foreach_configuration");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_foreach_configuration(g_wifi_manager_handle,
+ (wifi_manager_config_list_cb)callback, user_data));
}
EXPORT_API int wifi_config_get_name(wifi_config_h config, char **name)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_name");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_get_name(config, name));
}
EXPORT_API int wifi_config_get_security_type(wifi_config_h config, wifi_security_type_e *security_type)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_security_type");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_get_security_type(config, (wifi_manager_security_type_e *)security_type));
}
/**
@@ -73,107 +83,127 @@ EXPORT_API int wifi_config_get_security_type(wifi_config_h config, wifi_security
EXPORT_API int wifi_config_set_proxy_address(wifi_config_h config, wifi_address_family_e address_family, const char *proxy_address)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_proxy_address");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_set_proxy_address(config,
+ (wifi_manager_address_family_e)address_family, proxy_address));
}
EXPORT_API int wifi_config_get_proxy_address(wifi_config_h config, wifi_address_family_e *address_family, char **proxy_address)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_proxy_address");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_get_proxy_address(config,
+ (wifi_manager_address_family_e *)address_family, proxy_address));
}
EXPORT_API int wifi_config_set_hidden_ap_property(wifi_config_h config, bool hidden)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_hidden_ap_property");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_set_hidden_ap_property(config, hidden));
}
EXPORT_API int wifi_config_get_hidden_ap_property(wifi_config_h config, bool *hidden)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_hidden_ap_property");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_get_hidden_ap_property(config, hidden));
}
-EXPORT_API int wifi_config_get_eap_anonymous_identity(wifi_config_h config, char** anonymous_identity)
+EXPORT_API int wifi_config_get_eap_anonymous_identity(wifi_config_h config, char **anonymous_identity)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_anonymous_identity");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_get_eap_anonymous_identity(config, anonymous_identity));
}
-EXPORT_API int wifi_config_set_eap_anonymous_identity(wifi_config_h config, const char* anonymous_identity)
+EXPORT_API int wifi_config_set_eap_anonymous_identity(wifi_config_h config, const char *anonymous_identity)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_anonymous_identity");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_set_eap_anonymous_identity(config, anonymous_identity));
}
-EXPORT_API int wifi_config_get_eap_ca_cert_file(wifi_config_h config, char** ca_cert)
+EXPORT_API int wifi_config_get_eap_ca_cert_file(wifi_config_h config, char **ca_cert)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_ca_cert_file");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_get_eap_ca_cert_file(config, ca_cert));
}
-EXPORT_API int wifi_config_set_eap_ca_cert_file(wifi_config_h config, const char* ca_cert)
+EXPORT_API int wifi_config_set_eap_ca_cert_file(wifi_config_h config, const char *ca_cert)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_ca_cert_file");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_set_eap_ca_cert_file(config, ca_cert));
}
-EXPORT_API int wifi_config_get_eap_client_cert_file(wifi_config_h config, char** client_cert)
+EXPORT_API int wifi_config_get_eap_client_cert_file(wifi_config_h config, char **client_cert)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_client_cert_file");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_get_eap_client_cert_file(config, client_cert));
}
-EXPORT_API int wifi_config_set_eap_client_cert_file(wifi_config_h config, const char* private_key, const char* client_cert)
+EXPORT_API int wifi_config_set_eap_client_cert_file(wifi_config_h config, const char *private_key, const char *client_cert)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_client_cert_file");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_set_eap_client_cert_file(config, private_key, client_cert));
}
-EXPORT_API int wifi_config_get_eap_identity(wifi_config_h config, char** identity)
+EXPORT_API int wifi_config_get_eap_identity(wifi_config_h config, char **identity)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_identity");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_get_eap_identity(config, identity));
}
-EXPORT_API int wifi_config_set_eap_identity(wifi_config_h config, const char* identity)
+EXPORT_API int wifi_config_set_eap_identity(wifi_config_h config, const char *identity)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_identity");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_set_eap_identity(config, identity));
}
EXPORT_API int wifi_config_get_eap_type(wifi_config_h config, wifi_eap_type_e *eap_type)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_type");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_get_eap_type(config, (wifi_manager_eap_type_e *)eap_type));
}
EXPORT_API int wifi_config_set_eap_type(wifi_config_h config, wifi_eap_type_e eap_type)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_type");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_set_eap_type(config, (wifi_manager_eap_type_e)eap_type));
}
-EXPORT_API int wifi_config_get_eap_auth_type(wifi_config_h config, wifi_eap_auth_type_e* eap_auth_type)
+EXPORT_API int wifi_config_get_eap_auth_type(wifi_config_h config, wifi_eap_auth_type_e *eap_auth_type)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_auth_type");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_get_eap_auth_type(config, (wifi_manager_eap_auth_type_e *)eap_auth_type));
}
EXPORT_API int wifi_config_set_eap_auth_type(wifi_config_h config, wifi_eap_auth_type_e eap_auth_type)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_auth_type");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_set_eap_auth_type(config, (wifi_manager_eap_auth_type_e)eap_auth_type));
}
-EXPORT_API int wifi_config_get_eap_subject_match(wifi_config_h config, char** subject_match)
+EXPORT_API int wifi_config_get_eap_subject_match(wifi_config_h config, char **subject_match)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_subject_match");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_get_eap_subject_match(config, subject_match));
}
-EXPORT_API int wifi_config_set_eap_subject_match(wifi_config_h config, const char* subject_match)
+EXPORT_API int wifi_config_set_eap_subject_match(wifi_config_h config, const char *subject_match)
{
DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_subject_match");
- return WIFI_ERROR_NOT_SUPPORTED;
+
+ return convert_to_wifi_error(wifi_manager_config_set_eap_subject_match(config, subject_match));
}
diff --git a/src/net_wifi_private.c b/src/net_wifi_private.c
new file mode 100755
index 0000000..2ecb0a1
--- /dev/null
+++ b/src/net_wifi_private.c
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "net_wifi_private.h"
+
+wifi_error_e convert_to_wifi_error(wifi_manager_error_e error)
+{
+ switch (error) {
+ case WIFI_MANAGER_ERROR_NONE:
+ return WIFI_ERROR_NONE;
+ case WIFI_MANAGER_ERROR_INVALID_PARAMETER:
+ return WIFI_ERROR_INVALID_PARAMETER;
+ case WIFI_MANAGER_ERROR_OUT_OF_MEMORY:
+ return WIFI_ERROR_OUT_OF_MEMORY;
+ case WIFI_MANAGER_ERROR_INVALID_OPERATION:
+ return WIFI_ERROR_INVALID_OPERATION;
+ case WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
+ return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+ case WIFI_MANAGER_ERROR_OPERATION_FAILED:
+ return WIFI_ERROR_OPERATION_FAILED;
+ case WIFI_MANAGER_ERROR_NO_CONNECTION:
+ return WIFI_ERROR_NO_CONNECTION;
+ case WIFI_MANAGER_ERROR_NOW_IN_PROGRESS:
+ return WIFI_ERROR_NOW_IN_PROGRESS;
+ case WIFI_MANAGER_ERROR_ALREADY_EXISTS:
+ return WIFI_ERROR_ALREADY_EXISTS;
+ case WIFI_MANAGER_ERROR_OPERATION_ABORTED:
+ return WIFI_ERROR_OPERATION_ABORTED;
+ case WIFI_MANAGER_ERROR_DHCP_FAILED:
+ return WIFI_ERROR_DHCP_FAILED;
+ case WIFI_MANAGER_ERROR_INVALID_KEY:
+ return WIFI_ERROR_INVALID_KEY;
+ case WIFI_MANAGER_ERROR_NO_REPLY:
+ return WIFI_ERROR_NO_REPLY;
+ case WIFI_MANAGER_ERROR_SECURITY_RESTRICTED:
+ return WIFI_ERROR_SECURITY_RESTRICTED;
+ case WIFI_MANAGER_ERROR_PERMISSION_DENIED:
+ return WIFI_ERROR_PERMISSION_DENIED;
+ case WIFI_MANAGER_ERROR_NOT_SUPPORTED:
+ return WIFI_ERROR_NOT_SUPPORTED;
+ default:
+ return WIFI_ERROR_OPERATION_FAILED;
+ }
+}
+
+wifi_security_type_e convert_to_wifi_security_type(wifi_manager_security_type_e type)
+{
+ switch (type) {
+ case WIFI_MANAGER_SECURITY_TYPE_NONE:
+ return WIFI_SECURITY_TYPE_NONE;
+ case WIFI_MANAGER_SECURITY_TYPE_WEP:
+ return WIFI_SECURITY_TYPE_WEP;
+ case WIFI_MANAGER_SECURITY_TYPE_WPA_PSK:
+ return WIFI_SECURITY_TYPE_WPA_PSK;
+ case WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK:
+ return WIFI_SECURITY_TYPE_WPA2_PSK;
+ case WIFI_MANAGER_SECURITY_TYPE_EAP:
+ return WIFI_SECURITY_TYPE_EAP;
+ default:
+ return WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK;
+ }
+}
+
+wifi_eap_type_e convert_to_wifi_eap_type(wifi_manager_eap_type_e type)
+{
+ switch (type) {
+ case WIFI_MANAGER_EAP_TYPE_PEAP:
+ return WIFI_EAP_TYPE_PEAP;
+ case WIFI_MANAGER_EAP_TYPE_TLS:
+ return WIFI_EAP_TYPE_TLS;
+ case WIFI_MANAGER_EAP_TYPE_TTLS:
+ return WIFI_EAP_TYPE_TTLS;
+ case WIFI_MANAGER_EAP_TYPE_SIM:
+ return WIFI_EAP_TYPE_SIM;
+ case WIFI_MANAGER_EAP_TYPE_AKA:
+ case WIFI_MANAGER_EAP_TYPE_AKA_PRIME:
+ return WIFI_EAP_TYPE_AKA;
+ default:
+ return WIFI_MANAGER_EAP_TYPE_PEAP;
+ }
+}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100755
index 0000000..b56a11c
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -0,0 +1,25 @@
+PROJECT(wifi_test C)
+
+SET(fw_test "${fw_name}-test")
+
+SET(dependents "capi-base-common glib-2.0 ")
+SET(pc_dependents "capi-base-common")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_test} REQUIRED ${dependents})
+FOREACH(flag ${${fw_test}_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIE")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+aux_source_directory(. sources)
+FOREACH(src ${sources})
+ GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
+ MESSAGE("${src_name}")
+ ADD_EXECUTABLE(${src_name} ${src})
+ TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS})
+ENDFOREACH()
+
+INSTALL(TARGETS wifi_test RUNTIME DESTINATION bin/)
diff --git a/test/wifi_test.c b/test/wifi_test.c
new file mode 100755
index 0000000..faf85c8
--- /dev/null
+++ b/test/wifi_test.c
@@ -0,0 +1,1904 @@
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <netdb.h>
+#include <sys/socket.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/un.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <signal.h>
+#include <assert.h>
+#include <wifi.h>
+#include <tizen_error.h>
+
+#define LOG_RED "\033[0;31m"
+#define LOG_GREEN "\033[0;32m"
+#define LOG_BROWN "\033[0;33m"
+#define LOG_BLUE "\033[0;34m"
+#define LOG_END "\033[0;m"
+
+gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data);
+
+static const char *__test_convert_error_to_string(wifi_error_e err_type)
+{
+ switch (err_type) {
+ case WIFI_ERROR_NONE:
+ return "NONE";
+ case WIFI_ERROR_INVALID_PARAMETER:
+ return "INVALID_PARAMETER";
+ case WIFI_ERROR_OUT_OF_MEMORY:
+ return "OUT_OF_MEMORY";
+ case WIFI_ERROR_INVALID_OPERATION:
+ return "INVALID_OPERATION";
+ case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
+ return "ADDRESS_FAMILY_NOT_SUPPORTED";
+ case WIFI_ERROR_OPERATION_FAILED:
+ return "OPERATION_FAILED";
+ case WIFI_ERROR_NO_CONNECTION:
+ return "NO_CONNECTION";
+ case WIFI_ERROR_NOW_IN_PROGRESS:
+ return "NOW_IN_PROGRESS";
+ case WIFI_ERROR_ALREADY_EXISTS:
+ return "ALREADY_EXISTS";
+ case WIFI_ERROR_OPERATION_ABORTED:
+ return "OPERATION_ABORTED";
+ case WIFI_ERROR_DHCP_FAILED:
+ return "DHCP_FAILED";
+ case WIFI_ERROR_INVALID_KEY:
+ return "INVALID_KEY";
+ case WIFI_ERROR_NO_REPLY:
+ return "NO_REPLY";
+ case WIFI_ERROR_SECURITY_RESTRICTED:
+ return "SECURITY_RESTRICTED";
+ case WIFI_ERROR_PERMISSION_DENIED:
+ return "PERMISSION_DENIED";
+ case WIFI_ERROR_NOT_SUPPORTED:
+ return "NOT_SUPPORTED";
+ }
+
+ return "UNKNOWN";
+}
+
+static void __test_device_state_callback(wifi_device_state_e state, void* user_data)
+{
+ printf("Device state changed callback");
+
+ if (state == WIFI_DEVICE_STATE_ACTIVATED)
+ printf(", state : Activated\n");
+ else
+ printf(", state : Deactivated\n");
+}
+
+static void __test_bg_scan_completed_callback(wifi_error_e error_code, void* user_data)
+{
+ printf("Background Scan Completed, error code : %s\n",
+ __test_convert_error_to_string(error_code));
+}
+
+static void __test_scan_request_callback(wifi_error_e error_code, void* user_data)
+{
+ if (user_data != NULL)
+ printf("user_data : %s\n", (char *)user_data);
+
+ printf("Scan Completed from scan request, error code : %s\n",
+ __test_convert_error_to_string(error_code));
+}
+
+static void __test_connection_state_callback(wifi_connection_state_e state, wifi_ap_h ap, void* user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+
+ printf("Connection state changed callback");
+
+ switch (state) {
+ case WIFI_CONNECTION_STATE_CONNECTED:
+ printf(", state : Connected");
+ break;
+ case WIFI_CONNECTION_STATE_ASSOCIATION:
+ printf(", state : Association");
+ break;
+ case WIFI_CONNECTION_STATE_CONFIGURATION:
+ printf(", state : Configuration");
+ break;
+ case WIFI_CONNECTION_STATE_DISCONNECTED:
+ printf(", state : Disconnected");
+ break;
+ case WIFI_CONNECTION_STATE_FAILURE:
+ printf(", state : Failure");
+ break;
+ default:
+ printf(", state : Unknown");
+ }
+
+ rv = wifi_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_ERROR_NONE)
+ printf(", Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ else {
+ printf(", AP name : %s\n", ap_name);
+ g_free(ap_name);
+ }
+}
+
+static void __test_activated_callback(wifi_error_e result, void* user_data)
+{
+ if (result == WIFI_ERROR_NONE)
+ printf("Wi-Fi Activation Succeeded\n");
+ else
+ printf("Wi-Fi Activation Failed! error : %s\n", __test_convert_error_to_string(result));
+}
+
+static void __test_deactivated_callback(wifi_error_e result, void* user_data)
+{
+ if (result == WIFI_ERROR_NONE)
+ printf("Wi-Fi Deactivation Succeeded\n");
+ else
+ printf("Wi-Fi Deactivation Failed! error : %s\n", __test_convert_error_to_string(result));
+}
+
+static void __test_connected_callback(wifi_error_e result, void* user_data)
+{
+ if (result == WIFI_ERROR_NONE)
+ printf("Wi-Fi Connection Succeeded\n");
+ else
+ printf("Wi-Fi Connection Failed! error : %s\n", __test_convert_error_to_string(result));
+}
+
+static void __test_disconnected_callback(wifi_error_e result, void* user_data)
+{
+ if (result == WIFI_ERROR_NONE)
+ printf("Wi-Fi Disconnection Succeeded\n");
+ else
+ printf("Wi-Fi Disconnection Failed! error : %s\n", __test_convert_error_to_string(result));
+}
+
+static void __test_rssi_level_callback(wifi_rssi_level_e rssi_level, void* user_data)
+{
+ printf("RSSI level changed callback, level = %d\n", rssi_level);
+}
+
+static const char* __test_print_state(wifi_connection_state_e state)
+{
+ switch (state) {
+ case WIFI_CONNECTION_STATE_FAILURE:
+ return "Failure";
+ case WIFI_CONNECTION_STATE_DISCONNECTED:
+ return "Disconnected";
+ case WIFI_CONNECTION_STATE_ASSOCIATION:
+ return "Association";
+ case WIFI_CONNECTION_STATE_CONNECTED:
+ return "Connected";
+ case WIFI_CONNECTION_STATE_CONFIGURATION:
+ return "Configuration";
+ }
+
+ return "Unknown";
+}
+
+static bool __test_compare_ap_name(const char *ap_name, const char *ap_name_part)
+{
+ int ap_name_len = strlen(ap_name);
+ int ap_name_part_len = strlen(ap_name_part);
+
+ if (strncmp(ap_name, ap_name_part,
+ ap_name_len > ap_name_part_len ? ap_name_len : ap_name_part_len) == 0)
+ return true;
+ else
+ return false;
+}
+
+static bool __test_found_ap_callback(wifi_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ wifi_connection_state_e state;
+
+ rv = wifi_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ rv = wifi_ap_get_connection_state(ap, &state);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get State [%s]\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+
+ printf("AP name : %s, state : %s\n", ap_name, __test_print_state(state));
+ g_free(ap_name);
+
+ return true;
+}
+
+static bool __test_found_connect_ap_callback(wifi_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ bool required = false;
+
+ if (wifi_ap_is_passphrase_required(ap, &required) == WIFI_ERROR_NONE)
+ printf("Passphrase required : %s\n", required ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get Passphrase required\n");
+
+ if (required) {
+ char passphrase[100];
+ printf("Input passphrase for %s : ", ap_name);
+ rv = scanf("%99s", passphrase);
+
+ rv = wifi_ap_set_passphrase(ap, passphrase);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to set passphrase : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+ }
+
+ rv = wifi_connect(ap, __test_connected_callback, NULL);
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to connection request [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
+ else
+ printf("Success to connection request [%s]\n", ap_name);
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool __test_found_connect_wps_callback(wifi_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ int user_sel;
+ char pin[32] = {0,};
+
+ printf("%s - Input WPS method (1:PBC, 2:PIN) :\n", ap_name);
+ rv = scanf("%9d", &user_sel);
+
+ switch (user_sel) {
+ case 1:
+ rv = wifi_connect_by_wps_pbc(ap, __test_connected_callback, NULL);
+ break;
+ case 2:
+ printf("Input PIN code :\n");
+ rv = scanf("%31s", pin);
+ rv = wifi_connect_by_wps_pin(ap, pin, __test_connected_callback, NULL);
+ break;
+ default:
+ printf("Invalid input!\n");
+ g_free(ap_name);
+ return false;
+ }
+
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to connection request [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
+ else
+ printf("Success to connection request [%s]\n", ap_name);
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool __test_found_disconnect_ap_callback(wifi_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ rv = wifi_disconnect(ap, __test_disconnected_callback, NULL);
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to disconnection reqeust %s : [%s]\n", ap_name, __test_convert_error_to_string(rv));
+ else
+ printf("Success to disconnection request %s\n", ap_name);
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool __test_found_forget_ap_callback(wifi_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ rv = wifi_forget_ap(ap);
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to forget [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
+ else
+ printf("Success to forget [%s]\n", ap_name);
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool __test_found_eap_ap_callback(wifi_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ wifi_security_type_e type;
+
+ if (wifi_ap_get_security_type(ap, &type) == WIFI_ERROR_NONE)
+ printf("Security type : %d\n", type);
+ else
+ printf("Fail to get Security type\n");
+
+ if (type != WIFI_SECURITY_TYPE_EAP) {
+ g_free(ap_name);
+ return false;
+ }
+
+ char input_str1[100];
+ printf("Input user name for %s : ", ap_name);
+ rv = scanf("%99s", input_str1);
+
+ char input_str2[100];
+ printf("Input password for %s : ", ap_name);
+ rv = scanf("%99s", input_str2);
+
+ rv = wifi_ap_set_eap_passphrase(ap, input_str1, input_str2);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to set eap passphrase : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+
+ char *inputed_name = NULL;
+ bool is_pass_set;
+ rv = wifi_ap_get_eap_passphrase(ap, &inputed_name, &is_pass_set);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get eap passphrase : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+
+ printf("name : %s, is password set : %s\n", inputed_name, is_pass_set ? "TRUE" : "FALSE");
+
+ printf("Input certificate file:\n");
+ rv = scanf("%99s", input_str1);
+
+ rv = wifi_ap_set_eap_ca_cert_file(ap, input_str1);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to set eap certificatefile : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+
+ int input_int;
+ printf("Input EAP type:\n");
+ printf("0 -> WIFI_EAP_TYPE_PEAP\n");
+ printf("1 -> WIFI_EAP_TYPE_TLS\n");
+ printf("2 -> WIFI_EAP_TYPE_TTLS\n");
+ printf("3 -> WIFI_EAP_TYPE_SIM\n");
+ printf("4 -> WIFI_EAP_TYPE_AKA\n");
+ rv = scanf("%d", &input_int);
+
+ rv = wifi_ap_set_eap_type(ap, input_int);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to set eap type : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+
+ printf("Input EAP authentication type:\n");
+ printf("0 -> WIFI_EAP_AUTH_TYPE_NONE\n");
+ printf("1 -> WIFI_EAP_AUTH_TYPE_PAP\n");
+ printf("2 -> WIFI_EAP_AUTH_TYPE_MSCHAP\n");
+ printf("3 -> WIFI_EAP_AUTH_TYPE_MSCHAPV2\n");
+ printf("4 -> WIFI_EAP_AUTH_TYPE_GTC\n");
+ printf("5 -> WIFI_EAP_AUTH_TYPE_MD5\n");
+ rv = scanf("%d", &input_int);
+
+ rv = wifi_ap_set_eap_auth_type(ap, input_int);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to set eap auth type : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+
+ rv = wifi_connect(ap, __test_connected_callback, NULL);
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to connection request [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
+ else
+ printf("Success to connection request [%s]\n", ap_name);
+
+ g_free(ap_name);
+ g_free(inputed_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool test_get_user_int(const char *msg, int *num)
+{
+ if (msg == NULL || num == NULL)
+ return false;
+
+ int rv;
+ char buf[32] = {0,};
+ printf("%s\n", msg);
+ rv = read(0, buf, 32);
+
+ if (rv < 0 || *buf == 0 || *buf == '\n' || *buf == '\r')
+ return false;
+
+ *num = atoi(buf);
+ return true;
+}
+
+static bool __test_found_change_ip_method_callback(wifi_ap_h ap, void *user_data)
+{
+ int rv;
+ char *ap_name;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ wifi_ip_config_type_e type;
+ int method;
+ int address_type;
+
+ printf("Input new method type (1:dhcp, 2:manual, 3:auto) :\n");
+ rv = scanf("%9d", &method);
+ if (rv <= 0) {
+ g_free(ap_name);
+ return false;
+ }
+
+ rv = test_get_user_int("Input Address type to get"
+ "(0:IPV4, 1:IPV6):", &address_type);
+
+ if (rv == false || (address_type != 0 && address_type != 1)) {
+ printf("Invalid input!!\n");
+ return false;
+ }
+
+ switch (method) {
+ case 1:
+ type = WIFI_IP_CONFIG_TYPE_DYNAMIC;
+ break;
+ case 2:
+ type = WIFI_IP_CONFIG_TYPE_STATIC;
+ break;
+ case 3:
+ type = WIFI_IP_CONFIG_TYPE_AUTO;
+ break;
+ default:
+ printf("Invalid input!\n");
+ g_free(ap_name);
+ return false;
+ }
+
+ rv = wifi_ap_set_ip_config_type(ap, address_type, type);
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to set ip method type[%s]\n", __test_convert_error_to_string(rv));
+
+ if (type == WIFI_IP_CONFIG_TYPE_STATIC) {
+ char ip_addr[16];
+
+ printf("Input new ip address (x:skip, 0:clear) :\n");
+ rv = scanf("%15s", ip_addr);
+ if (rv > 0) {
+ switch (ip_addr[0]) {
+ case 'x':
+ rv = WIFI_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_ap_set_ip_address(ap, address_type, NULL);
+ break;
+ default:
+ rv = wifi_ap_set_ip_address(ap, address_type, ip_addr);
+ }
+
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to set ip address[%s]\n",
+ __test_convert_error_to_string(rv));
+ }
+
+ printf("Input new subnet mask (x:skip, 0:clear) :\n");
+ rv = scanf("%15s", ip_addr);
+ if (rv > 0) {
+ switch (ip_addr[0]) {
+ case 'x':
+ rv = WIFI_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_ap_set_subnet_mask(ap, address_type, NULL);
+ break;
+ default:
+ rv = wifi_ap_set_subnet_mask(ap, address_type, ip_addr);
+ }
+
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to set subnet mask[%s]\n",
+ __test_convert_error_to_string(rv));
+ }
+
+ printf("Input new gateway address (x:skip, 0:clear) :\n");
+ rv = scanf("%15s", ip_addr);
+ if (rv > 0) {
+ switch (ip_addr[0]) {
+ case 'x':
+ rv = WIFI_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_ap_set_gateway_address(ap, address_type, NULL);
+ break;
+ default:
+ rv = wifi_ap_set_gateway_address(ap, address_type, ip_addr);
+ }
+
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to set gateway address[%s]\n",
+ __test_convert_error_to_string(rv));
+ }
+ }
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool __test_found_change_proxy_method_callback(wifi_ap_h ap, void *user_data)
+{
+ int rv, address_type;
+ char *ap_name;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ printf("ap_name %s, user input name %s\n", ap_name, ap_name_part);
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ wifi_proxy_type_e type;
+ char proxy_addr[65];
+ int method;
+
+ printf("Input new method type (1:direct, 2:manual, 3:auto) :\n");
+ rv = scanf("%9d", &method);
+ if (rv <= 0) {
+ g_free(ap_name);
+ return false;
+ }
+
+ rv = test_get_user_int("Input Address type to get"
+ "(0:IPV4, 1:IPV6):", &address_type);
+
+ if (rv == false || (address_type != 0 && address_type != 1)) {
+ printf("Invalid input!!\n");
+ return false;
+ }
+
+ switch (method) {
+ case 1:
+ type = WIFI_PROXY_TYPE_DIRECT;
+ break;
+ case 2:
+ type = WIFI_PROXY_TYPE_MANUAL;
+ break;
+ case 3:
+ type = WIFI_PROXY_TYPE_AUTO;
+ break;
+ default:
+ printf("Invalid input!\n");
+ g_free(ap_name);
+ return false;
+ }
+
+ rv = wifi_ap_set_proxy_type(ap, type);
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to set proxy method type[%s]\n", __test_convert_error_to_string(rv));
+
+ printf("Input new proxy address (x:skip, 0:clear) :\n");
+ rv = scanf("%64s", proxy_addr);
+
+ if (rv > 0) {
+ switch (proxy_addr[0]) {
+ case 'x':
+ rv = WIFI_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_ap_set_proxy_address(ap, address_type, NULL);
+ break;
+ default:
+ rv = wifi_ap_set_proxy_address(ap, address_type, proxy_addr);
+ }
+
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to set proxy address[%s]\n", __test_convert_error_to_string(rv));
+ }
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool __test_found_print_ap_info_callback(wifi_ap_h ap, void *user_data)
+{
+ int rv, address_type = 0;
+ char *ap_name;
+ char *str_value;
+ int int_value;
+ wifi_connection_state_e conn_state;
+ wifi_ip_config_type_e ip_type;
+ wifi_proxy_type_e proxy_type;
+ wifi_security_type_e sec_type;
+ wifi_encryption_type_e enc_type;
+ wifi_eap_type_e eap_type;
+ wifi_eap_auth_type_e eap_auth_type;
+ bool bool_value;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ printf("ap_name %s, user input name %s\n", ap_name, ap_name_part);
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ /* Basic info */
+ printf("ESSID : %s\n", ap_name);
+
+ if (wifi_ap_get_bssid(ap, &str_value) == WIFI_ERROR_NONE) {
+ printf("BSSID : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get BSSID\n");
+
+ if (wifi_ap_get_rssi(ap, &int_value) == WIFI_ERROR_NONE)
+ printf("RSSI : %d\n", int_value);
+ else
+ printf("Fail to get RSSI\n");
+
+ if (wifi_ap_get_frequency(ap, &int_value) == WIFI_ERROR_NONE)
+ printf("Frequency : %d\n", int_value);
+ else
+ printf("Fail to get Frequency\n");
+
+ if (wifi_ap_get_max_speed(ap, &int_value) == WIFI_ERROR_NONE)
+ printf("Max speed : %d\n", int_value);
+ else
+ printf("Fail to get Max speed\n");
+
+ if (wifi_ap_is_favorite(ap, &bool_value) == WIFI_ERROR_NONE)
+ printf("Favorite : %s\n", bool_value ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get Favorite\n");
+
+ /* Network info */
+ if (wifi_ap_get_connection_state(ap, &conn_state) == WIFI_ERROR_NONE)
+ printf("Connection State : %d\n", conn_state);
+ else
+ printf("Fail to get Connection State\n");
+
+ rv = test_get_user_int("Input Address type to get"
+ "(0:IPV4, 1:IPV6):", &address_type);
+
+ if (rv == false || (address_type != 0 && address_type != 1)) {
+ printf("Invalid input!!\n");
+ return false;
+ }
+
+ if (wifi_ap_get_ip_config_type(ap, address_type, &ip_type) == WIFI_ERROR_NONE)
+ printf("IP config type : %d\n", ip_type);
+ else
+ printf("Fail to get IP config type\n");
+
+ if (wifi_ap_get_ip_address(ap, address_type, &str_value) == WIFI_ERROR_NONE) {
+ printf("IP : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get IP\n");
+
+ if (wifi_ap_get_subnet_mask(ap, address_type, &str_value) == WIFI_ERROR_NONE) {
+ printf("Subnet mask : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get Subnet mask\n");
+
+ if (wifi_ap_get_gateway_address(ap, address_type, &str_value) == WIFI_ERROR_NONE) {
+ printf("Gateway : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get Gateway\n");
+
+ if (wifi_ap_get_proxy_type(ap, &proxy_type) == WIFI_ERROR_NONE)
+ printf("Proxy type : %d\n", proxy_type);
+ else
+ printf("Fail to get Proxy type\n");
+
+ if (wifi_ap_get_proxy_address(ap, address_type, &str_value) == WIFI_ERROR_NONE) {
+ printf("Proxy : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get Proxy\n");
+
+ if (wifi_ap_get_dns_address(ap, 1, address_type, &str_value) == WIFI_ERROR_NONE) {
+ printf("DNS1 : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get DNS1\n");
+
+ if (wifi_ap_get_dns_address(ap, 2, address_type, &str_value) == WIFI_ERROR_NONE) {
+ printf("DNS2 : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get DNS2\n");
+
+ /* Security info */
+ if (wifi_ap_get_security_type(ap, &sec_type) == WIFI_ERROR_NONE)
+ printf("Security type : %d\n", sec_type);
+ else
+ printf("Fail to get Security type\n");
+
+ if (wifi_ap_get_encryption_type(ap, &enc_type) == WIFI_ERROR_NONE)
+ printf("Encryption type : %d\n", enc_type);
+ else
+ printf("Fail to get Encryption type\n");
+
+ if (wifi_ap_is_passphrase_required(ap, &bool_value) == WIFI_ERROR_NONE)
+ printf("Passphrase required : %s\n", bool_value ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get Passphrase required\n");
+
+ if (wifi_ap_is_wps_supported(ap, &bool_value) == WIFI_ERROR_NONE)
+ printf("WPS supported : %s\n", bool_value ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get WPS supported\n");
+
+ if (sec_type != WIFI_SECURITY_TYPE_EAP) {
+ g_free(ap_name);
+ return false;
+ }
+
+ /* EAP info */
+ if (wifi_ap_get_eap_type(ap, &eap_type) == WIFI_ERROR_NONE)
+ printf("EAP type : %d\n", eap_type);
+ else
+ printf("Fail to get EAP type\n");
+
+ if (wifi_ap_get_eap_auth_type(ap, &eap_auth_type) == WIFI_ERROR_NONE)
+ printf("EAP auth type : %d\n", eap_auth_type);
+ else
+ printf("Fail to get EAP auth type\n");
+
+ if (wifi_ap_get_eap_passphrase(ap, &str_value, &bool_value) == WIFI_ERROR_NONE) {
+ printf("EAP user name : %s\n", str_value);
+ printf("EAP is password setted : %s\n", bool_value ? "TRUE" : "FALSE");
+ g_free(str_value);
+ } else
+ printf("Fail to get EAP passphrase(user name/password)\n");
+
+ if (wifi_ap_get_eap_ca_cert_file(ap, &str_value) == WIFI_ERROR_NONE) {
+ printf("EAP ca cert file : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get EAP ca cert file\n");
+
+ if (wifi_ap_get_eap_client_cert_file(ap, &str_value) == WIFI_ERROR_NONE) {
+ printf("EAP client cert file : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get EAP client cert file\n");
+
+ if (wifi_ap_get_eap_private_key_file(ap, &str_value) == WIFI_ERROR_NONE) {
+ printf("EAP private key file : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get EAP private key file\n");
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool _test_config_list_cb(const wifi_config_h config, void *user_data)
+{
+ gchar *name = NULL;
+ wifi_security_type_e security_type;
+
+ wifi_config_get_name(config, &name);
+ wifi_config_get_security_type(config, &security_type);
+
+ printf("Name[%s] ", name);
+ printf("Security type[%d] ", security_type);
+ if (security_type == WIFI_SECURITY_TYPE_EAP) {
+ wifi_eap_type_e eap_type;
+ wifi_eap_auth_type_e eap_auth_type;
+ wifi_config_get_eap_type(config, &eap_type);
+ printf("Eap type[%d] ", eap_type);
+ wifi_config_get_eap_auth_type(config, &eap_auth_type);
+ printf("Eap auth type[%d]", eap_auth_type);
+ }
+ printf("\n");
+
+ g_free(name);
+
+ return true;
+}
+
+struct _wifi_conf {
+ char name[33];
+ int type;
+};
+static bool _test_config_list_cb_for_remove(const wifi_config_h config, void *user_data)
+{
+
+ struct _wifi_conf *c = (struct _wifi_conf *)user_data;
+ gchar *name = NULL;
+ wifi_security_type_e security_type;
+
+ wifi_config_get_name(config, &name);
+ wifi_config_get_security_type(config, &security_type);
+
+ if (strncmp(name, c->name, sizeof(c->name)) == 0 && security_type == c->type) {
+ int rv = wifi_config_remove(config);
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to remove configurations [%s]\n", __test_convert_error_to_string(rv));
+ else
+ printf("Success to remove configuration [%s]\n", name);
+ g_free(name);
+ return false;
+ }
+
+ g_free(name);
+ return true;
+}
+
+static bool __test_found_specific_aps_callback(wifi_ap_h ap, void *user_data)
+{
+ printf("Found specific ap Completed\n");
+
+ int rv;
+ char *ap_name = NULL;
+ wifi_security_type_e security_type = WIFI_SECURITY_TYPE_NONE;
+
+ rv = wifi_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ printf("[AP name] : %s\n", ap_name);
+
+ rv = wifi_ap_get_security_type(ap, &security_type);
+ if (rv == WIFI_ERROR_NONE)
+ printf("[Security type] : %d\n", security_type);
+ else {
+ printf("Fail to get Security type\n");
+ g_free(ap_name);
+ return false;
+ }
+
+ switch (security_type) {
+ case WIFI_SECURITY_TYPE_WEP:
+ case WIFI_SECURITY_TYPE_WPA_PSK:
+ case WIFI_SECURITY_TYPE_WPA2_PSK:
+ {
+ char passphrase[100];
+ printf("Input passphrase for %s : ", ap_name);
+ rv = scanf("%99s", passphrase);
+
+ rv = wifi_ap_set_passphrase(ap, passphrase);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to set passphrase : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+ }
+ break;
+ case WIFI_SECURITY_TYPE_EAP:
+ {
+ char input_str1[100];
+ printf("Input user name for %s : ", ap_name);
+ rv = scanf("%99s", input_str1);
+
+ char input_str2[100];
+ printf("Input password for %s : ", ap_name);
+ rv = scanf("%99s", input_str2);
+
+ rv = wifi_ap_set_eap_passphrase(ap, input_str1, input_str2);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to set eap passphrase : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+
+ char *inputed_name = NULL;
+ bool is_pass_set;
+ rv = wifi_ap_get_eap_passphrase(ap, &inputed_name, &is_pass_set);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get eap passphrase : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+
+ printf("name : %s, is password set : %s\n", inputed_name, is_pass_set ? "TRUE" : "FALSE");
+ g_free(inputed_name);
+ }
+ break;
+ case WIFI_SECURITY_TYPE_NONE:
+ default:
+ break;
+ }
+
+ rv = wifi_connect(ap, __test_connected_callback, NULL);
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to connection request [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
+ else
+ printf("Success to connection request [%s]\n", ap_name);
+
+ g_free(ap_name);
+ return true;
+}
+
+static void __test_scan_specific_ap_callback(wifi_error_e error_code, void* user_data)
+{
+ int rv;
+
+ printf("Specific scan Completed from scan request, error code : %s\n",
+ __test_convert_error_to_string(error_code));
+
+ if (error_code != WIFI_ERROR_NONE)
+ return;
+
+ rv = wifi_foreach_found_specific_aps(__test_found_specific_aps_callback, user_data);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get specific AP(can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return;
+ }
+}
+
+int test_wifi_init(void)
+{
+ int rv = wifi_initialize();
+
+ if (rv == WIFI_ERROR_NONE) {
+ wifi_set_device_state_changed_cb(__test_device_state_callback, NULL);
+ wifi_set_background_scan_cb(__test_bg_scan_completed_callback, NULL);
+ wifi_set_connection_state_changed_cb(__test_connection_state_callback, NULL);
+ wifi_set_rssi_level_changed_cb(__test_rssi_level_callback, NULL);
+ } else {
+ printf("Wifi init failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Wifi init succeeded\n");
+ return 1;
+}
+
+int test_wifi_deinit(void)
+{
+ int rv = 0;
+
+ rv = wifi_deinitialize();
+
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Wifi deinit failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Wifi deinit succeeded\n");
+ return 1;
+}
+
+int test_wifi_activate(void)
+{
+ int rv = 0;
+
+ bool state = false;
+
+ rv = wifi_is_activated(&state);
+
+ if (state != true) {
+ rv = wifi_activate(__test_activated_callback, NULL);
+
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to activate Wi-Fi device [%s]", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ } else {
+ __test_activated_callback(WIFI_ERROR_NONE, NULL);
+ }
+
+ return 1;
+}
+
+int test_wifi_deactivate(void)
+{
+ int rv = 0;
+ bool state = false;
+
+ rv = wifi_is_activated(&state);
+
+ if (state == true) {
+ rv = wifi_deactivate(__test_deactivated_callback, NULL);
+
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to deactivate Wi-Fi device [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ } else {
+ __test_deactivated_callback(WIFI_ERROR_NONE, NULL);
+ }
+
+ return 1;
+}
+
+int test_is_activated(void)
+{
+ int rv = 0;
+ bool state = false;
+
+ rv = wifi_is_activated(&state);
+
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get Wi-Fi device state [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Success to get Wi-Fi device state : %s\n", (state) ? "TRUE" : "FALSE");
+
+ return 1;
+}
+
+int test_get_connection_state(void)
+{
+ int rv = 0;
+ wifi_connection_state_e connection_state;
+
+ rv = wifi_get_connection_state(&connection_state);
+
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get connection state [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Success to get connection state : ");
+ switch (connection_state) {
+ case WIFI_CONNECTION_STATE_ASSOCIATION:
+ printf("Association\n");
+ break;
+ case WIFI_CONNECTION_STATE_CONNECTED:
+ printf("Connected\n");
+ break;
+ case WIFI_CONNECTION_STATE_CONFIGURATION:
+ printf("Configuration\n");
+ break;
+ case WIFI_CONNECTION_STATE_DISCONNECTED:
+ printf("Disconnected\n");
+ break;
+ default:
+ printf("Unknown\n");
+ }
+
+ return 1;
+}
+
+int test_get_mac_address(void)
+{
+ int rv = 0;
+ char *mac_addr = NULL;
+
+ rv = wifi_get_mac_address(&mac_addr);
+
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get MAC address [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("MAC address : %s\n", mac_addr);
+ g_free(mac_addr);
+
+ return 1;
+}
+
+int test_get_interface_name(void)
+{
+ int rv = 0;
+ char *if_name = NULL;
+
+ rv = wifi_get_network_interface_name(&if_name);
+
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get Interface name [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Interface name : %s\n", if_name);
+ g_free(if_name);
+
+ return 1;
+}
+
+int test_scan_request(void)
+{
+ int rv = 0;
+
+ rv = wifi_scan(__test_scan_request_callback, NULL);
+
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Scan request failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Scan request succeeded\n");
+
+ return 1;
+}
+
+int test_get_connected_ap(void)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ wifi_ap_h ap_h;
+
+ rv = wifi_get_connected_ap(&ap_h);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get connected AP [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ rv = wifi_ap_get_essid(ap_h, &ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get essid [%s]\n", __test_convert_error_to_string(rv));
+ wifi_ap_destroy(ap_h);
+ return -1;
+ }
+
+ printf("Connected AP : %s\n", ap_name);
+ g_free(ap_name);
+ wifi_ap_destroy(ap_h);
+
+ return 1;
+}
+
+int test_foreach_found_aps(void)
+{
+ int rv = 0;
+
+ rv = wifi_foreach_found_aps(__test_found_ap_callback, NULL);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get AP list [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Get AP list finished\n");
+
+ return 1;
+}
+
+int test_connect_ap(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_is_activated(&state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to connect : ");
+ rv = scanf("%32s", ap_name);
+
+ rv = wifi_foreach_found_aps(__test_found_connect_ap_callback, ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to connect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Connection step finished\n");
+ return 1;
+}
+
+int test_connect_specific_ap(void)
+{
+ int rv;
+ char ap_name[33];
+
+ printf("Input a part of specific AP name to connect : ");
+ rv = scanf("%32s", ap_name);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_scan_specific_ap(ap_name, __test_scan_specific_ap_callback, NULL);
+
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Scan request failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Scan specific AP request succeeded\n");
+ return 1;
+}
+
+int test_disconnect_ap(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_is_activated(&state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to disconnect : ");
+ rv = scanf("%32s", ap_name);
+
+ rv = wifi_foreach_found_aps(__test_found_disconnect_ap_callback, ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to disconnect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Disconnection step finished\n");
+ return 1;
+}
+
+int test_connect_wps(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_is_activated(&state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to connect by wps : ");
+ rv = scanf("%32s", ap_name);
+
+ rv = wifi_foreach_found_aps(__test_found_connect_wps_callback, ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to connect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Connection step finished\n");
+ return 1;
+}
+
+int test_forget_ap(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_is_activated(&state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to forget : ");
+ rv = scanf("%32s", ap_name);
+
+ rv = wifi_foreach_found_aps(__test_found_forget_ap_callback, ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to forget (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Forget AP finished\n");
+ return 1;
+}
+
+int test_connect_eap_ap(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_is_activated(&state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to connect : ");
+ rv = scanf("%32s", ap_name);
+
+ rv = wifi_foreach_found_aps(__test_found_eap_ap_callback, ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to connect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Connection step finished\n");
+ return 1;
+}
+
+int test_set_ip_method(void)
+{
+ int rv;
+ char ap_name[33];
+ bool state;
+
+ rv = wifi_is_activated(&state);
+ if (rv != WIFI_ERROR_NONE || state == false)
+ return -1;
+
+ printf("Input a part of AP name to change IP method : ");
+ rv = scanf("%32s", ap_name);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_foreach_found_aps(__test_found_change_ip_method_callback, ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to change (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("IP method changing finished\n");
+ return 1;
+}
+
+int test_set_proxy_method(void)
+{
+ int rv;
+ char ap_name[33];
+ bool state;
+
+ rv = wifi_is_activated(&state);
+ if (rv != WIFI_ERROR_NONE || state == false)
+ return -1;
+
+ printf("Input a part of AP name to change Proxy method : ");
+ rv = scanf("%32s", ap_name);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_foreach_found_aps(__test_found_change_proxy_method_callback, ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to change (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Proxy method changing finished\n");
+ return 1;
+}
+
+int test_get_ap_info(void)
+{
+ int rv;
+ char ap_name[33];
+ bool state;
+
+ rv = wifi_is_activated(&state);
+ if (rv != WIFI_ERROR_NONE || state == false)
+ return -1;
+
+ printf("Input a part of AP name to get detailed info : ");
+ rv = scanf("%32s", ap_name);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_foreach_found_aps(__test_found_print_ap_info_callback, ap_name);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get AP info (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("AP info printing finished\n");
+ return 1;
+}
+
+int test_load_configuration(void)
+{
+ int rv;
+
+ rv = wifi_config_foreach_configuration(_test_config_list_cb, NULL);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get configurations [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
+int test_save_configuration(void)
+{
+ int rv;
+ char name[33] = { 0, };
+ char passphrase[100] = { 0, };
+ int type = 0;
+ wifi_config_h config;
+
+ printf("Input AP configuration\n");
+ printf("Name : ");
+ rv = scanf("%32s", name);
+ if (rv <= 0)
+ return -1;
+
+ printf("Passphrase : ");
+ rv = scanf("%99s", passphrase);
+ if (rv <= 0)
+ return -1;
+
+ printf("Security type(None(0), WEP(1), WPA-PSK(2), EAP(4) : ");
+ rv = scanf("%d", &type);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_config_create(name, passphrase, type, &config);
+ if (rv != WIFI_ERROR_NONE)
+ return -1;
+
+ rv = wifi_config_save_configuration(config);
+ if (rv != WIFI_ERROR_NONE)
+ return -1;
+
+ rv = wifi_config_destroy(config);
+ if (rv != WIFI_ERROR_NONE)
+ return -1;
+
+ return 1;
+}
+
+int test_remove_configuration(void)
+{
+ int rv;
+ struct _wifi_conf c;
+
+ printf("Input AP configuration\n");
+ printf("Name : ");
+ rv = scanf("%32s", c.name);
+ if (rv <= 0)
+ return -1;
+
+ printf("Security type(None(0), WEP(1), WPA-PSK(2), EAP(4) : ");
+ rv = scanf("%d", &c.type);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_config_foreach_configuration(_test_config_list_cb_for_remove, &c);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to get configurations [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
+int test_set_configuration_proxy_and_hidden(void)
+{
+ int rv;
+ char name[33] = { 0, };
+ char passphrase[100] = { 0, };
+ int type = 0;
+ char proxy[100] = { 0, };
+ int hidden = 0;
+ wifi_config_h config;
+
+ printf("Input AP configuration\n");
+ printf("Name : ");
+ rv = scanf("%32s", name);
+ if (rv <= 0)
+ return -1;
+
+ printf("Passphrase : ");
+ rv = scanf("%99s", passphrase);
+ if (rv <= 0)
+ return -1;
+
+ printf("Security type(None(0), WEP(1), WPA-PSK(2), EAP(4) : ");
+ rv = scanf("%d", &type);
+ if (rv <= 0)
+ return -1;
+
+ printf("Proxy(server:port) : ");
+ rv = scanf("%99s", proxy);
+ if (rv <= 0)
+ return -1;
+
+ printf("Hidden(1:Hidden) : ");
+ rv = scanf("%d", &hidden);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_config_create(name, passphrase, type, &config);
+ if (rv != WIFI_ERROR_NONE)
+ return -1;
+
+ rv = wifi_config_save_configuration(config);
+ if (rv != WIFI_ERROR_NONE) {
+ wifi_config_destroy(config);
+ return -1;
+ }
+
+ rv = wifi_config_set_proxy_address(config, WIFI_ADDRESS_FAMILY_IPV4, proxy);
+ if (rv != WIFI_ERROR_NONE) {
+ wifi_config_destroy(config);
+ return -1;
+ }
+
+ if (hidden == 1)
+ rv = wifi_config_set_hidden_ap_property(config, TRUE);
+ else
+ rv = wifi_config_set_hidden_ap_property(config, FALSE);
+ if (rv != WIFI_ERROR_NONE) {
+ wifi_config_destroy(config);
+ return -1;
+ }
+
+ rv = wifi_config_destroy(config);
+ if (rv != WIFI_ERROR_NONE)
+ return -1;
+
+ return 1;
+}
+
+int test_set_eap_configuration(void)
+{
+ int rv;
+ char name[33] = { 0, };
+ char passphrase[100] = { 0, };
+ int type = WIFI_SECURITY_TYPE_EAP;
+ wifi_config_h config;
+
+ printf("Input EAP configuration\n");
+ printf("Name : ");
+ rv = scanf("%32s", name);
+ if (rv <= 0)
+ return -1;
+
+ printf("Passphrase : ");
+ rv = scanf("%99s", passphrase);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_config_create(name, passphrase, type, &config);
+ if (rv != WIFI_ERROR_NONE)
+ return -1;
+
+ rv = wifi_config_save_configuration(config);
+ if (rv != WIFI_ERROR_NONE)
+ return -1;
+
+ rv = wifi_config_set_eap_type(config, WIFI_EAP_TYPE_TLS);
+ if (rv != WIFI_ERROR_NONE)
+ return -1;
+
+ rv = wifi_config_set_eap_auth_type(config, WIFI_EAP_AUTH_TYPE_MD5);
+ if (rv != WIFI_ERROR_NONE)
+ return -1;
+
+ rv = wifi_config_destroy(config);
+ if (rv != WIFI_ERROR_NONE)
+ return -1;
+
+ return 1;
+}
+
+int test_wifi_tdls_disconnect(void)
+{
+ int rv = 0;
+
+ char peer_mac[18];
+ printf("Enter Mac_address: ");
+ if (scanf(" %17s", peer_mac) < 1)
+ return -1;
+
+ if (strlen(peer_mac) > 17) {
+ printf("Wrong Mac_address\n");
+ return -1;
+ }
+
+ rv = wifi_tdls_disconnect(peer_mac);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("test_wifi_tdls_disconnect() is failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ return 1;
+}
+
+int test_wifi_tdls_get_connected_peer(void)
+{
+ int rv = 0;
+ char *mac_addr = NULL;
+
+ rv = wifi_tdls_get_connected_peer(&mac_addr);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("wifi_tdls_get_connected_peer() is failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ printf("Peer Mac address is [%s]\n", mac_addr);
+ g_free(mac_addr);
+ return 1;
+}
+
+int test_wifi_connect_specific_ap(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ char passphrase[65];
+ bool state = false;
+ int sec_type;
+
+ wifi_is_activated(&state);
+ if (state == false)
+ return -1;
+
+ printf("Input hidden AP name to connect : ");
+ rv = scanf("%32s", ap_name);
+ printf("Input Security Type :\n");
+ printf("0 -> WIFI_SECURITY_TYPE_NONE\n");
+ printf("1 -> WIFI_SECURITY_TYPE_WEP\n");
+ printf("2 -> WIFI_SECURITY_TYPE_WPA_PSK/WIFI_SECURITY_TYPE_WPA2_PSK\n");
+ rv = scanf("%d", &sec_type);
+ if (sec_type == 1 || sec_type == 2) {
+ printf("Input hidden AP passphrase : ");
+ rv = scanf("%64s", passphrase);
+ }
+
+ rv = wifi_connect_specific_ap(ap_name, sec_type, passphrase,
+ __test_connected_callback, NULL);
+ if (rv != WIFI_ERROR_NONE) {
+ printf("Fail to connect to hidden AP [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Hidden Connection step finished\n");
+ return 1;
+}
+
+int main(int argc, char **argv)
+{
+ GMainLoop *mainloop;
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
+#endif
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ GIOChannel *channel = g_io_channel_unix_new(0);
+ g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread, NULL);
+
+ printf("Test Thread created...\n");
+
+ g_main_loop_run(mainloop);
+
+ return 0;
+}
+
+gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
+{
+ int rv;
+ char a[10];
+
+ printf("Event received from stdin\n");
+
+ rv = read(0, a, 10);
+
+ if (rv <= 0 || a[0] == '0') {
+ rv = wifi_deinitialize();
+
+ if (rv != WIFI_ERROR_NONE)
+ printf("Fail to deinitialize.\n");
+
+ exit(1);
+ }
+
+ if (a[0] == '\n' || a[0] == '\r') {
+ printf("\n\n Network Connection API Test App\n\n");
+ printf("Options..\n");
+ printf(LOG_GREEN "1 - Wi-Fi init and set callbacks\n" LOG_END);
+ printf("2 - Wi-Fi deinit(unset callbacks automatically)\n");
+ printf(LOG_GREEN "3 - Activate Wi-Fi device\n" LOG_END);
+ printf("4 - Deactivate Wi-Fi device\n");
+ printf("5 - Is Wi-Fi activated?\n");
+ printf("6 - Get connection state\n");
+ printf("7 - Get MAC address\n");
+ printf("8 - Get Wi-Fi interface name\n");
+ printf(LOG_GREEN "9 - Scan request\n" LOG_END);
+ printf("a - Get Connected AP\n");
+ printf("b - Get AP list\n");
+ printf(LOG_GREEN "c - Connect\n" LOG_END);
+ printf("d - Disconnect\n");
+ printf("e - Connect by wps pbc\n");
+ printf("f - Forget an AP\n");
+ printf("g - Set & connect EAP\n");
+ printf("h - Set IP method type\n");
+ printf("i - Set Proxy method type\n");
+ printf("j - Get Ap info\n");
+ printf("k - Connect Specific AP\n");
+ printf("l - Load configuration\n");
+ printf("m - Save configuration\n");
+ printf("n - Remove configuration\n");
+ printf("o - Set configuration proxy and hidden\n");
+ printf("p - Set EAP configuration\n");
+ printf("q - TDLS TearDown\n");
+ printf("r - TDLS Get Connected Peer\n");
+ printf("s - Connect to Hidden AP\n");
+ printf(LOG_RED "0 - Exit \n" LOG_END);
+
+ printf("ENTER - Show options menu.......\n");
+ }
+
+ switch (a[0]) {
+ case '1':
+ rv = test_wifi_init();
+ break;
+ case '2':
+ rv = test_wifi_deinit();
+ break;
+ case '3':
+ rv = test_wifi_activate();
+ break;
+ case '4':
+ rv = test_wifi_deactivate();
+ break;
+ case '5':
+ rv = test_is_activated();
+ break;
+ case '6':
+ rv = test_get_connection_state();
+ break;
+ case '7':
+ rv = test_get_mac_address();
+ break;
+ case '8':
+ rv = test_get_interface_name();
+ break;
+ case '9':
+ rv = test_scan_request();
+ break;
+ case 'a':
+ rv = test_get_connected_ap();
+ break;
+ case 'b':
+ rv = test_foreach_found_aps();
+ break;
+ case 'c':
+ rv = test_connect_ap();
+ break;
+ case 'd':
+ rv = test_disconnect_ap();
+ break;
+ case 'e':
+ rv = test_connect_wps();
+ break;
+ case 'f':
+ rv = test_forget_ap();
+ break;
+ case 'g':
+ rv = test_connect_eap_ap();
+ break;
+ case 'h':
+ rv = test_set_ip_method();
+ break;
+ case 'i':
+ rv = test_set_proxy_method();
+ break;
+ case 'j':
+ rv = test_get_ap_info();
+ break;
+ case 'k':
+ rv = test_connect_specific_ap();
+ break;
+ case 'l':
+ rv = test_load_configuration();
+ break;
+ case 'm':
+ rv = test_save_configuration();
+ break;
+ case 'n':
+ rv = test_remove_configuration();
+ break;
+ case 'o':
+ rv = test_set_configuration_proxy_and_hidden();
+ break;
+ case 'p':
+ rv = test_set_eap_configuration();
+ break;
+ case 'q':
+ rv = test_wifi_tdls_disconnect();
+ break;
+ case 'r':
+ rv = test_wifi_tdls_get_connected_peer();
+ break;
+ case 's':
+ rv = test_wifi_connect_specific_ap();
+ break;
+ default:
+ break;
+ }
+
+ if (rv == 1)
+ printf("Operation succeeded!\n");
+ else
+ printf("Operation failed!\n");
+
+ return TRUE;
+}
+