Improve debug output and add level cluster signals

This commit is contained in:
Simon Stürz 2020-11-26 18:32:07 +01:00
parent 5901dc06b5
commit cc725a9533
8 changed files with 45 additions and 5 deletions

View File

@ -141,6 +141,31 @@ void ZigbeeClusterLevelControl::processDataIndication(ZigbeeClusterLibrary::Fram
Command command = static_cast<Command>(frame.header.command); Command command = static_cast<Command>(frame.header.command);
qCDebug(dcZigbeeCluster()) << "Command sent from" << m_node << m_endpoint << this << command; qCDebug(dcZigbeeCluster()) << "Command sent from" << m_node << m_endpoint << this << command;
emit commandSent(command, frame.payload); 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<FadeMode>(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<MoveMode>(moveModeValue), rate);
break;
}
default:
qCDebug(dcZigbeeCluster()) << "Command received without special implementation";
break;
}
} }
break; break;
case Server: case Server:

View File

@ -107,7 +107,8 @@ protected:
signals: signals:
void currentLevelChanged(quint8 level); void currentLevelChanged(quint8 level);
void commandSent(ZigbeeClusterLevelControl::Command command, const QByteArray &parameter = QByteArray()); void commandSent(ZigbeeClusterLevelControl::Command command, const QByteArray &parameter = QByteArray());
void commandMoveSent(MoveMode moveMode, quint8 rate = 0xff);
void commandStepSent(FadeMode fadeMode, quint8 stepSize, quint16 transitionTime);
}; };

View File

@ -125,6 +125,15 @@ void ZigbeeClusterOnOff::processDataIndication(ZigbeeClusterLibrary::Frame frame
case CommandToggle: case CommandToggle:
emit commandSent(CommandToggle); emit commandSent(CommandToggle);
break; 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<Effect>(effectValue), effectVariant);
break;
}
case CommandOnWithTimedOff: { case CommandOnWithTimedOff: {
QByteArray payload = frame.payload; QByteArray payload = frame.payload;
QDataStream payloadStream(&payload, QIODevice::ReadOnly); QDataStream payloadStream(&payload, QIODevice::ReadOnly);

View File

@ -97,6 +97,9 @@ signals:
void commandSent(Command command); void commandSent(Command command);
// On and off time is in 1/10 seconds // On and off time is in 1/10 seconds
void commandOnWithTimedOffSent(bool acceptOnlyWhenOn, quint16 onTime, quint16 offTime); 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 #endif // ZIGBEECLUSTERONOFF_H

View File

@ -273,6 +273,7 @@ public:
Cirronet = 0x1000, Cirronet = 0x1000,
Chipcon = 0x1001, Chipcon = 0x1001,
Ember = 0x1003, Ember = 0x1003,
Philips = 0x100b,
Ikea = 0x117C, Ikea = 0x117C,
FeiBit = 0x117E FeiBit = 0x117E
}; };

View File

@ -669,6 +669,6 @@ QDebug operator<<(QDebug debug, ZigbeeNetwork *network)
<< network->backendType() << ", " << network->backendType() << ", "
<< "Channel: " << network->channel() << ", " << "Channel: " << network->channel() << ", "
<< network->state() << network->state()
<< ") "; << ")";
return debug.space(); return debug.space().quote();
} }

View File

@ -721,6 +721,7 @@ QDebug operator<<(QDebug debug, ZigbeeNode *node)
{ {
debug.nospace().noquote() << "ZigbeeNode(" << ZigbeeUtils::convertUint16ToHexString(node->shortAddress()); debug.nospace().noquote() << "ZigbeeNode(" << ZigbeeUtils::convertUint16ToHexString(node->shortAddress());
debug.nospace().noquote() << ", " << node->extendedAddress().toString(); debug.nospace().noquote() << ", " << node->extendedAddress().toString();
debug.nospace().noquote() << ", RX on:" << node->macCapabilities().receiverOnWhenIdle;
debug.nospace().noquote() << ")"; debug.nospace().noquote() << ")";
return debug.space().quote(); return debug.space().quote();
} }

View File

@ -303,6 +303,6 @@ QDebug operator<<(QDebug debug, ZigbeeNodeEndpoint *endpoint)
debug.nospace().noquote() << ", " << static_cast<Zigbee::GreenPowerDevice>(endpoint->deviceId()); debug.nospace().noquote() << ", " << static_cast<Zigbee::GreenPowerDevice>(endpoint->deviceId());
} }
debug.nospace().noquote() << ") "; debug.nospace().noquote() << ")";
return debug; return debug.space().quote();
} }