Skip to content

Commit

Permalink
zstack reporting configuration fix
Browse files Browse the repository at this point in the history
  • Loading branch information
u236 committed May 22, 2023
1 parent a397a4e commit a61f66b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion controller.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef CONTROLLER_H
#define CONTROLLER_H

#define SERVICE_VERSION "3.3.0"
#define SERVICE_VERSION "3.3.1"
#define UPDATE_AVAILABILITY_INTERVAL 10000

#include "homed.h"
Expand Down
7 changes: 5 additions & 2 deletions zigbee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,14 +557,15 @@ void ZigBee::interviewError(const Device &device, const QString &reason)
bool ZigBee::bindRequest(const Device &device, quint8 endpointId, quint16 clusterId, const QByteArray &address, quint8 dstEndpointId, bool unbind)
{
m_adapter->setRequestAddress(device->ieeeAddress());
m_replyReceived = false;

if (!m_adapter->bindRequest(m_requestId, device->networkAddress(), endpointId, clusterId, address, dstEndpointId, unbind))
{
logWarning << "Device" << device->name() << "endpoint" << QString::asprintf("0x%02x", endpointId) << "cluster" << QString::asprintf("0x%04x", clusterId) << (unbind ? "unbinding" : "binding") << "request aborted";
return false;
}

if (!m_adapter->waitForSignal(this, SIGNAL(replyReceived()), NETWORK_REQUEST_TIMEOUT))
if (!m_replyReceived && !m_adapter->waitForSignal(this, SIGNAL(replyReceived()), NETWORK_REQUEST_TIMEOUT))
{
logWarning << "Device" << device->name() << "endpoint" << QString::asprintf("0x%02x", endpointId) << "cluster" << QString::asprintf("0x%04x", clusterId) << (unbind ? "unbinding" : "binding") << "timed out";
return false;
Expand Down Expand Up @@ -602,14 +603,15 @@ bool ZigBee::configureReporting(const Device &device, quint8 endpointId, const R
}

m_adapter->setRequestAddress(device->ieeeAddress());
m_replyReceived = false;

if (!m_adapter->unicastRequest(m_requestId, device->networkAddress(), 0x01, endpointId, reporting->clusterId(), request))
{
logWarning << "Device" << device->name() << "endpoint" << QString::asprintf("0x%02x", endpointId) << reporting->name().toUtf8().constData() << "reporting configuration request aborted";
return false;
}

if (!m_adapter->waitForSignal(this, SIGNAL(replyReceived()), NETWORK_REQUEST_TIMEOUT))
if (!m_replyReceived && !m_adapter->waitForSignal(this, SIGNAL(replyReceived()), NETWORK_REQUEST_TIMEOUT))
{
logWarning << "Device" << device->name() << "endpoint" << QString::asprintf("0x%02x", endpointId) << reporting->name().toUtf8().constData() << "reporting configuration request timed out";
return false;
Expand Down Expand Up @@ -1643,6 +1645,7 @@ void ZigBee::requestFinished(quint8 id, quint8 status)
if (id == m_requestId)
{
m_requestStatus = status;
m_replyReceived = true;
emit replyReceived();
}

Expand Down
2 changes: 1 addition & 1 deletion zigbee.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class ZigBee : public QObject

QMetaEnum m_events;
quint8 m_requestId, m_requestStatus, m_interPanChannel;
bool m_interPanLock;
bool m_replyReceived, m_interPanLock;

QString m_statusLedPin, m_blinkLedPin, m_otaUpgradeFile;
bool m_debug;
Expand Down

0 comments on commit a61f66b

Please sign in to comment.