Commit f8549457 authored by Kishen Maloor's avatar Kishen Maloor

Support multiple device types in /oic/d

Change-Id: Ibeb772d601c004f31ed49c85559f7b9cbcab261c
Signed-off-by: Kishen Maloor's avatarKishen Maloor <kishen.maloor@intel.com>
parent decbeaa8
......@@ -379,6 +379,37 @@ oc_core_add_new_device(const char *uri, const char *rt, const char *name,
return &oc_device_info[device_count - 1];
}
static void
oc_device_bind_rt(size_t device_index, const char *rt)
{
oc_resource_t *r = oc_core_get_resource_by_index(OCF_D, device_index);
oc_string_array_t types;
memcpy(&types, &r->types, sizeof(oc_string_array_t));
size_t num_types = oc_string_array_get_allocated_size(types);
num_types++;
memset(&r->types, 0, sizeof(oc_string_array_t));
oc_new_string_array(&r->types, num_types);
size_t i;
for (i = 0; i < num_types; i++) {
if (i == 0) {
oc_string_array_add_item(r->types, rt);
} else {
oc_string_array_add_item(r->types,
oc_string_array_get_item(types, (i - 1)));
}
}
oc_free_string_array(&types);
}
void
oc_device_bind_resource_type(size_t device, const char *type)
{
oc_device_bind_rt(device, type);
}
static void
oc_core_platform_handler(oc_request_t *request, oc_interface_mask_t iface_mask,
void *data)
......
......@@ -111,6 +111,8 @@ void oc_resource_set_default_interface(oc_resource_t *resource,
oc_interface_mask_t iface_mask);
void oc_resource_bind_resource_type(oc_resource_t *resource, const char *type);
void oc_device_bind_resource_type(size_t device, const char *type);
void oc_process_baseline_interface(oc_resource_t *resource);
/**
......
......@@ -118,8 +118,10 @@ static int
app_init(void)
{
int ret = oc_init_platform("OCF", NULL, NULL);
ret |= oc_add_device("/oic/d", "oic.wk.d", "OBT", "ocf.2.0.2",
"ocf.res.1.3.0", NULL, NULL);
ret |= oc_add_device("/oic/d", "oic.d.dots", "OBT", "ocf.2.0.5",
"ocf.res.1.0.0,ocf.sh.1.0.0", NULL, NULL);
oc_device_bind_resource_type(0, "oic.d.ams");
oc_device_bind_resource_type(0, "oic.d.cms");
return ret;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment