Return error if zigbee network is not online yet and fix crash if reply is already finished before getting a response

pull/10/head
Simon Stürz 2020-11-19 11:11:25 +01:00
parent 0acc4d667f
commit 4b7e6a0ddb
2 changed files with 5 additions and 5 deletions

View File

@ -72,13 +72,13 @@ ZigbeeNetworkReply *ZigbeeNetworkDeconz::sendRequest(const ZigbeeNetworkRequest
});
// Finish the reply right the way if the network is offline
if (!m_controller->available()) {
if (!m_controller->available() || state() != ZigbeeNetwork::StateRunning) {
finishNetworkReply(reply, ZigbeeNetworkReply::ErrorNetworkOffline);
return reply;
}
ZigbeeInterfaceDeconzReply *interfaceReply = m_controller->requestSendRequest(request);
connect(interfaceReply, &ZigbeeInterfaceDeconzReply::finished, this, [this, reply, interfaceReply](){
connect(interfaceReply, &ZigbeeInterfaceDeconzReply::finished, reply, [this, reply, interfaceReply](){
if (interfaceReply->statusCode() != Deconz::StatusCodeSuccess) {
qCWarning(dcZigbeeController()) << "Could send request to controller. SQN:" << interfaceReply->sequenceNumber() << interfaceReply->statusCode();
finishNetworkReply(reply, ZigbeeNetworkReply::ErrorInterfaceError);

View File

@ -81,13 +81,13 @@ ZigbeeNetworkReply *ZigbeeNetworkNxp::sendRequest(const ZigbeeNetworkRequest &re
});
// Finish the reply right the way if the network is offline
if (!m_controller->available()) {
if (!m_controller->available() || state() != ZigbeeNetwork::StateRunning) {
finishNetworkReply(reply, ZigbeeNetworkReply::ErrorNetworkOffline);
return reply;
}
ZigbeeInterfaceNxpReply *interfaceReply = m_controller->requestSendRequest(request);
connect(interfaceReply, &ZigbeeInterfaceNxpReply::finished, this, [this, reply, interfaceReply](){
connect(interfaceReply, &ZigbeeInterfaceNxpReply::finished, reply, [this, reply, interfaceReply](){
if (interfaceReply->status() != Nxp::StatusSuccess) {
qCWarning(dcZigbeeController()) << "Could send request to controller. SQN:" << interfaceReply->sequenceNumber() << interfaceReply->status();
finishNetworkReply(reply, ZigbeeNetworkReply::ErrorInterfaceError);
@ -102,7 +102,7 @@ ZigbeeNetworkReply *ZigbeeNetworkNxp::sendRequest(const ZigbeeNetworkRequest &re
}
quint8 networkRequestId = interfaceReply->responseData().at(0);
qCDebug(dcZigbeeNetwork()) << "Request has network SQN" << networkRequestId;
//qCDebug(dcZigbeeNetwork()) << "Request has network SQN" << networkRequestId;
reply->request().setRequestId(networkRequestId);
m_pendingReplies.insert(networkRequestId, reply);