CoAP Device Access
About 1 min
Overview
This page is the English counterpart of the Chinese CoAP Device Access guide. It summarizes device access protocol configuration and integration verification while keeping the document path aligned with the Chinese documentation structure.
How To Use This Page
- Follow the same operation order as the Chinese source page.
- Keep configuration values, topic names, ports, commands, and file paths consistent with your deployment environment.
- Screenshots and diagrams reuse the Chinese documentation image directory so assets are maintained in one place.
- For production changes, validate the operation in a test environment before applying it online.
Reference Commands And Configuration
The following snippets are preserved from the source guide because commands, configuration keys, and protocol examples should remain exact.
Commands:
get performs a GET request
put performs a PUT request
post performs a POST request
delete performs a DELETE request
在这里,我们用coap://vs0.inf.ethz.ch/来作一个简单的测试
coap get coap://vs0.inf.ethz.ch/
(2.05) ************************************************************
I-D
测试一下现在的最小的物联网系统CoAP版
coap get coap://iot-coap.phodal.com/id/1
(2.05) [{"id":1,"value":"is id 1","sensors1":19,"sensors2":20}]$ docker run -it --rm --name libcoap --network host heeejianbo/my-libcoap:1.0$ coap-client
coap-client v4.3.1 -- a small CoAP implementation
Copyright (C) 2010-2022 Olaf Bergmann <bergmann@tzi.org> and others
Build: v4.3.1-4-g02b7647
TLS Library: OpenSSL - runtime 1.1.1t, libcoap built for 1.1.1t
(DTLS and TLS support; PSK, PKI, PKCS11, and no RPK support)使用 coap-client 向 test/topic 发布消息进行测试:
coap-client -m post -e "Hello, CoAP" "coap://127.0.0.1/ps/test/topic?qos=0"创建一个 CoAP 订阅者,并等待 60 秒以接收 test/topic 主题上的消息:
coap-client -m get -s 60 -O 6,0x00 -o - -T "obstoken" "coap://127.0.0.1/ps/test/topic"