commit a9606ff58acb7aeaa9e93bd3b832d219898913d9 Author: JasonYANG170 Date: Thu May 9 11:00:07 2024 +0800 up new code diff --git a/.env b/.env new file mode 100644 index 0000000..e69de29 diff --git a/IOT.pro b/IOT.pro new file mode 100644 index 0000000..bdd4c29 --- /dev/null +++ b/IOT.pro @@ -0,0 +1,41 @@ +QT += core gui +QT += mqtt +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +CONFIG += c++17 + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + dialog.cpp \ + dialog2.cpp \ + form.cpp \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + dialog.h \ + dialog2.h \ + form.h \ + mainwindow.h + +FORMS += \ + dialog.ui \ + dialog2.ui \ + form.ui \ + mainwindow.ui + +TRANSLATIONS += \ + IOT_zh_CN.ts +CONFIG += lrelease +CONFIG += embed_translations + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target + +DISTFILES += \ + .env diff --git a/IOT.pro.user b/IOT.pro.user new file mode 100644 index 0000000..de8e4d7 --- /dev/null +++ b/IOT.pro.user @@ -0,0 +1,271 @@ + + + + + + EnvironmentId + {5913d737-a7b3-40d5-81b3-ef43144c2778} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + 0 + false + true + false + 0 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + false + true + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + + 0 + true + + true + true + Builtin.DefaultTidyAndClazy + 8 + false + + + + true + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop Qt 6.8.0 MinGW 64-bit + Desktop Qt 6.8.0 MinGW 64-bit + qt.qt6.dev.win64_mingw_kit + 1 + 0 + 0 + + 0 + C:\Users\qw200\Documents\C or C++ for YANG\build-IOT-Desktop_Qt_6_6_0_MinGW_64_bit-Debug + C:/Users/qw200/Documents/C or C++ for YANG/build-IOT-Desktop_Qt_6_6_0_MinGW_64_bit-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + 构建 + 构建 + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + 清除 + 清除 + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + E:\C++-QT\build-IOT-Desktop_Qt_6_6_0_MinGW_64_bit-Release + E:/C++-QT/build-IOT-Desktop_Qt_6_6_0_MinGW_64_bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + 构建 + 构建 + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + 清除 + 清除 + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + C:\Users\qw200\Documents\C or C++ for YANG\build-IOT-Desktop_Qt_6_6_0_MinGW_64_bit-Profile + C:/Users/qw200/Documents/C or C++ for YANG/build-IOT-Desktop_Qt_6_6_0_MinGW_64_bit-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + 构建 + 构建 + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + 清除 + 清除 + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + 部署 + 部署 + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + 0 + true + + + 2 + + false + -e cpu-cycles --call-graph "dwarf,4096" -F 250 + IOT2 + Qt4ProjectManager.Qt4RunConfiguration:E:/C++-QT/IOT/IOT.pro + E:/C++-QT/IOT/IOT.pro + true + true + true + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/IOT_zh_CN.ts b/IOT_zh_CN.ts new file mode 100644 index 0000000..14bccd1 --- /dev/null +++ b/IOT_zh_CN.ts @@ -0,0 +1,3 @@ + + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..c023956 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +## HI diff --git a/dialog.cpp b/dialog.cpp new file mode 100644 index 0000000..0ceb116 --- /dev/null +++ b/dialog.cpp @@ -0,0 +1,269 @@ +#include "dialog.h" +#include "ui_dialog.h" +#include +#include +QStringList parts; +QByteArray byteArray; +QString formattedVersion; +QString newves; +QString ID; +QString remainderx; +Dialog::Dialog(const QString& text, QWidget *parent) : + QDialog(parent), + ui(new Ui::Dialog), + client(new QMqttClient(this)) +{ + ui->setupUi(this); + setWindowTitle("设备管理"); + ID=text; + ui->label_6->setText("设备ID:"+text); + trimmedText = text.mid(2); // 从索引2(即"fp"之后)开始截取文本 + + client->setHostname("url"); + client->setPort(123); + client->setClientId("clientid"); + client->connectToHost(); + + QObject::connect(client, &QMqttClient::connected, [this]() { + qDebug() << "Connected to MQTT broker!"; + // 订阅主题 + QMqttTopicFilter filter("Flowerpot"); + client->subscribe(filter); + }); + + QObject::connect(client, &QMqttClient::messageReceived, [this](const QByteArray& message, const QMqttTopicName& topic) { + QString messageContent = message; + QString desiredPrefix = "#ID" + trimmedText; + formattedVersion =""; + if (messageContent.startsWith(desiredPrefix)) { + + ui->label_7->setText("设备状态:在线"); + QString messageString = QString::fromUtf8(message); + qDebug() << "Received message:" << message << "from topic:" << topic.name(); + parts = messageString.split('#'); + + for (const QString& part : parts) { + qDebug() << "Split part:" << part; + } + QString firmwareVersion = parts[8]; + int versionNumber = firmwareVersion.toInt(); // 将字符串转换为整数 + + int x = versionNumber / 100; // 获取百位数 + int y = (versionNumber / 10) % 10; // 获取十位数 + int z = versionNumber % 10; // 获取个位数 + + formattedVersion = QString("V%1.%2.%3").arg(x).arg(y).arg(z); // 创建格式化后的版本号字符串 + ui->label_8->setText("固件版本:"+formattedVersion); + ui->label_3->setText(parts[2]+"%"); + ui->label_4->setText(parts[4]+"%"); + ui->label_5->setText(parts[3]+"%"); + if(parts[6]=="1"){ + ui->pushButton->setStyleSheet("background-color: red;"); + }else{ + ui->pushButton->setStyleSheet("background-color: white;"); + } + if(parts[7]=="1"){ + ui->pushButton_2->setStyleSheet("background-color: red;"); + }else{ + ui->pushButton_2->setStyleSheet("background-color: white;"); + } + if(parts[5]=="1"){ + ui->pushButton_3->setStyleSheet("background-color: red;"); + }else{ + ui->pushButton_3->setStyleSheet("background-color: white;"); + } + ui->checkBox->blockSignals(true); + if (parts[9] == "1") { + ui->checkBox->setCheckState(Qt::Checked); // 设置为选中状态 + } else { + ui->checkBox->setCheckState(Qt::Unchecked); // 设置为未选中状态 + } + ui->checkBox->blockSignals(false); + } else { + // 忽略其他的消息 + } + }); + //更新检查服务器 + QNetworkAccessManager *manager = new QNetworkAccessManager(this); + QUrl url("updata url"); + QNetworkRequest request(url); + + // Set unsafe SSL configuration + QSslConfiguration config = request.sslConfiguration(); + config.setPeerVerifyMode(QSslSocket::VerifyNone); + request.setSslConfiguration(config); + + QNetworkReply *reply = manager->get(request); + + // Connect to the finished signal + connect(reply, &QNetworkReply::finished, [=]() { + if (reply->error() == QNetworkReply::NoError) { + // Read the JSON data + QByteArray data = reply->readAll(); + + // Display the JSON data in a message box + QJsonDocument jsonDoc = QJsonDocument::fromJson(QString(data).toUtf8()); + QJsonObject jsonObj = jsonDoc.object(); + + // 获取数据 + QJsonObject jObj2 = jsonDoc["data"].toObject(); + QString str = jObj2 ["content"].toString(); + qDebug() << str; + newves = str.left(6); // 提取前6个字符组成newves + + remainderx = str.mid(6); // 提取剩下的字符 + remainderx.replace("#", "\n"); + qDebug() << "update1111111"; + qDebug() << newves; + qDebug() << formattedVersion; + if (newves != formattedVersion) { + // QMessageBox::warning(this, "Error", "已发布新版本\"" + info + "\"。\n点击\"设置\"下载最新版本。"); + // ui->pushButton_4->setText("发现新版本"); + ui->pushButton_6->setStyleSheet("background-color: red;"); + ui->pushButton_6->setText("发现新版本!"); +qDebug() << "update"; + } + else { + // ui->pushButton_4->setText("暂无更新"); +qDebug() << "no"; + } + } + else { + // Display an error message + QMessageBox::warning(this, "Error", reply->errorString()); + } + + // Clean up + reply->deleteLater(); + manager->deleteLater(); + }); +} + +Dialog::~Dialog() +{ + delete ui; +} + + + +void Dialog::on_pushButton_clicked() +{ + if (client->state() == QMqttClient::Connected) { + QMqttTopicName topic("Flowerpot"); + if (parts[6]=="1") { + QString str = "#IDTO" + trimmedText+"&OFFHOT"; + byteArray = str.toUtf8(); + }else{ + QString str = "#IDTO" + trimmedText+"&ONHOT"; + byteArray = str.toUtf8(); + } + + + client->publish(topic, byteArray, 0, false); + // 发送消息后做其他处理 + } else { + QMessageBox::warning(this, "Error", "MQTT client is not connected!"); + } +} + + +void Dialog::on_pushButton_2_clicked() +{ + if (client->state() == QMqttClient::Connected) { + QMqttTopicName topic("Flowerpot"); + if (parts[7]=="1") { + QString str = "#IDTO" + trimmedText+"&OFFLED"; + byteArray = str.toUtf8(); + }else{ + QString str = "#IDTO" + trimmedText+"&ONLED"; + byteArray = str.toUtf8(); + } + + + client->publish(topic, byteArray, 0, false); + // 发送消息后做其他处理 + } else { + QMessageBox::warning(this, "Error", "MQTT client is not connected!"); + } +} + + +void Dialog::on_pushButton_3_clicked() +{ + if (client->state() == QMqttClient::Connected) { + QMqttTopicName topic("Flowerpot"); + if (parts[5]=="1") { + QString str = "#IDTO" + trimmedText+"&OFFPUMP"; + byteArray = str.toUtf8(); + }else{ + QString str = "#IDTO" + trimmedText+"&ONPUMP"; + byteArray = str.toUtf8(); + } + + + client->publish(topic, byteArray, 0, false); + // 发送消息后做其他处理 + } else { + QMessageBox::warning(this, "Error", "MQTT client is not connected!"); + } +} + + +void Dialog::on_pushButton_4_clicked() +{ + // 实例化第二个 Dialog2 对象 + Dialog2 dialog2; + + // 显示第二个 Dialog2 + dialog2.exec(); +} + +void Dialog::on_pushButton_5_clicked() +{ + +} + +void Dialog::on_pushButton_6_clicked() +{ + form* formDialog = new form(ID, formattedVersion,newves,remainderx,this); // 使用其他名称替换 'form' + formDialog->show(); +} + + +void Dialog::on_checkBox_stateChanged(int arg1) +{ + if (arg1 == Qt::Checked) { + qDebug() << "复选框被选中"; + // 根据选中状态执行特定操作 + if (client->state() == QMqttClient::Connected) { + QMqttTopicName topic("Flowerpot"); + QString str = "#IDTO" + trimmedText+"&ONAUTO"; + byteArray = str.toUtf8(); + client->publish(topic, byteArray, 0, false); + // 发送消息后做其他处理 + } else { + QMessageBox::warning(this, "Error", "MQTT client is not connected!"); + } + } else if (arg1 == Qt::Unchecked) { + qDebug() << "复选框未被选中"; + // 根据未选中状态执行特定操作 + if (client->state() == QMqttClient::Connected) { + QMqttTopicName topic("Flowerpot"); + QString str = "#IDTO" + trimmedText+"&OFFAUTO"; + byteArray = str.toUtf8(); + client->publish(topic, byteArray, 0, false); + // 发送消息后做其他处理 + } else { + QMessageBox::warning(this, "Error", "MQTT client is not connected!"); + } + } +} + +void Dialog::closeEvent(QCloseEvent *event) +{ + // 断开 MQTT 连接 + client->disconnectFromHost(); + + // 调用父类的关闭事件处理函数 + QDialog::closeEvent(event); +} diff --git a/dialog.h b/dialog.h new file mode 100644 index 0000000..e2b80d0 --- /dev/null +++ b/dialog.h @@ -0,0 +1,44 @@ +#ifndef DIALOG_H +#define DIALOG_H +#include +#include "form.h" // 添加对 form.h 的引用 +#include "ui_form.h" +#include +#include +#include "dialog2.h" +#include "ui_dialog2.h" +namespace Ui { +class Dialog; +} + +class Dialog : public QDialog +{ + Q_OBJECT + +public: + explicit Dialog(const QString& text, QWidget *parent = nullptr); + ~Dialog(); +protected: + void closeEvent(QCloseEvent *event) override; +private slots: + void on_pushButton_5_clicked(); + + void on_pushButton_clicked(); + + void on_pushButton_2_clicked(); + + void on_pushButton_3_clicked(); + + void on_pushButton_4_clicked(); + + void on_pushButton_6_clicked(); + + void on_checkBox_stateChanged(int arg1); + +private: + Ui::Dialog *ui; + QMqttClient* client; + QString trimmedText; +}; + +#endif // DIALOG_H diff --git a/dialog.ui b/dialog.ui new file mode 100644 index 0000000..2bf1a30 --- /dev/null +++ b/dialog.ui @@ -0,0 +1,242 @@ + + + Dialog + + + + 0 + 0 + 401 + 367 + + + + Dialog + + + + + + + 16777215 + 130 + + + + 智能植物培育设备 + + + + + + + + + + 设备ID: + + + + + + + 设备状态:离线 + + + + + + + 固件版本: + + + + + + + 你的植物似乎很开心 + + + + + + + + + + 16777215 + 50 + + + + + + + + + + + + + + + 环境温度 + + + + + + 0.00% + + + + + + + + + + 土壤湿度 + + + + + + 0.00% + + + + + + + + + + 环境湿度 + + + + + + 0.00% + + + + + + + + + + + + + 0 + 150 + + + + 控制台 + + + + + + AI自动控制 + + + + + + + + + + 0 + 50 + + + + 环境恒温 + + + + + + + + 0 + 50 + + + + 环境光照 + + + + + + + + 0 + 50 + + + + 浇水 + + + + + + + + + + + + 0 + 50 + + + + AI对话 + + + + + + + + 0 + 50 + + + + AI生长预测 + + + + + + + + 0 + 50 + + + + 检查固件更新 + + + + + + + + + + + + + diff --git a/dialog2.cpp b/dialog2.cpp new file mode 100644 index 0000000..21e9eb5 --- /dev/null +++ b/dialog2.cpp @@ -0,0 +1,75 @@ +#include "dialog2.h" +#include "qnetworkaccessmanager.h" +#include "qnetworkreply.h" +#include "ui_dialog2.h" + +Dialog2::Dialog2(QWidget *parent) + : QDialog(parent) + , ui(new Ui::Dialog2) +{ + ui->setupUi(this); + setWindowTitle("AI Chat"); +} + +Dialog2::~Dialog2() +{ + delete ui; +} +QString strall; +QString discuss; +QString ask; +QString answer; +void Dialog2::on_pushButton_clicked() +{ + ui->textBrowser->setPlainText("正在等待ChatGPT回答您的问题,请稍等......"); + ask=ui->textEdit->toPlainText(); + discuss=discuss+"Q:"+ask+"A:"; + QString test2;"ESP8266控制电路数据上传:"+ask; + qDebug() << "ESP8266控制电路数据上传:"+ui->textEdit->toPlainText();; + // if(ask.length()>880){ + // QMessageBox::warning(this, "Error", "长度超出限制,当前共"+QString::number(ask.length())+"字节\n请删除部分字符使其控制在880字节以内。"); + //} + + + int num=0; + + QNetworkAccessManager manager; + + // 创建POST请求 + QUrl url("aiurl"); // 更换为你要访问的API地址 + QNetworkRequest request(url); + QString accessToken = "token"; + QByteArray authHeader = "Bearer " + accessToken.toUtf8(); + + request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); + request.setRawHeader("Authorization", authHeader); + // 准备POST数据 + QByteArray postData; + postData.append("session_id=123&content=[{\"role\":\"system\",\"content\":\"You are Flowerpot AI, a large language model trained by YANG\\nCarefully heed the user's instructions.\\nRespond using Markdown.\\nCurrent Date: 2024/3/18 14:00:23\\n\"},{\"role\":\"user\",\"content\":\""+ask.toUtf8()+"\"}]&max_context_length=5¶ms={\"model\":\"gpt-3.5-turbo\",\"temperature\":1,\"max_tokens\":2048,\"presence_penalty\":0,\"frequency_penalty\":0,\"max_context_length\":5,\"voiceShortName\":\"zh-CN-XiaoxiaoNeural\",\"rate\":1,\"pitch\":1}"); // 根据API要求,构建合适的POST参数 + + // 发送POST请求 + QNetworkReply *reply = manager.post(request, postData); + + // 等待请求完成 + QEventLoop loop; + QObject::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit); + loop.exec(); + QString str1="You:\n"+ask+"\n\n"; + + // 获取返回值 + if(reply->error() == QNetworkReply::NoError) { + QString responsex = reply->readAll(); + QString response= responsex.remove(responsex.length() - 6, 6); + QString str2="Chat Robot:\n"+response+"\n\n"; + strall=strall+str1+str2; + ui->textBrowser->setPlainText(strall); + QString test1="AI数据应答:"+response; + qDebug() << test1; + } else { + qDebug() << "Error:" << reply->errorString(); + } + + // 清理 + reply->deleteLater(); +} + diff --git a/dialog2.h b/dialog2.h new file mode 100644 index 0000000..28e2974 --- /dev/null +++ b/dialog2.h @@ -0,0 +1,25 @@ +#ifndef DIALOG2_H +#define DIALOG2_H + +#include + +namespace Ui { +class Dialog2; +} + +class Dialog2 : public QDialog +{ + Q_OBJECT + +public: + explicit Dialog2(QWidget *parent = nullptr); + ~Dialog2(); + +private slots: + void on_pushButton_clicked(); + +private: + Ui::Dialog2 *ui; +}; + +#endif // DIALOG2_H diff --git a/dialog2.ui b/dialog2.ui new file mode 100644 index 0000000..b3e785a --- /dev/null +++ b/dialog2.ui @@ -0,0 +1,65 @@ + + + Dialog2 + + + + 0 + 0 + 400 + 347 + + + + Dialog + + + + + + <html><head/><body><p align="center"><span style=" font-size:16pt;">Flower Chat</span></p></body></html> + + + + + + + + 0 + 230 + + + + + + + + + + + 16777215 + 51 + + + + + + + + + 16777215 + 51 + + + + 发送 + + + + + + + + + + diff --git a/form.cpp b/form.cpp new file mode 100644 index 0000000..21945e6 --- /dev/null +++ b/form.cpp @@ -0,0 +1,98 @@ +#include "form.h" +#include "ui_form.h" +#include +#include +QString st; +QString upid; +form::form(const QString& id, const QString& ves, const QString& newves, const QString& log,QWidget *parent) : + QDialog(parent), + ui(new Ui::form), + client(new QMqttClient(this)) +{ + ui->setupUi(this); + setWindowTitle("更新检查"); + st=id; + upid = id.mid(2); + //设备更新 + if(id!=""){ + client->setHostname("mqtt"); + client->setPort(123); + client->setClientId("clientid"); + client->connectToHost(); + + QObject::connect(client, &QMqttClient::connected, [this]() { + qDebug() << "Connected to MQTT broker!"; + // 订阅主题 + QMqttTopicFilter filter("Flowerpot"); + client->subscribe(filter); + }); + + ui->label_6->setText("设备ID:"+id); + ui->label_8->setText("固件版本:"+ves); + ui->label_3->setText(ves); + ui->label_5->setText(newves); + ui->textBrowser->setText(log); + if(ves==""){ + ui->label_7->setText("设备状态:离线"); + }else{ + ui->label_7->setText("设备状态:在线"); +} + } + //程序更新 + else{ +ui->label_6->setText("万物互联IOT设备PC控制软件更新"); +if(newves!=""){ +ui->label_7->setText("服务器状态:在线"); +}else{ +ui->label_7->setText("服务器状态:离线"); +} + + ui->label_8->setText("服务器最新版本:"+newves); + ui->label->setText("当前版本:"+ves); + ui->label_3->setText(ves); + ui->label_5->setText(newves); + ui->textBrowser->setText(log); + } +} +form::~form() +{ + delete ui; +} +#include +#include +void form::on_pushButton_clicked() +{ + if(st!=""){ + QMqttTopicName topic("Flowerpot"); + + QString str = "#IDTO"+upid+"&Updata"; + QByteArray byteArray = str.toUtf8(); + + + + client->publish(topic, byteArray, 0, false); + }else{ + QMessageBox::information(this, "密码提示", "即将打开链接,密钥:2xzk"); + QUrl url("updataurl"); // 替换为您要打开的网页URL + if (QDesktopServices::openUrl(url)) { + + + } else { +// 处理无法打开链接的错误 + + } + } + +} + +void form::closeEvent(QCloseEvent *event) +{ + if(st!=""){ + // 断开 MQTT 连接 + client->disconnectFromHost(); + + // 调用父类的关闭事件处理函数 + QDialog::closeEvent(event); + qDebug() << "offfff"; + } +} diff --git a/form.h b/form.h new file mode 100644 index 0000000..aedfe69 --- /dev/null +++ b/form.h @@ -0,0 +1,29 @@ +#ifndef FORM_H +#define FORM_H + +#include +#include +#include + +namespace Ui { +class form; +} + +class form : public QDialog +{ + Q_OBJECT +protected: + void closeEvent(QCloseEvent *event) override; +public: + explicit form(const QString& id, const QString& ves, const QString& newves, const QString& log,QWidget *parent = nullptr); + ~form(); + +private slots: + void on_pushButton_clicked(); + +private: + Ui::form *ui; + QMqttClient* client; +}; + +#endif // FORM_H diff --git a/form.ui b/form.ui new file mode 100644 index 0000000..fc13975 --- /dev/null +++ b/form.ui @@ -0,0 +1,163 @@ + + + form + + + + 0 + 0 + 400 + 428 + + + + Dialog + + + + + + + 16777215 + 130 + + + + 更新 + + + + + + + + + + 设备ID: + + + + + + + 设备状态: + + + + + + + 固件版本: + + + + + + + 你的植物似乎很开心 + + + + + + + + + + 16777215 + 50 + + + + + + + + + + + + + + + 当前版本 + + + + + + V1.0.0 + + + + + + + + + + 最新版本 + + + + + + V1.0.0 + + + + + + + + + + + + 更新日志 + + + + + + + 0 + 0 + + + + + + + + + 175 + 0 + + + + <html><head/><body><p align="justify">注意事项:</p><p align="justify">1.更新过程中请勿断开设备电源。</p><p align="justify">2.更新过程中请勿退出程序。</p><p align="justify">3.更新完成后,设备会自动重启。</p><p align="justify">4.设备重启过程中请耐心等待。</p><p align="justify">5.再次检查更新提示</p><p align="justify">“已是最新版本”时表明更新成功<br/></p></body></html> + + + + + + + + + + + 0 + 35 + + + + 更新 + + + + + + + + diff --git a/lib/Qt6Mqtt.prl b/lib/Qt6Mqtt.prl new file mode 100644 index 0000000..7aafd7a --- /dev/null +++ b/lib/Qt6Mqtt.prl @@ -0,0 +1,3 @@ +QMAKE_PRL_TARGET = libQt6Mqtt.a +QMAKE_PRL_CONFIG = shared +QMAKE_PRL_VERSION = 6.8.0 diff --git a/lib/cmake/Qt6BuildInternals/StandaloneTests/QtMqttTestsConfig.cmake b/lib/cmake/Qt6BuildInternals/StandaloneTests/QtMqttTestsConfig.cmake new file mode 100644 index 0000000..7c57fd7 --- /dev/null +++ b/lib/cmake/Qt6BuildInternals/StandaloneTests/QtMqttTestsConfig.cmake @@ -0,0 +1,8 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +# TODO: Ideally this should look for each Qt module separately, with each module's specific version, +# bypassing the Qt6 Config file, aka find_package(Qt6SpecificFoo) repated x times. But it's not +# critical. +find_package(Qt6 6.8.0 + COMPONENTS Mqtt) diff --git a/lib/cmake/Qt6Mqtt/Qt6MqttAdditionalTargetInfo.cmake b/lib/cmake/Qt6Mqtt/Qt6MqttAdditionalTargetInfo.cmake new file mode 100644 index 0000000..1ba4ec4 --- /dev/null +++ b/lib/cmake/Qt6Mqtt/Qt6MqttAdditionalTargetInfo.cmake @@ -0,0 +1,48 @@ +# Additional target information for Qt6Mqtt +if(NOT DEFINED QT_DEFAULT_IMPORT_CONFIGURATION) + set(QT_DEFAULT_IMPORT_CONFIGURATION RELEASE) +endif() +__qt_internal_promote_target_to_global_checked(Qt6::Mqtt) +get_target_property(_qt_imported_location Qt6::Mqtt IMPORTED_LOCATION_RELEASE) +get_target_property(_qt_imported_implib Qt6::Mqtt IMPORTED_IMPLIB_RELEASE) +get_target_property(_qt_imported_location_default Qt6::Mqtt IMPORTED_LOCATION_${QT_DEFAULT_IMPORT_CONFIGURATION}) +get_target_property(_qt_imported_implib_default Qt6::Mqtt IMPORTED_IMPLIB_${QT_DEFAULT_IMPORT_CONFIGURATION}) + +# Import target "Qt6::Mqtt" for configuration "RelWithDebInfo" +set_property(TARGET Qt6::Mqtt APPEND PROPERTY IMPORTED_CONFIGURATIONS RELWITHDEBINFO) + +if(_qt_imported_location) + set_property(TARGET Qt6::Mqtt PROPERTY IMPORTED_LOCATION_RELWITHDEBINFO "${_qt_imported_location}") +endif() +if(_qt_imported_implib) + set_property(TARGET Qt6::Mqtt PROPERTY IMPORTED_IMPLIB_RELWITHDEBINFO "${_qt_imported_implib}") +endif() + +# Import target "Qt6::Mqtt" for configuration "MinSizeRel" +set_property(TARGET Qt6::Mqtt APPEND PROPERTY IMPORTED_CONFIGURATIONS MINSIZEREL) + +if(_qt_imported_location) + set_property(TARGET Qt6::Mqtt PROPERTY IMPORTED_LOCATION_MINSIZEREL "${_qt_imported_location}") +endif() +if(_qt_imported_implib) + set_property(TARGET Qt6::Mqtt PROPERTY IMPORTED_IMPLIB_MINSIZEREL "${_qt_imported_implib}") +endif() + +# Default configuration +if(_qt_imported_location_default) + set_property(TARGET Qt6::Mqtt PROPERTY IMPORTED_LOCATION "${_qt_imported_location_default}") +endif() +if(_qt_imported_implib_default) + set_property(TARGET Qt6::Mqtt PROPERTY IMPORTED_IMPLIB "${_qt_imported_implib_default}") +endif() +__qt_internal_promote_target_to_global_checked(Qt6::MqttPrivate) + +unset(_qt_imported_location) +unset(_qt_imported_location_default) +unset(_qt_imported_soname) +unset(_qt_imported_soname_default) +unset(_qt_imported_objects) +unset(_qt_imported_objects_default) +unset(_qt_imported_clr) +unset(_qt_imported_clr_default) +unset(_qt_imported_configs) diff --git a/lib/cmake/Qt6Mqtt/Qt6MqttConfig.cmake b/lib/cmake/Qt6Mqtt/Qt6MqttConfig.cmake new file mode 100644 index 0000000..ec4b897 --- /dev/null +++ b/lib/cmake/Qt6Mqtt/Qt6MqttConfig.cmake @@ -0,0 +1,177 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + + +####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() ####### +####### Any changes to this file will be overwritten by the next CMake run #### +####### The input file was QtModuleConfig.cmake.in ######## + +get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE) + +macro(set_and_check _var _file) + set(${_var} "${_file}") + if(NOT EXISTS "${_file}") + message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !") + endif() +endmacro() + +macro(check_required_components _NAME) + foreach(comp ${${_NAME}_FIND_COMPONENTS}) + if(NOT ${_NAME}_${comp}_FOUND) + if(${_NAME}_FIND_REQUIRED_${comp}) + set(${_NAME}_FOUND FALSE) + endif() + endif() + endforeach() +endmacro() + +#################################################################################### + +cmake_minimum_required(VERSION 3.16...3.21) + +include(CMakeFindDependencyMacro) + +get_filename_component(_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_import_prefix "${_import_prefix}" REALPATH) + +# Extra cmake code begin + +# Extra cmake code end + +# Find required dependencies, if any. +if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/Qt6MqttDependencies.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/Qt6MqttDependencies.cmake") + _qt_internal_suggest_dependency_debugging(Mqtt + __qt_Mqtt_pkg ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE) +endif() + +# If *ConfigDependencies.cmake exists, the variable value will be defined there. +# Don't override it in that case. +if(NOT DEFINED "Qt6Mqtt_FOUND") + set("Qt6Mqtt_FOUND" TRUE) +endif() + +if (NOT QT_NO_CREATE_TARGETS AND Qt6Mqtt_FOUND) + include("${CMAKE_CURRENT_LIST_DIR}/Qt6MqttTargets.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/Qt6MqttAdditionalTargetInfo.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/Qt6MqttExtraProperties.cmake" + OPTIONAL) + + # DEPRECATED + # Provide old style variables for includes, compile definitions, etc. + # These variables are deprecated and only provided on a best-effort basis to facilitate porting. + # Consider using target_link_libraries(app PRIVATE Qt6Mqtt) instead. + set(Qt6Mqtt_LIBRARIES "Qt6::Mqtt") + + get_target_property(_Qt6Mqtt_OWN_INCLUDE_DIRS + Qt6::Mqtt INTERFACE_INCLUDE_DIRECTORIES) + if(NOT _Qt6Mqtt_OWN_INCLUDE_DIRS) + set(_Qt6Mqtt_OWN_INCLUDE_DIRS "") + endif() + + if(TARGET Qt6::MqttPrivate) + get_target_property(_Qt6Mqtt_OWN_PRIVATE_INCLUDE_DIRS + Qt6::MqttPrivate INTERFACE_INCLUDE_DIRECTORIES) + if(NOT _Qt6Mqtt_OWN_PRIVATE_INCLUDE_DIRS) + set(_Qt6Mqtt_OWN_PRIVATE_INCLUDE_DIRS "") + endif() + endif() + + get_target_property(Qt6Mqtt_DEFINITIONS + Qt6::Mqtt INTERFACE_COMPILE_DEFINITIONS) + if(NOT Qt6Mqtt_DEFINITIONS) + set(Qt6Mqtt_DEFINITIONS "") + else() + list(TRANSFORM Qt6Mqtt_DEFINITIONS PREPEND "-D") + endif() + + get_target_property(Qt6Mqtt_COMPILE_DEFINITIONS + Qt6::Mqtt INTERFACE_COMPILE_DEFINITIONS) + if(NOT Qt6Mqtt_COMPILE_DEFINITIONS) + set(Qt6Mqtt_COMPILE_DEFINITIONS "") + endif() + + set(Qt6Mqtt_INCLUDE_DIRS + ${_Qt6Mqtt_OWN_INCLUDE_DIRS}) + + set(Qt6Mqtt_PRIVATE_INCLUDE_DIRS + ${_Qt6Mqtt_OWN_PRIVATE_INCLUDE_DIRS}) + + foreach(_module_dep ${_Qt6Mqtt_MODULE_DEPENDENCIES}) + if(_module_dep MATCHES ".+Private$") + set(_private_suffix "Private") + else() + set(_private_suffix "") + endif() + list(APPEND Qt6Mqtt${_private_suffix}_INCLUDE_DIRS + ${Qt6${_module_dep}_INCLUDE_DIRS}) + list(APPEND Qt6Mqtt${_private_suffix}_PRIVATE_INCLUDE_DIRS + ${Qt6${_module_dep}_PRIVATE_INCLUDE_DIRS}) + if(_private_suffix) + list(APPEND Qt6Mqtt_PRIVATE_INCLUDE_DIRS + ${Qt6${_module_dep}_PRIVATE_INCLUDE_DIRS}) + endif() + list(APPEND Qt6Mqtt${_private_suffix}_DEFINITIONS + ${Qt6${_module_dep}_DEFINITIONS}) + list(APPEND Qt6Mqtt${_private_suffix}_COMPILE_DEFINITIONS + ${Qt6${_module_dep}_COMPILE_DEFINITIONS}) + endforeach() + unset(_private_suffix) + + list(REMOVE_DUPLICATES Qt6Mqtt_INCLUDE_DIRS) + list(REMOVE_DUPLICATES Qt6Mqtt_PRIVATE_INCLUDE_DIRS) + list(REMOVE_DUPLICATES Qt6Mqtt_DEFINITIONS) + list(REMOVE_DUPLICATES Qt6Mqtt_COMPILE_DEFINITIONS) +endif() + +if (TARGET Qt6::Mqtt) + qt_make_features_available(Qt6::Mqtt) + + foreach(extra_cmake_include ) + include("${CMAKE_CURRENT_LIST_DIR}/${extra_cmake_include}") + endforeach() + + if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/Qt6MqttPlugins.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/Qt6MqttPlugins.cmake") + endif() + + list(APPEND QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE "Mqtt") + + get_target_property(_qt_module_target_type "Qt6::Mqtt" TYPE) + if(NOT _qt_module_target_type STREQUAL "INTERFACE_LIBRARY") + get_target_property(_qt_module_plugin_types + Qt6::Mqtt MODULE_PLUGIN_TYPES) + if(_qt_module_plugin_types) + list(APPEND QT_ALL_PLUGIN_TYPES_FOUND_VIA_FIND_PACKAGE "${_qt_module_plugin_types}") + endif() + endif() + + + # Load Module's BuildInternals should any exist + if (Qt6BuildInternals_DIR AND + EXISTS "${CMAKE_CURRENT_LIST_DIR}/Qt6MqttBuildInternals.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/Qt6MqttBuildInternals.cmake") + endif() + + if(NOT QT_NO_CREATE_VERSIONLESS_TARGETS) + if(CMAKE_VERSION VERSION_LESS 3.18 OR QT_USE_OLD_VERSION_LESS_TARGETS) + include("${CMAKE_CURRENT_LIST_DIR}/Qt6MqttVersionlessTargets.cmake") + else() + include("${CMAKE_CURRENT_LIST_DIR}/Qt6MqttVersionlessAliasTargets.cmake") + endif() + endif() +else() + + set(Qt6Mqtt_FOUND FALSE) + if(NOT DEFINED Qt6Mqtt_NOT_FOUND_MESSAGE) + set(Qt6Mqtt_NOT_FOUND_MESSAGE + "Target \"Qt6::Mqtt\" was not found.") + + if(QT_NO_CREATE_TARGETS) + string(APPEND Qt6Mqtt_NOT_FOUND_MESSAGE + "Possibly due to QT_NO_CREATE_TARGETS being set to TRUE and thus " + "${CMAKE_CURRENT_LIST_DIR}/Qt6MqttTargets.cmake was not " + "included to define the target.") + endif() + endif() +endif() diff --git a/lib/cmake/Qt6Mqtt/Qt6MqttConfigVersion.cmake b/lib/cmake/Qt6Mqtt/Qt6MqttConfigVersion.cmake new file mode 100644 index 0000000..32ed4cf --- /dev/null +++ b/lib/cmake/Qt6Mqtt/Qt6MqttConfigVersion.cmake @@ -0,0 +1,68 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +# Include the basic version config file to get results of regular version checking. +include("${CMAKE_CURRENT_LIST_DIR}/Qt6MqttConfigVersionImpl.cmake") + +set(__qt_disable_package_version_check FALSE) + +# Allow to opt out of the version check. +if(QT_NO_PACKAGE_VERSION_CHECK) + set(__qt_disable_package_version_check TRUE) +endif() + +# Extra CMake code begin + +# Extra CMake code end + +if((NOT PACKAGE_VERSION_COMPATIBLE) OR PACKAGE_VERSION_UNSUITABLE) + set(__qt_package_version_incompatible TRUE) +else() + set(__qt_package_version_incompatible FALSE) +endif() + +if(__qt_disable_package_version_check) + # Don't show the warning needlessly if we know that we're doing an exact search, and the + # version found is not the exactly same. + if(${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION_EXACT + AND NOT PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(QT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING TRUE) + endif() + + # Warn if version check is disabled regardless if it's a Qt repo build or user project build. + # Allow to opt out of warning. + if(__qt_package_version_incompatible AND NOT QT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING + AND NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) + message(WARNING + "Package ${PACKAGE_FIND_NAME} with version ${PACKAGE_VERSION} was accepted as " + "compatible because QT_NO_PACKAGE_VERSION_CHECK was set to TRUE. There is no guarantee " + "the build will succeed. You can silence this warning by passing " + "-DQT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING=TRUE") + endif() + + # Mark version as compatible. This is how we disable the version check. + set(PACKAGE_VERSION_COMPATIBLE TRUE) + unset(PACKAGE_VERSION_UNSUITABLE) + +# If QT_REPO_MODULE_VERSION is set, that means we are building a Qt repo. Show message that one can +# disable the check if they need to. +elseif(QT_REPO_MODULE_VERSION AND __qt_package_version_incompatible) + if(PACKAGE_FIND_VERSION_RANGE) + set(__qt_package_version_message_prefix "Version range ${PACKAGE_FIND_VERSION_RANGE}") + else() + set(__qt_package_version_message_prefix "Version ${PACKAGE_FIND_VERSION}") + endif() + + message(WARNING + "${__qt_package_version_message_prefix} of package ${PACKAGE_FIND_NAME} was requested but " + "an incompatible version was found: ${PACKAGE_VERSION}. You can pass " + "-DQT_NO_PACKAGE_VERSION_CHECK=TRUE to disable the version check and force the " + "incompatible version to be used. There is no guarantee the build will succeed. " + "Use at your own risk. " + "You can silence this warning by passing -DQT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING=TRUE") +endif() + +unset(__qt_disable_package_version_check) +unset(__qt_disable_package_version_check_due_to_developer_build) +unset(__qt_package_version_message_prefix) +unset(__qt_package_version_incompatible) diff --git a/lib/cmake/Qt6Mqtt/Qt6MqttConfigVersionImpl.cmake b/lib/cmake/Qt6Mqtt/Qt6MqttConfigVersionImpl.cmake new file mode 100644 index 0000000..3baab70 --- /dev/null +++ b/lib/cmake/Qt6Mqtt/Qt6MqttConfigVersionImpl.cmake @@ -0,0 +1,43 @@ +# This is a basic version file for the Config-mode of find_package(). +# It is used by write_basic_package_version_file() as input file for configure_file() +# to create a version-file which can be installed along a config.cmake file. +# +# The created file sets PACKAGE_VERSION_EXACT if the current version string and +# the requested version string are exactly the same and it sets +# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version. +# The variable CVF_VERSION must be set before calling configure_file(). + +set(PACKAGE_VERSION "6.8.0") + +if (PACKAGE_FIND_VERSION_RANGE) + # Package version must be in the requested version range + if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN) + OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX) + OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX))) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + endif() +else() + if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) + endif() + endif() +endif() + + +# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: +if(CMAKE_SIZEOF_VOID_P STREQUAL "" OR "8" STREQUAL "") + return() +endif() + +# check that the installed version has the same 32/64bit-ness as the one which is currently searching: +if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8") + math(EXPR installedBits "8 * 8") + set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") + set(PACKAGE_VERSION_UNSUITABLE TRUE) +endif() diff --git a/lib/cmake/Qt6Mqtt/Qt6MqttDependencies.cmake b/lib/cmake/Qt6Mqtt/Qt6MqttDependencies.cmake new file mode 100644 index 0000000..f15e8f2 --- /dev/null +++ b/lib/cmake/Qt6Mqtt/Qt6MqttDependencies.cmake @@ -0,0 +1,46 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +# Make sure Qt6 is found before anything else. +set(Qt6Mqtt_FOUND FALSE) + +if("${_qt_cmake_dir}" STREQUAL "") + set(_qt_cmake_dir "${QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR}") +endif() +set(__qt_use_no_default_path_for_qt_packages "NO_DEFAULT_PATH") +if(QT_DISABLE_NO_DEFAULT_PATH_IN_QT_PACKAGES) + set(__qt_use_no_default_path_for_qt_packages "") +endif() + +# Don't propagate REQUIRED so we don't immediately FATAL_ERROR, rather let the find_dependency calls +# set _NOT_FOUND_MESSAGE which will be displayed by the includer of the Dependencies file. +set(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED FALSE) + +if(NOT Qt6_FOUND) + find_dependency(Qt6 6.8.0 + PATHS + ${QT_BUILD_CMAKE_PREFIX_PATH} + "${CMAKE_CURRENT_LIST_DIR}/.." + "${_qt_cmake_dir}" + ${_qt_additional_packages_prefix_paths} + ${__qt_use_no_default_path_for_qt_packages} + ) +endif() + + +# note: _third_party_deps example: "ICU\\;FALSE\\;1.0\\;i18n uc data;ZLIB\\;FALSE\\;\\;" +set(__qt_Mqtt_third_party_deps "") +_qt_internal_find_third_party_dependencies("Mqtt" __qt_Mqtt_third_party_deps) + +# Find Qt tool package. +set(__qt_Mqtt_tool_deps "") +_qt_internal_find_tool_dependencies("Mqtt" __qt_Mqtt_tool_deps) + +# note: target_deps example: "Qt6Core\;5.12.0;Qt6Gui\;5.12.0" +set(__qt_Mqtt_target_deps "Qt6Core\;6.8.0;Qt6Network\;6.8.0") +set(__qt_Mqtt_find_dependency_paths "${CMAKE_CURRENT_LIST_DIR}/.." "${_qt_cmake_dir}") +_qt_internal_find_qt_dependencies("Mqtt" __qt_Mqtt_target_deps + __qt_Mqtt_find_dependency_paths) + +set(_Qt6Mqtt_MODULE_DEPENDENCIES "Core;Network") +set(Qt6Mqtt_FOUND TRUE) diff --git a/lib/cmake/Qt6Mqtt/Qt6MqttTargets.cmake b/lib/cmake/Qt6Mqtt/Qt6MqttTargets.cmake new file mode 100644 index 0000000..967467f --- /dev/null +++ b/lib/cmake/Qt6Mqtt/Qt6MqttTargets.cmake @@ -0,0 +1,100 @@ +# Generated by CMake + +if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8) + message(FATAL_ERROR "CMake >= 2.8.0 required") +endif() +if(CMAKE_VERSION VERSION_LESS "2.8.3") + message(FATAL_ERROR "CMake >= 2.8.3 required") +endif() +cmake_policy(PUSH) +cmake_policy(VERSION 2.8.3...3.24) +#---------------------------------------------------------------- +# Generated CMake target import file. +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +if(CMAKE_VERSION VERSION_LESS 3.0.0) + message(FATAL_ERROR "This file relies on consumers using CMake 3.0.0 or greater.") +endif() + +# Protect against multiple inclusion, which would fail when already imported targets are added once more. +set(_cmake_targets_defined "") +set(_cmake_targets_not_defined "") +set(_cmake_expected_targets "") +foreach(_cmake_expected_target IN ITEMS Qt6::Mqtt Qt6::MqttPrivate) + list(APPEND _cmake_expected_targets "${_cmake_expected_target}") + if(TARGET "${_cmake_expected_target}") + list(APPEND _cmake_targets_defined "${_cmake_expected_target}") + else() + list(APPEND _cmake_targets_not_defined "${_cmake_expected_target}") + endif() +endforeach() +unset(_cmake_expected_target) +if(_cmake_targets_defined STREQUAL _cmake_expected_targets) + unset(_cmake_targets_defined) + unset(_cmake_targets_not_defined) + unset(_cmake_expected_targets) + unset(CMAKE_IMPORT_FILE_VERSION) + cmake_policy(POP) + return() +endif() +if(NOT _cmake_targets_defined STREQUAL "") + string(REPLACE ";" ", " _cmake_targets_defined_text "${_cmake_targets_defined}") + string(REPLACE ";" ", " _cmake_targets_not_defined_text "${_cmake_targets_not_defined}") + message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_cmake_targets_defined_text}\nTargets not yet defined: ${_cmake_targets_not_defined_text}\n") +endif() +unset(_cmake_targets_defined) +unset(_cmake_targets_not_defined) +unset(_cmake_expected_targets) + + +# Create imported target Qt6::Mqtt +add_library(Qt6::Mqtt SHARED IMPORTED) + +set_target_properties(Qt6::Mqtt PROPERTIES + COMPATIBLE_INTERFACE_STRING "QT_MAJOR_VERSION" + INTERFACE_COMPILE_DEFINITIONS "QT_MQTT_LIB" + INTERFACE_INCLUDE_DIRECTORIES "C:/Users/qw200/Downloads/qtmqtt-dev/build/Desktop_Qt_6_8_0_MinGW_64_bit-Release/include;C:/Users/qw200/Downloads/qtmqtt-dev/build/Desktop_Qt_6_8_0_MinGW_64_bit-Release/include/QtMqtt" + INTERFACE_LINK_LIBRARIES "Qt6::Core;Qt6::Network" + INTERFACE_QT_MAJOR_VERSION "6" + INTERFACE_SOURCES "\$<\$>:C:/Users/qw200/Downloads/qtmqtt-dev/build/Desktop_Qt_6_8_0_MinGW_64_bit-Release/src/mqtt/meta_types/qt6mqtt_release_metatypes.json>" + _qt_config_module_name "mqtt" + _qt_is_public_module "TRUE" + _qt_module_has_headers "ON" + _qt_module_has_private_headers "TRUE" + _qt_module_has_public_headers "TRUE" + _qt_module_include_name "QtMqtt" + _qt_module_interface_name "Mqtt" + _qt_package_name "Qt6Mqtt" + _qt_package_version "6.8.0" + _qt_private_module_target_name "MqttPrivate" +) + +# Create imported target Qt6::MqttPrivate +add_library(Qt6::MqttPrivate INTERFACE IMPORTED) + +set_target_properties(Qt6::MqttPrivate PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "C:/Users/qw200/Downloads/qtmqtt-dev/build/Desktop_Qt_6_8_0_MinGW_64_bit-Release/src/mqtt;\$<\$>:C:/Users/qw200/Downloads/qtmqtt-dev/build/Desktop_Qt_6_8_0_MinGW_64_bit-Release/include/QtMqtt/6.8.0>;\$<\$>:C:/Users/qw200/Downloads/qtmqtt-dev/build/Desktop_Qt_6_8_0_MinGW_64_bit-Release/include/QtMqtt/6.8.0/QtMqtt>;\$<\$>:>;\$<\$>:>" + INTERFACE_LINK_LIBRARIES "Qt6::CorePrivate;Qt6::Mqtt" + _qt_config_module_name "mqtt_private" + _qt_is_private_module "TRUE" + _qt_package_name "Qt6Mqtt" + _qt_package_version "6.8.0" + _qt_public_module_target_name "Mqtt" +) + +# Import target "Qt6::Mqtt" for configuration "Release" +set_property(TARGET Qt6::Mqtt APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(Qt6::Mqtt PROPERTIES + IMPORTED_IMPLIB_RELEASE "C:/Users/qw200/Downloads/qtmqtt-dev/build/Desktop_Qt_6_8_0_MinGW_64_bit-Release/lib/libQt6Mqtt.a" + IMPORTED_LOCATION_RELEASE "C:/Users/qw200/Downloads/qtmqtt-dev/build/Desktop_Qt_6_8_0_MinGW_64_bit-Release/bin/Qt6Mqtt.dll" + ) + +# This file does not depend on other imported targets which have +# been exported from the same project but in a separate export set. + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) +cmake_policy(POP) diff --git a/lib/cmake/Qt6Mqtt/Qt6MqttVersionlessAliasTargets.cmake b/lib/cmake/Qt6Mqtt/Qt6MqttVersionlessAliasTargets.cmake new file mode 100644 index 0000000..24c74bf --- /dev/null +++ b/lib/cmake/Qt6Mqtt/Qt6MqttVersionlessAliasTargets.cmake @@ -0,0 +1,7 @@ +# Protect against multiple inclusion, which would fail when already imported targets are +# added once more. +_qt_internal_check_multiple_inclusion(_targets_not_defined "Mqtt;MqttPrivate") + +_qt_internal_create_versionless_alias_targets("${_targets_not_defined}" Qt6) + +unset(_targets_not_defined) diff --git a/lib/cmake/Qt6Mqtt/Qt6MqttVersionlessTargets.cmake b/lib/cmake/Qt6Mqtt/Qt6MqttVersionlessTargets.cmake new file mode 100644 index 0000000..824ed56 --- /dev/null +++ b/lib/cmake/Qt6Mqtt/Qt6MqttVersionlessTargets.cmake @@ -0,0 +1,7 @@ +# Protect against multiple inclusion, which would fail when already imported targets are +# added once more. +_qt_internal_check_multiple_inclusion(_targets_not_defined "Mqtt;MqttPrivate") + +_qt_internal_create_versionless_targets("${_targets_not_defined}" Qt6) + +unset(_targets_not_defined) diff --git a/lib/libQt6Mqtt.a b/lib/libQt6Mqtt.a new file mode 100644 index 0000000..0f5f4c1 Binary files /dev/null and b/lib/libQt6Mqtt.a differ diff --git a/lib/pkgconfig/Qt6Mqtt.pc b/lib/pkgconfig/Qt6Mqtt.pc new file mode 100644 index 0000000..849eecc --- /dev/null +++ b/lib/pkgconfig/Qt6Mqtt.pc @@ -0,0 +1,12 @@ +prefix=/QT/6.8.0/mingw_64 +exec_prefix=${prefix} +bindir=${prefix}/bin +libexecdir=${prefix}/./bin +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: Qt6 Mqtt +Description: Qt Mqtt module +Version: 6.8.0 +Libs: -L${libdir} -lQt6Mqtt +Cflags: -I${includedir}/QtMqtt -I${includedir} -DQT_MQTT_LIB diff --git a/lib/pkgconfig/preliminary_pc_for_Qt6Mqtt_Release_step2.pc b/lib/pkgconfig/preliminary_pc_for_Qt6Mqtt_Release_step2.pc new file mode 100644 index 0000000..8d6f3a2 --- /dev/null +++ b/lib/pkgconfig/preliminary_pc_for_Qt6Mqtt_Release_step2.pc @@ -0,0 +1,14 @@ +prefix=/QT/6.8.0/mingw_64 +exec_prefix=${prefix} +bindir=${prefix}/bin +libexecdir=${prefix}/./bin +libdir=${prefix}/lib +includedir=${prefix}/include + + +Name: Qt6 Mqtt +Description: Qt Mqtt module +Version: 6.8.0 +Libs: -L${libdir} -lQt6Mqtt +Cflags: -I${includedir}/QtMqtt -I${includedir} -DQT_MQTT_LIB +Requires: diff --git a/lib/pkgconfig/preliminary_pc_for_Qt6Mqtt_step1.pc b/lib/pkgconfig/preliminary_pc_for_Qt6Mqtt_step1.pc new file mode 100644 index 0000000..6d0e88a --- /dev/null +++ b/lib/pkgconfig/preliminary_pc_for_Qt6Mqtt_step1.pc @@ -0,0 +1,14 @@ +prefix=/QT/6.8.0/mingw_64 +exec_prefix=${prefix} +bindir=${prefix}/bin +libexecdir=${prefix}/./bin +libdir=${prefix}/lib +includedir=${prefix}/include +$<$:mkspecsdir=${prefix}/mkspecs> +$<1: > +Name: Qt6 Mqtt +Description: Qt Mqtt module +Version: 6.8.0 +Libs: $<$,INTERFACE_LIBRARY>>:-L${libdir} -lQt6Mqtt> $<$:$, >> $, > +Cflags: $<$:-I$, -I>> $<$:-D$, -D>> +Requires: $, > diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..20827b3 --- /dev/null +++ b/main.cpp @@ -0,0 +1,25 @@ + +#include "mainwindow.h" + +#include + +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + QTranslator translator; + const QStringList uiLanguages = QLocale::system().uiLanguages(); + for (const QString &locale : uiLanguages) { + const QString baseName = "IOT_" + QLocale(locale).name(); + if (translator.load(":/i18n/" + baseName)) { + a.installTranslator(&translator); + break; + } + } + MainWindow w; + w.show(); + return a.exec(); +} diff --git a/mainwindow.cpp b/mainwindow.cpp new file mode 100644 index 0000000..254fcc0 --- /dev/null +++ b/mainwindow.cpp @@ -0,0 +1,312 @@ +#include +#include "mainwindow.h" +#include "qjsondocument.h" +#include "qjsonobject.h" +#include "qnetworkaccessmanager.h" +#include "qnetworkreply.h" +#include "ui_mainwindow.h" +#include +#include +#include +#include +#include +#include +#include + +#include +QString newves33; +QString ves33="V1.0.0"; +QString remainderx33; +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::MainWindow) +{ + ui->setupUi(this); +setWindowTitle("万物互联IOT桌面端"); + // 恢复上次保存的按钮信息 + restoreButtonSettings(); + //更新检查连接 + QNetworkAccessManager *manager = new QNetworkAccessManager(this); + QUrl url("api1url"); + QNetworkRequest request(url); + + // Set unsafe SSL configuration + QSslConfiguration config = request.sslConfiguration(); + config.setPeerVerifyMode(QSslSocket::VerifyNone); + request.setSslConfiguration(config); + + QNetworkReply *reply = manager->get(request); + + // Connect to the finished signal + connect(reply, &QNetworkReply::finished, [=]() { + if (reply->error() == QNetworkReply::NoError) { + // Read the JSON data + QByteArray data = reply->readAll(); + + // Display the JSON data in a message box + QJsonDocument jsonDoc = QJsonDocument::fromJson(QString(data).toUtf8()); + QJsonObject jsonObj = jsonDoc.object(); + + // 获取数据 + QJsonObject jObj2 = jsonDoc["data"].toObject(); + QString str = jObj2 ["content"].toString(); + qDebug() << str; + newves33 = str.left(6); // 提取前6个字符组成newves + + remainderx33 = str.mid(6); // 提取剩下的字符 + remainderx33.replace("#", "\n"); + qDebug() << "update1111111"; + qDebug() << newves33; + qDebug() << ves33; + if (newves33 != ves33) { + // QMessageBox::warning(this, "Error", "已发布新版本\"" + info + "\"。\n点击\"设置\"下载最新版本。"); + ui->pushButton->setText("发现新版本"); + qDebug() << "update"; + } + else { + // ui->pushButton_4->setText("暂无更新"); + qDebug() << "no"; + } + } + else { + // Display an error message + QMessageBox::warning(this, "Error", reply->errorString()); + } + + // Clean up + reply->deleteLater(); + manager->deleteLater(); + }); + everyday(); + everyEinglish(); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::on_pushButton_clicked() +{ + form* formDialog = new form("",ves33,newves33,remainderx33,this); // 使用其他名称替换 'form' + formDialog->show(); + +} + +void MainWindow::onNewButtonClicked() +{ + // 在新按钮被点击时执行的操作 + qDebug() << "New Button Clicked"; +} + +void MainWindow::on_pushButton_2_clicked() +{ + // 创建一个新的 addButton + + + // 创建输入对话框 + bool ok; + QString buttonText = QInputDialog::getText(this, "添加设备", "请输入设备ID:", QLineEdit::Normal, "", &ok); + + // 如果用户点击了“OK”按钮,则设置按钮的文本名称为输入的内容 + if (ok && !buttonText.isEmpty()) { + + if (buttonText.contains("fp")) { + QPushButton* newButton = new QPushButton("Add Button", ui->groupBox); + + // 获取已存在的布局对象 + QVBoxLayout* layout = ui->verticalLayout; + + // 添加新的 addButton 到布局 + layout->addWidget(newButton); + newButton->setText("Flowerpot\nID:"+buttonText); + // 连接新按钮的 clicked 信号到 lambda 函数 + connect(newButton, &QPushButton::clicked, [=]() { + // 获取当前按钮的索引 + int buttonIndex = layout->indexOf(newButton) + 1; + // 显示当前按钮的索引 + + // 如果 addButton 文本名称包含 "fp",则弹出相应的窗口 + if (buttonText.contains("fp")) { + QString fpText = buttonText.mid(buttonText.indexOf("fp")); + Dialog* dialog = new Dialog(fpText, this); + dialog->show(); + } + + // 可以在这里添加其他点击按钮时的操作 + }); + }else{ + QMessageBox::information(this, "设备ID错误", "设备ID错误,检查你输入的设备ID是否正确!" ); + + } + + } + + +} + +void MainWindow::saveButtonSettings() +{ + // 获取已存在的布局对象 + QVBoxLayout* layout = ui->verticalLayout; + + // 创建 QSettings 对象,用于读写注册表信息 + QSettings settings("IOT", "IOT"); + + // 清空注册表中的旧按钮信息 + settings.remove("Buttons"); + + // 保存每个按钮的文本和索引 + for (int i = 0; i < layout->count(); i++) { + QPushButton* button = qobject_cast(layout->itemAt(i)->widget()); + if (button) { + QString buttonText = button->text(); + settings.setValue(QString("Buttons/button%1Text").arg(i), buttonText); + } + } +} + +void MainWindow::restoreButtonSettings() +{ + // 获取已存在的布局对象 + QVBoxLayout* layout = ui->verticalLayout; + + // 创建 QSettings 对象,用于读写注册表信息 + QSettings settings("IOT", "IOT"); + + // 遍历按钮索引,读取注册表中的按钮信息,并添加按钮到布局 + int buttonIndex = 0; + while (true) { + QString buttonText = settings.value(QString("Buttons/button%1Text").arg(buttonIndex)).toString(); + if (buttonText.isEmpty()) { + break; // 没有更多的按钮信息可读取,退出循环 + } + + QPushButton* newButton = new QPushButton(buttonText, ui->groupBox); + layout->addWidget(newButton); + + // 连接按钮的 clicked 信号到槽函数 + connect(newButton, &QPushButton::clicked, [=]() { + // 显示按钮索引 + // QMessageBox::information(this, "Button Index", "This is button number " + QString::number(buttonIndex)); + if (buttonText.contains("fp")) { + QString fpText = buttonText.mid(buttonText.indexOf("fp")); + Dialog* dialog = new Dialog(fpText, this); + dialog->show(); + } + // 可以在这里添加按钮点击时的操作 + }); + + buttonIndex++; + } +} + +void MainWindow::closeEvent(QCloseEvent* event) +{ + saveButtonSettings(); + event->accept(); +} +void MainWindow::everyday() +{ + QNetworkAccessManager *manager = new QNetworkAccessManager(this); + QUrl url("updataurl"); + QNetworkRequest request(url); + + // Set unsafe SSL configuration + QSslConfiguration config = request.sslConfiguration(); + config.setPeerVerifyMode(QSslSocket::VerifyNone); + request.setSslConfiguration(config); + + QNetworkReply *reply = manager->get(request); + + // Connect to the finished signal + connect(reply, &QNetworkReply::finished, [=]() { + if (reply->error() == QNetworkReply::NoError) { + // Read the JSON data + QByteArray data = reply->readAll(); + + // Display the JSON data in a message box + QJsonDocument jsonDoc = QJsonDocument::fromJson(QString(data).toUtf8()); + QJsonObject jsonObj = jsonDoc.object(); + + // 获取数据 + QString city = jsonObj["city"].toString(); + QJsonObject jObj2 = jsonDoc["info"].toObject(); + QString high = jObj2 ["high"].toString(); + QString low = jObj2 ["low"].toString(); + QString date = jObj2 ["date"].toString(); + QString week = jObj2 ["week"].toString(); + QString type = jObj2 ["type"].toString(); + QJsonObject jObj23 = jObj2["air"].toObject(); + QString aqiname = jObj23 ["aqi_name"].toString(); + QString tip =jObj2["tip"].toString(); + QString info = city+" "+date+" "+week+" "+type+"\n温度:"+low+"-"+high+" 空气质量:"+aqiname; + ui->label_2->setWordWrap(true); + ui->label_2->setText("每日天气:\n\n"+info); + } + else { + // Display an error message + QMessageBox::warning(this, "Error", reply->errorString()); + } + + // Clean up + reply->deleteLater(); + manager->deleteLater(); + }); +} + +void MainWindow::everyEinglish() +{ + QNetworkAccessManager *manager = new QNetworkAccessManager(this); + QUrl url("api2url"); + QNetworkRequest request(url); + + // Set unsafe SSL configuration + QSslConfiguration config = request.sslConfiguration(); + config.setPeerVerifyMode(QSslSocket::VerifyNone); + request.setSslConfiguration(config); + + QNetworkReply *reply = manager->get(request); + + // Connect to the finished signal + connect(reply, &QNetworkReply::finished, [=]() { + if (reply->error() == QNetworkReply::NoError) { + // Read the JSON data + QByteArray data = reply->readAll(); + + // Display the JSON data in a message box + + QJsonDocument jsonDoc = QJsonDocument::fromJson(QString(data).toUtf8()); + QJsonObject jsonObj = jsonDoc.object(); + + QJsonObject jObj2 = jsonDoc["data"].toObject(); + QString key1Val = jObj2["zh"].toString(); + QString key1Val2 = jObj2["en"].toString(); + ui->label_3->setWordWrap(true); + ui->label_3->setText("每日英语:\n\n"+key1Val2); + // QMessageBox::information(this, "JSON Data", key1Val2); + + } else { + // Display an error message + QMessageBox::warning(this, "Error", reply->errorString()); + } + + // Clean up + reply->deleteLater(); + manager->deleteLater(); + }); +} + +void MainWindow::on_pushButton_3_clicked() +{ + // 获取信号的发送者 + QVBoxLayout* layout = ui->verticalLayout; + QLayoutItem* item; + while ((item = layout->takeAt(0)) != nullptr) { + if (item->widget()) { + delete item->widget(); + } + delete item; + } +} + diff --git a/mainwindow.h b/mainwindow.h new file mode 100644 index 0000000..fde4f80 --- /dev/null +++ b/mainwindow.h @@ -0,0 +1,39 @@ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +#include "dialog.h" +#include "ui_dialog.h" + +QT_BEGIN_NAMESPACE +namespace Ui { class MainWindow; } +QT_END_NAMESPACE + +class MainWindow : public QMainWindow + +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +private slots: + void onNewButtonClicked(); + void on_pushButton_clicked(); + void restoreButtonSettings(); + void on_pushButton_2_clicked(); + void saveButtonSettings(); + void closeEvent(QCloseEvent*); + void everyday(); + void everyEinglish(); + void on_pushButton_3_clicked(); + + private: + Ui::MainWindow *ui; + +}; + +#endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 0000000..ee950c2 --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,135 @@ + + + MainWindow + + + + 0 + 0 + 633 + 382 + + + + MainWindow + + + + + + + + false + + + + 每日英语: + + + + + + + + 0 + 40 + + + + + 500 + 16777215 + + + + 添加设备 + + + + + + + + 16777215 + 16777215 + + + + 我的设备 + + + + + + + + + + + + 今日天气: + + + + + + + + 503 + 16777215 + + + + <html><head/><body><p><span style=" font-size:18pt;">万物互联IOT设备PC控制中心</span></p></body></html> + + + + + + + + 0 + 40 + + + + + 498 + 16777215 + + + + 检查更新 + + + + + + + + 0 + 40 + + + + 删除全部设备 + + + + + + + + + 0 + 0 + 633 + 18 + + + + + + + +