diff options
author | Jooseok Park <jooseok.park@samsung.com> | 2016-12-13 13:22:52 +0900 |
---|---|---|
committer | Jooseok Park <jooseok.park@samsung.com> | 2016-12-13 13:24:55 +0900 |
commit | 4b81f4d4062fef9ee6f4a3108974cf36e3f588e7 (patch) | |
tree | 7ae37a28e1b5d927b42ba1aa3dadb5f6207abed2 | |
parent | bac28135df70543623c4685060e5095d204a7d1d (diff) | |
parent | 41e94254edeca4344310fcc9d3ccfcf4519e1fa3 (diff) | |
download | iotcon-4b81f4d4062fef9ee6f4a3108974cf36e3f588e7.tar.gz iotcon-4b81f4d4062fef9ee6f4a3108974cf36e3f588e7.tar.bz2 iotcon-4b81f4d4062fef9ee6f4a3108974cf36e3f588e7.zip |
Merge branch 'tizen_3.0' into tizen (iotcon 0.3.8)submit/tizen/20161213.050408
Change-Id: I78653acefac0eb9d2a60333e2d6fce737403f34e
-rw-r--r-- | packaging/iotcon.spec | 2 | ||||
-rw-r--r-- | src/ic-ioty-convert.c | 2 | ||||
-rw-r--r-- | src/ic-ioty-ocprocess.c | 28 | ||||
-rw-r--r-- | src/ic-ioty-parse.c | 64 | ||||
-rw-r--r-- | src/ic-ioty-parse.h | 4 | ||||
-rw-r--r-- | src/ic-ioty.c | 182 | ||||
-rw-r--r-- | src/ic-ioty.h | 4 | ||||
-rw-r--r-- | src/ic-lite-resource.h | 2 | ||||
-rw-r--r-- | src/ic-presence.c | 5 | ||||
-rw-r--r-- | src/ic-provisioning-find.c | 3 | ||||
-rw-r--r-- | src/ic-provisioning-struct.c | 10 | ||||
-rw-r--r-- | src/ic-provisioning.c | 9 | ||||
-rw-r--r-- | src/ic-remote-resource-caching.c | 4 | ||||
-rw-r--r-- | src/ic-remote-resource-crud.c | 4 | ||||
-rw-r--r-- | src/ic-remote-resource.c | 6 | ||||
-rw-r--r-- | src/ic-remote-resource.h | 5 | ||||
-rw-r--r-- | src/ic-request.h | 4 | ||||
-rw-r--r-- | src/ic-resource.h | 2 | ||||
-rw-r--r-- | src/ic-response.h | 4 | ||||
-rw-r--r-- | src/ic-types.c | 8 | ||||
-rw-r--r-- | src/ic-types.h | 2 | ||||
-rw-r--r-- | src/ic-utils.c | 3 | ||||
-rw-r--r-- | src/ic.c | 1 | ||||
-rw-r--r-- | test/iotcon-test-basic-client.c | 10 | ||||
-rw-r--r-- | test/iotcon-test-encap-client.c | 14 |
25 files changed, 177 insertions, 205 deletions
diff --git a/packaging/iotcon.spec b/packaging/iotcon.spec index 065ed90..f083411 100644 --- a/packaging/iotcon.spec +++ b/packaging/iotcon.spec @@ -1,6 +1,6 @@ Name: iotcon Summary: Tizen IoT Connectivity -Version: 0.3.2 +Version: 0.3.8 Release: 0 Group: Network & Connectivity/Service License: Apache-2.0 diff --git a/src/ic-ioty-convert.c b/src/ic-ioty-convert.c index 002a8b6..55dc40d 100644 --- a/src/ic-ioty-convert.c +++ b/src/ic-ioty-convert.c @@ -406,7 +406,7 @@ static int _icl_ioty_fill_oic_rep_payload_value_array(OCRepPayload *payload, if (NULL == attributes_arr[i]) { ERR("OCRepPayloadCreate() Fail"); free(attributes_arr); - return ret; + return IOTCON_ERROR_OUT_OF_MEMORY; } ret = _icl_ioty_fill_oic_rep_payload_value(attributes_arr[i], ((icl_val_attributes_s*)node->data)->attributes); diff --git a/src/ic-ioty-ocprocess.c b/src/ic-ioty-ocprocess.c index a9fe77f..15659b1 100644 --- a/src/ic-ioty-ocprocess.c +++ b/src/ic-ioty-ocprocess.c @@ -94,8 +94,6 @@ void* icl_ioty_ocprocess_thread(void *data) FN_CALL; int ret; - // TODO: Current '100ms' is not proven sleep time. Revise the time after test. - // TODO: Or recommend changes to event driven architecture icl_ioty_polling_interval = ICL_IOTY_TIME_INTERVAL_DEFAULT; /* For setting this thread name */ @@ -276,12 +274,12 @@ OCStackApplicationResult icl_ioty_ocprocess_device_info_cb(void *ctx, "No Authorization"); RETV_IF(NULL == resp->payload, OC_STACK_KEEP_TRANSACTION); - if (PAYLOAD_TYPE_DEVICE != resp->payload->type) { + if (PAYLOAD_TYPE_REPRESENTATION != resp->payload->type) { ERR("Invalid payload type (%d)", resp->payload->type); return OC_STACK_KEEP_TRANSACTION; } - ret = ic_ioty_parse_oic_device_payload((OCDevicePayload *)resp->payload, + ret = ic_ioty_parse_oic_device_payload((OCRepPayload *)resp->payload, &info); if (IOTCON_ERROR_NONE != ret) { ERR("ic_ioty_parse_oic_device_payload() Fail(%d)", ret); @@ -351,12 +349,12 @@ OCStackApplicationResult icl_ioty_ocprocess_platform_info_cb(void *ctx, "No Authorization"); RETV_IF(NULL == resp->payload, OC_STACK_KEEP_TRANSACTION); - if (PAYLOAD_TYPE_PLATFORM != resp->payload->type) { + if (PAYLOAD_TYPE_REPRESENTATION != resp->payload->type) { ERR("Invalid payload type (%d)", resp->payload->type); return OC_STACK_KEEP_TRANSACTION; } - ret = ic_ioty_parse_oic_platform_payload((OCPlatformPayload *)resp->payload, + ret = ic_ioty_parse_oic_platform_payload((OCRepPayload *)resp->payload, &info); if (IOTCON_ERROR_NONE != ret) { ERR("ic_ioty_parse_oic_platform_payload() Fail(%d)", ret); @@ -413,6 +411,8 @@ OCStackApplicationResult icl_ioty_ocprocess_presence_cb(void *ctx, RETV_IF(NULL == resp, OC_STACK_KEEP_TRANSACTION); RETV_IF(NULL == presence, OC_STACK_KEEP_TRANSACTION); + DBG("presence->handle:[%p] vs handle:[%p]", presence->handle, handle); + ret = ic_ioty_parse_oic_presence_payload(&resp->devAddr, (OCPresencePayload*)resp->payload, resp->result, &presence_response); if (IOTCON_ERROR_NONE != ret) { @@ -751,8 +751,8 @@ OCEntityHandlerResult icl_ioty_ocprocess_request_cb(OCEntityHandlerFlag flag, req->observation_info.action = obs_type; req->observation_info.observe_id = observe_id; req->repr = repr; - req->oic_request_h = IC_POINTER_TO_INT64(request->requestHandle); - req->oic_resource_h = IC_POINTER_TO_INT64(request->resource); + req->oic_request_h = request->requestHandle; + req->oic_resource_h = request->resource; icl_request_container_s *req_container = calloc(1, sizeof(icl_request_container_s)); req_container->request = req; @@ -851,7 +851,7 @@ OCEntityHandlerResult icl_ioty_ocprocess_lite_request_cb(OCEntityHandlerFlag fla FN_CALL; iotcon_request_type_e req_type; iotcon_lite_resource_h resource = user_data; - iotcon_representation_h repr; + iotcon_representation_h repr = NULL; iotcon_response_h res = NULL; RETV_IF(NULL == resource, OC_EH_ERROR); @@ -868,16 +868,14 @@ OCEntityHandlerResult icl_ioty_ocprocess_lite_request_cb(OCEntityHandlerFlag fla /* representation */ if (request->payload) ic_ioty_parse_oic_rep_payload((OCRepPayload*)request->payload, true, &repr); - else - repr = NULL; res = calloc(1, sizeof(struct icl_resource_response)); if (NULL == res) { ERR("calloc() Fail(%d)", errno); return OC_EH_ERROR; } - res->oic_request_h = IC_POINTER_TO_INT64(request->requestHandle); - res->oic_resource_h = IC_POINTER_TO_INT64(request->resource); + res->oic_request_h = request->requestHandle; + res->oic_resource_h = request->resource; switch (req_type) { case IOTCON_REQUEST_GET: @@ -886,6 +884,10 @@ OCEntityHandlerResult icl_ioty_ocprocess_lite_request_cb(OCEntityHandlerFlag fla g_idle_add(_icl_ioty_ocprocess_lite_resource_response_idle_cb, res); break; case IOTCON_REQUEST_POST: + if (NULL == repr) { + ERR("repr is NULL!!"); + break; + } if (resource->cb) { if (false == resource->cb(resource, repr->attributes, resource->cb_data)) { res->result = IOTCON_RESPONSE_ERROR; diff --git a/src/ic-ioty-parse.c b/src/ic-ioty-parse.c index e9b5875..188df57 100644 --- a/src/ic-ioty-parse.c +++ b/src/ic-ioty-parse.c @@ -249,6 +249,9 @@ static int _parse_remote_resource(OCDevAddr *dev_addr, iotcon_remote_resource_h temp; iotcon_connectivity_type_e conn_type; + DBG("dev_addr: adapter [%d], flags [%d], port [%d], addr [%s]", + dev_addr->adapter, dev_addr->flags, dev_addr->port, dev_addr->addr); + _ioty_parse_oic_transport(adapter, dev_addr->flags, &conn_type, &conn_options); switch (conn_type) { @@ -434,10 +437,13 @@ int ic_ioty_parse_oic_discovery_payload(OCDevAddr *dev_addr, return IOTCON_ERROR_NONE; } -int ic_ioty_parse_oic_device_payload(OCDevicePayload *payload, +int ic_ioty_parse_oic_device_payload(OCRepPayload *payload, iotcon_device_info_h *device_info) { + FN_CALL; struct icl_device_info *info = NULL; + char **dmv = NULL; + size_t dim[MAX_REP_ARRAY_DEPTH] = {1, 0, 0}; RETV_IF(NULL == device_info, IOTCON_ERROR_INVALID_PARAMETER); @@ -447,23 +453,24 @@ int ic_ioty_parse_oic_device_payload(OCDevicePayload *payload, return IOTCON_ERROR_OUT_OF_MEMORY; } - if (payload->deviceName) - info->device_name = strdup(payload->deviceName); - else - info->device_name = strdup(""); - if (NULL == info->device_name) - ERR("strdup(device_name) Fail(%d)", errno); - - info->spec_ver = ic_utils_strdup(payload->specVersion); - info->device_id = ic_utils_strdup(payload->sid); - info->data_model_ver = OCCreateString(payload->dataModelVersions); + OCRepPayloadGetPropString(payload, OC_RSRVD_DEVICE_NAME, &(info->device_name)); + OCRepPayloadGetPropString(payload, OC_RSRVD_SPEC_VERSION, &(info->spec_ver)); + OCRepPayloadGetPropString(payload, OC_RSRVD_DEVICE_ID, &(info->device_id)); + OCRepPayloadGetStringArray(payload, OC_RSRVD_DATA_MODEL_VERSION, &dmv, dim); + if (dmv) { + if (dmv[0]) { + info->data_model_ver = ic_utils_strdup(dmv[0]); + free(dmv[0]); + } + free(dmv); + } *device_info = info; return IOTCON_ERROR_NONE; } -int ic_ioty_parse_oic_platform_payload(OCPlatformPayload *payload, +int ic_ioty_parse_oic_platform_payload(OCRepPayload *payload, iotcon_platform_info_h *platform_info) { struct icl_platform_info *info = NULL; @@ -477,26 +484,17 @@ int ic_ioty_parse_oic_platform_payload(OCPlatformPayload *payload, return IOTCON_ERROR_OUT_OF_MEMORY; } - info->platform_id = ic_utils_strdup(payload->info.platformID); - info->manuf_name = ic_utils_strdup(payload->info.manufacturerName); - if (payload->info.manufacturerUrl) - info->manuf_url = ic_utils_strdup(payload->info.manufacturerUrl); - if (payload->info.modelNumber) - info->model_number = ic_utils_strdup(payload->info.modelNumber); - if (payload->info.dateOfManufacture) - info->date_of_manuf = ic_utils_strdup(payload->info.dateOfManufacture); - if (payload->info.platformVersion) - info->platform_ver = ic_utils_strdup(payload->info.platformVersion); - if (payload->info.operatingSystemVersion) - info->os_ver = ic_utils_strdup(payload->info.operatingSystemVersion); - if (payload->info.hardwareVersion) - info->hardware_ver = ic_utils_strdup(payload->info.hardwareVersion); - if (payload->info.firmwareVersion) - info->firmware_ver = ic_utils_strdup(payload->info.firmwareVersion); - if (payload->info.supportUrl) - info->support_url = ic_utils_strdup(payload->info.supportUrl); - if (payload->info.systemTime) - info->system_time = ic_utils_strdup(payload->info.systemTime); + OCRepPayloadGetPropString(payload, OC_RSRVD_PLATFORM_ID, &(info->platform_id)); + OCRepPayloadGetPropString(payload, OC_RSRVD_MFG_NAME, &(info->manuf_name)); + OCRepPayloadGetPropString(payload, OC_RSRVD_MFG_URL, &(info->manuf_url)); + OCRepPayloadGetPropString(payload, OC_RSRVD_MODEL_NUM, &(info->model_number)); + OCRepPayloadGetPropString(payload, OC_RSRVD_MFG_DATE, &(info->date_of_manuf)); + OCRepPayloadGetPropString(payload, OC_RSRVD_PLATFORM_VERSION, &(info->platform_ver)); + OCRepPayloadGetPropString(payload, OC_RSRVD_OS_VERSION, &(info->os_ver)); + OCRepPayloadGetPropString(payload, OC_RSRVD_HARDWARE_VERSION, &(info->hardware_ver)); + OCRepPayloadGetPropString(payload, OC_RSRVD_FIRMWARE_VERSION, &(info->firmware_ver)); + OCRepPayloadGetPropString(payload, OC_RSRVD_SUPPORT_URL, &(info->support_url)); + OCRepPayloadGetPropString(payload, OC_RSRVD_SYSTEM_TIME, &(info->system_time)); *platform_info = info; @@ -907,7 +905,7 @@ int ic_ioty_parse_oic_rep_payload(OCRepPayload *payload, bool is_parent, node = node->next; } } else { - // TODO: verify spec + /* TODO: verify spec */ iotcon_resource_interfaces_add(ifaces, IOTCON_INTERFACE_DEFAULT); } diff --git a/src/ic-ioty-parse.h b/src/ic-ioty-parse.h index 0fb0753..3f42f6d 100644 --- a/src/ic-ioty-parse.h +++ b/src/ic-ioty-parse.h @@ -38,9 +38,9 @@ int ic_ioty_parse_oic_discovery_payload(OCDevAddr *dev_addr, int connectivity_prefer, OCDiscoveryPayload *discovered, GList **resource_list); -int ic_ioty_parse_oic_device_payload(OCDevicePayload *payload, +int ic_ioty_parse_oic_device_payload(OCRepPayload *payload, iotcon_device_info_h *device_info); -int ic_ioty_parse_oic_platform_payload(OCPlatformPayload *payload, +int ic_ioty_parse_oic_platform_payload(OCRepPayload *payload, iotcon_platform_info_h *platform_info); int ic_ioty_parse_oic_presence_payload(OCDevAddr *dev_addr, OCPresencePayload *payload, diff --git a/src/ic-ioty.c b/src/ic-ioty.c index 0fce711..10bafe3 100644 --- a/src/ic-ioty.c +++ b/src/ic-ioty.c @@ -208,7 +208,7 @@ int icl_ioty_remove_generated_pin_cb(iotcon_generated_pin_cb cb) return IOTCON_ERROR_NO_DATA; } - if (1 == g_list_length(icl_generated_pin_cb_list)) { + if (1 > g_list_length(icl_generated_pin_cb_list)) { ERR("It is required at least one function"); return IOTCON_ERROR_INVALID_PARAMETER; } @@ -459,7 +459,6 @@ int icl_ioty_find_resource(const char *host_address, return ret; } - // TODO: QoS is come from lib. ret = OCDoResource(&handle, OC_REST_DISCOVER, full_uri, NULL, NULL, oic_conn_type, OC_LOW_QOS, &cbdata, NULL, 0); icl_ioty_mutex_unlock(); @@ -549,7 +548,7 @@ int icl_ioty_find_device_info(const char *host_address, free(full_uri); return ret; } - // TODO: QoS is come from lib. And user can set QoS to client structure. + ret = OCDoResource(&handle, OC_REST_DISCOVER, full_uri, NULL, NULL, oic_conn_type, OC_LOW_QOS, &cbdata, NULL, 0); icl_ioty_mutex_unlock(); @@ -638,7 +637,7 @@ int icl_ioty_find_platform_info(const char *host_address, free(full_uri); return ret; } - // TODO: QoS is come from lib. And user can set QoS to client structure. + ret = OCDoResource(&handle, OC_REST_DISCOVER, full_uri, NULL, NULL, oic_conn_type, OC_LOW_QOS, &cbdata, NULL, 0); icl_ioty_mutex_unlock(); @@ -720,37 +719,24 @@ int icl_ioty_set_platform_info() } int icl_ioty_add_presence_cb(const char *host_address, - int connectivity_type, + iotcon_connectivity_type_e connectivity_type, const char *resource_type, iotcon_presence_cb cb, void *user_data, iotcon_presence_h *presence_handle) { int ret; - int index = 0; - int conn_extra; - int conn_options; OCDoHandle handle; - const char *address; char uri[PATH_MAX] = {0}; OCCallbackData cbdata = {0}; - OCConnectivityType oic_conn_type; + OCConnectivityType oic_conn_type = CT_ADAPTER_IP; iotcon_presence_h presence = NULL; + OCDevAddr dev_addr = {0}; RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == presence_handle, IOTCON_ERROR_INVALID_PARAMETER); - if (NULL == host_address) - address = IC_MULTICAST_ADDRESS; - else - address = host_address; - - if (IC_EQUAL == strncmp(IC_COAPS, address, strlen(IC_COAPS))) - index = strlen(IC_COAPS); - else if (IC_EQUAL == strncmp(IC_COAP, address, strlen(IC_COAP))) - index = strlen(IC_COAP); - - snprintf(uri, sizeof(uri), "%s%s", &address[index], OC_RSRVD_PRESENCE_URI); + snprintf(uri, sizeof(uri), "%s", OC_RSRVD_PRESENCE_URI); presence = calloc(1, sizeof(struct icl_presence)); if (NULL == presence) { @@ -761,27 +747,38 @@ int icl_ioty_add_presence_cb(const char *host_address, presence->user_data = user_data; if (host_address) presence->host_address = strdup(host_address); - presence->connectivity_type - = connectivity_type % IC_CONNECTIVITY_REMOVE_EXTRA_OPTIONS; if (resource_type) presence->resource_type = strdup(resource_type); + if (!(IOTCON_CONNECTIVITY_IP & connectivity_type)) { + DBG("default IP type is addeded"); + connectivity_type |= IOTCON_CONNECTIVITY_IP; + } + presence->connectivity_type = connectivity_type; + + if (IOTCON_CONNECTIVITY_PREFER_TCP & connectivity_type) + oic_conn_type |= CT_ADAPTER_TCP; + if (IOTCON_CONNECTIVITY_IPV4_ONLY & connectivity_type) + oic_conn_type |= CT_IP_USE_V4; + if (IOTCON_CONNECTIVITY_IPV6_ONLY & connectivity_type) + oic_conn_type |= CT_IP_USE_V6; cbdata.context = presence; cbdata.cd = NULL; cbdata.cb = icl_ioty_ocprocess_presence_cb; - conn_extra = connectivity_type - presence->connectivity_type; - - conn_options = ic_utils_host_address_get_connectivity(host_address, - presence->connectivity_type); - if (NULL == host_address && IOTCON_CONNECTIVITY_IP == presence->connectivity_type) { - if (IOTCON_CONNECTIVITY_IPV4_ONLY & conn_extra) - conn_options |= IC_UTILS_CONNECTIVITY_IPV4; - else if (IOTCON_CONNECTIVITY_IPV6_ONLY & conn_extra) - conn_options |= IC_UTILS_CONNECTIVITY_IPV6; + if (NULL != host_address) { + int temp_conn_type; + int conn_options; + temp_conn_type = connectivity_type % IC_CONNECTIVITY_REMOVE_EXTRA_OPTIONS; + conn_options = ic_utils_host_address_get_connectivity(host_address, temp_conn_type); + ret = ic_ioty_convert_host_address(host_address, + temp_conn_type, conn_options, &dev_addr); + if (IOTCON_ERROR_NONE != ret) { + ERR("ic_ioty_convert_host_address() Fail(%d)", ret); + icl_destroy_presence(presence); + return ret; + } } - oic_conn_type = ic_ioty_convert_connectivity_type(presence->connectivity_type, - conn_options); ret = icl_ioty_mutex_lock(); if (IOTCON_ERROR_NONE != ret) { @@ -789,8 +786,19 @@ int icl_ioty_add_presence_cb(const char *host_address, icl_destroy_presence(presence); return ret; } - ret = OCDoResource(&handle, OC_REST_PRESENCE, uri, NULL, NULL, oic_conn_type, + + DBG("uri:[%s], connectivity_type:[%d(0x%x)], oic_conn_type:[%d(0x%x)]", + uri, connectivity_type, connectivity_type, oic_conn_type, oic_conn_type); + if (NULL != host_address) { + DBG("dev_addr.addr:[%s], dev_addr.port:[%d]", dev_addr.addr, dev_addr.port); + ret = OCDoResource(&handle, OC_REST_PRESENCE, uri, &dev_addr, NULL, oic_conn_type, OC_LOW_QOS, &cbdata, NULL, 0); + } else { + ret = OCDoResource(&handle, OC_REST_PRESENCE, uri, NULL, NULL, oic_conn_type, + OC_LOW_QOS, &cbdata, NULL, 0); + } + DBG("oic handle:[%p]", handle); + icl_ioty_mutex_unlock(); presence->handle = handle; @@ -816,6 +824,8 @@ int icl_ioty_remove_presence_cb(iotcon_presence_h presence) ERR("icl_ioty_mutex_lock() Fail(%d)", ret); return ret; } + + DBG("presence_handle->handle:[%p]", presence->handle); ret = OCCancel(presence->handle, OC_LOW_QOS, NULL, 0); icl_ioty_mutex_unlock(); @@ -845,12 +855,11 @@ static int _icl_ioty_remote_resource_observe(iotcon_remote_resource_h resource, iotcon_query_h query, iotcon_remote_resource_observe_cb cb, void *user_data, - OCDoHandle *observe_handle) + OCDoHandle *obs_handle) { int ret, options_size = 0; char *uri = NULL; OCMethod method; - OCDoHandle handle; OCDevAddr dev_addr = {0}; OCCallbackData cbdata = {0}; OCConnectivityType oic_conn_type; @@ -929,8 +938,8 @@ static int _icl_ioty_remote_resource_observe(iotcon_remote_resource_h resource, free(uri); return ret; } - // TODO: QoS is come from lib. And user can set QoS to client structure. - ret = OCDoResource(&handle, method, uri, &dev_addr, NULL, oic_conn_type, + + ret = OCDoResource(obs_handle, method, uri, &dev_addr, NULL, oic_conn_type, OC_HIGH_QOS, &cbdata, oic_options_ptr, options_size); icl_ioty_mutex_unlock(); @@ -942,7 +951,6 @@ static int _icl_ioty_remote_resource_observe(iotcon_remote_resource_h resource, } free(uri); - *observe_handle = handle; return IOTCON_ERROR_NONE; @@ -956,28 +964,25 @@ int icl_ioty_remote_resource_observe_register( void *user_data) { int ret; - OCDoHandle handle = NULL; RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER); - RETV_IF(resource->observe_handle, IOTCON_ERROR_ALREADY); + RETV_IF(resource->obs_handle, IOTCON_ERROR_ALREADY); ret = _icl_ioty_remote_resource_observe(resource, observe_policy, query, cb, user_data, - &handle); + &(resource->obs_handle)); if (IOTCON_ERROR_NONE != ret) { ERR("_icl_ioty_remote_resource_observe() Fail(%d)", ret); return ret; } - resource->observe_handle = IC_POINTER_TO_INT64(handle); return IOTCON_ERROR_NONE; } int icl_ioty_remote_resource_observe_cancel(iotcon_remote_resource_h resource, - int64_t observe_handle) + OCDoHandle obs_handle) { int ret; int options_size = 0; - OCDoHandle handle; OCHeaderOption *oic_options_ptr = NULL; OCHeaderOption oic_options[MAX_HEADER_OPTIONS]; @@ -994,14 +999,13 @@ int icl_ioty_remote_resource_observe_cancel(iotcon_remote_resource_h resource, oic_options_ptr = oic_options; options_size = g_hash_table_size(resource->header_options->hash); } - handle = IC_INT64_TO_POINTER(observe_handle); ret = icl_ioty_mutex_lock(); if (IOTCON_ERROR_NONE != ret) { ERR("icl_ioty_mutex_lock() Fail(%d)", ret); return ret; } - ret = OCCancel(handle, OC_HIGH_QOS, oic_options_ptr, options_size); + ret = OCCancel(obs_handle, OC_HIGH_QOS, oic_options_ptr, options_size); icl_ioty_mutex_unlock(); if (OC_STACK_OK != ret) { @@ -1018,15 +1022,15 @@ int icl_ioty_remote_resource_observe_deregister( int ret; RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); - RETV_IF(0 == resource->observe_handle, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == resource->obs_handle, IOTCON_ERROR_INVALID_PARAMETER); - ret = icl_ioty_remote_resource_observe_cancel(resource, resource->observe_handle); + ret = icl_ioty_remote_resource_observe_cancel(resource, resource->obs_handle); if (IOTCON_ERROR_NONE != ret) { ERR("icl_ioty_remote_resource_observe_cancel() Fail(%d)", ret); return ret; } - resource->observe_handle = 0; + resource->obs_handle = NULL; return IOTCON_ERROR_NONE; } @@ -1294,7 +1298,7 @@ static void _icl_ioty_encap_get_cb(iotcon_remote_resource_h resource, } /* CACHING */ - if (resource->caching.observe) { + if (resource->caching.obs_handle) { switch (err) { case IOTCON_ERROR_NONE: repr = response->repr; @@ -1405,7 +1409,7 @@ int icl_ioty_remote_resource_start_monitoring(iotcon_remote_resource_h resource, } /* get */ - if (resource->caching.observe) + if (resource->caching.obs_handle) return IOTCON_ERROR_NONE; ret = icl_ioty_remote_resource_set_checking_interval(resource, @@ -1424,7 +1428,7 @@ int icl_ioty_remote_resource_stop_monitoring(iotcon_remote_resource_h resource) RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); - if (0 == resource->caching.observe && resource->timer_id) { + if (NULL == resource->caching.obs_handle && resource->timer_id) { g_source_remove(resource->timer_id); resource->timer_id = 0; } @@ -1452,7 +1456,6 @@ int icl_ioty_remote_resource_start_caching(iotcon_remote_resource_h resource, { FN_CALL; int ret; - OCDoHandle handle = NULL; RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); @@ -1461,12 +1464,11 @@ int icl_ioty_remote_resource_start_caching(iotcon_remote_resource_h resource, /* observe */ ret = _icl_ioty_remote_resource_observe(resource, IOTCON_OBSERVE_IGNORE_OUT_OF_ORDER, - NULL, _icl_ioty_caching_observe_cb, NULL, &handle); + NULL, _icl_ioty_caching_observe_cb, NULL, &(resource->caching.obs_handle)); if (IOTCON_ERROR_NONE != ret) { ERR("_icl_ioty_remote_resource_observe() Fail(%d)", ret); return ret; } - resource->caching.observe = IC_POINTER_TO_INT64(handle); /* get */ if (resource->monitoring.presence) @@ -1494,12 +1496,12 @@ int icl_ioty_remote_resource_stop_caching(iotcon_remote_resource_h resource) } ret = icl_ioty_remote_resource_observe_cancel(resource, - resource->caching.observe); + resource->caching.obs_handle); if (IOTCON_ERROR_NONE != ret) { ERR("icl_ioty_remote_resource_observe_cancel() Fail(%d)", ret); return IOTCON_ERROR_INVALID_PARAMETER; } - resource->caching.observe = 0; + resource->caching.obs_handle = NULL; return IOTCON_ERROR_NONE; } @@ -1509,13 +1511,13 @@ int icl_ioty_start_presence(unsigned int time_to_live) { int ret; - RETV_IF(IC_PRESENCE_TTL_SECONDS_MAX < time_to_live, IOTCON_ERROR_INVALID_PARAMETER); - ret = icl_ioty_mutex_lock(); if (IOTCON_ERROR_NONE != ret) { ERR("icl_ioty_mutex_lock() Fail(%d)", ret); return ret; } + + DBG("time_to_live:[%d]", time_to_live); ret = OCStartPresence(time_to_live); icl_ioty_mutex_unlock(); @@ -1638,7 +1640,7 @@ int icl_ioty_resource_create(const char *uri_path, iotcon_resource_destroy(resource); return IOTCON_ERROR_IOTIVITY; } - resource->handle = IC_POINTER_TO_INT64(handle); + resource->res_handle = handle; for (c = res_types->type_list, i = 0; c; c = c->next, i++) { if (0 == i) /* skip a first resource type */ @@ -1662,7 +1664,6 @@ int icl_ioty_resource_bind_type(iotcon_resource_h resource, { FN_CALL; int ret; - OCResourceHandle handle; iotcon_resource_types_h resource_types; RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); @@ -1681,8 +1682,7 @@ int icl_ioty_resource_bind_type(iotcon_resource_h resource, return ret; } - handle = IC_INT64_TO_POINTER(resource->handle); - ret = _icl_ioty_resource_bind_type(handle, resource_type); + ret = _icl_ioty_resource_bind_type(resource->res_handle, resource_type); if (IOTCON_ERROR_NONE != ret) { ERR("_icl_ioty_resource_bind_type Fail(%d)", ret); iotcon_resource_types_destroy(resource_types); @@ -1700,7 +1700,6 @@ int icl_ioty_resource_bind_interface(iotcon_resource_h resource, { FN_CALL; int ret; - OCResourceHandle handle; RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); @@ -1710,8 +1709,7 @@ int icl_ioty_resource_bind_interface(iotcon_resource_h resource, return ret; } - handle = IC_INT64_TO_POINTER(resource->handle); - ret = _icl_ioty_resource_bind_interface(handle, iface); + ret = _icl_ioty_resource_bind_interface(resource->res_handle, iface); if (IOTCON_ERROR_NONE != ret) { ERR("_icl_ioty_resource_bind_interface() Fail(%d)", ret); return ret; @@ -1725,21 +1723,17 @@ int icl_ioty_resource_bind_child_resource(iotcon_resource_h parent, { FN_CALL; int ret; - OCResourceHandle handle_parent, handle_child; RETV_IF(NULL == parent, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == child, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(parent == child, IOTCON_ERROR_INVALID_PARAMETER); - handle_parent = IC_INT64_TO_POINTER(parent->handle); - handle_child = IC_INT64_TO_POINTER(child->handle); - ret = icl_ioty_mutex_lock(); if (IOTCON_ERROR_NONE != ret) { ERR("icl_ioty_mutex_lock() Fail(%d)", ret); return ret; } - ret = OCBindResource(handle_parent, handle_child); + ret = OCBindResource(parent->res_handle, child->res_handle); icl_ioty_mutex_unlock(); if (OC_STACK_OK != ret) { @@ -1755,20 +1749,16 @@ int icl_ioty_resource_unbind_child_resource(iotcon_resource_h parent, { FN_CALL; int ret; - OCResourceHandle handle_parent, handle_child; RETV_IF(NULL == parent, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == child, IOTCON_ERROR_INVALID_PARAMETER); - handle_parent = IC_INT64_TO_POINTER(parent->handle); - handle_child = IC_INT64_TO_POINTER(child->handle); - ret = icl_ioty_mutex_lock(); if (IOTCON_ERROR_NONE != ret) { ERR("icl_ioty_mutex_lock() Fail(%d)", ret); return ret; } - ret = OCUnBindResource(handle_parent, handle_child); + ret = OCUnBindResource(parent->res_handle, child->res_handle); icl_ioty_mutex_unlock(); if (OC_STACK_OK != ret) { @@ -1788,7 +1778,6 @@ int icl_ioty_resource_notify(iotcon_resource_h resource, iotcon_representation_h iotcon_observers_h observers_ori; OCObservationId obs_ids[IC_OBSERVE_ID_MAX_LEN]; OCQualityOfService oc_qos; - OCResourceHandle handle; RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); @@ -1814,17 +1803,15 @@ int icl_ioty_resource_notify(iotcon_resource_h resource, iotcon_representation_h oc_qos = ic_ioty_convert_qos(qos); - handle = IC_INT64_TO_POINTER(resource->handle); - ret = icl_ioty_mutex_lock(); if (IOTCON_ERROR_NONE != ret) { ERR("icl_ioty_mutex_lock() Fail(%d)", ret); return ret; } if (payload) - ret = OCNotifyListOfObservers(handle, obs_ids, obs_length, payload, oc_qos); + ret = OCNotifyListOfObservers(resource->res_handle, obs_ids, obs_length, payload, oc_qos); else - ret = OCNotifyAllObservers(handle, oc_qos); + ret = OCNotifyAllObservers(resource->res_handle, oc_qos); icl_ioty_mutex_unlock(); if (OC_STACK_NO_OBSERVERS == ret) { @@ -1842,25 +1829,22 @@ int icl_ioty_resource_destroy(iotcon_resource_h resource) { FN_CALL; int ret; - OCResourceHandle handle; RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); - handle = IC_INT64_TO_POINTER(resource->handle); - ret = icl_ioty_mutex_lock(); if (IOTCON_ERROR_NONE != ret) { ERR("icl_ioty_mutex_lock() Fail(%d)", ret); return ret; } - ret = OCDeleteResource(handle); + ret = OCDeleteResource(resource->res_handle); icl_ioty_mutex_unlock(); if (OC_STACK_OK != ret) { ERR("OCDeleteResource() Fail(%d)", ret); return ic_ioty_parse_oic_error(ret); } - resource->handle = 0; + resource->res_handle = NULL; return IOTCON_ERROR_NONE; } @@ -1877,7 +1861,6 @@ int icl_ioty_lite_resource_create(const char *uri_path, FN_CALL; int ret, i; GList *c; - OCResourceHandle handle; iotcon_lite_resource_h resource; const char *res_iface = NULL; @@ -1910,7 +1893,7 @@ int icl_ioty_lite_resource_create(const char *uri_path, icl_ioty_lite_resource_destroy(resource); return ret; } - ret = OCCreateResource(&handle, res_types->type_list->data, res_iface, uri_path, + ret = OCCreateResource(&(resource->res_handle), res_types->type_list->data, res_iface, uri_path, icl_ioty_ocprocess_lite_request_cb, resource, policies); icl_ioty_mutex_unlock(); if (OC_STACK_OK != ret) { @@ -1918,12 +1901,11 @@ int icl_ioty_lite_resource_create(const char *uri_path, icl_ioty_lite_resource_destroy(resource); return IOTCON_ERROR_IOTIVITY; } - resource->handle = IC_POINTER_TO_INT64(handle); for (c = res_types->type_list, i = 0; c; c = c->next, i++) { if (0 == i) /* skip a first resource type */ continue; - _icl_ioty_resource_bind_type(handle, c->data); + _icl_ioty_resource_bind_type(resource->res_handle, c->data); } *resource_handle = resource; @@ -1935,25 +1917,22 @@ int icl_ioty_lite_resource_destroy(iotcon_lite_resource_h resource) { FN_CALL; int ret; - OCResourceHandle handle; RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); - handle = IC_INT64_TO_POINTER(resource->handle); - ret = icl_ioty_mutex_lock(); if (IOTCON_ERROR_NONE != ret) { ERR("icl_ioty_mutex_lock() Fail(%d)", ret); return ret; } - ret = OCDeleteResource(handle); + ret = OCDeleteResource(resource->res_handle); icl_ioty_mutex_unlock(); if (OC_STACK_OK != ret) { ERR("OCDeleteResource() Fail(%d)", ret); return ic_ioty_parse_oic_error(ret); } - resource->handle = 0; + resource->res_handle = NULL; free(resource->uri_path); free(resource); @@ -1964,18 +1943,15 @@ int icl_ioty_lite_resource_notify(iotcon_lite_resource_h resource) { FN_CALL; int ret; - OCResourceHandle handle; RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); - handle = IC_INT64_TO_POINTER(resource->handle); - ret = icl_ioty_mutex_lock(); if (IOTCON_ERROR_NONE != ret) { ERR("icl_ioty_mutex_lock() Fail(%d)", ret); return ret; } - ret = OCNotifyAllObservers(handle, IOTCON_QOS_HIGH); + ret = OCNotifyAllObservers(resource->res_handle, IOTCON_QOS_HIGH); icl_ioty_mutex_unlock(); if (OC_STACK_NO_OBSERVERS == ret) { @@ -2020,8 +1996,8 @@ int icl_ioty_response_send(iotcon_response_h response_handle) RETV_IF(NULL == response_handle, IOTCON_ERROR_INVALID_PARAMETER); - response.requestHandle = IC_INT64_TO_POINTER(response_handle->oic_request_h); - response.resourceHandle = IC_INT64_TO_POINTER(response_handle->oic_resource_h); + response.requestHandle = response_handle->oic_request_h; + response.resourceHandle = response_handle->oic_resource_h; response.ehResult = ic_ioty_convert_response_result(response_handle->result); if (response_handle->header_options && response_handle->header_options->hash) { diff --git a/src/ic-ioty.h b/src/ic-ioty.h index 293b609..f8fcfa2 100644 --- a/src/ic-ioty.h +++ b/src/ic-ioty.h @@ -72,7 +72,7 @@ int icl_ioty_find_platform_info(const char *host_address, void *user_data); int icl_ioty_add_presence_cb(const char *host_address, - int connectivity_type, + iotcon_connectivity_type_e connectivity_type, const char *resource_type, iotcon_presence_cb cb, void *user_data, @@ -102,7 +102,7 @@ int icl_ioty_remote_resource_delete(iotcon_remote_resource_h resource, iotcon_remote_resource_response_cb cb, void *user_data); int icl_ioty_remote_resource_observe_cancel(iotcon_remote_resource_h resource, - int64_t handle); + OCDoHandle obs_handle); int icl_ioty_remote_resource_start_monitoring(iotcon_remote_resource_h resource, iotcon_remote_resource_state_changed_cb cb, void *user_data); int icl_ioty_remote_resource_stop_monitoring(iotcon_remote_resource_h resource); diff --git a/src/ic-lite-resource.h b/src/ic-lite-resource.h index 00b05d7..315bc26 100644 --- a/src/ic-lite-resource.h +++ b/src/ic-lite-resource.h @@ -23,7 +23,7 @@ struct icl_lite_resource { char *uri_path; iotcon_attributes_h attributes; - int64_t handle; + OCResourceHandle res_handle; uint8_t policies; iotcon_lite_resource_post_request_cb cb; void *cb_data; diff --git a/src/ic-presence.c b/src/ic-presence.c index 9b2d409..7c59cbc 100644 --- a/src/ic-presence.c +++ b/src/ic-presence.c @@ -34,11 +34,6 @@ API int iotcon_start_presence(unsigned int time_to_live) RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET), IOTCON_ERROR_PERMISSION_DENIED); - if (0 == time_to_live) - time_to_live = IC_PRESENCE_TTL_SECONDS_DEFAULT; - else if (IC_PRESENCE_TTL_SECONDS_MAX < time_to_live) - time_to_live = IC_PRESENCE_TTL_SECONDS_MAX; - ret = icl_ioty_start_presence(time_to_live); if (IOTCON_ERROR_NONE != ret) { ERR("icl_ioty_start_presence() Fail(%d)", ret); diff --git a/src/ic-provisioning-find.c b/src/ic-provisioning-find.c index 9e599f4..e5dfc3d 100644 --- a/src/ic-provisioning-find.c +++ b/src/ic-provisioning-find.c @@ -544,8 +544,9 @@ static int _provisioning_find_secure_port(icl_provisioning_find_cb_container_s * } ICL_PROVISIONING_MUTEX_FIND_UNLOCK(container->cb_data); + DBG("uri:[%s]", uri); ret = OCDoResource(&container->handle, OC_REST_DISCOVER, uri, 0, 0, - container->oic_device->connType, OC_LOW_QOS, &cbdata, NULL, 0); + container->oic_device->connType, OC_HIGH_QOS, &cbdata, NULL, 0); icl_ioty_mutex_unlock(); if (OC_STACK_OK != ret) { ERR("OCDoResource() Fail(%d)", ret); diff --git a/src/ic-provisioning-struct.c b/src/ic-provisioning-struct.c index 0bfd799..fef6060 100644 --- a/src/ic-provisioning-struct.c +++ b/src/ic-provisioning-struct.c @@ -153,7 +153,14 @@ int icl_provisioning_parse_oic_dev_address(OCDevAddr *dev_addr, int secure_port, if (CT_IP_USE_V4 & conn_type) { snprintf(temp, sizeof(temp), "%s:%d", dev_addr->addr, port); } else if (CT_IP_USE_V6 & conn_type) { - snprintf(temp, sizeof(temp), "[%s]:%d", dev_addr->addr, port); + char addressEncoded[128] = {0}; + OCStackResult ret = OCEncodeAddressForRFC6874(addressEncoded, + sizeof(addressEncoded), dev_addr->addr); + if (OC_STACK_OK != ret) { + ERR("OCEncodeAddressForRFC6874 : encoding error (%d)", ret); + return IOTCON_ERROR_INVALID_PARAMETER; + } + snprintf(temp, sizeof(temp), "[%s]:%d", addressEncoded, port); } else { ERR("Invalid Connectivity Type(%d)", conn_type); return IOTCON_ERROR_INVALID_PARAMETER; @@ -162,6 +169,7 @@ int icl_provisioning_parse_oic_dev_address(OCDevAddr *dev_addr, int secure_port, ERR("Invalid Connectivity Type(%d)", conn_type); return IOTCON_ERROR_INVALID_PARAMETER; } + DBG("temp:[%s]", temp); *host_address = strdup(temp); diff --git a/src/ic-provisioning.c b/src/ic-provisioning.c index bd72e0c..7f052a2 100644 --- a/src/ic-provisioning.c +++ b/src/ic-provisioning.c @@ -180,7 +180,7 @@ static void _provisioning_input_pin_cb(char *pin, size_t len) RET_IF(NULL == icl_randompin_cb_container.cb); RET_IF(NULL == pin); - RET_IF(len <= OXM_RANDOM_PIN_SIZE); + RET_IF(len <= OXM_RANDOM_PIN_MAX_SIZE); temp = icl_randompin_cb_container.cb(icl_randompin_cb_container.user_data); if ((NULL == temp) || (len <= strlen(temp))) { @@ -305,6 +305,10 @@ static gboolean _provisioning_register_unowned_device(gpointer p) container = g_queue_pop_tail(icl_register_queue); _provisioning_register_mutex_unlock(); + if (NULL == container) { + ERR("container is NULL"); + return G_SOURCE_CONTINUE; + } dev_list = icl_provisioning_device_get_device(container->device); @@ -565,8 +569,7 @@ static OicSecAcl_t* _provisioning_convert_acl(iotcon_provisioning_device_h devic } resource->href = ic_utils_strdup(uri_path); - // TODO: resource types & resource interfaces - // temp code + /* TODO: resource types & resource interfaces */ resource->types = calloc(1, sizeof(char*)); if (NULL == resource->types) { ERR("calloc() Fail(%d)", errno); diff --git a/src/ic-remote-resource-caching.c b/src/ic-remote-resource-caching.c index d54727f..e22cb77 100644 --- a/src/ic-remote-resource-caching.c +++ b/src/ic-remote-resource-caching.c @@ -40,7 +40,7 @@ API int iotcon_remote_resource_start_caching(iotcon_remote_resource_h resource, ERR("The resource should be cloned."); return IOTCON_ERROR_INVALID_PARAMETER; } - if (resource->caching.observe) { + if (resource->caching.obs_handle) { ERR("Already Start Caching"); return IOTCON_ERROR_ALREADY; } @@ -68,7 +68,7 @@ API int iotcon_remote_resource_stop_caching(iotcon_remote_resource_h resource) IOTCON_ERROR_PERMISSION_DENIED); RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); - if (0 == resource->caching.observe) { + if (0 == resource->caching.obs_handle) { ERR("Not Cached"); return IOTCON_ERROR_INVALID_PARAMETER; } diff --git a/src/ic-remote-resource-crud.c b/src/ic-remote-resource-crud.c index d8dc861..0de99b8 100644 --- a/src/ic-remote-resource-crud.c +++ b/src/ic-remote-resource-crud.c @@ -147,7 +147,7 @@ API int iotcon_remote_resource_observe_register( IOTCON_ERROR_PERMISSION_DENIED); RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER); - RETV_IF(resource->observe_handle, IOTCON_ERROR_ALREADY); + RETV_IF(resource->obs_handle, IOTCON_ERROR_ALREADY); if (true == resource->is_found) { ERR("The resource should be cloned."); @@ -180,7 +180,7 @@ API int iotcon_remote_resource_observe_deregister( return IOTCON_ERROR_INVALID_PARAMETER; } - if (0 == resource->observe_handle) { + if (NULL == resource->obs_handle) { ERR("It doesn't have a observe_handle"); return IOTCON_ERROR_INVALID_PARAMETER; } diff --git a/src/ic-remote-resource.c b/src/ic-remote-resource.c index d094a80..d2999cb 100644 --- a/src/ic-remote-resource.c +++ b/src/ic-remote-resource.c @@ -141,7 +141,7 @@ static void _icl_remote_resource_destroy(iotcon_remote_resource_h resource) if (resource->monitoring.presence) iotcon_remote_resource_stop_monitoring(resource); - if (resource->caching.observe) + if (resource->caching.obs_handle) iotcon_remote_resource_stop_caching(resource); free(resource); @@ -169,7 +169,7 @@ API int iotcon_remote_resource_destroy(iotcon_remote_resource_h resource) RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED); RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); - if (resource->observe_handle) + if (resource->obs_handle) iotcon_remote_resource_observe_deregister(resource); icl_remote_resource_unref(resource); @@ -428,7 +428,7 @@ API int iotcon_remote_resource_set_checking_interval(iotcon_remote_resource_h re RETV_IF(ICL_REMOTE_RESOURCE_MAX_CHECKING_INTERVAL < interval || interval <= 0, IOTCON_ERROR_INVALID_PARAMETER); - if (resource->monitoring.presence || resource->caching.observe) { + if (resource->monitoring.presence || resource->caching.obs_handle) { ret = icl_ioty_remote_resource_set_checking_interval(resource, interval); if (IOTCON_ERROR_NONE != ret) { ERR("icl_ioty_remote_resource_set_checking_interval() Fail(%d)", ret); diff --git a/src/ic-remote-resource.h b/src/ic-remote-resource.h index 6e2cc04..fb4221a 100644 --- a/src/ic-remote-resource.h +++ b/src/ic-remote-resource.h @@ -22,12 +22,13 @@ #include "iotcon-types.h" #include "iotcon-remote-resource.h" #include "ic-options.h" +#include <octypes.h> typedef struct icl_remote_resource_caching { iotcon_representation_h repr; iotcon_remote_resource_cached_representation_changed_cb cb; void *user_data; - int64_t observe; + OCDoHandle obs_handle; } icl_remote_resource_caching_s; typedef struct icl_remote_resource_monitoring { @@ -50,7 +51,7 @@ struct icl_remote_resource { iotcon_resource_interfaces_h ifaces; iotcon_connectivity_type_e connectivity_type; int connectivity_options; - int64_t observe_handle; + OCDoHandle obs_handle; int checking_interval; unsigned int timer_id; icl_remote_resource_caching_s caching; diff --git a/src/ic-request.h b/src/ic-request.h index 8b77a66..4b7fb79 100644 --- a/src/ic-request.h +++ b/src/ic-request.h @@ -32,8 +32,8 @@ struct icl_resource_request { iotcon_query_h query; struct icl_observe_info observation_info; iotcon_representation_h repr; - int64_t oic_request_h; - int64_t oic_resource_h; + OCRequestHandle oic_request_h; + OCResourceHandle oic_resource_h; }; #endif /* __IOTCON_INTERNAL_REQUEST_H__ */ diff --git a/src/ic-resource.h b/src/ic-resource.h index b6fda39..56ea383 100644 --- a/src/ic-resource.h +++ b/src/ic-resource.h @@ -40,7 +40,7 @@ struct icl_resource { iotcon_resource_interfaces_h ifaces; iotcon_request_handler_cb cb; void *user_data; - int64_t handle; + OCResourceHandle res_handle; iotcon_observers_h observers; GList *children; }; diff --git a/src/ic-response.h b/src/ic-response.h index aae9395..29143fb 100644 --- a/src/ic-response.h +++ b/src/ic-response.h @@ -31,8 +31,8 @@ struct icl_resource_response { char *iface; int result; iotcon_representation_h repr; - int64_t oic_request_h; - int64_t oic_resource_h; + OCRequestHandle oic_request_h; + OCResourceHandle oic_resource_h; }; #endif /* __IOTCON_INTERNAL_RESPONSE_H__ */ diff --git a/src/ic-types.c b/src/ic-types.c index 8b4799d..e44069b 100644 --- a/src/ic-types.c +++ b/src/ic-types.c @@ -156,7 +156,7 @@ int icl_create_presence_cb_data(iotcon_presence_h presence, RETV_IF(NULL == presence_cb_data, IOTCON_ERROR_INVALID_PARAMETER); cd = calloc(1, sizeof(icl_presence_cb_s)); - if (NULL == presence_cb_data) { + if (NULL == cd) { ERR("calloc() Fail(%d)", errno); return IOTCON_ERROR_OUT_OF_MEMORY; } @@ -296,10 +296,10 @@ void icl_destroy_caching_container(void *data) return; } - if (cb_container->observe_handle) { + if (cb_container->obs_handle) { icl_ioty_remote_resource_observe_cancel(cb_container->resource, - cb_container->observe_handle); - cb_container->observe_handle = 0; + cb_container->obs_handle); + cb_container->obs_handle = NULL; } if (cb_container->timeout) { diff --git a/src/ic-types.h b/src/ic-types.h index 45d5b2b..e0b4c12 100644 --- a/src/ic-types.h +++ b/src/ic-types.h @@ -88,7 +88,7 @@ typedef struct { iotcon_remote_resource_cached_representation_changed_cb cb; void *user_data; iotcon_remote_resource_h resource; - int64_t observe_handle; + OCDoHandle obs_handle; int timeout; } icl_caching_container_s; diff --git a/src/ic-utils.c b/src/ic-utils.c index 6de3247..ba7937f 100644 --- a/src/ic-utils.c +++ b/src/ic-utils.c @@ -36,7 +36,6 @@ static int _ic_ocf_feature = -1; static const char *IC_FEATURE_OCF = "http://tizen.org/feature/iot.ocf"; #endif -// TODO: Can't access in user side daemon #if 0 #ifdef TZ_VER_3 static const char *IC_PRIV_FILE_NETWORK_GET = "/usr/share/iotcon/iotcon-network-get"; @@ -44,7 +43,7 @@ static const char *IC_PRIV_FILE_INTERNET = "/usr/share/iotcon/iotcon-internet"; #endif #endif -// TODO: Temporary code (need guide from security team) +/* TODO : need guide from security team */ #define SMACK_LABEL_LEN 255 static const char *IC_PRIVILEGE_INTERNET = "http://tizen.org/privilege/internet"; static const char *IC_PRIVILEGE_NETWORK_GET = "http://tizen.org/privilege/network.get"; @@ -86,6 +86,7 @@ API int iotcon_initialize(const char *file_path) API int iotcon_deinitialize(void) { + FN_CALL; RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED); ic_utils_mutex_lock(IC_UTILS_MUTEX_INIT); diff --git a/test/iotcon-test-basic-client.c b/test/iotcon-test-basic-client.c index 75f5f7c..f9657c4 100644 --- a/test/iotcon-test-basic-client.c +++ b/test/iotcon-test-basic-client.c @@ -71,16 +71,10 @@ static void _on_observe(iotcon_remote_resource_h resource, iotcon_error_e err, } INFO("notify_cb information"); - switch (opened) { - case true: + if (opened) INFO("[Door] opened."); - break; - case false: + else INFO("[Door] closed."); - break; - default: - break; - } if (5 == i++) { iotcon_remote_resource_observe_deregister(resource); diff --git a/test/iotcon-test-encap-client.c b/test/iotcon-test-encap-client.c index 7d7ab90..c34b52d 100644 --- a/test/iotcon-test-encap-client.c +++ b/test/iotcon-test-encap-client.c @@ -86,16 +86,10 @@ static void _representation_changed_cb(iotcon_remote_resource_h resource, return; } - switch (opened) { - case true: - INFO("door is opened"); - break; - case false: - INFO("door is closed"); - break; - default: - break; - } + if (opened) + INFO("[Door] opened."); + else + INFO("[Door] closed."); } static bool _found_resource(iotcon_remote_resource_h resource, iotcon_error_e result, |