if (!g_wifi_aware_session) {\
printf("wifi-aware-session handle is not created yet\n");\
return;\
- }\
+ } \
} while (0)
#define RET_IF_NDP_IS_NULL()\
if (!g_ndp) {\
printf("wifi_aware_data_path handle is not created yet\n");\
return;\
- }\
+ } \
} while (0)
enum {
[CMD_OPEN_SOL]
= "Publish",
[CMD_OPEN_ACT]
- ="Subscribe",
+ = "Subscribe",
[CMD_PSK_SOL]
- ="Publish",
+ = "Publish",
[CMD_PSK_ACT]
- ="Subscribe",
+ = "Subscribe",
[CMD_INVALID]
= NULL,
printf(MAKE_GREEN"Test 3. Solicited/Active/DataPath(Open)"RESET_COLOR"\n");
else if (i == CMD_PSK_SOL)
printf(MAKE_GREEN"Test 4. Solicited/Active/DataPath(PSK)"RESET_COLOR"\n");
-
+
printf(" [%02d] %s\n", i, g_menu_str[i]);
}
{
if (error == WIFI_AWARE_ERROR_NONE) {
printf("Subscribe discovery session started...\n");
- }
- else {
+ } else {
printf("Subscribe is failed...\n");
return;
}
if (error != WIFI_AWARE_ERROR_NONE) {
printf("Sending message is failed...\n");
__test_finish(0);
- }
- else {
+ } else {
printf("Sent message successfully...\n");
}
}
*
*/
-/**
-
- * This file declares functions for testing Wi-Fi aware CAPIs.
- *
- * @file wifi-aware-test.h
- * @author Jiung Yu (jiung.yu@samsung.com)
- */
#ifndef __WIFI_AWARE_TEST_H__
#define __WIFI_AWARE_TEST_H__
int wifi_aware_subscribe_set_type(wifi_aware_subscribe_h subscribe, wifi_aware_subscribe_type_e subscribe_type);
/**
- * @brief Sets the name of the service.
+ * @brief Sets the name of the service.
* @since_tizen 6.0
* @param[in] subscribe The Wi-Fi Aware Subscribe handle
* @param[in] service_name UTF-8 name which identifies the service
* @since_tizen 6.0
* @remark Only for the services within the @a distance are searched.
* @param[in] subscribe The Wi-Fi Aware Subscribe handle
- * @param[in] distance The maximum distance
+ * @param[in] distance The maximum distance
* @return 0 on success, otherwise a negative error value
* @retval #WIFI_AWARE_ERROR_NONE
* @retval #WIFI_AWARE_ERROR_INVALID_PARAMETER
* @see wifi_aware_session_unset_terminated_cb()
*/
typedef void(*wifi_aware_session_terminated_cb)(wifi_aware_session_h session,
- wifi_aware_termination_reason_e reason, void *user_data);
+ wifi_aware_termination_reason_e reason, void *user_data);
/**
* @brief Registers a callback function to notify session is terminated.
* @see wifi_aware_session_unset_terminated_cb()
*/
int wifi_aware_session_set_terminated_cb(wifi_aware_session_h session,
- wifi_aware_session_terminated_cb callback, void *user_data);
+ wifi_aware_session_terminated_cb callback, void *user_data);
/**
* @brief Unregisters the session terminated callback function.
wifi_aware_published_cb callback, void *user_data);
/**
- * @brief Called when Subscribe request is finished.
+ * @brief Called when Subscribe request is finished.
* @since_tizen 6.0
* @param[in] session The Wi-Fi Aware Session handle
* @param[in] error The error code
* @remark If the publisher doesn't enabled ranging or the subscriber doesn't set both max and min distance,\n
* @a distance would be negative value.
* @param[in] session The Wi-Fi Aware Session handle
- * @param[in] peer The found Peer information
+ * @param[in] peer The found Peer information
* @param[in] service_specific_info Sequence of octets which were received from published service
* @param[in] service_specific_info_len The length of @a service_specific_info
* @param[in] distance The distance to the peer
/**
* @brief Called when the Wi-Fi Aware Data Path has been lost.
* @since_tizen 6.0
- * @param[in] data_path The terminated Data Path handle
+ * @param[in] data_path The terminated Data Path handle
* @param[in] reason The reason of termination
* @param[in] user_data The user data passed from request function
* @see wifi_aware_data_path_set_terminated_cb()
%check
export LD_LIBRARY_PATH=./src/
LD_PRELOAD=./tests/unittest/libwifi-aware-mock.so ./tests/unittest/wifi-aware-unittest
-#LD_LIBRARY_PATH=
%if 0%{?gcov:1}
lcov -c --ignore-errors graph --no-external -b . -d . -o %{name}.info
%attr(755,root,root) %{_bindir}/wifi-aware-subscribe-matching-filter-test
%files cts-verifier
-#%manifest wifi-aware-test.manifest
%attr(755,root,root) %{_bindir}/cts-verifier
%if 0%{?gcov:1}
/*
#define CHECK_FEATURE_SUPPORTED(feature_name)\
do {\
- bool feature_supported = FALSE;\
- if (!system_info_get_platform_bool(feature_name,\
- &feature_supported)) {\
- if (feature_supported == FALSE) {\
- WIFI_AWARE_LOGE("%s feature is disabled",\
- feature_name);\
- __WIFI_AWARE_FUNC_EXIT__;\
- return WIFI_AWARE_ERROR_NOT_SUPPORTED;\
- } \
- } else {\
- WIFI_AWARE_LOGE("Error - Feature getting from System Info");\
- __WIFI_AWARE_FUNC_EXIT__;\
- return WIFI_AWARE_ERROR_OPERATION_FAILED;\
- }\
+ bool feature_supported = FALSE;\
+ if (!system_info_get_platform_bool(feature_name,\
+ &feature_supported)) {\
+ if (feature_supported == FALSE) {\
+ WIFI_AWARE_LOGE("%s feature is disabled", feature_name);\
+ __WIFI_AWARE_FUNC_EXIT__;\
+ return WIFI_AWARE_ERROR_NOT_SUPPORTED;\
+ } \
+ } else {\
+ WIFI_AWARE_LOGE("Error - Feature getting from System Info");\
+ __WIFI_AWARE_FUNC_EXIT__;\
+ return WIFI_AWARE_ERROR_OPERATION_FAILED;\
+ }\
} while (0)
*/
*
*/
-/**
- * This file implements Wi-Fi Aware user library.
- *
- * @file wifi-aware-client.c
- * @author Jiung Yu (jiung.yu@samsung.com)
- */
-
-
#include <glib.h>
#include <net/if.h>
}
static void __ndp_confirmed_cb(GDBusConnection *connection,
- const gchar *sender, const gchar *object_path,
- const gchar *interface, const gchar *signal,
- GVariant *parameters, gpointer user_data)
+ const gchar *sender, const gchar *object_path,
+ const gchar *interface, const gchar *signal,
+ GVariant *parameters, gpointer user_data)
{
__WIFI_AWARE_FUNC_ENTER__;
WIFI_AWARE_LOGD("NAN Data Path Confirmed");
}
static void __data_path_terminated_cb(GDBusConnection *connection,
- const gchar *sender, const gchar *object_path,
- const gchar *interface, const gchar *signal,
- GVariant *parameters, gpointer user_data)
+ const gchar *sender, const gchar *object_path,
+ const gchar *interface, const gchar *signal,
+ GVariant *parameters, gpointer user_data)
{
__WIFI_AWARE_FUNC_ENTER__;
wifi_aware_gdbus_deregister_signal(DATA_PATH_TERMINATED_SIGNAL);
ndp->terminated_signal_id = 0;
-
+
__WIFI_AWARE_FUNC_ENTER__;
return ret;
*
*/
-/**
- * This file implements Wi-Fi Aware gdbus global.
- *
- * @file wifi-aware-gdbus.c
- * @author Jiung Yu (jiung.yu@samsung.com)
- */
-
#include <system_info.h>
#include "wifi-aware-log.h"
static wifi_aware_gdbus_data gdbus_data = {NULL, NULL};
static struct {
- const char *interface;
- const char *member;
+ const char *interface;
+ const char *member;
} wifi_aware_gdbus_signal_map[] = {
/*
- {
- WIFI_AWARE_DISCOVERY_INTERFACE,
- "MacAddressChanged",
- _mac_address_changed
- },
- */
+ {
+ WIFI_AWARE_DISCOVERY_INTERFACE,
+ "MacAddressChanged",
+ _mac_address_changed
+ },
+ */
[SERVICE_DISCOVERED_SIGNAL] = {
WIFI_AWARE_DISCOVERY_INTERFACE,
"ServiceDiscovered",
const char *method, GVariant *params,
GAsyncReadyCallback callback, void *user_data)
{
- if (gdbus_data.connection == NULL) {
- WIFI_AWARE_LOGE("GDBusconnection is NULL");
+ if (gdbus_data.connection == NULL) {
+ WIFI_AWARE_LOGE("GDBusconnection is NULL");
return WIFI_AWARE_ERROR_OPERATION_FAILED;
- }
+ }
g_dbus_connection_call(gdbus_data.connection,
WIFI_AWARE_INTERFACE,
callback,
user_data);
- return WIFI_AWARE_ERROR_NONE;
+ return WIFI_AWARE_ERROR_NONE;
}
WIFI_AWARE_LOGE("Invalid Publish Id");
return WIFI_AWARE_ERROR_INVALID_PARAMETER;
}
-
+
params = __create_cancel_publish_request_param(client_id, pub_id);
DBUS_DEBUG_VARIANT(params);
WIFI_AWARE_LOGE("Invalid Subscribe Id");
return WIFI_AWARE_ERROR_INVALID_PARAMETER;
}
-
+
params = __create_cancel_subscribe_request_param(client_id, sub_id);
DBUS_DEBUG_VARIANT(params);
wifi_aware_peer_s *peer_handle = (wifi_aware_peer_s *)peer;
RET_VAL_IF(peer_handle == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "peer is NULL");
- if (!g_hash_table_remove(peer_map, GINT_TO_POINTER(peer_handle->id))) {
+ if (!g_hash_table_remove(peer_map, GINT_TO_POINTER(peer_handle->id)))
WIFI_AWARE_LOGE("peer %d doesn't exist", peer_handle->id);
- }
return WIFI_AWARE_ERROR_NONE;
}
*
*/
-/**
- * This file implements Wi-Fi Aware user library.
- *
- * @file wifi-aware-client.c
- * @author Jiung Yu (jiung.yu@samsung.com)
- */
-
-
#include <glib.h>
#include <cynara-client.h>
#include <stdio.h>
/**
* These enum values has dependency with nan-manager daemon.
- * If the daemon changes error enum, It also must be changed.
+ * If the daemon changes error enum, It also must be changed.
*/
enum {
NAN_ERROR_NONE = 0,
typedef struct {
uint16_t pub_sub_id;
wifi_aware_session_type_e session_type;
- wifi_aware_publish_h publish_config;
- wifi_aware_subscribe_h subscribe_config;
+ wifi_aware_publish_h publish_config;
+ wifi_aware_subscribe_h subscribe_config;
bool is_requested;
wifi_aware_published_cb published_cb;
if (strstr(error, "NoReply") != NULL)
return WIFI_AWARE_ERROR_INVALID_OPERATION;
else if (NULL != strstr(error, "UnknownMethod"))
- return WIFI_AWARE_ERROR_INVALID_OPERATION;
- else if (NULL != strstr(error, "InvalidArguments"))
- return WIFI_AWARE_ERROR_INVALID_PARAMETER;
- else if (NULL != strstr(error, "AccessDenied"))
- return WIFI_AWARE_ERROR_PERMISSION_DENIED;
- else if (NULL != strstr(error, "PermissionDenied"))
- return WIFI_AWARE_ERROR_PERMISSION_DENIED;
- else if (NULL != strstr(error, "NotSupported"))
- return WIFI_AWARE_ERROR_NOT_SUPPORTED;
- else if (NULL != strstr(error, "InProgress"))
- return WIFI_AWARE_ERROR_NOW_IN_PROGRESS;
+ return WIFI_AWARE_ERROR_INVALID_OPERATION;
+ else if (NULL != strstr(error, "InvalidArguments"))
+ return WIFI_AWARE_ERROR_INVALID_PARAMETER;
+ else if (NULL != strstr(error, "AccessDenied"))
+ return WIFI_AWARE_ERROR_PERMISSION_DENIED;
+ else if (NULL != strstr(error, "PermissionDenied"))
+ return WIFI_AWARE_ERROR_PERMISSION_DENIED;
+ else if (NULL != strstr(error, "NotSupported"))
+ return WIFI_AWARE_ERROR_NOT_SUPPORTED;
+ else if (NULL != strstr(error, "InProgress"))
+ return WIFI_AWARE_ERROR_NOW_IN_PROGRESS;
else
WIFI_AWARE_LOGI("Unknown Error %s", error);
wifi_aware_error_e _wifi_aware_convert_gdbus_error(GDBusError error)
{
- switch(error) {
+ switch (error) {
case G_DBUS_ERROR_NO_REPLY:
return WIFI_AWARE_ERROR_INVALID_OPERATION;
case G_DBUS_ERROR_UNKNOWN_METHOD:
WIFI_AWARE_LOGI("Client ID: %i, error: %d", g_wifi_aware->client_id, nan_error);
error = _wifi_aware_convert_nan_manager_error(nan_error);
}
-
+
if (g_wifi_aware->enabled_cb) {
wifi_aware_enabled_cb enabled_cb = g_wifi_aware->enabled_cb;
g_wifi_aware->enabled_cb = NULL;
}
static void __session_add_published_callback(wifi_aware_session_h session,
- wifi_aware_published_cb callback, void *user_data)
+ wifi_aware_published_cb callback, void *user_data)
{
- wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
- handle->published_cb = callback;
- handle->published_cb_data = user_data;
+ wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
+ handle->published_cb = callback;
+ handle->published_cb_data = user_data;
}
static int __is_published(wifi_aware_session_h session)
{
- wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
+ wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
return handle->session_type == WIFI_AWARE_SESSION_PUBLISH && handle->pub_sub_id > 0;
}
static void __session_set_pub_sub_id(wifi_aware_session_h session, uint16_t pub_sub_id)
{
- wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
+ wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
handle->pub_sub_id = pub_sub_id;
}
WIFI_AWARE_LOGE("Publish/Subsribe Request failure: %s", dbus_error->message);
error = _wifi_aware_convert_error_string_to_enum(dbus_error->message);
g_error_free(dbus_error);
- }
- else {
+ } else {
g_variant_get(reply, "(qi)", id, &nan_error);
WIFI_AWARE_LOGI("Pub/Sub ID: %u, error: %d", *id, nan_error);
error = _wifi_aware_convert_nan_manager_error(nan_error);
}
static void __session_add_subscribed_callback(wifi_aware_session_h session,
- wifi_aware_subscribed_cb callback, void *user_data)
+ wifi_aware_subscribed_cb callback, void *user_data)
{
- wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
- handle->subscribed_cb = callback;
- handle->subscribed_cb_data = user_data;
+ wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
+ handle->subscribed_cb = callback;
+ handle->subscribed_cb_data = user_data;
}
static int __is_subscribed(wifi_aware_session_h session)
{
- wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
+ wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
return handle->session_type == WIFI_AWARE_SESSION_SUBSCRIBE && handle->pub_sub_id > 0;
}
static void __wifi_aware_subscribe_invoke_callback(wifi_aware_session_h session, wifi_aware_error_e error)
{
RET_IF(session == NULL, "Session is NULL");
- wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
+ wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
if (handle->subscribed_cb) {
wifi_aware_subscribed_cb subscribed_cb = handle->subscribed_cb;
uint16_t _wifi_aware_session_get_pub_sub_id(wifi_aware_session_h session)
{
- wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
+ wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
return handle->pub_sub_id;
}
const char *_wifi_aware_session_get_service_name(wifi_aware_session_h session)
{
- wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
+ wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
if (handle->session_type == WIFI_AWARE_SESSION_PUBLISH) {
wifi_aware_publish_request_s *req =
(wifi_aware_publish_request_s *)handle->publish_config;
return req->service_name;
- }
- else {
+ } else {
wifi_aware_subscribe_request_s *req =
(wifi_aware_subscribe_request_s *)handle->subscribe_config;
return req->service_name;
{
session_handle->pub_sub_id = 0;
session_handle->session_type = WIFI_AWARE_SESSION_PUBLISH;
- session_handle->publish_config = NULL;
- session_handle->subscribe_config = NULL;
+ session_handle->publish_config = NULL;
+ session_handle->subscribe_config = NULL;
session_handle->is_requested = false;
session_handle->published_cb = NULL;
}
static void __session_terminated_cb(GDBusConnection *connection,
- const gchar *sender, const gchar *object_path,
- const gchar *interface, const gchar *signal,
- GVariant *parameters, gpointer user_data)
+ const gchar *sender, const gchar *object_path,
+ const gchar *interface, const gchar *signal,
+ GVariant *parameters, gpointer user_data)
{
WIFI_AWARE_LOGD("session is terminated.");
void _wifi_aware_publish_set_default_values(wifi_aware_publish_h publish)
{
- wifi_aware_publish_request_s *req = (wifi_aware_publish_request_s *)publish;
+ wifi_aware_publish_request_s *req = (wifi_aware_publish_request_s *)publish;
req->ttl = 0;
req->publish_type = WIFI_AWARE_PUBLISH_TYPE_UNSOLICITED;
req->specific_info_len = 0;
void _wifi_aware_subscribe_set_default_values(
wifi_aware_subscribe_h subscribe)
{
- wifi_aware_subscribe_request_s *req = (wifi_aware_subscribe_request_s *)subscribe;
+ wifi_aware_subscribe_request_s *req = (wifi_aware_subscribe_request_s *)subscribe;
req->ttl = 0;
req->subscribe_type = WIFI_AWARE_SUBSCRIBE_TYPE_PASSIVE;
//memset(req->specific_info[WIFI_AWARE_MAX_SERVICE_SPECIFIC_INFO_LEN], 0, WIFI_AWARE_MAX_SERVICE_SPECIFIC_INFO_LEN);
static bool __unpack_byte_array(unsigned char *array, GVariant *var, uint16_t len)
{
- GVariantIter *iter = NULL;
- int length = 0;
+ GVariantIter *iter = NULL;
+ int length = 0;
- if (array == NULL || var == NULL || len == 0) {
- WIFI_AWARE_LOGI("Invalid parameter");
- return false;
- }
+ if (array == NULL || var == NULL || len == 0) {
+ WIFI_AWARE_LOGI("Invalid parameter");
+ return false;
+ }
- g_variant_get(var, "ay", &iter);
- if (iter == NULL) {
- WIFI_AWARE_LOGE("Fail to get iterator");
- return false;
- }
+ g_variant_get(var, "ay", &iter);
+ if (iter == NULL) {
+ WIFI_AWARE_LOGE("Fail to get iterator");
+ return false;
+ }
- while (g_variant_iter_loop(iter, "y", &array[length])) {
- ++length;
- if (length >= len)
- break;
- }
- g_variant_iter_free(iter);
+ while (g_variant_iter_loop(iter, "y", &array[length])) {
+ ++length;
+ if (length >= len)
+ break;
+ }
+ g_variant_iter_free(iter);
return true;
}
}
static void __service_discovered_cb(GDBusConnection *connection,
- const gchar *sender, const gchar *object_path,
- const gchar *interface, const gchar *signal,
- GVariant *parameters, gpointer user_data)
+ const gchar *sender, const gchar *object_path,
+ const gchar *interface, const gchar *signal,
+ GVariant *parameters, gpointer user_data)
{
__WIFI_AWARE_FUNC_ENTER__;
WIFI_AWARE_LOGD("NAN Service is discovered");
}
static void __message_received_cb(GDBusConnection *connection,
- const gchar *sender, const gchar *object_path,
- const gchar *interface, const gchar *signal,
- GVariant *parameters, gpointer user_data)
+ const gchar *sender, const gchar *object_path,
+ const gchar *interface, const gchar *signal,
+ GVariant *parameters, gpointer user_data)
{
__WIFI_AWARE_FUNC_ENTER__;
WIFI_AWARE_LOGD("NAN Service is discovered");
RET_VAL_IF(!_wifi_aware_session_is_subscribe_type(session),
WIFI_AWARE_ERROR_INVALID_OPERATION, "This session is not for Subscribe");
- wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
+ wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
handle->discovered_cb = callback;
handle->discovered_cb_data = user_data;
handle->discovered_signal_id =
RET_VAL_IF(!_wifi_aware_session_is_subscribe_type(session),
WIFI_AWARE_ERROR_INVALID_OPERATION, "This session is not for Subscribe");
- wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
+ wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
handle->discovered_cb = NULL;
handle->discovered_cb_data = NULL;
if (handle->discovered_signal_id > 0)
__WIFI_AWARE_FUNC_ENTER__;
RET_VAL_IF(session == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_session_h is NULL");
- wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
+ wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
handle->received_cb = callback;
handle->received_cb_data = user_data;
handle->received_signal_id =
__WIFI_AWARE_FUNC_ENTER__;
RET_VAL_IF(session == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_session_h is NULL");
- wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
+ wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
handle->received_cb = NULL;
handle->received_cb_data = NULL;
if (handle->received_signal_id > 0)
WIFI_AWARE_LOGE("Followup Request failure: %s", dbus_error->message);
error = _wifi_aware_convert_error_string_to_enum(dbus_error->message);
g_error_free(dbus_error);
- }
- else {
+ } else {
g_variant_get(reply, "(i)", &nan_error);
WIFI_AWARE_LOGI("error: %d", nan_error);
error = _wifi_aware_convert_nan_manager_error(nan_error);
*
*/
-/**
- * This file implements Wi-Fi Aware user library.
- *
- * @file wifi-aware-client.c
- * @author Jiung Yu (jiung.yu@samsung.com)
- */
-
-
#include <glib.h>
#include "wifi-aware.h"
#define MATCHING_FILTER_FORMAT_NUM 8
matching_filter_format_t test_matching_filter[MATCHING_FILTER_FORMAT_NUM]
- = { {5, {0, 0, 0, 0, 0}}, // <0><0><0><0><0> -> wildcard
- {10, {1, 1, 1, 2, 1, 3, 1, 4, 1, 5}}, // <1,1,><1,2><1,3><1,4><1,5> -> value filter 1
- {10, {1, 1, 1, 2, 1, 1, 1, 4, 1, 5}}, // <1,1,><1,2><1,1><1,4><1,5> -> value filter 2
- {6, {0, 1, 2, 0, 1, 4}}, // <0><1,2><0><1,4> -> value filter 3
- {8, {0, 1, 2, 1, 3, 0, 1, 5}}, // <0><1,2><1,3><0><1,5> -> value filter 4
- {6, {1, 1, 0, 1, 3, 0}}, // <1,1><0><1,3><0> -> value filter 5
- {8, {1, 1, 0, 1, 3, 0, 1, 5}}, // <1,1><0><1,3><0><1,5> -> value filter 6
- {0, {0, }}, // No filter
+ = { {5, {0, 0, 0, 0, 0} }, // <0><0><0><0><0> -> wildcard
+ {10, {1, 1, 1, 2, 1, 3, 1, 4, 1, 5} }, // <1,1,><1,2><1,3><1,4><1,5> -> value filter 1
+ {10, {1, 1, 1, 2, 1, 1, 1, 4, 1, 5} }, // <1,1,><1,2><1,1><1,4><1,5> -> value filter 2
+ {6, {0, 1, 2, 0, 1, 4} }, // <0><1,2><0><1,4> -> value filter 3
+ {8, {0, 1, 2, 1, 3, 0, 1, 5} }, // <0><1,2><1,3><0><1,5> -> value filter 4
+ {6, {1, 1, 0, 1, 3, 0} }, // <1,1><0><1,3><0> -> value filter 5
+ {8, {1, 1, 0, 1, 3, 0, 1, 5} }, // <1,1><0><1,3><0><1,5> -> value filter 6
+ {0, {0, } }, // No filter
};
#ifdef __cplusplus
*
*/
-/**
- * This file implements Wi-Fi Aware test executable.
- *
- * @file wifi-aware-test.c
- * @author Jiung Yu (jiung.yu@samsung.com)
- */
-
-
-/*****************************************************************************
- * Standard headers
- *****************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <glib.h>
-/*****************************************************************************
- * System headers
- *****************************************************************************/
#include <system_info.h>
-/*****************************************************************************
- * Wi-Fi Aware library headers
- *****************************************************************************/
#include "wifi-aware.h"
-/*****************************************************************************
- * Intelligent Network Monitoring(WIFI_AWARE) test local headers
- *****************************************************************************/
-#include "wifi-aware-test.h"
-
-/*****************************************************************************
- * Macros and Typedefs
- *****************************************************************************/
-
#define RESET_COLOR "\e[m"
#define MAKE_RED "\e[31m"
#define MAKE_GREEN "\e[32m"
else
printf("\\\\x%02X", *ptr);
ptr++;
- }
- printf("\n");
+ }
+ printf("\n");
}
void test_full_menu()
else
PRINT_FAILURE_ERROR("\tPeer's Port:", ret);
__test_finish(1);
- }
- else {
+ } else {
PRINT_FAILURE("[CB][OpenDataPath] Failure(%d:%s) %p", error, __print_error(error), data_path);
__test_finish(0);
}
ret = wifi_aware_publish_set_type(publish, g_pub_type);
if (ret == WIFI_AWARE_ERROR_NONE) {
- printf("\tPublish Type: %s\n", g_pub_type == WIFI_AWARE_PUBLISH_TYPE_UNSOLICITED ?
+ printf("\tPublish Type: %s\n", g_pub_type == WIFI_AWARE_PUBLISH_TYPE_UNSOLICITED ?
"Unsolicited" : "Solicited");
- }
- else {
+ } else {
PRINT_FAILURE_ERROR("\tPublish Type:", ret);
return false;
}
ret = wifi_aware_publish_set_service_name(publish, g_service_name);
if (ret == WIFI_AWARE_ERROR_NONE) {
printf("\tService Name: %s\n", g_service_name);
- }
- else {
+ } else {
PRINT_FAILURE_ERROR("\tService Name:", ret);
return false;
}
if (ret == WIFI_AWARE_ERROR_NONE) {
printf("\tService Specific Info: ");
__print_byte_array(specific_info, len);
- }
- else {
+ } else {
PRINT_FAILURE_ERROR("\tService Specific Info:", ret);
return false;
}
ret = wifi_aware_publish_enable_ranging(publish, g_ranging);
if (ret == WIFI_AWARE_ERROR_NONE) {
printf("\tRanging: %s\n", g_ranging ? "Enable" : "Disable");
- }
- else {
+ } else {
PRINT_FAILURE_ERROR("\tRanging:", ret);
return false;
}
{
if (error == WIFI_AWARE_ERROR_NONE) {
PRINT_SUCCESS("[CB][Enable] Enabled");
- }
- else {
+ } else {
PRINT_FAILURE_ERROR("[CB][Enable]", error);
return;
}
*
*/
-/**
- * This file implements Wi-Fi Aware test executable.
- *
- * @file wifi-aware-test.c
- * @author Jiung Yu (jiung.yu@samsung.com)
- */
-
-
-/*****************************************************************************
- * Standard headers
- *****************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <glib.h>
-/*****************************************************************************
- * System headers
- *****************************************************************************/
#include <system_info.h>
-/*****************************************************************************
- * Wi-Fi Aware library headers
- *****************************************************************************/
#include "wifi-aware.h"
-/*****************************************************************************
- * Intelligent Network Monitoring(WIFI_AWARE) test local headers
- *****************************************************************************/
-#include "wifi-aware-test.h"
-
-/*****************************************************************************
- * Macros and Typedefs
- *****************************************************************************/
-
#define RESET_COLOR "\e[m"
#define MAKE_RED "\e[31m"
#define MAKE_GREEN "\e[32m"
else
printf("\\\\x%02X", *ptr);
ptr++;
- }
- printf("\n");
+ }
+ printf("\n");
}
static void test_quit()
else
PRINT_FAILURE_ERROR("\tPeer's Port:", ret);
__test_finish(1);
- }
- else {
+ } else {
PRINT_FAILURE("[CB][OpenDataPath] Failure(%d:%s) %p", error, __print_error(error), data_path);
__test_finish(0);
}
printf("\tPeer's NMI: Failure(%d:%s)\n", ret, __print_error(ret));
} else {
printf("\tPeer's NMI: ");
- if (mac != NULL) {
+ if (mac != NULL)
__print_mac(mac);
- }
printf("\n");
}
ret = wifi_aware_subscribe_set_type(subscribe, g_sub_type);
if (ret == WIFI_AWARE_ERROR_NONE) {
- printf("\tSubscribe Type: %s\n", g_sub_type == WIFI_AWARE_SUBSCRIBE_TYPE_PASSIVE ?
+ printf("\tSubscribe Type: %s\n", g_sub_type == WIFI_AWARE_SUBSCRIBE_TYPE_PASSIVE ?
"Passive" : "Active");
- }
- else {
+ } else {
PRINT_FAILURE_ERROR("\tSubscribe Type:", ret);
return false;
}
g_service_name);
if (ret == WIFI_AWARE_ERROR_NONE) {
printf("\tService Name: %s\n", g_service_name);
- }
- else {
+ } else {
PRINT_FAILURE_ERROR("\tService Name:", ret);
return false;
}
if (ret == WIFI_AWARE_ERROR_NONE) {
printf("\tService Specific Info: ");
__print_byte_array(specific_info, len);
- }
- else {
+ } else {
PRINT_FAILURE_ERROR("\tService Specific Info:", ret);
return false;
}
ret = wifi_aware_subscribe_set_min_distance(subscribe, g_min_distance);
if (ret == WIFI_AWARE_ERROR_NONE) {
printf("\tMin Distance: %d\n", g_min_distance);
- }
- else {
+ } else {
PRINT_FAILURE_ERROR("\tMin Distance:", ret);
return false;
}
ret = wifi_aware_subscribe_set_max_distance(subscribe, g_max_distance);
if (ret == WIFI_AWARE_ERROR_NONE) {
printf("\tMax Distance: %d\n", g_min_distance);
- }
- else {
+ } else {
PRINT_FAILURE_ERROR("\tMax Distance:", ret);
return false;
}
{
if (error == WIFI_AWARE_ERROR_NONE) {
PRINT_SUCCESS("[CB][Enable] Enabled");
- }
- else {
+ } else {
PRINT_FAILURE_ERROR("[CB][Enable]", error);
return;
}
*
*/
-/**
- * This file implements Wi-Fi Aware test executable.
- *
- * @file wifi-aware-test.c
- * @author Jiung Yu (jiung.yu@samsung.com)
- */
-
-
-/*****************************************************************************
- * Standard headers
- *****************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <glib.h>
-/*****************************************************************************
- * System headers
- *****************************************************************************/
#include <system_info.h>
-/*****************************************************************************
- * Wi-Fi Aware library headers
- *****************************************************************************/
#include "wifi-aware.h"
-/*****************************************************************************
- * Intelligent Network Monitoring(WIFI_AWARE) test local headers
- *****************************************************************************/
-#include "wifi-aware-test.h"
-
-/*****************************************************************************
- * Macros and Typedefs
- *****************************************************************************/
-
#define RESET_COLOR "\e[m"
#define MAKE_RED "\e[31m"
#define MAKE_GREEN "\e[32m"
if (!g_wifi_aware_session) {\
printf("wifi-aware-session handle is not created yet\n");\
return;\
- }\
+ } \
} while (0)
#define RET_IF_NDP_IS_NULL()\
if (!g_ndp) {\
printf("wifi_aware_data_path handle is not created yet\n");\
return;\
- }\
+ } \
} while (0)
#define MATCH_FILTER "bytes used for matching"
CMD_INVALID,
};
-/*****************************************************************************
- * Global Variables
- *****************************************************************************/
-
static char *g_menu_str[] = {
[CMD_QUIT]
= "QUIT",
static int g_session_type = -1; // 0: publish, 1: subscribe
static unsigned char g_msg[4];
-/*****************************************************************************
- * Local Functions Definition
- *****************************************************************************/
-
static inline char* __cmd_transform(char*str)
{
int i, j;
static void __print_result(int ret, gchar *function_name)
{
- if (ret == WIFI_AWARE_ERROR_NONE) {
- printf(MAKE_GREEN"%s"RESET_COLOR"\n", function_name);
- } else {
- printf(MAKE_RED"%s: %s ", function_name, __print_error(ret));
- printf(RESET_COLOR"\n");
- }
-
- printf("%s() result=[%d]\n", function_name, ret);
+ if (ret == WIFI_AWARE_ERROR_NONE) {
+ printf(MAKE_GREEN"%s"RESET_COLOR"\n", function_name);
+ } else {
+ printf(MAKE_RED"%s: %s ", function_name, __print_error(ret));
+ printf(RESET_COLOR"\n");
+ }
+
+ printf("%s() result=[%d]\n", function_name, ret);
}
void __print_byte_array(const unsigned char *data, size_t len)
else
printf("\\\\x%02X", *ptr);
ptr++;
- }
- printf("\n");
+ }
+ printf("\n");
}
void test_full_menu()
while (i < filter_len) {
len = filter[i];
printf("%d: ", len);
- for (int j = 1; j <= len; ++j) {
+ for (int j = 1; j <= len; ++j)
printf("%d, ", filter[i + j]);
- }
printf("\n");
i += len + 1;
}
printf("Do you want to set Service Specific Information? (0-No, 1-Yes) ");
if (scanf("%d", &set_info) < 0)
return;
-
+
if (set_info == 1) {
if (scanf(" %" STR(MAX_SPECIFIC_INFO_LEN) "s", str_specific_info) < 0)
return;
static wifi_aware_peer_h __get_peer_by_id(int peer_id)
{
GSList *list = (GSList *)g_slist_find_custom(g_peer_list,
- GINT_TO_POINTER(peer_id), (GCompareFunc)__equal_peer_id);
+ GINT_TO_POINTER(peer_id), (GCompareFunc)__equal_peer_id);
if (!list) {
printf("No Peer %d ", peer_id);
return NULL;
printf("Do you want to set Service Specific Information? (0-No, 1-Yes) ");
if (scanf("%d", &set_info) < 0)
return;
-
+
if (set_info == 1) {
if (scanf(" %" STR(MAX_SPECIFIC_INFO_LEN) "s", str_specific_info) < 0)
return;
return;
wifi_aware_peer_h peer = __get_peer_by_id(peer_id);
- printf("Selected peer: %p", peer);
+ printf("Selected peer: %p", peer);
int ret = wifi_aware_session_send_message(g_wifi_aware_session, peer, g_msg, len, __message_result_cb, peer);
__print_result(ret, "wifi_aware_send_message");
else
printf("Fail to get Port number\n");
}
- }
- else {
+ } else {
printf("\n>>Fail to open Data path. data path: %p. error: %s\n", data_path, __print_error(error));
}
+++ /dev/null
-/*
- * Wi-Fi Aware Test Program
- *
- * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
-
- * This file declares functions for testing Wi-Fi aware CAPIs.
- *
- * @file wifi-aware-test.h
- * @author Jiung Yu (jiung.yu@samsung.com)
- */
-#ifndef __WIFI_AWARE_TEST_H__
-#define __WIFI_AWARE_TEST_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __WIFI_AWARE_TEST_H__ */
class WifiAwarePublish : public WifiAware
{
protected:
- virtual void SetUp() {
+ virtual void SetUp()
+ {
WifiAware::SetUp();
wifi_aware_publish_create(&g_publish_config);
}
- virtual void TearDown() {
+ virtual void TearDown()
+ {
wifi_aware_publish_destroy(g_publish_config);
WifiAware::TearDown();
}
class WifiAwareSession : public WifiAware
{
protected:
- virtual void SetUp() {
+ virtual void SetUp()
+ {
g_published = false;
g_subscribed = false;
WifiAware::SetUp();
RUN_GMAIN_LOOP;
}
- virtual void TearDown() {
+ virtual void TearDown()
+ {
wifi_aware_disable();
WifiAware::TearDown();
}
class WifiAwareSubscribe : public WifiAware
{
protected:
- virtual void SetUp() {
+ virtual void SetUp()
+ {
WifiAware::SetUp();
wifi_aware_subscribe_create(&g_subscribe_config);
}
- virtual void TearDown() {
+ virtual void TearDown()
+ {
wifi_aware_subscribe_destroy(g_subscribe_config);
WifiAware::TearDown();
}
class WifiAware : public ::testing::Test
{
protected:
- virtual void SetUp() {
+ virtual void SetUp()
+ {
g_enabled = false;
g_wifi_aware_supported = false;
system_info_get_platform_bool(WIFI_AWARE_FEATURE,
wifi_aware_initialize();
}
- virtual void TearDown() {
+ virtual void TearDown()
+ {
wifi_aware_deinitialize();
}
#include "wifi-aware.h"
#define CHECK_WIFI_AWARE_SUPPORTED(ret) do { \
- if (!WifiAware::g_wifi_aware_supported) { \
- ASSERT_EQ(ret, WIFI_AWARE_ERROR_NOT_SUPPORTED) << "FAIL NOT_SUPPORTED"; \
- } \
- } while (0)
+ if (!WifiAware::g_wifi_aware_supported) { \
+ ASSERT_EQ(ret, WIFI_AWARE_ERROR_NOT_SUPPORTED) << "FAIL NOT_SUPPORTED"; \
+ } \
+ } while (0)
#define CHECK_RESULT(ret, expected, message) do { \
- CHECK_WIFI_AWARE_SUPPORTED(ret); \
- ASSERT_EQ(ret, expected) << "FAIL " << message; \
- } while (0)
+ CHECK_WIFI_AWARE_SUPPORTED(ret); \
+ ASSERT_EQ(ret, expected) << "FAIL " << message; \
+ } while (0)
#define CALLBACK_TIMEOUT 20000
#define RUN_GMAIN_LOOP do { \
WifiAware::g_main_loop = g_main_loop_new(NULL, false); \
- WifiAware::g_timeout_id = g_timeout_add(CALLBACK_TIMEOUT, \
+ WifiAware::g_timeout_id = g_timeout_add(CALLBACK_TIMEOUT, \
WifiAware::_wifi_aware_callback_timeout, WifiAware::g_main_loop); \
- g_main_loop_run(WifiAware::g_main_loop); \
- g_source_remove(WifiAware::g_timeout_id); \
- WifiAware::g_main_loop = NULL; \
- } while (0)
+ g_main_loop_run(WifiAware::g_main_loop); \
+ g_source_remove(WifiAware::g_timeout_id); \
+ WifiAware::g_main_loop = NULL; \
+ } while (0)
#define QUIT_GMAIN_LOOP do { \
- if (WifiAware::g_main_loop) { \
- g_main_loop_quit(WifiAware::g_main_loop); \
- WifiAware::g_main_loop = NULL; \
- } \
- } while (0)
+ if (WifiAware::g_main_loop) { \
+ g_main_loop_quit(WifiAware::g_main_loop); \
+ WifiAware::g_main_loop = NULL; \
+ } \
+ } while (0)
#define SERVICE_NAME "NanService"
#define SERVICE_INFO "ServiceInfo"