Hi,
I?m using iotivity-constrained on an Arduino 101 board and trying to use
multiple sensors. I would like to map each sensor to a standard type so that
the device can have multiple resource types at the same time. However, so far
it seemed that iotivity-constrained only allowed binding to one.
I tweaked the ?apps/server_zephyr.c? as following to bind a new temperature
type. However, I could only see the first one, which is ?oic.r.light?, when
connecting to the device. If the ?oic.r.temperature? comes first, it will
appear instead of the ?oic.r.light?.
----
static void
register_resources(void)
{
oc_resource_t *res = oc_new_resource("/a/light", 2, 0);
oc_resource_bind_resource_type(res, "oic.r.light");
oc_resource_bind_resource_type(res, "oic.r.temperature");
oc_resource_bind_resource_interface(res, OC_IF_RW);
oc_resource_set_default_interface(res, OC_IF_RW);
oc_resource_set_discoverable(res, true);
oc_resource_set_periodic_observable(res, 1);
oc_resource_set_request_handler(res, OC_GET, get_status, NULL);
oc_resource_set_request_handler(res, OC_POST, post_status, NULL);
oc_resource_set_request_handler(res, OC_PUT, put_status, NULL);
oc_add_resource(res);
}
----
It seems that the API oc_new_resource() allow multiple types. It uses the
second parameter to determine the number. Has this feature already been
implemented? If yes, please let me know what I am missing?
Thanks
Kien
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.iotivity.org/pipermail/iotivity-dev/attachments/20170405/b3afa2d5/attachment.html>