找回密码
 立即注册
搜索
查看: 271|回复: 0

QtMqtt 库的使用

[复制链接]

266

主题

0

回帖

1119

积分

管理员

积分
1119
发表于 2024-1-18 10:31:26 | 显示全部楼层 |阅读模式

QtMqtt 库是官方的 mqtt 库,但是是属于 Qt for Automation 商业套件的。需要下载源码自己编译才能用。

源码:https://github.com/qt/qtmqtt
文档:https://doc.qt.io/QtMQTT/qmqttclient.html

编译成静态库

在 Qt5.15.0_MSVC2019_x64_static\include 创建 QtMqtt 文件夹,将头文件从源码 src 文件夹拷贝过去。

set path=D:\Qt\kits\Qt5.15.0_MSVC2019_x64_static\bin;%path%
qmake
nmake
nmake install
nmake docs

使用的时候 pro 文件加 QT  += mqtt

MQTT Broker 非加密测试:

broker:test.mosquitto.org 1883

MQTT Broker 单向向认证测试:

broker:test.mosquitto.org 8883

MQTT Broker 双向认证测试:

broker:test.mosquitto.org 8884

证书生成与注册

http://test.mosquitto.org/ssl/

生成私钥:

openssl genrsa -out client.key

生成客户端证书:

openssl req -out client.csr -key client.key -new

在服务器上添加证书:


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|棱讯科技 ( 粤ICP备2024228160号-2|粤公网安备44030002003510号 )

GMT+8, 2024-7-27 18:09 , Processed in 0.015730 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表