nan-plugin: add NAN init/deinit 84/261884/3
authorCheoleun Moon <chleun.moon@samsung.com>
Wed, 28 Jul 2021 07:18:44 +0000 (16:18 +0900)
committercheoleun moon <chleun.moon@samsung.com>
Mon, 30 Aug 2021 07:52:49 +0000 (07:52 +0000)
Change-Id: I8c342786e9908a5a25ef80526036afd203ff4cd3
Signed-off-by: Cheoleun Moon <chleun.moon@samsung.com>
plugins/nan/nan-plugin.cpp
tests/vine-test/vine-test-glib.cpp

index ef108e864e490eb304d528f48671e16e9f65823b..8393d614924e9e31314a1cb9286ceee816d41583 100755 (executable)
@@ -224,7 +224,14 @@ vine_disc_error nan_cancel_resolve_ip(void *plugin_handle)
 
 vine_disc_error nan_init(void **plugin_handle, void *disc_handle)
 {
+       int ret = wifi_aware_initialize();
+       if (ret != WIFI_AWARE_ERROR_NONE && ret != WIFI_AWARE_ERROR_ALREADY_INITIALIZED) {
+               VINE_LOGE("wifi_aware_initialize() fails");
+               return __convert_nan_error_to_vine_disc_error(ret);
+       }
+
        vine_nan_s *handle = new vine_nan_s;
+       VINE_LOGD("Create plugin_handle[%p]", handle);
 
        handle->disc_handle = disc_handle;
        handle->publish_config = nullptr;
@@ -233,6 +240,7 @@ vine_disc_error nan_init(void **plugin_handle, void *disc_handle)
 
        handle->port = -1;
 
+       *plugin_handle = handle;
        // NAN will be enabled when publish() or subscribe()
        // because enable function works asynchronously.
 
@@ -250,6 +258,7 @@ void nan_deinit(void *plugin_handle)
        // , and if NAN data path is broken or not when NAN is disabled.
 
        delete nan_handle;
+       wifi_aware_deinitialize();
 }
 
 static void __published_cb(wifi_aware_session_h session,
@@ -383,9 +392,12 @@ static void __subscribe_failed(vine_nan_s *nan_handle)
 static void __subscribed_cb(wifi_aware_session_h session,
        wifi_aware_error_e error, void *user_data)
 {
-       RET_IF(error == WIFI_AWARE_ERROR_NONE, "No error");
+       if (error == WIFI_AWARE_ERROR_NONE) {
+               VINE_LOGD("No error");
+               return;
+       }
 
-       VINE_LOGE("Fails to subscribe. error: %s", __convert_nan_error_to_vine_disc_error(error));
+       VINE_LOGE("Fails to subscribe. error: %d", __convert_nan_error_to_vine_disc_error(error));
        __subscribe_failed((vine_nan_s *)user_data);
 }
 
index b973466aa76bbf791caf573a5de5da05969ef050..163e20443795e3f5fa5fea9a0fac3959c8154471 100755 (executable)
@@ -106,6 +106,18 @@ static void __select_method()
 
        if (g_disc_method == 2)
                g_dp_method = 0;
+
+       switch (g_disc_method) {
+       case 0:
+               printf("Default is selected\n");
+               break;
+       case 1:
+               printf("BLE is selected\n");
+               break;
+       case 2:
+               printf("NAN is selected\n");
+               break;
+       }
 }
 
 static void __init()