libcoap 简单测试

来源:互联网 发布:类似聚合数据的网站 编辑:程序博客网 时间:2024/06/01 22:48

最近在研究CoAP,打算使用libcoap体验一下CoAP,在网上找了些资料,整理如下。

1. 什么是libcoap?

libcoap: C-Implementation of CoAP

libcoap implements a lightweight application-protocol for devices that are constrained their resources such as computing power, RF range, memory, bandwith, or network packet sizes. This protocol, CoAP was standardized in the IETF as RFC 7252.

2. 如何获取libcoap?

sudo apt-get install autoconf automake libtool
git clone https://github.com/obgm/libcoap.git
cd libcoap
./autogen.sh
./configure –enable-documentation=no
make
sudo make install

简单说一下上面的指令(我是使用的平台是Raspberry Pi 3):
1. 需要安装autoconf automake libtool这几个工具,不然会提醒缺少工具。
2. clone source code到本地。
3. 执行一下autogen.sh脚本。
4. 再执行一下configure脚本,后面带一下参数。

在网上找资料的时候,有个老外用的命令是这个
./configure –no-documentation
但是不知道我我在参数列表找不到–no-documentation
然后用./configure –help 看到了下图的提示,于是改用
./configure –enable-documentation=no

解决libcoap配置问题
5. make 和 make install,可以看看Terminal输出具体这两个指令做了什么事情。

3.如何体验libcoap?

进入example目录
一个Terminal先启动Server

./coap-server

另一个Terminal启动Client

./coap-client -m get coap://localhost

Client有信息输出就是成功了.
过程大致如下
测试过程

4.参考资料?

  • https://libcoap.net/
  • https://github.com/smartuni/examples/wiki/libcoap
  • http://blog.csdn.net/xukai871105/article/details/44980041
  • https://www.phodal.com/blog/coap-command-line-tools-set/
原创粉丝点击