From a2a79ac0841609e7f13fe437d1382151f8c0928a Mon Sep 17 00:00:00 2001 From: luocai Date: Wed, 14 Aug 2024 19:51:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0ota=20cdc=E4=B8=B2=E5=8F=A3?= =?UTF-8?q?=E6=89=93=E5=BC=80=E5=A4=B1=E8=B4=A5=E5=90=8E=E7=BB=A7=E7=BB=AD?= =?UTF-8?q?=E5=B0=9D=E8=AF=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Analyser/Application.cpp | 17 +++++++++++++++-- Analyser/Application.h | 2 ++ Analyser/qml/OperationItem.qml | 9 ++++++++- Analyser/qml/main.qml | 2 +- Readme.md | 6 ++++++ 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/Analyser/Application.cpp b/Analyser/Application.cpp index 052b8d1..2f0327b 100644 --- a/Analyser/Application.cpp +++ b/Analyser/Application.cpp @@ -217,7 +217,7 @@ void Application::uploadImage(const QString &path, int operation) { m_uploadImageSendedSize = 0; ModuleCommunication::UploadImageInformation request; if (path.endsWith(".jpg")) { - auto image = ImageDecoder::extractJpegYComponent(path.toStdString()); + auto image = ImageDecoder::extractJpegYComponent(Amass::StringUtility::UTF8ToGBK(path.toStdString())); if (!image) { LOG(error) << "decode failed."; return; @@ -252,10 +252,18 @@ void Application::uploadImage(const QString &path, int operation) { m_communication->uploadImageInfo(request); LOG(info) << "upload image, md5: " << ModuleCommunication::protocolDataFormatString(request.md5, sizeof(request.md5)); - + m_imageUploadling = true; m_startUploadTime = std::chrono::system_clock::now(); } +void Application::timerEvent(QTimerEvent *event) { + static int i = 0; + if (i <= 4000 && !m_imageUploadling) { + uploadImage("./1722829247678.jpg", 0); + LOG(info) << "register times: " << i++; + } +} + ModuleCommunication *Application::module() const { return m_communication.get(); } @@ -374,9 +382,11 @@ void Application::onCommandFinished(ModuleCommunication::MessageId messageId, m_communication->uploadImageData(m_uploadImageSendedSize, (const uint8_t *)m_uploadBuffer.data() + m_uploadImageSendedSize, remainSize < ImageSliceSize ? remainSize : ImageSliceSize); + m_imageUploadling = true; } else { LOG(info) << "upload finished, elapsed: " << duration_cast(system_clock::now() - m_startUploadTime); + m_imageUploadling = false; } } @@ -440,4 +450,7 @@ bool Application::startOta(const QString &path) { void Application::onCdcDeviceDiscovered(const QSerialPortInfo &info) { auto status = m_updater->open(info); LOG(info) << "open cdc port: " << info.portName().toStdString() << ", status: " << status; + if (!status) { + QTimer::singleShot(0, this, [this]() { m_updater->startSearchDevice(); }); + } } diff --git a/Analyser/Application.h b/Analyser/Application.h index 92f163e..97aa382 100644 --- a/Analyser/Application.h +++ b/Analyser/Application.h @@ -77,6 +77,7 @@ signals: protected: Application(int &argc, char **argv); + void timerEvent(QTimerEvent *event) final; void onNewEnrollResult(uint16_t userid); void onNewVerifyResult(uint16_t userid, const QString &username, uint16_t elapsed); void onNewPalmFeature(const PalmFeature &feature); @@ -110,6 +111,7 @@ private: uint32_t m_uploadImageSendedSize; std::vector m_uploadBuffer; + bool m_imageUploadling = false; std::shared_ptr m_videoPlayer; VideoFrameProvider *m_videoFrameProvider; diff --git a/Analyser/qml/OperationItem.qml b/Analyser/qml/OperationItem.qml index c36e720..54da041 100644 --- a/Analyser/qml/OperationItem.qml +++ b/Analyser/qml/OperationItem.qml @@ -151,12 +151,19 @@ Item { TextField { id: imagePath Layout.columnSpan: 2 - implicitWidth: 180 + implicitWidth: 200 placeholderText: "请选择图片" onPressed: { fileDialog.open() } } + Text { + text: qsTr("用户姓名") + } + TextField { + id: imageEnrollName + implicitWidth: 100 + } Button { text: "注册" onClicked: App.uploadImage(imagePath.text, 0) diff --git a/Analyser/qml/main.qml b/Analyser/qml/main.qml index fe652e7..6d5e8f5 100644 --- a/Analyser/qml/main.qml +++ b/Analyser/qml/main.qml @@ -5,7 +5,7 @@ import Analyser Window { width: 1120 - height: 680 + height: 700 visible: true title: qsTr(Qt.application.name + " " + Qt.application.version) diff --git a/Readme.md b/Readme.md index 4565f18..edf603e 100644 --- a/Readme.md +++ b/Readme.md @@ -75,3 +75,9 @@ cv181x_alios/boards/cv181xc_qfn/configs/partition_alios_spinor.xml cv181x_alios/solutions/smart_doorbell/face_lock_app/flash-part.h ``` +修改`cv181x_alios/pack-ota.sh`,以支持将boot打进ota升级文件中。(有升级变砖风险) + +``` +# $ota_pack_tool $OTA_PKG imtb yoc.bin algo.bin.1 boot $@ +``` +