Gregg and Neil Hi, Thanks a lot for your responses.
If I understand the latest suggestion: need to use <HostURI> of devices, to find the resources of that device. This is very reasonable, at least for "simple" devices, when <HostURI> = <device> Still I wonder about the way IoTivity APIs and libraries. According to my best understanding the OCF spec, a single server response to "/oic/res" returns both the device information (incl. "di" value) and resource information (incl. types, interfaces and "href" URLs). An example taken from the public core spec here <http://screencast.com/t/v24yioxu> So working at the protocol level, the device-to-resource is relation exists within a single payload. The library does not take advantage of it. Am I missing something? Thank in advance, Max On Tue, Jun 28, 2016 at 11:23 PM, Wong Hon Chan, Neil D < neil.d.wong.hon.chan at intel.com> wrote: > > My "dream logic": > > > > First, the app finds the devices and identify them using the unique ID > (assuming the app logic needs to "remember" something about the devices, > and not just find them). > > Then, find the respective resources of the devices, so the app can > control the device. > > > > Unfortunately, failed to understand from the samples how it can be done. > > > > Looking in the Android code: > > Resource discovery is done via OcPlatform.findResource(), > > Device discovery is done via OcPlatform.getDeviceInfo(). > > Hello, > > below is a description of the flow that would be required when trying to > find the resources for a specific server: > > 1.OcPlatform.getDeviceInfo() > > 2.onDeviceFound(OcRepresentation ocRepresentation) > > 3.OcPlatform.findResource(<HostURI>, ...) > > > > e.g.: > > OcPlatform.getDeviceInfo("", > > OcPlatform.WELL_KNOWN_DEVICE_QUERY, > > EnumSet.of(OcConnectivityType.CT_IP_USE_V4), > > <OcPlatform.OnDeviceFoundListener>); > > > > The <listener> would then have an implementation of > onDeviceFound(OcRepresentation ocRepresentation); > > From this obtain the HostURI which is then used to make a call to > findResource() and now you will only find this specific HostURI's > resources > > Make a call to OcPlatform.findResource(<HostURI>, ...) > > > > *From:* iotivity-dev-bounces at lists.iotivity.org [mailto: > iotivity-dev-bounces at lists.iotivity.org] *On Behalf Of *Gregg Reynolds > *Sent:* Monday, June 27, 2016 1:49 PM > *To:* Max Kholmyansky <max001 at gmail.com> > *Cc:* iotivity-dev at lists.iotivity.org > *Subject:* Re: [dev] How to: device vs. resource discovery in IoTivity > > > > > On Jun 27, 2016 2:20 AM, "Max Kholmyansky" <max001 at gmail.com> wrote: > > > > Hi, > > > > I am confused since I failed to understand how to find the connection > between the "resources" and the "devices". > > > > To my best knowledge of the OCF spec: > > Devices must have unique identifiers set by manufacturers ("di" > attribute value). > > Devices can have multiple resources. For example, Smart Home spec says > "thermostat" device type must contain 2 "temperature" resources. > > I am not aware of any requirement for a unique identifier for a resource. > > I'm not an expert but my understanding is that every resource must have a > uri, which is unique by definition. > > > So I would expect IoTivity to expose a hierarchy between devices and > resources. > > I believe it's a virtual hierarchy. When you register ("create") a > resource you do not associate it with a device. so the oic/res resource is > effectively a resource manager that manages a (local) global list of > uri-resource pairs. > > every oic "widget" must have one canonical device but may have more. a > device in this sense is a resource of type oic.wk.d (I think, going from > memory here.) so to get all devices you query for that type. > > I'm not so clear about the association of resources and devices, but my > understanding is that the same resource could be associated with multiple > devices. But its hard to say - frankly, the OIC Spec is not exactly a > paragon of clarity. > > > > > My "dream logic": > > > > First, the app finds the devices and identify them using the unique ID > (assuming the app logic needs to "remember" something about the devices, > and not just find them). > > Then, find the respective resources of the devices, so the app can > control the device. > > > > Unfortunately, failed to understand from the samples how it can be done. > > > > Looking in the Android code: > > Resource discovery is done via OcPlatform.findResource(), > > Device discovery is done via OcPlatform.getDeviceInfo(). > > I suspect the idea is that after you do device discovery, you then do > resource discovery to a specific device, but we have now arrived at the > limits of my knowledge. > > hope that helps, or prompts Somebody Who Knows to clarify. > > gregg > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.iotivity.org/pipermail/iotivity-dev/attachments/20160630/78f9313b/attachment.html>
