summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeonah Moon <seonah1.moon@samsung.com>2020-03-31 14:49:09 +0900
committerSeonah Moon <seonah1.moon@samsung.com>2020-03-31 14:49:09 +0900
commit7e22da95760a3a93ee30fede0d52c87abe7be0b4 (patch)
tree58d3b9843037698d34b7b119ad8a5bf78b1785bf
parent7f8951676da2bfbbfcacc7787a4c15c6ac2d3ef7 (diff)
parent257b6f6bea8915bee1bf88c4a8e809da836ccb4a (diff)
downloadwifi-aware-7e22da95760a3a93ee30fede0d52c87abe7be0b4.tar.gz
wifi-aware-7e22da95760a3a93ee30fede0d52c87abe7be0b4.tar.bz2
wifi-aware-7e22da95760a3a93ee30fede0d52c87abe7be0b4.zip
Merge branch 'master' of github.sec.samsung.net:tizen-sys-con/capi-network-wifi-aware
-rw-r--r--include/wifi-aware.h14
-rw-r--r--src/include/wifi-aware-config.h2
-rw-r--r--src/include/wifi-aware-private.h4
-rw-r--r--src/wifi-aware-gdbus.c4
-rw-r--r--src/wifi-aware-private.c33
-rw-r--r--src/wifi-aware.c42
-rw-r--r--test/wifi-aware-publish-test.c5
-rw-r--r--test/wifi-aware-subscribe-test.c25
-rw-r--r--test/wifi-aware-test.c2
9 files changed, 55 insertions, 76 deletions
diff --git a/include/wifi-aware.h b/include/wifi-aware.h
index 3b2df6e..4e045fc 100644
--- a/include/wifi-aware.h
+++ b/include/wifi-aware.h
@@ -98,6 +98,10 @@ typedef enum {
* Rejected by peer
*/
WIFI_AWARE_ERROR_REJECTED_BY_PEER = TIZEN_ERROR_WIFI_AWARE|0x04,
+ /**
+ * Wi-Fi Interface is down
+ */
+ WIFI_AWARE_ERROR_INTERFACE_DOWN = TIZEN_ERROR_WIFI_AWARE|0x05,
} wifi_aware_error_e;
typedef enum {
@@ -264,16 +268,6 @@ int wifi_aware_publish_set_service_specific_info(wifi_aware_publish_h publish, c
int wifi_aware_publish_set_match_filter(wifi_aware_publish_h publish, const unsigned char *match_filter, size_t len);
/**
- * @brief TODO (Need decision to add) Set whether notifying a termination of the service or not.
- * @since_tizen 6.0
- * @param[in] publish
- * @param[in] enable
- * @return 0 on success, otherwise a negative error value
- * @retval #WIFI_AWARE_ERROR_NONE
- */
-int wifi_aware_publish_set_enable_termination_event(wifi_aware_publish_h publish, bool enable);
-
-/**
* @brief Set whether the ranging function is supported or not.
* @since_tizen 6.0
* @param[in] publish
diff --git a/src/include/wifi-aware-config.h b/src/include/wifi-aware-config.h
index c17ad7c..2d1090f 100644
--- a/src/include/wifi-aware-config.h
+++ b/src/include/wifi-aware-config.h
@@ -45,7 +45,6 @@ typedef struct {
uint16_t specific_info_len;
uint8_t match_filter[WIFI_AWARE_MAX_MATCH_FILTER_LEN];
uint16_t match_filter_len;
- bool enable_termination_event;
bool enable_ranging;
} wifi_aware_publish_request_s;
@@ -58,7 +57,6 @@ typedef struct {
uint16_t specific_info_len;
uint8_t match_filter[WIFI_AWARE_MAX_MATCH_FILTER_LEN];
uint16_t match_filter_len;
- uint8_t enable_termination_event;
} wifi_aware_subscribe_request_s;
#ifdef __cplusplus
diff --git a/src/include/wifi-aware-private.h b/src/include/wifi-aware-private.h
index 7798783..24be508 100644
--- a/src/include/wifi-aware-private.h
+++ b/src/include/wifi-aware-private.h
@@ -36,7 +36,7 @@ int _wifi_aware_init();
int _wifi_aware_deinit();
void _add_enabled_callback(wifi_aware_enabled_cb callback, void *user_data);
int _wifi_aware_enable_request();
-int _wifi_aware_is_enabled();
+bool _wifi_aware_is_enabled();
int _wifi_aware_disable_request();
int _wifi_aware_session_handle_create(wifi_aware_session_type_e session_type, wifi_aware_session_h *session_handle);
@@ -61,7 +61,6 @@ void _wifi_aware_publish_set_service_specific_info(wifi_aware_publish_h publish,
const unsigned char *service_specific_info, size_t len);
void _wifi_aware_publish_set_match_filter(wifi_aware_publish_h publish,
const unsigned char *match_filter, size_t len);
-void _wifi_aware_publish_set_enable_termination_event(wifi_aware_publish_h publish, bool enable);
void _wifi_aware_publish_set_enable_ranging(wifi_aware_publish_h publish, bool enable);
wifi_aware_publish_request_s *_wifi_aware_publish_get_request(wifi_aware_publish_h publish_handle);
uint16_t _wifi_aware_session_get_publish_id(wifi_aware_session_h session);
@@ -76,7 +75,6 @@ void _wifi_aware_subscribe_set_service_specific_info(wifi_aware_subscribe_h subs
const unsigned char *service_specific_info, size_t len);
void _wifi_aware_subscribe_set_match_filter(wifi_aware_subscribe_h subscribe,
const unsigned char *match_filter, size_t len);
-void _wifi_aware_subscribe_set_enable_termination_event(wifi_aware_subscribe_h subscribe, bool enable);
wifi_aware_subscribe_request_s *_wifi_aware_subscribe_get_request(wifi_aware_subscribe_h subscribe_handle);
uint16_t _wifi_aware_session_get_subscribe_id(wifi_aware_session_h session);
diff --git a/src/wifi-aware-gdbus.c b/src/wifi-aware-gdbus.c
index a4d324c..91044a9 100644
--- a/src/wifi-aware-gdbus.c
+++ b/src/wifi-aware-gdbus.c
@@ -272,7 +272,6 @@ static GVariant *__create_publish_request_param(int client_id, wifi_aware_publis
g_variant_builder_add(builder, "{sv}", "match_filter_len", g_variant_new("q", req->match_filter_len));
g_variant_builder_add(builder, "{sv}", "match_filter", __pack_byte_array(req->match_filter, req->match_filter_len));
}
- g_variant_builder_add(builder, "{sv}", "enable_termination_event", g_variant_new("b", req->enable_termination_event));
g_variant_builder_add(builder, "{sv}", "enable_ranging", g_variant_new("b", req->enable_ranging));
params = g_variant_new("(ia{sv})", client_id, builder);
@@ -303,7 +302,6 @@ static GVariant *__create_update_publish_request_param(int client_id,
g_variant_builder_add(builder, "{sv}", "match_filter_len", g_variant_new("q", req->match_filter_len));
g_variant_builder_add(builder, "{sv}", "match_filter", __pack_byte_array(req->match_filter, req->match_filter_len));
}
- g_variant_builder_add(builder, "{sv}", "enable_termination_event", g_variant_new("b", req->enable_termination_event));
g_variant_builder_add(builder, "{sv}", "enable_ranging", g_variant_new("b", req->enable_ranging));
params = g_variant_new("(iqa{sv})", client_id, pub_id, builder);
@@ -328,7 +326,6 @@ static GVariant *__create_subscribe_request_param(int client_id, wifi_aware_subs
g_variant_builder_add(builder, "{sv}", "match_filter_len", g_variant_new("q", req->match_filter_len));
g_variant_builder_add(builder, "{sv}", "match_filter", __pack_byte_array(req->match_filter, req->match_filter_len));
}
- g_variant_builder_add(builder, "{sv}", "enable_termination_event", g_variant_new("b", req->enable_termination_event));
params = g_variant_new("(ia{sv})", client_id, builder);
g_variant_builder_unref(builder);
@@ -358,7 +355,6 @@ static GVariant *__create_update_subscribe_request_param(int client_id,
g_variant_builder_add(builder, "{sv}", "match_filter_len", g_variant_new("q", req->match_filter_len));
g_variant_builder_add(builder, "{sv}", "match_filter", __pack_byte_array(req->match_filter, req->match_filter_len));
}
- g_variant_builder_add(builder, "{sv}", "enable_termination_event", g_variant_new("b", req->enable_termination_event));
params = g_variant_new("(iua{sv})", client_id, sub_id, builder);
g_variant_builder_unref(builder);
diff --git a/src/wifi-aware-private.c b/src/wifi-aware-private.c
index dec8583..f6ab50d 100644
--- a/src/wifi-aware-private.c
+++ b/src/wifi-aware-private.c
@@ -52,6 +52,7 @@ enum {
NAN_ERROR_NO_CLIENT,
NAN_ERROR_TOO_MANY_REQUESTS,
NAN_ERROR_REJECTED_BY_PEER,
+ NAN_ERROR_INTERFACE_DOWN,
NAN_ERROR_UNKNOWN,
} nan_manager_error_e;
@@ -179,6 +180,8 @@ wifi_aware_error_e _wifi_aware_convert_nan_manager_error(int error)
return WIFI_AWARE_ERROR_RESOURCE_BUSY;
case NAN_ERROR_REJECTED_BY_PEER:
return WIFI_AWARE_ERROR_REJECTED_BY_PEER;
+ case NAN_ERROR_INTERFACE_DOWN:
+ return WIFI_AWARE_ERROR_INTERFACE_DOWN;
case NAN_ERROR_UNKNOWN:
default:
return WIFI_AWARE_ERROR_OPERATION_FAILED;
@@ -433,6 +436,7 @@ static int __wifi_aware_create()
return WIFI_AWARE_ERROR_OUT_OF_MEMORY;
}
+ g_wifi_aware->client_id = -1;
g_wifi_aware->peer_map =
g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, _wifi_aware_peer_destroy);
@@ -515,9 +519,9 @@ int _wifi_aware_enable_request()
return wifi_aware_gdbus_enable(req, __enable_request_reply);
}
-int _wifi_aware_is_enabled()
+bool _wifi_aware_is_enabled()
{
- return (g_wifi_aware->client_id >= 0 ? 1 : 0);
+ return g_wifi_aware->client_id >= 0;
}
int _wifi_aware_disable_request()
@@ -530,6 +534,9 @@ int _wifi_aware_disable_request()
int _wifi_aware_session_handle_create(wifi_aware_session_type_e session_type,
wifi_aware_session_h *session_handle)
{
+ RET_VAL_IF(!session_handle, WIFI_AWARE_ERROR_INVALID_PARAMETER, "Invalid Parameter");
+ RET_VAL_IF(session_type != WIFI_AWARE_SESSION_PUBLISH && session_type != WIFI_AWARE_SESSION_SUBSCRIBE,
+ WIFI_AWARE_ERROR_INVALID_PARAMETER, "Invalid Parameter");
wifi_aware_session_s *session =
(wifi_aware_session_s *)g_try_malloc0(sizeof(wifi_aware_session_s));
RET_VAL_IF(session == NULL, WIFI_AWARE_ERROR_OUT_OF_MEMORY, "Out of memory");
@@ -604,6 +611,8 @@ void _wifi_aware_session_unset_terminated_cb(wifi_aware_session_h session)
int _wifi_aware_publish_handle_create(wifi_aware_publish_h *publish)
{
+ RET_VAL_IF(publish == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "Invalid Parameter");
+
wifi_aware_publish_request_s *req =
(wifi_aware_publish_request_s *)g_try_malloc0(sizeof(wifi_aware_publish_request_s));
RET_VAL_IF(req == NULL, WIFI_AWARE_ERROR_OUT_OF_MEMORY, "Out of memory");
@@ -620,7 +629,6 @@ void _wifi_aware_publish_set_default_values(wifi_aware_publish_h publish)
req->publish_type = WIFI_AWARE_PUBLISH_TYPE_UNSOLICITED;
req->specific_info_len = 0;
req->match_filter_len = 0;
- req->enable_termination_event = false;
req->enable_ranging = false;
}
@@ -660,12 +668,6 @@ void _wifi_aware_publish_set_match_filter(wifi_aware_publish_h publish,
req->match_filter_len = len;
}
-void _wifi_aware_publish_set_enable_termination_event(wifi_aware_publish_h publish, bool enable)
-{
- wifi_aware_publish_request_s *req = (wifi_aware_publish_request_s *)publish;
- req->enable_termination_event = enable;
-}
-
void _wifi_aware_publish_set_enable_ranging(wifi_aware_publish_h publish, bool enable)
{
wifi_aware_publish_request_s *req = (wifi_aware_publish_request_s *)publish;
@@ -687,6 +689,8 @@ int _wifi_aware_publish_request(wifi_aware_session_h session,
RET_VAL_IF(publish == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_publish_h is NULL");
RET_VAL_IF(!_wifi_aware_session_is_publish_type(session), WIFI_AWARE_ERROR_INVALID_OPERATION,
"This session is not for Publish");
+ RET_VAL_IF(_wifi_aware_session_get_service_name(session) == NULL,
+ WIFI_AWARE_ERROR_INVALID_OPERATION, "Service name is NULL");
RET_VAL_IF(__session_is_requested(session), WIFI_AWARE_ERROR_NOW_IN_PROGRESS,
"There is a pending request");
@@ -742,6 +746,8 @@ int _wifi_aware_update_publish_request(wifi_aware_session_h session,
int _wifi_aware_subscribe_handle_create(wifi_aware_subscribe_h *subscribe)
{
+ RET_VAL_IF(subscribe == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "Invalid Parameter");
+
wifi_aware_subscribe_request_s *req =
(wifi_aware_subscribe_request_s *)g_try_malloc0(sizeof(wifi_aware_subscribe_request_s));
RET_VAL_IF(req == NULL, WIFI_AWARE_ERROR_OUT_OF_MEMORY, "Out of memory");
@@ -761,7 +767,6 @@ void _wifi_aware_subscribe_set_default_values(
req->specific_info_len = 0;
//memset(req->match_filter[WIFI_AWARE_MAX_MATCH_FILTER_LEN], 0, WIFI_AWARE_MAX_MATCH_FILTER_LEN);
req->match_filter_len = 0;
- req->enable_termination_event = false;
}
void _wifi_aware_subscribe_set_ttl(wifi_aware_subscribe_h subscribe, unsigned short ttl)
@@ -801,12 +806,6 @@ void _wifi_aware_subscribe_set_match_filter(wifi_aware_subscribe_h subscribe,
req->match_filter_len = len;
}
-void _wifi_aware_subscribe_set_enable_termination_event(wifi_aware_subscribe_h subscribe, bool enable)
-{
- wifi_aware_subscribe_request_s *req = (wifi_aware_subscribe_request_s *)subscribe;
- req->enable_termination_event = enable;
-}
-
static void __session_set_subscribe_config(wifi_aware_session_h session_handle,
wifi_aware_subscribe_h subscribe)
{
@@ -853,6 +852,8 @@ int _wifi_aware_update_subscribe_request(wifi_aware_session_h session,
RET_VAL_IF(subscribe == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_subscribe_h is NULL");
RET_VAL_IF(!_wifi_aware_session_is_subscribe_type(session), WIFI_AWARE_ERROR_INVALID_OPERATION,
"This session is not for Subscribe");
+ RET_VAL_IF(_wifi_aware_session_get_service_name(session) == NULL,
+ WIFI_AWARE_ERROR_INVALID_OPERATION, "Service name is NULL");
RET_VAL_IF(!__is_subscribed(session), WIFI_AWARE_ERROR_INVALID_OPERATION,
"The subscribe is not done yet");
RET_VAL_IF(__session_is_requested(session), WIFI_AWARE_ERROR_NOW_IN_PROGRESS,
diff --git a/src/wifi-aware.c b/src/wifi-aware.c
index 4885a13..8f04318 100644
--- a/src/wifi-aware.c
+++ b/src/wifi-aware.c
@@ -73,6 +73,7 @@ API int wifi_aware_enable(wifi_aware_enabled_cb callback, void *user_data)
__WIFI_AWARE_FUNC_ENTER__;
CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE);
RET_VAL_IF(!_wifi_aware_is_initialized(), WIFI_AWARE_ERROR_NOT_INITIALIZED, "Not initialized");
+ RET_VAL_IF(_wifi_aware_is_enabled(), WIFI_AWARE_ERROR_INVALID_OPERATION, "Already enabled");
_add_enabled_callback(callback, user_data);
@@ -90,10 +91,7 @@ API int wifi_aware_disable()
__WIFI_AWARE_FUNC_ENTER__;
CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE);
RET_VAL_IF(!_wifi_aware_is_initialized(), WIFI_AWARE_ERROR_NOT_INITIALIZED, "Not initialized");
-
- RET_VAL_IF(_wifi_aware_is_enabled() == 0,
- WIFI_AWARE_ERROR_INVALID_OPERATION,
- "_wifi_aware_is_enabled");
+ RET_VAL_IF(!_wifi_aware_is_enabled(), WIFI_AWARE_ERROR_INVALID_OPERATION, "Not enabled");
ret = _wifi_aware_disable_request();
RET_VAL_IF(ret != WIFI_AWARE_ERROR_NONE, ret, "_wifi_aware_disable_request");
@@ -266,20 +264,6 @@ API int wifi_aware_publish_set_match_filter(wifi_aware_publish_h publish,
return WIFI_AWARE_ERROR_NONE;
}
-API int wifi_aware_publish_set_enable_termination_event(
- wifi_aware_publish_h publish,
- bool enable)
-{
- __WIFI_AWARE_FUNC_ENTER__;
- CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE);
- RET_VAL_IF(publish == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_publish_h is NULL");
-
- _wifi_aware_publish_set_enable_termination_event(publish, enable);
-
- __WIFI_AWARE_FUNC_EXIT__;
- return WIFI_AWARE_ERROR_NONE;
-}
-
API int wifi_aware_publish_set_enable_ranging(
wifi_aware_publish_h publish,
bool enable)
@@ -303,6 +287,7 @@ API int wifi_aware_session_publish(wifi_aware_session_h session,
CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE);
RET_VAL_IF(!_wifi_aware_is_initialized(), WIFI_AWARE_ERROR_NOT_INITIALIZED, "Not initialized");
+ RET_VAL_IF(!_wifi_aware_is_enabled(), WIFI_AWARE_ERROR_INVALID_OPERATION, "Not enabled");
RET_VAL_IF(session == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_session_h is NULL");
RET_VAL_IF(publish == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_publish_h is NULL");
@@ -322,6 +307,7 @@ API int wifi_aware_session_update_publish(wifi_aware_session_h session,
CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE);
RET_VAL_IF(!_wifi_aware_is_initialized(), WIFI_AWARE_ERROR_NOT_INITIALIZED, "Not initialized");
+ RET_VAL_IF(!_wifi_aware_is_enabled(), WIFI_AWARE_ERROR_INVALID_OPERATION, "Not enabled");
RET_VAL_IF(session == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_session_h is NULL");
RET_VAL_IF(publish == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_publish_h is NULL");
@@ -450,20 +436,6 @@ API int wifi_aware_subscribe_set_match_filter(
return WIFI_AWARE_ERROR_NONE;
}
-API int wifi_aware_subscribe_set_enable_termination_event(
- wifi_aware_subscribe_h subscribe,
- bool enable)
-{
- __WIFI_AWARE_FUNC_ENTER__;
- CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE);
- RET_VAL_IF(subscribe == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_subscribe_h is NULL");
-
- _wifi_aware_subscribe_set_enable_termination_event(subscribe, enable);
-
- __WIFI_AWARE_FUNC_EXIT__;
- return WIFI_AWARE_ERROR_NONE;
-}
-
API int wifi_aware_session_subscribe(wifi_aware_session_h session,
wifi_aware_subscribe_h subscribe,
wifi_aware_subscribed_cb callback, void *user_data)
@@ -473,6 +445,7 @@ API int wifi_aware_session_subscribe(wifi_aware_session_h session,
CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE);
RET_VAL_IF(!_wifi_aware_is_initialized(), WIFI_AWARE_ERROR_NOT_INITIALIZED, "Not initialized");
+ RET_VAL_IF(!_wifi_aware_is_enabled(), WIFI_AWARE_ERROR_INVALID_OPERATION, "Not enabled");
RET_VAL_IF(session == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_session_h is NULL");
RET_VAL_IF(subscribe == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_subscribe_h is NULL");
@@ -490,6 +463,7 @@ API int wifi_aware_session_stop(wifi_aware_session_h session)
CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE);
RET_VAL_IF(!_wifi_aware_is_initialized(), WIFI_AWARE_ERROR_NOT_INITIALIZED, "Not initialized");
+ RET_VAL_IF(!_wifi_aware_is_enabled(), WIFI_AWARE_ERROR_INVALID_OPERATION, "Not enabled");
RET_VAL_IF(session == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_session_h is NULL");
ret = _wifi_aware_session_cancel(session);
@@ -508,6 +482,7 @@ API int wifi_aware_session_update_subscribe(wifi_aware_session_h session,
CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE);
RET_VAL_IF(!_wifi_aware_is_initialized(), WIFI_AWARE_ERROR_NOT_INITIALIZED, "Not initialized");
+ RET_VAL_IF(!_wifi_aware_is_enabled(), WIFI_AWARE_ERROR_INVALID_OPERATION, "Not enabled");
RET_VAL_IF(session == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_session_h is NULL");
RET_VAL_IF(subscribe == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_subscribe_h is NULL");
@@ -553,6 +528,7 @@ API int wifi_aware_session_send_message(wifi_aware_session_h session,
__WIFI_AWARE_FUNC_ENTER__;
CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE);
RET_VAL_IF(!_wifi_aware_is_initialized(), WIFI_AWARE_ERROR_NOT_INITIALIZED, "Not initialized");
+ RET_VAL_IF(!_wifi_aware_is_enabled(), WIFI_AWARE_ERROR_INVALID_OPERATION, "Not enabled");
RET_VAL_IF(session == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_session_h is NULL");
RET_VAL_IF(peer == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER,
"wifi_aware_peer_h is NULL");
@@ -722,6 +698,7 @@ API int wifi_aware_data_path_open(wifi_aware_data_path_h data_path, wifi_aware_d
__WIFI_AWARE_FUNC_ENTER__;
CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE);
RET_VAL_IF(!_wifi_aware_is_initialized(), WIFI_AWARE_ERROR_NOT_INITIALIZED, "Not initialized");
+ RET_VAL_IF(!_wifi_aware_is_enabled(), WIFI_AWARE_ERROR_INVALID_OPERATION, "Not enabled");
RET_VAL_IF(data_path == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "Data path is NULL");
ret = _wifi_aware_data_path_open(data_path, callback, user_data);
@@ -737,6 +714,7 @@ API int wifi_aware_data_path_close(wifi_aware_data_path_h data_path)
__WIFI_AWARE_FUNC_ENTER__;
CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE);
RET_VAL_IF(!_wifi_aware_is_initialized(), WIFI_AWARE_ERROR_NOT_INITIALIZED, "Not initialized");
+ RET_VAL_IF(!_wifi_aware_is_enabled(), WIFI_AWARE_ERROR_INVALID_OPERATION, "Not enabled");
RET_VAL_IF(data_path == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "Data path is NULL");
ret = _wifi_aware_data_path_close(data_path);
diff --git a/test/wifi-aware-publish-test.c b/test/wifi-aware-publish-test.c
index b1a7526..39e34f1 100644
--- a/test/wifi-aware-publish-test.c
+++ b/test/wifi-aware-publish-test.c
@@ -180,6 +180,8 @@ const char *__print_error(wifi_aware_error_e err)
return "ALREADY_INITIALIZED";
case WIFI_AWARE_ERROR_REJECTED_BY_PEER:
return "REJECTED_BY_PEER";
+ case WIFI_AWARE_ERROR_INTERFACE_DOWN:
+ return "INTERFACE_IS_DOWN";
default:
return "UNKNOWN";
}
@@ -356,10 +358,11 @@ static void __message_received_cb(wifi_aware_session_h session, wifi_aware_peer_
printf("\n>>Receive message from a Wi-Fi Aware Peer\n");
- memcpy(buf, message, 1024);
if (wifi_aware_peer_get_mac(peer, &mac) != WIFI_AWARE_ERROR_NONE)
printf("Fail to get Peer's NMI: %s\n", __print_error(ret));
+ memcpy(buf, message, 1024);
+ buf[len] = '\0';
printf("Message: %s\n", buf);
printf("Peer's NMI: ");
if (mac != NULL) {
diff --git a/test/wifi-aware-subscribe-test.c b/test/wifi-aware-subscribe-test.c
index 8f70443..2331522 100644
--- a/test/wifi-aware-subscribe-test.c
+++ b/test/wifi-aware-subscribe-test.c
@@ -132,6 +132,8 @@ static wifi_aware_subscribe_type_e g_sub_type;
static wifi_aware_security_type_e g_security_type;
static char g_psk[MAX_PSK_LEN + 1];
+static bool g_service_discovered = false;
+
static inline void __usage_full()
{
int i;
@@ -187,6 +189,8 @@ const char *__print_error(wifi_aware_error_e err)
return "ALREADY_INITIALIZED";
case WIFI_AWARE_ERROR_REJECTED_BY_PEER:
return "REJECTED_BY_PEER";
+ case WIFI_AWARE_ERROR_INTERFACE_DOWN:
+ return "INTERFACE_IS_DOWN";
default:
return "UNKNOWN";
}
@@ -356,10 +360,11 @@ static void __message_received_cb(wifi_aware_session_h session, wifi_aware_peer_
printf("\n>>Receive message from a Wi-Fi Aware Peer\n");
- memcpy(buf, message, 1024);
if (wifi_aware_peer_get_mac(peer, &mac) != WIFI_AWARE_ERROR_NONE)
printf("Fail to get Peer's NMI: %s\n", __print_error(ret));
+ memcpy(buf, message, 1024);
+ buf[len] = '\0';
printf("Message: %s\n", buf);
printf("Peer's NMI: ");
if (mac != NULL) {
@@ -382,13 +387,16 @@ static void __service_discovered_cb(wifi_aware_session_h session,
__print_byte_array(service_specific_info, service_specific_info_len);
printf("\n");
- printf("\n>>Send message\n");
- unsigned char send_message[1024] = {0, };
- size_t message_len = strlen(MSG_SUB_TO_PUB);
- memcpy(send_message, MSG_SUB_TO_PUB, message_len);
- int ret = wifi_aware_session_send_message(session, peer, send_message, message_len, __message_result_cb, NULL);
- if (ret != WIFI_AWARE_ERROR_NONE)
- printf("Fail to send message: %s\n", __print_error(ret));
+ if (g_service_discovered == false) {
+ g_service_discovered = true;
+ printf("\n>>Send message\n");
+ unsigned char send_message[1024] = {0, };
+ size_t message_len = strlen(MSG_SUB_TO_PUB);
+ memcpy(send_message, MSG_SUB_TO_PUB, message_len);
+ int ret = wifi_aware_session_send_message(session, peer, send_message, message_len, __message_result_cb, NULL);
+ if (ret != WIFI_AWARE_ERROR_NONE)
+ printf("Fail to send message: %s\n", __print_error(ret));
+ }
}
static void __session_terminated_cb(wifi_aware_session_h session,
@@ -469,6 +477,7 @@ static void __enabled_cb(wifi_aware_error_e error, void *user_data)
return;
}
+ g_service_discovered = false;
ret = wifi_aware_session_set_service_discovered_cb(g_wifi_aware_session, __service_discovered_cb, NULL);
__print_result(ret, "set service_discovered_cb");
diff --git a/test/wifi-aware-test.c b/test/wifi-aware-test.c
index facea04..5e531c4 100644
--- a/test/wifi-aware-test.c
+++ b/test/wifi-aware-test.c
@@ -282,6 +282,8 @@ const char *__print_error(wifi_aware_error_e err)
return "ALREADY_INITIALIZED";
case WIFI_AWARE_ERROR_REJECTED_BY_PEER:
return "REJECTED_BY_PEER";
+ case WIFI_AWARE_ERROR_INTERFACE_DOWN:
+ return "INTERFACE_IS_DOWN";
default:
return "UNKNOWN";
}