return options;
}
+static int _ioty_oic_action_to_ioty_action(int oic_action)
+{
+ int action;
+
+ switch (oic_action) {
+ case OC_OBSERVE_REGISTER:
+ action = IOTCON_OBSERVE_REGISTER;
+ break;
+ case OC_OBSERVE_DEREGISTER:
+ action = IOTCON_OBSERVE_DEREGISTER;
+ break;
+ case OC_OBSERVE_NO_OPTION:
+ default:
+ ERR("Invalid action (%d)", oic_action);
+ action = IOTCON_OBSERVE_NO_OPTION;
+ }
+ return action;
+}
static int _worker_req_handler(void *context)
{
GVariant *value;
- int ret, conn_type;
+ int ret, conn_type, action;
struct icd_req_context *ctx = context;
GVariantBuilder payload_builder;
char addr[PATH_MAX] = {0};
conn_type = icd_ioty_transport_flag_to_conn_type(ctx->dev_addr->adapter,
ctx->dev_addr->flags);
+ action = _ioty_oic_action_to_ioty_action(ctx->observe_action);
+
value = g_variant_new("(siia(qs)a(ss)iiavxx)",
addr,
conn_type,
ctx->types,
ctx->options,
ctx->query,
- ctx->observe_action,
+ action,
ctx->observer_id,
&payload_builder,
ICD_POINTER_TO_INT64(ctx->request_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,
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);
IOTCON_ACTIVE = (1 << 2), /**< Indicates resource initialized and activated */
IOTCON_SLOW = (1 << 3), /**< Indicates resource which takes some delay to respond */
IOTCON_SECURE = (1 << 4), /**< Indicates secure resource */
+ IOTCON_EXPLICIT_DISCOVERABLE = (1 << 5), /**< When this bit is set, the resource is allowed to be discovered only if discovery request contains an explicit querystring. */
} iotcon_resource_property_e;
/**