intel / iotivity-node

Node.js bindings for IoTivity
https://www.iotivity.org/
42 stars 44 forks source link

findResource API does not filter resources with options.resourceTypes #139

Open ttzeng opened 7 years ago

ttzeng commented 7 years ago

Per the findResources API, I thought passing options.resourceTypes argument to findResources() can discover only the desired resource type, but the following code snippet still got all resource in the foundResource listener. Is this valid?

client.on("error", serverError)
          .findResources({ resourceTypes: [ 'no_such_resource' ] }, foundResource).then(
nagineni commented 7 years ago

@ttzeng, try changing property name resourceTypes to resourceType. I recently checked this query-oriented discovery and it was working fine for me.

https://github.com/01org/iot-js-api/blob/ocf-1.1.0/api/ocf/client.md#35-the-findresourcesoptions-listener-method

ttzeng commented 7 years ago

Thanks @nagineni , it works. It really discovers the desired resource type in the given string array, so it seems a property name typo and will be fixed in future commit?

zolkis commented 7 years ago

@ttzeng did you mean to fix the spec, i.e. resourceType should actually be resourceTypes and require it to be an array?

ttzeng commented 7 years ago

@zolkis sorry for my misled. I meant the property name resourceTypes in the Spec right refers a array of strings, but it sounds a typo in the iotivity-node implementation, so I was wondering whether it will be fixed in future iotivity-node revisions?