抓住CoAP协议的“心” (3)

PUT资源数据

coap://coap.me:>put /sink --payload 'Hi From IoT Technology' --format text/plain ----------------------------------- Response ----------------------------------- PUT coap://coap.me/sink MID: 64266, Type: ACK, Token: FC2CE751AD5A232A, RTT: 368ms Options: {"Content-Format":"text/plain"} Status : 204-No Content, Payload: 6B ................................... Payload .................................... PUT OK -------------------------------------------------------------------------------- coap://coap.me:>get /sink ----------------------------------- Response ----------------------------------- GET coap://coap.me/sink MID: 64267, Type: ACK, Token: 3439364639206648, RTT: 13478ms Options: {"ETag":0x01fd3e1298b1fb7a, "Content-Format":"text/plain"} Status : 205-Reset Content, Payload: 36B ................................... Payload .................................... you put here: Hi From IoT Technology -------------------------------------------------------------------------------- coap://coap.me:>

POST资源数据

coap://coap.me:>delete /sink ----------------------------------- Response ----------------------------------- DELETE coap://coap.me/sink MID: 64268, Type: ACK, Token: 0CCB572626A124A6, RTT: 391ms Options: {"Content-Format":"text/plain"} Status : 202-Accepted, Payload: 9B ................................... Payload .................................... DELETE OK -------------------------------------------------------------------------------- coap://coap.me:>post /sink --payload 'testing for post data' --format text/plain ----------------------------------- Response ----------------------------------- POST coap://coap.me/sink MID: 64269, Type: ACK, Token: A441392CC855852D, RTT: 424ms Options: {"Location-Path":["location1","location2","location3"], "Content-Format":"text/plain"} Status : 201-Created, Payload: 7B ................................... Payload .................................... POST OK -------------------------------------------------------------------------------- coap://coap.me:>get /sink ----------------------------------- Response ----------------------------------- GET coap://coap.me/sink MID: 64270, Type: ACK, Token: DC24713232F17DB7, RTT: 325ms Options: {"ETag":0xf97973ea26db6781, "Content-Format":"text/plain"} Status : 205-Reset Content, Payload: 54B ................................... Payload .................................... I was deleted, and you put here: testing for post data --------------------------------------------------------------------------------

到此为止,我相信大家对CoAP协议的消息格式应该有了一定的认知。更多信息和使用请浏览这个库的README。

下一篇,我将手把手带大家用Eclipse Californium搭建CoAP Server服务。

参考资料

CoAP英文官方文档: https://tools.ietf.org/html/rfc7252

CoAP Wiki百科: https://en.wikipedia.org/wiki/Constrained_Application_Protocol

CoAP-Shell客户端: https://github.com/sanshengshui/coap-shell

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zyydpf.html