diff --git a/DeviceConnection.cpp b/DeviceConnection.cpp index f998f16..413a26f 100644 --- a/DeviceConnection.cpp +++ b/DeviceConnection.cpp @@ -761,9 +761,15 @@ QString DeviceConnection::handleCommand(const std::string_view &replyText, const LOG(info) << "device factory reset"; } else if (function == "headdetectparam_getdata") { auto &data = reply.at("data").as_object(); - m_infomation.helmetThreshold = data.at("hatthreshold").as_int64(); - m_infomation.headThreshold = data.at("headthreshold").as_int64(); - m_infomation.detectFrameSize = data.at("detectframenum").as_int64(); + if (data.contains("hatthreshold")) { + m_infomation.helmetThreshold = data.at("hatthreshold").as_int64(); + } + if (data.contains("headthreshold")) { + m_infomation.headThreshold = data.at("headthreshold").as_int64(); + } + if (data.contains("detectframenum")) { + m_infomation.detectFrameSize = data.at("detectframenum").as_int64(); + } emit detectThresholdChanged(m_infomation.helmetThreshold, m_infomation.headThreshold, m_infomation.detectFrameSize); } else if (function == "thresholdwithhat_setdata") {