coap 源码简单修改测试

1.通过查看源码可知,返回值的定义为INDEX,修改INDEX的初始化值即可改变客户端的返回值。将INDEX的定义修改为test即可发现再次请求时返回值已经为从新定义的值。

main-->init_resources(ctx);-->coap_register_handler(r, COAP_REQUEST_GET, hnd_get_index);--->hnd_get_index-->coap_add_data(response, strlen(INDEX), (unsigned char *)INDEX);-->INDEX

2.注意需要在examples目录下执行make将应用从新编译,并且从新启动服务

1.

3.端口号修改,启动客户端时也要修改为相应的端口号./coap-client -m get -o result.txt coap://127.0.0.1:5688

4.请求地址的修改

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

./coap-client -m get  coap://127.0.0.1/time

猜你喜欢

转载自blog.csdn.net/weixin_42627035/article/details/84593338