From cc725a9533271fb3e895ddd6f4107d91606e2703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Thu, 26 Nov 2020 18:32:07 +0100 Subject: [PATCH] Improve debug output and add level cluster signals --- .../zcl/general/zigbeeclusterlevelcontrol.cpp | 25 +++++++++++++++++++ .../zcl/general/zigbeeclusterlevelcontrol.h | 3 ++- .../zcl/general/zigbeeclusteronoff.cpp | 9 +++++++ .../zcl/general/zigbeeclusteronoff.h | 3 +++ libnymea-zigbee/zigbee.h | 1 + libnymea-zigbee/zigbeenetwork.cpp | 4 +-- libnymea-zigbee/zigbeenode.cpp | 1 + libnymea-zigbee/zigbeenodeendpoint.cpp | 4 +-- 8 files changed, 45 insertions(+), 5 deletions(-) diff --git a/libnymea-zigbee/zcl/general/zigbeeclusterlevelcontrol.cpp b/libnymea-zigbee/zcl/general/zigbeeclusterlevelcontrol.cpp index 526d745..fee03c5 100644 --- a/libnymea-zigbee/zcl/general/zigbeeclusterlevelcontrol.cpp +++ b/libnymea-zigbee/zcl/general/zigbeeclusterlevelcontrol.cpp @@ -141,6 +141,31 @@ void ZigbeeClusterLevelControl::processDataIndication(ZigbeeClusterLibrary::Fram Command command = static_cast(frame.header.command); qCDebug(dcZigbeeCluster()) << "Command sent from" << m_node << m_endpoint << this << command; emit commandSent(command, frame.payload); + + switch (command) { + case CommandStep: { + QByteArray payload = frame.payload; + QDataStream payloadStream(&payload, QIODevice::ReadOnly); + payloadStream.setByteOrder(QDataStream::LittleEndian); + quint8 fadeModeValue = 0; quint8 stepSize; quint16 transitionTime; + payloadStream >> fadeModeValue >> stepSize >> transitionTime; + emit commandStepSent(static_cast(fadeModeValue), stepSize, transitionTime); + break; + } + case CommandMove: { + QByteArray payload = frame.payload; + QDataStream payloadStream(&payload, QIODevice::ReadOnly); + payloadStream.setByteOrder(QDataStream::LittleEndian); + quint8 moveModeValue = 0; quint8 rate;; + payloadStream >> moveModeValue >> rate; + emit commandMoveSent(static_cast(moveModeValue), rate); + break; + } + default: + qCDebug(dcZigbeeCluster()) << "Command received without special implementation"; + break; + } + } break; case Server: diff --git a/libnymea-zigbee/zcl/general/zigbeeclusterlevelcontrol.h b/libnymea-zigbee/zcl/general/zigbeeclusterlevelcontrol.h index 32459a7..62b2bd6 100644 --- a/libnymea-zigbee/zcl/general/zigbeeclusterlevelcontrol.h +++ b/libnymea-zigbee/zcl/general/zigbeeclusterlevelcontrol.h @@ -107,7 +107,8 @@ protected: signals: void currentLevelChanged(quint8 level); void commandSent(ZigbeeClusterLevelControl::Command command, const QByteArray ¶meter = QByteArray()); - + void commandMoveSent(MoveMode moveMode, quint8 rate = 0xff); + void commandStepSent(FadeMode fadeMode, quint8 stepSize, quint16 transitionTime); }; diff --git a/libnymea-zigbee/zcl/general/zigbeeclusteronoff.cpp b/libnymea-zigbee/zcl/general/zigbeeclusteronoff.cpp index 146da05..c13bddd 100644 --- a/libnymea-zigbee/zcl/general/zigbeeclusteronoff.cpp +++ b/libnymea-zigbee/zcl/general/zigbeeclusteronoff.cpp @@ -125,6 +125,15 @@ void ZigbeeClusterOnOff::processDataIndication(ZigbeeClusterLibrary::Frame frame case CommandToggle: emit commandSent(CommandToggle); break; + case CommandOffWithEffect: { + QByteArray payload = frame.payload; + QDataStream payloadStream(&payload, QIODevice::ReadOnly); + payloadStream.setByteOrder(QDataStream::LittleEndian); + quint8 effectValue = 0; quint16 effectVariant; + payloadStream >> effectValue >> effectVariant; + emit commandOffWithEffectSent(static_cast(effectValue), effectVariant); + break; + } case CommandOnWithTimedOff: { QByteArray payload = frame.payload; QDataStream payloadStream(&payload, QIODevice::ReadOnly); diff --git a/libnymea-zigbee/zcl/general/zigbeeclusteronoff.h b/libnymea-zigbee/zcl/general/zigbeeclusteronoff.h index 1ea8b22..561ff8f 100644 --- a/libnymea-zigbee/zcl/general/zigbeeclusteronoff.h +++ b/libnymea-zigbee/zcl/general/zigbeeclusteronoff.h @@ -97,6 +97,9 @@ signals: void commandSent(Command command); // On and off time is in 1/10 seconds void commandOnWithTimedOffSent(bool acceptOnlyWhenOn, quint16 onTime, quint16 offTime); + + // On and off time is in 1/10 seconds + void commandOffWithEffectSent(Effect effect, quint8 effectVariant); }; #endif // ZIGBEECLUSTERONOFF_H diff --git a/libnymea-zigbee/zigbee.h b/libnymea-zigbee/zigbee.h index d6b8fb6..54328bc 100644 --- a/libnymea-zigbee/zigbee.h +++ b/libnymea-zigbee/zigbee.h @@ -273,6 +273,7 @@ public: Cirronet = 0x1000, Chipcon = 0x1001, Ember = 0x1003, + Philips = 0x100b, Ikea = 0x117C, FeiBit = 0x117E }; diff --git a/libnymea-zigbee/zigbeenetwork.cpp b/libnymea-zigbee/zigbeenetwork.cpp index 7bc50b9..144865f 100644 --- a/libnymea-zigbee/zigbeenetwork.cpp +++ b/libnymea-zigbee/zigbeenetwork.cpp @@ -669,6 +669,6 @@ QDebug operator<<(QDebug debug, ZigbeeNetwork *network) << network->backendType() << ", " << "Channel: " << network->channel() << ", " << network->state() - << ") "; - return debug.space(); + << ")"; + return debug.space().quote(); } diff --git a/libnymea-zigbee/zigbeenode.cpp b/libnymea-zigbee/zigbeenode.cpp index 4c55d11..31b4281 100644 --- a/libnymea-zigbee/zigbeenode.cpp +++ b/libnymea-zigbee/zigbeenode.cpp @@ -721,6 +721,7 @@ QDebug operator<<(QDebug debug, ZigbeeNode *node) { debug.nospace().noquote() << "ZigbeeNode(" << ZigbeeUtils::convertUint16ToHexString(node->shortAddress()); debug.nospace().noquote() << ", " << node->extendedAddress().toString(); + debug.nospace().noquote() << ", RX on:" << node->macCapabilities().receiverOnWhenIdle; debug.nospace().noquote() << ")"; return debug.space().quote(); } diff --git a/libnymea-zigbee/zigbeenodeendpoint.cpp b/libnymea-zigbee/zigbeenodeendpoint.cpp index 4cd5e3f..35e85d3 100644 --- a/libnymea-zigbee/zigbeenodeendpoint.cpp +++ b/libnymea-zigbee/zigbeenodeendpoint.cpp @@ -303,6 +303,6 @@ QDebug operator<<(QDebug debug, ZigbeeNodeEndpoint *endpoint) debug.nospace().noquote() << ", " << static_cast(endpoint->deviceId()); } - debug.nospace().noquote() << ") "; - return debug; + debug.nospace().noquote() << ")"; + return debug.space().quote(); }