CoAP: Group similar resources under one

試著忘記壹切 提交于 2020-06-01 02:27:30

问题


I am using libcoap implementation of CoAP for one of my IOT application.

Query: I want to group more than one resource under one topic. For example, I want to group 'current time' resource and 'date' resource under 'TIME' resource.

On GET request to '/TIME' resource, server should provide date and current time to client. On GET request to '/TIME/current time' resource, server should provide current time to client. On GET request to '/TIME/date' resource, server should provide today's date to client.

Also, I am using Firefox Copper plugin to test my iot server application.


回答1:


Assuming you have created both the /TIME/currenttime and /TIME/date resources, what's left is that you create a /TIME/ resource (the slash at the end does matter) and announce it in .well-known/core as </TIME/>;if="core.b".

The GET handler for /TIME/ should return data in application/senml+json format, like [{"n":"currenttime","sv":"10:40:25"},{"n":"date","sv":"2018-07-27"}].

All the details are described in core-interfaces draft, but that's the gist of it.



来源:https://stackoverflow.com/questions/34893380/coap-group-similar-resources-under-one

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!