Add ranging test to wifi-aware-subscribe-test
authorCheoleun Moon <chleun.moon@samsung.com>
Mon, 6 Apr 2020 08:11:43 +0000 (17:11 +0900)
committerCheoleun Moon <chleun.moon@samsung.com>
Mon, 6 Apr 2020 08:11:43 +0000 (17:11 +0900)
test/wifi-aware-subscribe-test.c

index 84d86ad..bc197e6 100644 (file)
@@ -95,6 +95,8 @@ enum {
        CMD_PSK_ACTIVE,
        CMD_PSK_PASSIVE2,
        CMD_PSK_ACTIVE2,
+       CMD_OPEN_PASSIVE_RANGING,
+       CMD_OPEN_ACTIVE_RANGING,
 
        CMD_INVALID,
 };
@@ -116,12 +118,18 @@ static char *g_menu_str[] = {
                = "PSK + Passive (Wrong password)",
        [CMD_PSK_ACTIVE2]
                = "PSK + Active (Wrong password)",
+       [CMD_OPEN_PASSIVE_RANGING]
+               = "Open + Passive + Ranging",
+       [CMD_OPEN_ACTIVE_RANGING]
+               = "Open + Active + Ranging",
        [CMD_INVALID]
                = NULL,
 };
 
 static GMainLoop *g_main_loop_p;
 static bool g_initialized = false;
+static int g_min_distance = -1;
+static int g_max_distance = -1;
 
 static wifi_aware_session_h g_wifi_aware_session = NULL;
 static wifi_aware_subscribe_h g_subscribe_handle = NULL;
@@ -453,6 +461,26 @@ static bool __set_subscribe_config(wifi_aware_subscribe_h subscribe)
                return false;
        }
 
+       if (g_min_distance > 0) {
+               ret = wifi_aware_subscribe_set_min_distance(subscribe, g_min_distance);
+               if (ret == WIFI_AWARE_ERROR_NONE) {
+                       printf("min distance: %d", g_min_distance);
+               }
+               else {
+                       printf("Fail to set min distance\n");
+                       return false;
+               }
+       }
+       if (g_max_distance > 0) {
+               ret = wifi_aware_subscribe_set_max_distance(subscribe, g_max_distance);
+               if (ret == WIFI_AWARE_ERROR_NONE) {
+                       printf("max distance: %d", g_max_distance);
+               }
+               else {
+                       printf("Fail to set max distance\n");
+                       return false;
+               }
+       }
        return true;
 }
 
@@ -581,6 +609,26 @@ void test_psk_active2()
        run_common();
 }
 
+void test_open_passive_ranging()
+{
+       clear_resources();
+       g_sub_type = WIFI_AWARE_SUBSCRIBE_TYPE_PASSIVE;
+       g_security_type = WIFI_AWARE_SECURITY_TYPE_OPEN;
+       g_min_distance = 0;
+       g_max_distance = 10;
+       run_common();
+}
+
+void test_open_active_ranging()
+{
+       clear_resources();
+       g_sub_type = WIFI_AWARE_SUBSCRIBE_TYPE_ACTIVE;
+       g_security_type = WIFI_AWARE_SECURITY_TYPE_OPEN;
+       g_min_distance = 0;
+       g_max_distance = 10;
+       run_common();
+}
+
 void test_init()
 {
        int ret = 0;
@@ -601,6 +649,8 @@ test_func g_menu_func[] = {
        [CMD_PSK_ACTIVE]                = test_psk_active,
        [CMD_PSK_PASSIVE2]              = test_psk_passive2,
        [CMD_PSK_ACTIVE2]               = test_psk_active2,
+       [CMD_OPEN_PASSIVE_RANGING]              = test_open_passive_ranging,
+       [CMD_OPEN_ACTIVE_RANGING]               = test_open_active_ranging,
 
        [CMD_INVALID]                   = NULL,
 };