Qt CoAP
受限应用协议(CoAP)是一种用于物联网(IoT)中受限节点和受限网络的机器对机器(M2M)网络传输协议。 该协议旨在轻松与 HTTP 对接以实现与 Web 的集成,同时满足多播支持、极低开销以及适用于资源受限环境的简洁性等特殊要求。
Qt CoAP 模块实现了RFC 7252定义的CoAP客户端。通常,CoAP设计为使用UDP等数据报导向的传输层协议,因此当前的传输层实现基于UDP。不过,也可以基于TCP、WebSocket等实现自定义传输层。
Qt CoAP 模块支持:
注意:安全功能 需手动启用:QCoapClient 默认使用QtCoap::NoSecurity ,必须以安全模式构建才能启用 DTLS。参见“安全”部分。
使用该模块
要使用 Qt 模块,需要将其与模块库进行链接,既可以直接链接,也可以通过其他依赖项间接链接。包括CMake和qmake 在内的多种构建工具都对此提供了专门支持。
使用 CMake 构建
使用find_package() 命令在Qt6 包中定位所需的模块组件:
find_package(Qt6 REQUIRED COMPONENTS Coap)
target_link_libraries(mytarget PRIVATE Qt6::Coap)另请参阅“使用 CMake 构建”概述。
使用 qmake 构建
要配置模块以便使用 qmake 进行构建,请在项目的 .pro 文件中将该模块作为QT 变量的值添加:
QT += coap文章与指南
示例
参考
许可与署名
Qt CoAP 由The Qt Company 提供商业许可。此外,它还遵循GNU 通用公共许可证第 3 版。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.