From eb833edee9a339e9f6a1b20a4c66994f782855e1 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Fri, 30 Dec 2022 20:13:50 +0100 Subject: [PATCH] Align command signal names Originally the intention was to add the commandReceived() signal to the ColorControl cluster but noticing differences in various clusters wrt commandSent() and commandReceived() namings of those signals. Decided to commandReceived() as it feels more natural to use and also the Zigbee cluster spec uses that wording. --- .../zcl/general/zigbeeclusterlevelcontrol.cpp | 10 +++++----- .../zcl/general/zigbeeclusterlevelcontrol.h | 10 +++++----- .../zcl/general/zigbeeclusteronoff.cpp | 6 +++--- libnymea-zigbee/zcl/general/zigbeeclusteronoff.h | 6 +++--- .../zcl/general/zigbeeclusterscenes.cpp | 2 +- .../zcl/general/zigbeeclusterscenes.h | 2 +- .../zcl/lighting/zigbeeclustercolorcontrol.cpp | 16 ++++++++++++++++ .../zcl/lighting/zigbeeclustercolorcontrol.h | 5 +++++ 8 files changed, 39 insertions(+), 18 deletions(-) diff --git a/libnymea-zigbee/zcl/general/zigbeeclusterlevelcontrol.cpp b/libnymea-zigbee/zcl/general/zigbeeclusterlevelcontrol.cpp index fbaafba..45fd209 100644 --- a/libnymea-zigbee/zcl/general/zigbeeclusterlevelcontrol.cpp +++ b/libnymea-zigbee/zcl/general/zigbeeclusterlevelcontrol.cpp @@ -134,7 +134,7 @@ void ZigbeeClusterLevelControl::processDataIndication(ZigbeeClusterLibrary::Fram if (frame.header.frameControl.direction == ZigbeeClusterLibrary::DirectionClientToServer) { // Read the payload which is Command command = static_cast(frame.header.command); - emit commandSent(command, frame.payload, frame.header.transactionSequenceNumber); + emit commandReceived(command, frame.payload, frame.header.transactionSequenceNumber); bool withOnOff = false; switch (command) { @@ -147,7 +147,7 @@ void ZigbeeClusterLevelControl::processDataIndication(ZigbeeClusterLibrary::Fram payloadStream >> level >> transitionTime; withOnOff = command == CommandMoveToLevelWithOnOff; qCDebug(dcZigbeeCluster()).noquote().nospace() << "Command received from " << m_node << " " << m_endpoint << " " << this << " " << command << " withOnOff: " << withOnOff << " level: 0x" << QString::number(level, 16) << " transitionTime: 0x" << QString::number(transitionTime, 16); - emit commandMoveToLevelSent(withOnOff, level, transitionTime, frame.header.transactionSequenceNumber); + emit commandMoveToLevelReceived(withOnOff, level, transitionTime, frame.header.transactionSequenceNumber); break; } case CommandStepWithOnOff: @@ -159,7 +159,7 @@ void ZigbeeClusterLevelControl::processDataIndication(ZigbeeClusterLibrary::Fram payloadStream >> stepModeValue >> stepSize >> transitionTime; withOnOff = command == CommandMoveToLevelWithOnOff; qCDebug(dcZigbeeCluster()).noquote().nospace() << "Command received from " << m_node << " " << m_endpoint << " " << this << " " << command << " withOnOff: " << withOnOff << " stepModeValue: 0x" << QString::number(stepModeValue, 16) << " stepSize: 0x" << QString::number(stepSize, 16) << " transitionTime: 0x" << QString::number(transitionTime, 16); - emit commandStepSent(withOnOff, static_cast(stepModeValue), stepSize, transitionTime, frame.header.transactionSequenceNumber); + emit commandStepReceived(withOnOff, static_cast(stepModeValue), stepSize, transitionTime, frame.header.transactionSequenceNumber); break; } case CommandMoveWithOnOff: @@ -171,13 +171,13 @@ void ZigbeeClusterLevelControl::processDataIndication(ZigbeeClusterLibrary::Fram payloadStream >> moveModeValue >> rate; withOnOff = command == CommandMoveToLevelWithOnOff; qCDebug(dcZigbeeCluster()).noquote().nospace() << "Command received from " << m_node << " " << m_endpoint << " " << this << " " << command << " withOnOff:" << withOnOff << " moveModeValue: 0x" << QString::number(moveModeValue, 16) << " rate: 0x" << QString::number(rate, 16); - emit commandMoveSent(withOnOff, static_cast(moveModeValue), rate, frame.header.transactionSequenceNumber); + emit commandMoveReceived(withOnOff, static_cast(moveModeValue), rate, frame.header.transactionSequenceNumber); break; } case CommandStopWithOnOff: case CommandStop: withOnOff = command == CommandMoveToLevelWithOnOff; - emit commandStopSent(withOnOff, frame.header.transactionSequenceNumber); + emit commandStopReceived(withOnOff, frame.header.transactionSequenceNumber); break; default: qCDebug(dcZigbeeCluster()).noquote().nospace() << "Command received from " << m_node << " " << m_endpoint << " " << this << " " << command << " payload: 0x" << ZigbeeUtils::convertByteArrayToHexString(frame.payload); diff --git a/libnymea-zigbee/zcl/general/zigbeeclusterlevelcontrol.h b/libnymea-zigbee/zcl/general/zigbeeclusterlevelcontrol.h index 8406085..901814a 100644 --- a/libnymea-zigbee/zcl/general/zigbeeclusterlevelcontrol.h +++ b/libnymea-zigbee/zcl/general/zigbeeclusterlevelcontrol.h @@ -106,11 +106,11 @@ protected: signals: void currentLevelChanged(quint8 level); - void commandSent(ZigbeeClusterLevelControl::Command command, const QByteArray ¶meter, quint8 transactionSequenceNumber); - void commandMoveToLevelSent(bool withOnOff, quint8 level, quint16 transitionTime, quint8 transactionSequenceNumber); - void commandMoveSent(bool withOnOff, MoveMode moveMode, quint8 rate, quint8 transactionSeqenceNumber); - void commandStepSent(bool withOnOff, StepMode stepMode, quint8 stepSize, quint16 transitionTime, quint8 transactionSequenceNumber); - void commandStopSent(bool withOnOff, quint8 transactionSequenceNumber); + void commandReceived(ZigbeeClusterLevelControl::Command command, const QByteArray ¶meter, quint8 transactionSequenceNumber); + void commandMoveToLevelReceived(bool withOnOff, quint8 level, quint16 transitionTime, quint8 transactionSequenceNumber); + void commandMoveReceived(bool withOnOff, MoveMode moveMode, quint8 rate, quint8 transactionSeqenceNumber); + void commandStepReceived(bool withOnOff, StepMode stepMode, quint8 stepSize, quint16 transitionTime, quint8 transactionSequenceNumber); + void commandStopReceived(bool withOnOff, quint8 transactionSequenceNumber); }; diff --git a/libnymea-zigbee/zcl/general/zigbeeclusteronoff.cpp b/libnymea-zigbee/zcl/general/zigbeeclusteronoff.cpp index 331c634..6a753c2 100644 --- a/libnymea-zigbee/zcl/general/zigbeeclusteronoff.cpp +++ b/libnymea-zigbee/zcl/general/zigbeeclusteronoff.cpp @@ -110,7 +110,7 @@ void ZigbeeClusterOnOff::processDataIndication(ZigbeeClusterLibrary::Frame frame if (frame.header.frameControl.direction == ZigbeeClusterLibrary::DirectionClientToServer) { // Read the payload which is Command command = static_cast(frame.header.command); - emit commandSent(command, frame.payload, frame.header.transactionSequenceNumber); + emit commandReceived(command, frame.payload, frame.header.transactionSequenceNumber); switch (command) { case CommandOffWithEffect: { QByteArray payload = frame.payload; @@ -119,7 +119,7 @@ void ZigbeeClusterOnOff::processDataIndication(ZigbeeClusterLibrary::Frame frame quint8 effectValue = 0; quint16 effectVariant; payloadStream >> effectValue >> effectVariant; qCDebug(dcZigbeeCluster()) << "Command received from" << m_node << m_endpoint << this << command << "effect:" << effectValue << "effectVariant:" << effectVariant; - emit commandOffWithEffectSent(static_cast(effectValue), effectVariant, frame.header.transactionSequenceNumber); + emit commandOffWithEffectReceived(static_cast(effectValue), effectVariant, frame.header.transactionSequenceNumber); break; } case CommandOnWithTimedOff: { @@ -129,7 +129,7 @@ void ZigbeeClusterOnOff::processDataIndication(ZigbeeClusterLibrary::Frame frame quint8 acceptOnlyWhenOnInt = 0; quint16 onTime; quint16 offTime; payloadStream >> acceptOnlyWhenOnInt >> onTime >> offTime; qCDebug(dcZigbeeCluster()) << "Command received from" << m_node << m_endpoint << this << command << "accentOnlyWhenOnInt:" << acceptOnlyWhenOnInt << "onTime:" << onTime << "offTime:" << offTime; - emit commandOnWithTimedOffSent(static_cast(acceptOnlyWhenOnInt), onTime, offTime, frame.header.transactionSequenceNumber); + emit commandOnWithTimedOffReceived(static_cast(acceptOnlyWhenOnInt), onTime, offTime, frame.header.transactionSequenceNumber); break; } default: diff --git a/libnymea-zigbee/zcl/general/zigbeeclusteronoff.h b/libnymea-zigbee/zcl/general/zigbeeclusteronoff.h index 21cc226..10fd1af 100644 --- a/libnymea-zigbee/zcl/general/zigbeeclusteronoff.h +++ b/libnymea-zigbee/zcl/general/zigbeeclusteronoff.h @@ -94,12 +94,12 @@ signals: void powerChanged(bool power); // Client cluster signals - void commandSent(ZigbeeClusterOnOff::Command command, const QByteArray ¶meters, quint8 transactionSequenceNumber); + void commandReceived(ZigbeeClusterOnOff::Command command, const QByteArray ¶meters, quint8 transactionSequenceNumber); // On and off time is in 1/10 seconds - void commandOnWithTimedOffSent(bool acceptOnlyWhenOn, quint16 onTime, quint16 offTime, quint8 transactionSequenceNumber); + void commandOnWithTimedOffReceived(bool acceptOnlyWhenOn, quint16 onTime, quint16 offTime, quint8 transactionSequenceNumber); // On and off time is in 1/10 seconds - void commandOffWithEffectSent(ZigbeeClusterOnOff::Effect effect, quint8 effectVariant, quint8 transactionSequenceNumber); + void commandOffWithEffectReceived(ZigbeeClusterOnOff::Effect effect, quint8 effectVariant, quint8 transactionSequenceNumber); }; #endif // ZIGBEECLUSTERONOFF_H diff --git a/libnymea-zigbee/zcl/general/zigbeeclusterscenes.cpp b/libnymea-zigbee/zcl/general/zigbeeclusterscenes.cpp index d4e2b46..2df038e 100644 --- a/libnymea-zigbee/zcl/general/zigbeeclusterscenes.cpp +++ b/libnymea-zigbee/zcl/general/zigbeeclusterscenes.cpp @@ -49,7 +49,7 @@ void ZigbeeClusterScenes::processDataIndication(ZigbeeClusterLibrary::Frame fram quint16 groupId = 0; quint8 sceneId; payloadStream >> groupId >> sceneId; qCDebug(dcZigbeeCluster()).noquote() << "Received" << command << "for group" << "0x" + QString::number(groupId, 16) << "and scene" << sceneId << "from" << m_node << m_endpoint << this; - emit commandSent(command, groupId, sceneId, frame.header.transactionSequenceNumber); + emit commandReceived(command, groupId, sceneId, frame.header.transactionSequenceNumber); break; } case Server: diff --git a/libnymea-zigbee/zcl/general/zigbeeclusterscenes.h b/libnymea-zigbee/zcl/general/zigbeeclusterscenes.h index eb41894..e502d0d 100644 --- a/libnymea-zigbee/zcl/general/zigbeeclusterscenes.h +++ b/libnymea-zigbee/zcl/general/zigbeeclusterscenes.h @@ -63,7 +63,7 @@ public: explicit ZigbeeClusterScenes(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, Direction direction, QObject *parent = nullptr); signals: - void commandSent(ZigbeeClusterScenes::Command command, quint16 groupId, quint8 sceneId, quint8 transactionSequenceNumber); + void commandReceived(ZigbeeClusterScenes::Command command, quint16 groupId, quint8 sceneId, quint8 transactionSequenceNumber); protected: void processDataIndication(ZigbeeClusterLibrary::Frame frame) override; diff --git a/libnymea-zigbee/zcl/lighting/zigbeeclustercolorcontrol.cpp b/libnymea-zigbee/zcl/lighting/zigbeeclustercolorcontrol.cpp index 22a4f10..f68bf6f 100644 --- a/libnymea-zigbee/zcl/lighting/zigbeeclustercolorcontrol.cpp +++ b/libnymea-zigbee/zcl/lighting/zigbeeclustercolorcontrol.cpp @@ -223,6 +223,22 @@ ZigbeeClusterColorControl::ColorCapabilities ZigbeeClusterColorControl::colorCap return m_colorCapabilities; } +void ZigbeeClusterColorControl::processDataIndication(ZigbeeClusterLibrary::Frame frame) +{ + switch (m_direction) { + case Client: + if (frame.header.frameControl.direction == ZigbeeClusterLibrary::DirectionClientToServer) { + Command command = static_cast(frame.header.command); + emit commandReceived(command, frame.payload, frame.header.transactionSequenceNumber); + } + break; + case Server: + qCWarning(dcZigbeeCluster()) << "Unhandled ZCL indication in" << m_node << m_endpoint << this << frame; + break; + } + +} + void ZigbeeClusterColorControl::setAttribute(const ZigbeeClusterAttribute &attribute) { qCDebug(dcZigbeeCluster()) << "Attribute changed" << m_node << m_endpoint << this << static_cast(attribute.id()) << attribute.dataType(); diff --git a/libnymea-zigbee/zcl/lighting/zigbeeclustercolorcontrol.h b/libnymea-zigbee/zcl/lighting/zigbeeclustercolorcontrol.h index bfd0c7e..9311a86 100644 --- a/libnymea-zigbee/zcl/lighting/zigbeeclustercolorcontrol.h +++ b/libnymea-zigbee/zcl/lighting/zigbeeclustercolorcontrol.h @@ -238,6 +238,11 @@ signals: void colorTemperatureMiredsChanged(quint16 colorTemperatureMireds); void colorCapabilitiesChanged(ColorCapabilities colorCapabilities); + void commandReceived(ZigbeeClusterColorControl::Command command, const QByteArray &payload, quint8 transactionSequenceNumber); + +protected: + void processDataIndication(ZigbeeClusterLibrary::Frame frame) override; + private: quint16 m_colorTemperatureMireds = 0; ColorCapabilities m_colorCapabilities = ColorCapabilities();