From 49a24d2caff56d796fdef62190d2397036dac075 Mon Sep 17 00:00:00 2001 From: Cheoleun Moon Date: Mon, 23 Mar 2020 10:16:23 +0900 Subject: Remove set_enable_termination_event apis --- include/wifi-aware.h | 10 ---------- src/wifi-aware-private.c | 16 ++-------------- src/wifi-aware.c | 28 ---------------------------- 3 files changed, 2 insertions(+), 52 deletions(-) diff --git a/include/wifi-aware.h b/include/wifi-aware.h index 86da22f..75e7744 100644 --- a/include/wifi-aware.h +++ b/include/wifi-aware.h @@ -263,16 +263,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 diff --git a/src/wifi-aware-private.c b/src/wifi-aware-private.c index d2b91b0..711ea9e 100644 --- a/src/wifi-aware-private.c +++ b/src/wifi-aware-private.c @@ -620,7 +620,7 @@ 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_termination_event = true; req->enable_ranging = false; } @@ -660,12 +660,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; @@ -761,7 +755,7 @@ 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; + req->enable_termination_event = true; } void _wifi_aware_subscribe_set_ttl(wifi_aware_subscribe_h subscribe, unsigned short ttl) @@ -801,12 +795,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) { diff --git a/src/wifi-aware.c b/src/wifi-aware.c index eb80dec..426169e 100644 --- a/src/wifi-aware.c +++ b/src/wifi-aware.c @@ -266,20 +266,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) @@ -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) -- cgit v1.2.3 From 97d641c51fcce5e33b47ca0e480ea29793b2cd2d Mon Sep 17 00:00:00 2001 From: Cheoleun Moon Date: Mon, 23 Mar 2020 16:16:13 +0900 Subject: enable_termination_event is always true --- src/include/wifi-aware-config.h | 2 -- src/include/wifi-aware-private.h | 2 -- src/wifi-aware-gdbus.c | 4 ---- src/wifi-aware-private.c | 2 -- 4 files changed, 10 deletions(-) diff --git a/src/include/wifi-aware-config.h b/src/include/wifi-aware-config.h index 702c245..a9d9aea 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 b4d4e6c..c858c7b 100644 --- a/src/include/wifi-aware-private.h +++ b/src/include/wifi-aware-private.h @@ -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 0b1b726..b06cee8 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 711ea9e..b8ec685 100644 --- a/src/wifi-aware-private.c +++ b/src/wifi-aware-private.c @@ -620,7 +620,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 = true; req->enable_ranging = false; } @@ -755,7 +754,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 = true; } void _wifi_aware_subscribe_set_ttl(wifi_aware_subscribe_h subscribe, unsigned short ttl) -- cgit v1.2.3 From 72beac8df071255f5a5cb8795b81ab144948069b Mon Sep 17 00:00:00 2001 From: Cheoleun Moon Date: Mon, 23 Mar 2020 19:42:52 +0900 Subject: Add interface down error --- include/wifi-aware.h | 4 ++++ src/wifi-aware-private.c | 3 +++ test/wifi-aware-publish-test.c | 2 ++ test/wifi-aware-subscribe-test.c | 2 ++ test/wifi-aware-test.c | 2 ++ 5 files changed, 13 insertions(+) diff --git a/include/wifi-aware.h b/include/wifi-aware.h index 75e7744..69b67f0 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 { diff --git a/src/wifi-aware-private.c b/src/wifi-aware-private.c index b8ec685..dc2f41e 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; diff --git a/test/wifi-aware-publish-test.c b/test/wifi-aware-publish-test.c index 6be02c3..b2c686d 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"; } diff --git a/test/wifi-aware-subscribe-test.c b/test/wifi-aware-subscribe-test.c index 2318eb3..7b6d2bd 100644 --- a/test/wifi-aware-subscribe-test.c +++ b/test/wifi-aware-subscribe-test.c @@ -187,6 +187,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"; } diff --git a/test/wifi-aware-test.c b/test/wifi-aware-test.c index 7891bf7..9bf6eea 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"; } -- cgit v1.2.3 From 0a29ba1e8ca6c9eb2fd5995a523950166041ffb0 Mon Sep 17 00:00:00 2001 From: Cheoleun Moon Date: Thu, 26 Mar 2020 20:44:56 +0900 Subject: Check enabled state --- src/include/wifi-aware-private.h | 2 +- src/wifi-aware-private.c | 5 +++-- src/wifi-aware.c | 14 ++++++++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/include/wifi-aware-private.h b/src/include/wifi-aware-private.h index c858c7b..6c3bc2b 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); diff --git a/src/wifi-aware-private.c b/src/wifi-aware-private.c index dc2f41e..f3d2b66 100644 --- a/src/wifi-aware-private.c +++ b/src/wifi-aware-private.c @@ -436,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); @@ -518,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() diff --git a/src/wifi-aware.c b/src/wifi-aware.c index 426169e..0a83375 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"); @@ -289,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"); @@ -308,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"); @@ -445,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"); @@ -462,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); @@ -480,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"); @@ -525,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"); @@ -694,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); @@ -709,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); -- cgit v1.2.3 From 34550bead74c66cdc1444bb6cc66304b476b04c9 Mon Sep 17 00:00:00 2001 From: Cheoleun Moon Date: Thu, 26 Mar 2020 20:56:30 +0900 Subject: Refine test codes --- test/wifi-aware-publish-test.c | 3 ++- test/wifi-aware-subscribe-test.c | 23 +++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/test/wifi-aware-publish-test.c b/test/wifi-aware-publish-test.c index b2c686d..e5280da 100644 --- a/test/wifi-aware-publish-test.c +++ b/test/wifi-aware-publish-test.c @@ -358,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 7b6d2bd..b8bfd84 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; @@ -358,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) { @@ -384,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, @@ -471,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"); -- cgit v1.2.3 From ab90b22f32f76482742d3804765d04da59f5e76a Mon Sep 17 00:00:00 2001 From: Cheoleun Moon Date: Tue, 31 Mar 2020 11:54:53 +0900 Subject: Check invalid parameter error --- src/wifi-aware-private.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/wifi-aware-private.c b/src/wifi-aware-private.c index f3d2b66..a9553fd 100644 --- a/src/wifi-aware-private.c +++ b/src/wifi-aware-private.c @@ -534,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"); @@ -608,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"); @@ -684,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"); @@ -739,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"); @@ -843,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, -- cgit v1.2.3