* @{
*/
bool g_bCallbackCalledDiscover;
+bool g_bCallbackCalledResult;
+
struct cbdata {
cion_client_h client;
bool connected;
static void RunPollingLoop(void) {
main_loop = g_main_loop_new(NULL, FALSE);
- source_id = g_timeout_add(10000, __timeout_cb, NULL);\
+ source_id = g_timeout_add(60000, __timeout_cb, NULL);\
g_main_loop_run(main_loop);\
g_source_remove(source_id);
main_loop = NULL;
* @parameter const char *service_name,const cion_peer_info_h peer_info, const unsigned char *data,unsigned int data_size, unsigned char **return_data,unsigned int *return_data_size, void *user_data
* @return NA
*/
-void ServerDataReceivedCB(const char *service_name,const cion_peer_info_h peer_info, const unsigned char *data,unsigned int data_size, unsigned char **return_data,unsigned int *return_data_size, void *user_data)
+void ServerDataReceivedCB(const char *service_name,const cion_peer_info_h peer_info, const unsigned char *data,unsigned int data_size, unsigned char **return_data,unsigned int *return_data_size, void *user_data)
{
FPRINTF("[Line : %d][%s] Callback ServerDataReceivedCB called\\n", __LINE__, API_NAMESPACE);
char pszStr[] ="data_result";
nRetVal = cion_client_connect(cbdata->client, peer_info);
if (nRetVal != CION_ERROR_NONE)
FPRINTF("[Line : %d][%s] Failed cion_client_connect\\n", __LINE__, API_NAMESPACE);
+
+ StopPollingLoop();
}
/**
*/
static void ClientConnectionResultCB(const char *service_name,const cion_peer_info_h peer_info,const cion_connection_result_h result, void *user_data)
{
- FPRINTF("[Line : %d][%s] Callback ClientConnectionResultCB called\\n", __LINE__, API_NAMESPACE);
+ cion_connection_status_e status;
+ int nRetVal;
+
+ nRetVal = cion_connection_result_get_status(result, &status);
+
+ FPRINTF("[Line : %d][%s] Callback ClientConnectionResultCB called[%d][%d]\\n", __LINE__, API_NAMESPACE, nRetVal, status);
sleep(2);
+
+ if (status == CION_CONNECTION_STATUS_OK)
+ g_bCallbackCalledResult = true;
+
StopPollingLoop();
}
cion_server_h hServer;
g_bCallbackCalled = false;
g_bCallbackCalledDiscover = false;
+ g_bCallbackCalledResult = false;
int nTimeoutId = -1;
GThread *thread;
nRetVal = cion_server_listen(hServer, ServerConnectionRequestCB,hServer);
PRINT_RESULT(CION_ERROR_NONE, nRetVal, "cion_server_listen", CionGetError(nRetVal));
- nRetVal = cion_client_add_connection_result_cb(hClient,ClientConnectionResultCB, NULL);
+ nRetVal = cion_client_add_connection_result_cb(hClient, ClientConnectionResultCB, NULL);
PRINT_RESULT(CION_ERROR_NONE, nRetVal, "cion_client_add_connection_result_cb", CionGetError(nRetVal));
cbdata.client = hClient;
FPRINTF("[Line : %d][%s] Callback ClientServerDiscoveredCB4 not invoked\\n", __LINE__, API_NAMESPACE);
return 1;
}
+
+ RunPollingLoop();
+ if(g_bCallbackCalledResult != true)
+ {
+ FPRINTF("[Line : %d][%s] Callback ClientConnectionResultCB not invoked\\n", __LINE__, API_NAMESPACE);
+ return 1;
+ }
+
send_data.client = hClient;
thread = g_thread_new("send_data", SendDataThread, &send_data);
RunPollingLoop();
- PRINT_RESULT(CION_ERROR_NONE, send_data.ret, "cion_client_try_discovery", CionGetError(send_data.ret));
+ PRINT_RESULT(CION_ERROR_NONE, send_data.ret, "cion_client_send_data", CionGetError(send_data.ret));
if(strncmp((const char *)send_data.return_data, "data_result",send_data.return_data_size) != 0)
{
FPRINTF("[Line : %d][%s] data is not correct\\n", __LINE__, API_NAMESPACE);
unsigned char pszData[] = "ITc_cion_client_send_payload_async_p";
struct cbdata cbdata;
g_bCallbackCalled = false;
+ g_bCallbackCalledResult = false;
int nTimeoutId = -1;
nRetVal = cion_server_create(&hServer,"ITc_cion_client_send_payload_async_p","ITc_cion_client_send_payload_async_p", NULL);
nRetVal = cion_client_try_discovery(hClient, ClientServerDiscoveredCB3,&cbdata);
PRINT_RESULT_CLEANUP(CION_ERROR_NONE, nRetVal, "cion_client_try_discovery", CionGetError(nRetVal),cion_server_destroy(hServer);cion_client_destroy(hClient));
+ nRetVal = cion_client_add_connection_result_cb(hClient,ClientConnectionResultCB, NULL);
+ PRINT_RESULT(CION_ERROR_NONE, nRetVal, "cion_client_add_connection_result_cb", CionGetError(nRetVal));
+
RunPollingLoop();
if(g_bCallbackCalled != true)
{
return 1;
}
+ RunPollingLoop();
+ if(g_bCallbackCalledResult != true)
+ {
+ FPRINTF("[Line : %d][%s] Callback ClientConnectionResultCB not invoked\\n", __LINE__, API_NAMESPACE);
+ return 1;
+ }
+
nRetVal = cion_payload_create(&hPayload, CION_PAYLOAD_TYPE_DATA);
PRINT_RESULT_CLEANUP(CION_ERROR_NONE, nRetVal, "cion_payload_create", CionGetError(nRetVal),cion_server_destroy(hServer);cion_client_destroy(hClient));
CHECK_HANDLE(hPayload,"cion_payload_create");
#include <app.h>
#define API_NAMESPACE "CION_ITC"
-#define TIMEOUT_CB 10000
-#define TIMEOUT_CB1 5000
+#define TIMEOUT_CB 60000
+#define TIMEOUT_CB1 60000
/** @addtogroup itc-%{MODULE_NAME}
* @ingroup itc
* @{
static void RunPollingLoop(void) {
main_loop = g_main_loop_new(NULL, FALSE);
- source_id = g_timeout_add(5000, __timeout_cb, NULL);\
+ source_id = g_timeout_add(60000, __timeout_cb, NULL);\
g_main_loop_run(main_loop);\
g_source_remove(source_id);
main_loop = NULL;
/** @} */
-/** @} */
\ No newline at end of file
+/** @} */
static void RunPollingLoop(void) {
main_loop = g_main_loop_new(NULL, FALSE);
- source_id = g_timeout_add(10000, __timeout_cb, NULL);\
+ source_id = g_timeout_add(60000, __timeout_cb, NULL);\
g_main_loop_run(main_loop);\
g_source_remove(source_id);
main_loop = NULL;
ret = cion_peer_info_clone(peer_info, peer);
if (ret != CION_ERROR_NONE)
FPRINTF("[Line : %d][%s] failed cion_peer_info_clone\\n", __LINE__, API_NAMESPACE);
+
+ StopPollingLoop();
}
/**
static void __run_polling_loop(void) {
main_loop = g_main_loop_new(NULL, FALSE);
- source_id = g_timeout_add(10000, __timeout_cb, NULL);\
+ source_id = g_timeout_add(60000, __timeout_cb, NULL);\
g_main_loop_run(main_loop);\
g_source_remove(source_id);
main_loop = NULL;
static void __server_connection_request_cb(const char *service_name,
const cion_peer_info_h peer_info, void *user_data)
{
+ int ret;
+ cion_server_h server = (cion_server_h)user_data;
+
+ ret = cion_server_accept(server, peer_info);
+ if (ret != CION_ERROR_NONE)
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s] Failed to accept client", __func__);
}
static void __client_server_discovered_cb2(const char *service_name,
__client_connection_result_cb1, NULL);
assert_eq(ret, CION_ERROR_NONE);
- ret = cion_server_listen(server, __server_connection_request_cb, NULL);
+ ret = cion_server_listen(server, __server_connection_request_cb, server);
assert_eq(ret, CION_ERROR_NONE);
ret = cion_client_try_discovery(client, __client_server_discovered_cb2,
return 0;
}
-static void __server_connection_request_cb2(const char *service_name,
- const cion_peer_info_h peer_info, void *user_data)
-{
- int ret;
- cion_server_h server = (cion_server_h)user_data;
-
- ret = cion_server_accept(server, peer_info);
- if (ret != CION_ERROR_NONE)
- dlog_print(DLOG_ERROR, LOG_TAG, "[%s] Failed to accept client", __func__);
-}
-
static void __client_server_discovered_cb3(const char *service_name,
const cion_peer_info_h peer_info, void *user_data)
{
NULL);
assert_eq(ret, CION_ERROR_NONE);
- ret = cion_server_listen(server, __server_connection_request_cb2, server);
+ ret = cion_client_add_connection_result_cb(cbdata.client,
+ __client_connection_result_cb1, NULL);
+ assert_eq(ret, CION_ERROR_NONE);
+
+ ret = cion_server_listen(server, __server_connection_request_cb, server);
assert_eq(ret, CION_ERROR_NONE);
ret = cion_client_try_discovery(cbdata.client, __client_server_discovered_cb3,
assert_eq(ret, CION_ERROR_NONE);
dlog_print(DLOG_INFO, LOG_TAG,
- "[%s] Wait for discovering & connecting to server", __func__);
+ "[%s] Wait for discovering to server", __func__);
+ __run_polling_loop();
+
+ dlog_print(DLOG_INFO, LOG_TAG,
+ "[%s] Wait for connecting to server", __func__);
__run_polling_loop();
assert_eq(cbdata.connected, true);
ret = cion_server_set_data_received_cb(server, __server_data_received_cb, NULL);
assert_eq(ret, CION_ERROR_NONE);
- ret = cion_server_listen(server, __server_connection_request_cb2, server);
+ ret = cion_server_listen(server, __server_connection_request_cb, server);
assert_eq(ret, CION_ERROR_NONE);
ret = cion_client_add_connection_result_cb(client,
"utc_cion_client_send_payload_async_p", NULL);
assert_eq(ret, CION_ERROR_NONE);
- ret = cion_server_listen(server, __server_connection_request_cb2, server);
+ ret = cion_client_add_connection_result_cb(client,
+ __client_connection_result_cb1, NULL);
+ assert_eq(ret, CION_ERROR_NONE);
+
+ ret = cion_server_listen(server, __server_connection_request_cb, server);
assert_eq(ret, CION_ERROR_NONE);
cbdata.client = client;
assert_eq(ret, CION_ERROR_NONE);
dlog_print(DLOG_INFO, LOG_TAG,
- "[%s] Wait for discovering & connecting to server", __func__);
+ "[%s] Wait for discovering to server", __func__);
+ __run_polling_loop();
+
+ dlog_print(DLOG_INFO, LOG_TAG,
+ "[%s] Wait for connecting to server", __func__);
__run_polling_loop();
ret = cion_payload_create(&payload, CION_PAYLOAD_TYPE_DATA);
static void __run_polling_loop(void) {
main_loop = g_main_loop_new(NULL, FALSE);
- source_id = g_timeout_add(10000, __timeout_cb, NULL);\
+ source_id = g_timeout_add(60000, __timeout_cb, NULL);\
g_main_loop_run(main_loop);\
g_source_remove(source_id);
main_loop = NULL;
static void __run_polling_loop(void) {
main_loop = g_main_loop_new(NULL, FALSE);
- source_id = g_timeout_add(5000, __timeout_cb, NULL);\
+ source_id = g_timeout_add(60000, __timeout_cb, NULL);\
g_main_loop_run(main_loop);\
g_source_remove(source_id);
main_loop = NULL;
static void __run_polling_loop(void) {
main_loop = g_main_loop_new(NULL, FALSE);
- source_id = g_timeout_add(5000, __timeout_cb, NULL);\
+ source_id = g_timeout_add(60000, __timeout_cb, NULL);\
g_main_loop_run(main_loop);\
g_source_remove(source_id);
main_loop = NULL;
static void __run_polling_loop(void) {
main_loop = g_main_loop_new(NULL, FALSE);
- source_id = g_timeout_add(5000, __timeout_cb, NULL);\
+ source_id = g_timeout_add(60000, __timeout_cb, NULL);\
g_main_loop_run(main_loop);\
g_source_remove(source_id);
main_loop = NULL;
static void __run_polling_loop(void) {
main_loop = g_main_loop_new(NULL, FALSE);
- source_id = g_timeout_add(10000, __timeout_cb, NULL);\
+ source_id = g_timeout_add(60000, __timeout_cb, NULL);\
g_main_loop_run(main_loop);\
g_source_remove(source_id);
main_loop = NULL;