#include <stdio.h>
#include <stdlib.h>
#include <stdint.h> /* for uint8_t etc */
-#include <stdbool.h>
#include <errno.h>
#include <glib.h>
+#include <tizen_type.h>
#include <system_info.h>
#include <system_settings.h>
ERR("OCStop() Fail(%d)", result);
}
+static int _ioty_properties_to_oic_properties(int properties)
+{
+ int prop = OC_RES_PROP_NONE;
+
+ if (IOTCON_DISCOVERABLE & properties)
+ prop |= OC_DISCOVERABLE;
+
+ if (IOTCON_OBSERVABLE & properties)
+ prop |= OC_OBSERVABLE;
+
+ if (IOTCON_ACTIVE & properties)
+ prop |= OC_ACTIVE;
+
+ if (IOTCON_SLOW & properties)
+ prop |= OC_SLOW;
+
+ if (IOTCON_SECURE & properties)
+ prop |= OC_SECURE;
+
+ if (IOTCON_EXPLICIT_DISCOVERABLE & properties)
+ prop |= OC_EXPLICIT_DISCOVERABLE;
+
+ /* TODO: Secure option is not supported yet. */
+ properties = (properties & OC_SECURE)? (properties ^ OC_SECURE):properties;
+
+ return prop;
+}
OCResourceHandle icd_ioty_register_resource(const char *uri_path,
const char* const* res_types, int ifaces, int properties)
return NULL;
}
- /* Secure option is not supported yet. */
- properties = (properties & OC_SECURE)? (properties ^ OC_SECURE):properties;
+ properties = _ioty_properties_to_oic_properties(properties);
icd_ioty_csdk_lock();
ret = OCCreateResource(&handle, res_types[0], res_iface, uri_path,
return IOTCON_ERROR_NONE;
}
-
int icd_ioty_notify(OCResourceHandle handle, GVariant *msg, GVariant *observers)
{
- int i, error_code, obs_length, msg_length;
+ int i, obs_length, msg_length;
GVariant *repr_gvar;
GVariantIter obs_iter, msg_iter;
OCStackResult ret;
g_variant_iter_init(&msg_iter, msg);
msg_length = g_variant_iter_n_children(&msg_iter);
if (msg_length) {
- g_variant_iter_loop(&msg_iter, "(iv)", &error_code, &repr_gvar);
+ g_variant_iter_loop(&msg_iter, "v", &repr_gvar);
/* TODO : How to use error_code. */
payload = icd_payload_representation_from_gvariant(repr_gvar);
}
GVariantIter *options;
OCStackResult ret;
OCEntityHandlerResponse response = {0};
- int result, error_code, options_size;
+ int result, options_size;
int64_t request_handle, resource_handle;
- g_variant_get(resp, "(ia(qs)ivxx)",
- &error_code,
+ g_variant_get(resp, "(a(qs)ivxx)",
&options,
&result,
&repr_gvar,
int icd_ioty_find_resource(const char *host_address, int conn_type,
- const char *resource_type, unsigned int signum, const char *bus_name)
+ const char *resource_type, unsigned int signal_number, const char *bus_name)
{
int len;
OCStackResult result;
}
context->bus_name = ic_utils_strdup(bus_name);
- context->signum = signum;
+ context->signal_number = signal_number;
cbdata.context = context;
cbdata.cb = icd_ioty_ocprocess_find_cb;
}
-static gboolean _icd_ioty_crud(int type, icDbus *object, GDBusMethodInvocation *invocation,
- GVariant *resource, GVariant *query, GVariant *repr)
+static gboolean _icd_ioty_crud(int type,
+ icDbus *object,
+ GDBusMethodInvocation *invocation,
+ GVariant *resource,
+ GVariant *query,
+ GVariant *repr)
{
bool is_secure;
OCMethod rest_type;
}
-OCDoHandle icd_ioty_observer_start(GVariant *resource, int observe_type, GVariant *query,
- unsigned int signal_number, const char *bus_name)
+OCDoHandle icd_ioty_observer_start(GVariant *resource, int observe_type,
+ GVariant *query, unsigned int signal_number, const char *bus_name)
{
bool is_secure;
OCMethod method;
return NULL;
}
context->bus_name = ic_utils_strdup(bus_name);
- context->signum = signal_number;
+ context->signal_number = signal_number;
cbdata.context = context;
cbdata.cb = icd_ioty_ocprocess_observe_cb;
return IOTCON_ERROR_OUT_OF_MEMORY;
}
context->bus_name = ic_utils_strdup(bus_name);
- context->signum = signal_number;
+ context->signal_number = signal_number;
cbdata.context = context;
cbdata.cb = icd_ioty_ocprocess_info_cb;
ICD_IOTY_TIZEN_INFO_URI,
icd_ioty_ocprocess_tizen_info_handler,
NULL,
- OC_RES_PROP_NONE);
+ OC_EXPLICIT_DISCOVERABLE);
icd_ioty_csdk_unlock();
if (OC_STACK_OK != ret) {
ERR("OCCreateResource() Fail(%d)", ret);
return NULL;
}
context->bus_name = ic_utils_strdup(bus_name);
- context->signum = signal_number;
+ context->signal_number = signal_number;
cbdata.context = context;
cbdata.cb = icd_ioty_ocprocess_presence_cb;
oic_conn_type = icd_ioty_conn_type_to_oic_conn_type(conn_type);
- /* In case of IPV4 or IPV6, connectivity type is CT_ADAPTER_IP in iotivity 0.9.2 */
- if (CT_IP_USE_V4 == oic_conn_type && CT_IP_USE_V6 == oic_conn_type)
- oic_conn_type = CT_ADAPTER_IP;
-
icd_ioty_csdk_lock();
- result = OCDoResource(&handle, OC_REST_PRESENCE, uri, NULL, NULL, CT_ADAPTER_IP,
+ result = OCDoResource(&handle, OC_REST_PRESENCE, uri, NULL, NULL, oic_conn_type,
OC_LOW_QOS, &cbdata, NULL, 0);
icd_ioty_csdk_unlock();