diff --git a/Application.cpp b/Application.cpp index 8d13bfc..77f0fe8 100644 --- a/Application.cpp +++ b/Application.cpp @@ -248,7 +248,10 @@ void Application::startSearchDevice() { } void Application::upgradeDevice(const QString &file) { - constexpr auto versionPrefix = "RD_T009"; + if (m_device.expired()) return; + auto device = m_device.lock(); + auto infomation = device->infomation(); + auto versionPrefix = infomation.softwareVersion.left(7); constexpr auto version = "RD_T009_V21R003B013"; QFileInfo fileInfo(file); QString baseName = fileInfo.baseName(); @@ -258,13 +261,10 @@ void Application::upgradeDevice(const QString &file) { return; } QString firmware = baseName.mid(position, std::strlen(version)); - if (!m_device.expired()) { - auto device = m_device.lock(); - if (device->isConnected()) { - device->requestOta(firmware, file); - } else { - emit newMessage(2, "OTA升级", "设备已离线,请重新连接设备!"); - } + if (device->isConnected()) { + device->requestOta(firmware, file); + } else { + emit newMessage(2, "OTA升级", "设备已离线,请重新连接设备!"); } } diff --git a/CMakeLists.txt b/CMakeLists.txt index 66ad172..2307226 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ else() endif() option(Boost_USE_STATIC_LIBS OFF) -set(FFmpeg_ROOT ${Libraries_ROOT}/ffmpeg-6.1.1-full_build-shared) +set(FFmpeg_ROOT ${Libraries_ROOT}/ffmpeg-7.0.2-full_build-shared) set(FFmpeg_INCLUDE_DIR ${FFmpeg_ROOT}/include) set(FFmpeg_LIB_DIR ${FFmpeg_ROOT}/lib) diff --git a/DeviceConnection.cpp b/DeviceConnection.cpp index 3b2c37d..062fa1a 100644 --- a/DeviceConnection.cpp +++ b/DeviceConnection.cpp @@ -407,18 +407,6 @@ void DeviceConnection::transferBinContent() { } else if (m_sendedSize >= m_uploadBuffer.size()) { LOG(info) << "transfer ota file finished, wait " << WaitMd5CheckTime << " ms for send check, total sended size: " << m_sendedSize; - // QTimer::singleShot(WaitMd5CheckTime, this, [this]() { - // boost::json::object request; - // request["func"] = "a22devicefirmware_setdata"; - // request["deviceid"] = "0"; - // boost::json::object data; - // data["target_linux04_firmware"] = "RD_T009_V21R003B001"; - // request["data"] = std::move(data); - // auto text = boost::json::serialize(request); - // m_commandSocket->write(text.data(), text.size()); - // LOG(info) << "request md5 check result: " << text; - // }); - if (m_otaTimer == nullptr) { m_otaTimer = new QTimer(this); m_otaTimer->setSingleShot(true); diff --git a/DeviceListModel.cpp b/DeviceListModel.cpp index 38ad141..4f854ab 100644 --- a/DeviceListModel.cpp +++ b/DeviceListModel.cpp @@ -1,6 +1,7 @@ #include "DeviceListModel.h" #include "BoostLog.h" #include "DeviceConnection.h" +#include "Settings.h" #include #include #include @@ -186,6 +187,7 @@ void DeviceListModel::onDeviceDisconnected() { } void DeviceListModel::onDeviceReplyReadyRead() { + using namespace Amass; auto udp = dynamic_cast(sender()); while (udp->hasPendingDatagrams()) { QNetworkDatagram datagram = udp->receiveDatagram(); @@ -202,7 +204,12 @@ void DeviceListModel::onDeviceReplyReadyRead() { if (reply.contains("sw_ver")) { device.softwareVersion = QString::fromStdString(std::string(reply.at("sw_ver").as_string())); } - if (!device.softwareVersion.startsWith("RD_T009")) continue; // 其它设备不予显示 + auto settings = Singleton::instance(); + auto supportedDevices = settings->supportedDevices(); + auto item = std::find_if(supportedDevices.cbegin(), supportedDevices.cend(), [&device](const std::string &model) { + return device.softwareVersion.startsWith(QString::fromStdString(model)); + }); + if (item == supportedDevices.cend()) continue; // 其它设备不予显示 device.ip = datagram.senderAddress().toString(); auto iterator = std::find_if(m_devices.cbegin(), m_devices.cend(), diff --git a/Settings.cpp b/Settings.cpp index 9ac3de3..64f33ce 100644 --- a/Settings.cpp +++ b/Settings.cpp @@ -25,20 +25,36 @@ void Settings::save() { ptree.put("Application.DataCollection.ImageQuality", m_imageQuality); ptree.put("Application.DataCollection.ImageQuality.", "0-100,仅对jpg有效"); + for (auto &device : m_supportedDevices) { + ptree.add("Application.SupportedDevices.Model", device); + } + boost::property_tree::xml_writer_settings settings('\t', 1); boost::property_tree::write_xml(SettingsFilePath, ptree, std::locale(), settings); } void Settings::load() { boost::property_tree::ptree ptree; + m_supportedDevices.clear(); try { boost::property_tree::read_xml(SettingsFilePath, ptree); m_imageFormat = static_cast(ptree.get("Application.DataCollection.ImageFormat")); m_imageQuality = ptree.get("Application.DataCollection.ImageQuality"); + for (auto &child : ptree.get_child("Application.SupportedDevices")) { + if (child.first != "Model") continue; + m_supportedDevices.push_back(child.second.get("")); + } } catch (...) { LOG(error) << "parse " << SettingsFilePath << " failed."; } - LOG(info) << "image format: " << m_imageFormat << ", quality: " << m_imageQuality; + std::ostringstream oss; + oss << "["; + for (auto &device : m_supportedDevices) { + oss << device << ", "; + } + oss << "]"; + LOG(info) << "image format: " << m_imageFormat << ", quality: " << m_imageQuality + << ", supported devices: " << oss.str(); } ImageFormat Settings::imageFormat() const { @@ -48,3 +64,7 @@ ImageFormat Settings::imageFormat() const { int Settings::imageQuality() const { return m_imageQuality; } + +std::list Settings::supportedDevices() const { + return m_supportedDevices; +} diff --git a/Settings.h b/Settings.h index 3a9e27f..f553d72 100644 --- a/Settings.h +++ b/Settings.h @@ -12,6 +12,7 @@ public: void load(); ImageFormat imageFormat() const; int imageQuality() const; + std::list supportedDevices() const; protected: Settings(); @@ -19,6 +20,7 @@ protected: private: ImageFormat m_imageFormat = ImageFormat::Jpeg; // 0: jpg 1: yuv int m_imageQuality = 100; + std::list m_supportedDevices{"RD_T009", "RD_T013"}; }; #endif // SETTINGS_H diff --git a/qml/Main.qml b/qml/Main.qml index f62b5ab..5789317 100644 --- a/qml/Main.qml +++ b/qml/Main.qml @@ -80,7 +80,7 @@ ApplicationWindow { deviceList.currentIndex = index } onDoubleClicked: { - if (!softwareVersion.includes("R003")) { + if (softwareVersion.includes("T009") && !softwareVersion.includes("R003")) { showMessageDialog(2, "网络设置", "当前设备不支持有线网络设置!") } else if (onlineStatus) { networkPopup.open()