static __thread struct _profile_list_s profile_iterator = { 0, NULL };
static __thread struct _profile_list_s specific_profile_iterator = {0, NULL};
static __thread char specific_profile_essid[NET_WLAN_ESSID_LEN + 1] = { 0, };
-static __thread bool is_feature_checked = false;
-static __thread bool feature_supported = false;
static __thread GSList *managed_idler_list = NULL;
static __thread bool wifi_is_feature_checked[WIFI_SUPPORTED_FEATURE_MAX] = {0, };
static __thread bool wifi_feature_supported[WIFI_SUPPORTED_FEATURE_MAX] = {0, };
int _wifi_libnet_get_wifi_state(wifi_connection_state_e *connection_state)
{
- wifi_dbus *dbus_h = NULL;
- GError *error = NULL;
- GVariant *result = NULL;
- gint state = 0;
-
- dbus_h = _wifi_get_dbus_handle();
- if (dbus_h == NULL) {
- WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
- return WIFI_ERROR_INVALID_OPERATION;
- }
+ int rv;
+ net_wifi_state_t wlan_state = 0;
- result = g_dbus_connection_call_sync(dbus_h->dbus_conn,
- NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH,
- NETCONFIG_IWIFI,
- "GetWifiState",
- g_variant_new("()"),
- NULL, G_DBUS_CALL_FLAGS_NONE,
- DBUS_REPLY_TIMEOUT, dbus_h->ca,
- &error);
-
- if (error) {
- WIFI_LOG(WIFI_ERROR, "Fail to GetWifiState [%d: %s]", error->code, error->message);
- g_error_free(error);
+ rv = net_get_wifi_state(&wlan_state);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied");
+ return WIFI_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state");
return WIFI_ERROR_OPERATION_FAILED;
}
- if (result != NULL) {
- g_variant_get(result, "(i)", &state);
- g_variant_unref(result);
+ switch (wlan_state) {
+ case WIFI_OFF:
+ case WIFI_ON:
+ *connection_state = WIFI_CONNECTION_STATE_DISCONNECTED;
+ break;
+ case WIFI_ASSOCIATION:
+ *connection_state = WIFI_CONNECTION_STATE_ASSOCIATION;
+ break;
+ case WIFI_CONFIGURATION:
+ *connection_state = WIFI_CONNECTION_STATE_CONFIGURATION;
+ break;
+ case WIFI_CONNECTED:
+ *connection_state = WIFI_CONNECTION_STATE_CONNECTED;
+ break;
+ case WIFI_DISCONNECTING:
+ *connection_state = WIFI_CONNECTION_STATE_CONNECTED;
+ break;
+ default:
+ WIFI_LOG(WIFI_ERROR, "Unknown state");
+ return WIFI_ERROR_OPERATION_FAILED;
}
- *connection_state = state;
-
return WIFI_ERROR_NONE;
}
else if (strcmp(key, WIFI_TDLS_FEATURE) == 0)
value = __libnet_check_feature_supported(key, WIFI_SUPPORTED_FEATURE_WIFI_TDLS);
- SECURE_WIFI_LOG(WIFI_INFO, "%s feature is %s", key, (value ? "true" : "false"));
feature_supported |= value;
key = va_arg(list, const char *);
if (!key) break;
#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);
if (a[0] == '\n' || a[0] == '\r') {
printf("\n\n Network Connection API Test App\n\n");
printf("Options..\n");
- printf("1 - Wi-Fi init and set callbacks\n");
+ printf(LOG_GREEN "1 - Wi-Fi init and set callbacks\n" LOG_END);
printf("2 - Wi-Fi deinit(unset callbacks automatically)\n");
- printf("3 - Activate Wi-Fi device\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("9 - Scan request\n");
+ printf(LOG_GREEN "9 - Scan request\n" LOG_END);
printf("a - Get Connected AP\n");
printf("b - Get AP list\n");
- printf("c - Connect\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("o - Set EAP configuration\n");
printf("p - TDLS TearDown\n");
printf("q - TDLS Get Connected Peer\n");
- printf("0 - Exit \n");
+ printf(LOG_RED "0 - Exit \n" LOG_END);
printf("ENTER - Show options menu.......\n");
}