This commit is contained in:
parent
8e0018480b
commit
77dd027ff7
@ -392,7 +392,7 @@ void DeviceConnection::requestOta(const QString &firmware, const QString &file)
|
||||
killTimer(m_heartbeatTimerId);
|
||||
m_heartbeatTimerId = -1;
|
||||
}
|
||||
if (!m_requests.empty()) {
|
||||
while (!m_requests.empty()) { // 清除之前的命令
|
||||
m_requests.pop();
|
||||
}
|
||||
Task task;
|
||||
@ -693,6 +693,9 @@ void DeviceConnection::onConnected() {
|
||||
if (m_otaTimer != nullptr) {
|
||||
m_otaTimer->stop();
|
||||
}
|
||||
if (m_requestTimerId < 0) {
|
||||
m_requestTimerId = startTimer(HeartbeatInterval);
|
||||
}
|
||||
} else if (socket == m_h264Socket) {
|
||||
if (m_videoEnabled) {
|
||||
setLiveStreamEnabled(true);
|
||||
@ -703,6 +706,10 @@ void DeviceConnection::onConnected() {
|
||||
void DeviceConnection::onDisconnected() {
|
||||
auto socket = dynamic_cast<QTcpSocket *>(sender());
|
||||
if (socket == m_commandSocket) {
|
||||
if (m_requestTimerId > 0) {
|
||||
killTimer(m_requestTimerId);
|
||||
m_requestTimerId = -1;
|
||||
}
|
||||
if (m_heartbeatTimerId > 0) {
|
||||
killTimer(m_heartbeatTimerId);
|
||||
m_heartbeatTimerId = -1;
|
||||
@ -786,6 +793,7 @@ void DeviceConnection::timerEvent(QTimerEvent *event) {
|
||||
}
|
||||
heartbeats++;
|
||||
}
|
||||
} else if (event->timerId() == m_requestTimerId) {
|
||||
if (!m_requests.empty()) {
|
||||
auto &command = m_requests.front();
|
||||
auto elapsed = duration_cast<milliseconds>(system_clock::now() - command.time);
|
||||
|
@ -137,6 +137,7 @@ private:
|
||||
|
||||
H264FrameCallback m_frameCallback;
|
||||
std::queue<Task> m_requests;
|
||||
int m_requestTimerId = -1;
|
||||
int m_heartbeatTimerId = -1;
|
||||
int heartbeats = 0;
|
||||
NetworkInfomation m_networkInfomation;
|
||||
|
Loading…
Reference in New Issue
Block a user