Clean up clusters and implement default get methods for now
This commit is contained in:
parent
af26efac17
commit
4eafe285b0
@ -571,7 +571,7 @@ void ZigbeeNetworkNxp::onNodeLeftIndication(const ZigbeeAddress &ieeeAddress, bo
|
|||||||
{
|
{
|
||||||
qCDebug(dcZigbeeNetwork()) << "Received node left indication" << ieeeAddress.toString() << "rejoining:" << rejoining;
|
qCDebug(dcZigbeeNetwork()) << "Received node left indication" << ieeeAddress.toString() << "rejoining:" << rejoining;
|
||||||
if (!hasNode(ieeeAddress)) {
|
if (!hasNode(ieeeAddress)) {
|
||||||
qCWarning(dcZigbeeNetwork()) << "Unknown node left the network" << ieeeAddress.toString();
|
qCDebug(dcZigbeeNetwork()) << "Node left the network" << ieeeAddress.toString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -113,13 +113,7 @@ ZigbeeClusterDoorLock::DoorState ZigbeeClusterDoorLock::doorState() const
|
|||||||
void ZigbeeClusterDoorLock::setAttribute(const ZigbeeClusterAttribute &attribute)
|
void ZigbeeClusterDoorLock::setAttribute(const ZigbeeClusterAttribute &attribute)
|
||||||
{
|
{
|
||||||
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
||||||
if (hasAttribute(attribute.id())) {
|
updateOrAddAttribute(attribute);
|
||||||
m_attributes[attribute.id()] = attribute;
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
} else {
|
|
||||||
m_attributes.insert(attribute.id(), attribute);
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (attribute.id()) {
|
switch (attribute.id()) {
|
||||||
case AttributeLockState:
|
case AttributeLockState:
|
||||||
@ -135,10 +129,22 @@ void ZigbeeClusterDoorLock::setAttribute(const ZigbeeClusterAttribute &attribute
|
|||||||
|
|
||||||
void ZigbeeClusterDoorLock::processDataIndication(ZigbeeClusterLibrary::Frame frame)
|
void ZigbeeClusterDoorLock::processDataIndication(ZigbeeClusterLibrary::Frame frame)
|
||||||
{
|
{
|
||||||
//qCDebug(dcZigbeeCluster()) << "Processing cluster frame" << m_node << m_endpoint << this << frame;
|
qCDebug(dcZigbeeCluster()) << "Processing cluster frame" << m_node << m_endpoint << this << frame;
|
||||||
|
|
||||||
// Increase the tsn for continuous id increasing on both sides
|
// Increase the tsn for continuous id increasing on both sides
|
||||||
m_transactionSequenceNumber = frame.header.transactionSequenceNumber;
|
m_transactionSequenceNumber = frame.header.transactionSequenceNumber;
|
||||||
|
|
||||||
qCWarning(dcZigbeeCluster()) << "Unhandled ZCL indication in" << m_node << m_endpoint << this << frame;
|
switch (m_direction) {
|
||||||
|
case Client:
|
||||||
|
// If the client cluster sends data to a server cluster (independent which), the command was executed on the device like button pressed
|
||||||
|
if (frame.header.frameControl.direction == ZigbeeClusterLibrary::DirectionClientToServer) {
|
||||||
|
// Read the payload which is
|
||||||
|
Command command = static_cast<Command>(frame.header.command);
|
||||||
|
qCDebug(dcZigbeeCluster()) << "Received" << command << "from" << m_node << m_endpoint << this;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Server:
|
||||||
|
qCWarning(dcZigbeeCluster()) << "Unhandled ZCL indication in" << m_node << m_endpoint << this << frame;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,11 +39,5 @@ ZigbeeClusterBasic::ZigbeeClusterBasic(ZigbeeNetwork *network, ZigbeeNode *node,
|
|||||||
void ZigbeeClusterBasic::setAttribute(const ZigbeeClusterAttribute &attribute)
|
void ZigbeeClusterBasic::setAttribute(const ZigbeeClusterAttribute &attribute)
|
||||||
{
|
{
|
||||||
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
||||||
if (hasAttribute(attribute.id())) {
|
updateOrAddAttribute(attribute);
|
||||||
m_attributes[attribute.id()] = attribute;
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
} else {
|
|
||||||
m_attributes.insert(attribute.id(), attribute);
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,13 +64,7 @@ ZigbeeClusterReply *ZigbeeClusterIdentify::triggerEffect(ZigbeeClusterIdentify::
|
|||||||
void ZigbeeClusterIdentify::setAttribute(const ZigbeeClusterAttribute &attribute)
|
void ZigbeeClusterIdentify::setAttribute(const ZigbeeClusterAttribute &attribute)
|
||||||
{
|
{
|
||||||
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
||||||
if (hasAttribute(attribute.id())) {
|
updateOrAddAttribute(attribute);
|
||||||
m_attributes[attribute.id()] = attribute;
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
} else {
|
|
||||||
m_attributes.insert(attribute.id(), attribute);
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZigbeeClusterIdentify::processDataIndication(ZigbeeClusterLibrary::Frame frame)
|
void ZigbeeClusterIdentify::processDataIndication(ZigbeeClusterLibrary::Frame frame)
|
||||||
|
|||||||
@ -102,24 +102,24 @@ ZigbeeClusterReply *ZigbeeClusterLevelControl::commandStopWithOnOff()
|
|||||||
return executeClusterCommand(ZigbeeClusterLevelControl::CommandStopWithOnOff);
|
return executeClusterCommand(ZigbeeClusterLevelControl::CommandStopWithOnOff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quint8 ZigbeeClusterLevelControl::currentLevel() const
|
||||||
|
{
|
||||||
|
return m_currentLevel;
|
||||||
|
}
|
||||||
|
|
||||||
void ZigbeeClusterLevelControl::setAttribute(const ZigbeeClusterAttribute &attribute)
|
void ZigbeeClusterLevelControl::setAttribute(const ZigbeeClusterAttribute &attribute)
|
||||||
{
|
{
|
||||||
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
||||||
if (hasAttribute(attribute.id())) {
|
updateOrAddAttribute(attribute);
|
||||||
m_attributes[attribute.id()] = attribute;
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
} else {
|
|
||||||
m_attributes.insert(attribute.id(), attribute);
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the information for convenience
|
// Parse the information for convenience
|
||||||
if (attribute.id() == AttributeCurrentLevel) {
|
if (attribute.id() == AttributeCurrentLevel) {
|
||||||
bool valueOk = false;
|
bool valueOk = false;
|
||||||
quint8 value = attribute.dataType().toUInt8(&valueOk);
|
quint8 value = attribute.dataType().toUInt8(&valueOk);
|
||||||
if (valueOk) {
|
if (valueOk) {
|
||||||
qCDebug(dcZigbeeCluster()) << "CurrentLevel state changed on" << m_node << m_endpoint << this << value;
|
m_currentLevel = value;
|
||||||
emit currentLevelChanged(value);
|
qCDebug(dcZigbeeCluster()) << "CurrentLevel state changed on" << m_node << m_endpoint << this << m_currentLevel;
|
||||||
|
emit currentLevelChanged(m_currentLevel);
|
||||||
} else {
|
} else {
|
||||||
qCWarning(dcZigbeeCluster()) << "Failed to parse attribute data" << m_node << m_endpoint << this << attribute;
|
qCWarning(dcZigbeeCluster()) << "Failed to parse attribute data" << m_node << m_endpoint << this << attribute;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -94,7 +94,11 @@ public:
|
|||||||
ZigbeeClusterReply *commandStepWithOnOff(FadeMode fadeMode, quint8 stepSize = 0x01, quint16 transitionTime = 0xffff);
|
ZigbeeClusterReply *commandStepWithOnOff(FadeMode fadeMode, quint8 stepSize = 0x01, quint16 transitionTime = 0xffff);
|
||||||
ZigbeeClusterReply *commandStopWithOnOff();
|
ZigbeeClusterReply *commandStopWithOnOff();
|
||||||
|
|
||||||
|
quint8 currentLevel() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
quint8 m_currentLevel = 0;
|
||||||
|
|
||||||
void setAttribute(const ZigbeeClusterAttribute &attribute) override;
|
void setAttribute(const ZigbeeClusterAttribute &attribute) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@ -76,24 +76,24 @@ ZigbeeClusterReply *ZigbeeClusterOnOff::commandOnWithTimedOff(bool acceptOnlyWhe
|
|||||||
return executeClusterCommand(ZigbeeClusterOnOff::CommandOnWithTimedOff, payload);
|
return executeClusterCommand(ZigbeeClusterOnOff::CommandOnWithTimedOff, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ZigbeeClusterOnOff::power() const
|
||||||
|
{
|
||||||
|
return m_power;
|
||||||
|
}
|
||||||
|
|
||||||
void ZigbeeClusterOnOff::setAttribute(const ZigbeeClusterAttribute &attribute)
|
void ZigbeeClusterOnOff::setAttribute(const ZigbeeClusterAttribute &attribute)
|
||||||
{
|
{
|
||||||
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
||||||
if (hasAttribute(attribute.id())) {
|
updateOrAddAttribute(attribute);
|
||||||
m_attributes[attribute.id()] = attribute;
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
} else {
|
|
||||||
m_attributes.insert(attribute.id(), attribute);
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the information for convenience
|
// Parse the information for convenience
|
||||||
if (attribute.id() == AttributeOnOff) {
|
if (attribute.id() == AttributeOnOff) {
|
||||||
bool valueOk = false;
|
bool valueOk = false;
|
||||||
bool value = attribute.dataType().toBool(&valueOk);
|
bool value = attribute.dataType().toBool(&valueOk);
|
||||||
if (valueOk) {
|
if (valueOk) {
|
||||||
qCDebug(dcZigbeeCluster()) << "OnOff state changed on" << m_node << m_endpoint << this << value;
|
m_power = value;
|
||||||
emit powerChanged(value);
|
qCDebug(dcZigbeeCluster()) << "OnOff state changed on" << m_node << m_endpoint << this << m_power;
|
||||||
|
emit powerChanged(m_power);
|
||||||
} else {
|
} else {
|
||||||
qCWarning(dcZigbeeCluster()) << "Failed to parse attribute data" << m_node << m_endpoint << this << attribute;
|
qCWarning(dcZigbeeCluster()) << "Failed to parse attribute data" << m_node << m_endpoint << this << attribute;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,7 +79,11 @@ public:
|
|||||||
ZigbeeClusterReply *commandOnWithRecallGlobalScene();
|
ZigbeeClusterReply *commandOnWithRecallGlobalScene();
|
||||||
ZigbeeClusterReply *commandOnWithTimedOff(bool acceptOnlyWhenOn, quint16 onTime, quint16 offWaitTime);
|
ZigbeeClusterReply *commandOnWithTimedOff(bool acceptOnlyWhenOn, quint16 onTime, quint16 offWaitTime);
|
||||||
|
|
||||||
|
bool power() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool m_power = false;
|
||||||
|
|
||||||
void setAttribute(const ZigbeeClusterAttribute &attribute) override;
|
void setAttribute(const ZigbeeClusterAttribute &attribute) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@ -36,23 +36,23 @@ ZigbeeClusterPowerConfiguration::ZigbeeClusterPowerConfiguration(ZigbeeNetwork *
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double ZigbeeClusterPowerConfiguration::batteryPercentage() const
|
||||||
|
{
|
||||||
|
return m_batteryPercentage;
|
||||||
|
}
|
||||||
|
|
||||||
void ZigbeeClusterPowerConfiguration::setAttribute(const ZigbeeClusterAttribute &attribute)
|
void ZigbeeClusterPowerConfiguration::setAttribute(const ZigbeeClusterAttribute &attribute)
|
||||||
{
|
{
|
||||||
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
||||||
if (hasAttribute(attribute.id())) {
|
updateOrAddAttribute(attribute);
|
||||||
m_attributes[attribute.id()] = attribute;
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
} else {
|
|
||||||
m_attributes.insert(attribute.id(), attribute);
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attribute.id() == AttributeBatteryPercentageRemaining) {
|
if (attribute.id() == AttributeBatteryPercentageRemaining) {
|
||||||
bool valueOk = false;
|
bool valueOk = false;
|
||||||
quint8 value = attribute.dataType().toUInt8(&valueOk);
|
quint8 value = attribute.dataType().toUInt8(&valueOk);
|
||||||
if (valueOk) {
|
if (valueOk) {
|
||||||
qCDebug(dcZigbeeCluster()) << "PowerConfiguration attribute changed on" << m_node << m_endpoint << this << value;
|
m_batteryPercentage = value / 2.0;
|
||||||
emit batteryPercentageChanged(value / 2.0);
|
qCDebug(dcZigbeeCluster()) << "PowerConfiguration remaining battery percentage changed on" << m_node << m_endpoint << this << m_batteryPercentage << "%";
|
||||||
|
emit batteryPercentageChanged(m_batteryPercentage);
|
||||||
} else {
|
} else {
|
||||||
qCWarning(dcZigbeeCluster()) << "Failed to parse attribute data" << m_node << m_endpoint << this << attribute;
|
qCWarning(dcZigbeeCluster()) << "Failed to parse attribute data" << m_node << m_endpoint << this << attribute;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,7 +89,11 @@ public:
|
|||||||
|
|
||||||
explicit ZigbeeClusterPowerConfiguration(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, Direction direction, QObject *parent = nullptr);
|
explicit ZigbeeClusterPowerConfiguration(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, Direction direction, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
double batteryPercentage() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
double m_batteryPercentage = 0;
|
||||||
|
|
||||||
void setAttribute(const ZigbeeClusterAttribute &attribute) override;
|
void setAttribute(const ZigbeeClusterAttribute &attribute) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
@ -216,14 +216,7 @@ ZigbeeClusterReply *ZigbeeClusterColorControl::commandStepColorTemperature(Zigbe
|
|||||||
void ZigbeeClusterColorControl::setAttribute(const ZigbeeClusterAttribute &attribute)
|
void ZigbeeClusterColorControl::setAttribute(const ZigbeeClusterAttribute &attribute)
|
||||||
{
|
{
|
||||||
qCDebug(dcZigbeeCluster()) << "Attribute changed" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
qCDebug(dcZigbeeCluster()) << "Attribute changed" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
||||||
if (hasAttribute(attribute.id())) {
|
updateOrAddAttribute(attribute);
|
||||||
m_attributes[attribute.id()] = attribute;
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
} else {
|
|
||||||
m_attributes.insert(attribute.id(), attribute);
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZigbeeClusterColorControl::processDataIndication(ZigbeeClusterLibrary::Frame frame)
|
void ZigbeeClusterColorControl::processDataIndication(ZigbeeClusterLibrary::Frame frame)
|
||||||
|
|||||||
@ -36,24 +36,24 @@ ZigbeeClusterIlluminanceMeasurment::ZigbeeClusterIlluminanceMeasurment(ZigbeeNet
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quint16 ZigbeeClusterIlluminanceMeasurment::illuminance() const
|
||||||
|
{
|
||||||
|
return m_illuminance;
|
||||||
|
}
|
||||||
|
|
||||||
void ZigbeeClusterIlluminanceMeasurment::setAttribute(const ZigbeeClusterAttribute &attribute)
|
void ZigbeeClusterIlluminanceMeasurment::setAttribute(const ZigbeeClusterAttribute &attribute)
|
||||||
{
|
{
|
||||||
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
||||||
if (hasAttribute(attribute.id())) {
|
updateOrAddAttribute(attribute);
|
||||||
m_attributes[attribute.id()] = attribute;
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
} else {
|
|
||||||
m_attributes.insert(attribute.id(), attribute);
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the information for convenience
|
// Parse the information for convenience
|
||||||
if (attribute.id() == AttributeMeasuredValue) {
|
if (attribute.id() == AttributeMeasuredValue) {
|
||||||
bool valueOk = false;
|
bool valueOk = false;
|
||||||
quint16 value = attribute.dataType().toUInt16(&valueOk);
|
quint16 value = attribute.dataType().toUInt16(&valueOk);
|
||||||
if (valueOk) {
|
if (valueOk) {
|
||||||
qCDebug(dcZigbeeCluster()) << "Illuminance changed on" << m_node << m_endpoint << this << value << "lux";
|
m_illuminance = value;
|
||||||
emit illuminanceChanged(value);
|
qCDebug(dcZigbeeCluster()) << "Illuminance changed on" << m_node << m_endpoint << this << m_illuminance << "lux";
|
||||||
|
emit illuminanceChanged(m_illuminance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,7 +63,11 @@ public:
|
|||||||
|
|
||||||
explicit ZigbeeClusterIlluminanceMeasurment(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, Direction direction, QObject *parent = nullptr);
|
explicit ZigbeeClusterIlluminanceMeasurment(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, Direction direction, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
quint16 illuminance() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
quint16 m_illuminance = 0;
|
||||||
|
|
||||||
void setAttribute(const ZigbeeClusterAttribute &attribute) override;
|
void setAttribute(const ZigbeeClusterAttribute &attribute) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
@ -36,24 +36,24 @@ ZigbeeClusterOccupancySensing::ZigbeeClusterOccupancySensing(ZigbeeNetwork *netw
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ZigbeeClusterOccupancySensing::occupied() const
|
||||||
|
{
|
||||||
|
return m_occupied;
|
||||||
|
}
|
||||||
|
|
||||||
void ZigbeeClusterOccupancySensing::setAttribute(const ZigbeeClusterAttribute &attribute)
|
void ZigbeeClusterOccupancySensing::setAttribute(const ZigbeeClusterAttribute &attribute)
|
||||||
{
|
{
|
||||||
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
||||||
if (hasAttribute(attribute.id())) {
|
updateOrAddAttribute(attribute);
|
||||||
m_attributes[attribute.id()] = attribute;
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
} else {
|
|
||||||
m_attributes.insert(attribute.id(), attribute);
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the information for convenience
|
// Parse the information for convenience
|
||||||
if (attribute.id() == AttributeOccupancy) {
|
if (attribute.id() == AttributeOccupancy) {
|
||||||
bool valueOk = false;
|
bool valueOk = false;
|
||||||
bool value = attribute.dataType().toBool(&valueOk);
|
bool value = attribute.dataType().toBool(&valueOk);
|
||||||
if (valueOk) {
|
if (valueOk) {
|
||||||
qCDebug(dcZigbeeCluster()) << "Occupancy changed on" << m_node << m_endpoint << this << value;
|
m_occupied = value;
|
||||||
emit occupancyChanged(value);
|
qCDebug(dcZigbeeCluster()) << "Occupancy changed on" << m_node << m_endpoint << this << m_occupied;
|
||||||
|
emit occupancyChanged(m_occupied);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,7 +72,11 @@ public:
|
|||||||
|
|
||||||
explicit ZigbeeClusterOccupancySensing(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, Direction direction, QObject *parent = nullptr);
|
explicit ZigbeeClusterOccupancySensing(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, Direction direction, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
bool occupied() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool m_occupied = false;
|
||||||
|
|
||||||
void setAttribute(const ZigbeeClusterAttribute &attribute) override;
|
void setAttribute(const ZigbeeClusterAttribute &attribute) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
@ -36,33 +36,37 @@ ZigbeeClusterPressureMeasurement::ZigbeeClusterPressureMeasurement(ZigbeeNetwork
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double ZigbeeClusterPressureMeasurement::pressure() const
|
||||||
|
{
|
||||||
|
return m_pressure;
|
||||||
|
}
|
||||||
|
|
||||||
|
double ZigbeeClusterPressureMeasurement::pressureScaled() const
|
||||||
|
{
|
||||||
|
return m_pressureScaled;
|
||||||
|
}
|
||||||
|
|
||||||
void ZigbeeClusterPressureMeasurement::setAttribute(const ZigbeeClusterAttribute &attribute)
|
void ZigbeeClusterPressureMeasurement::setAttribute(const ZigbeeClusterAttribute &attribute)
|
||||||
{
|
{
|
||||||
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
||||||
if (hasAttribute(attribute.id())) {
|
updateOrAddAttribute(attribute);
|
||||||
m_attributes[attribute.id()] = attribute;
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
} else {
|
|
||||||
m_attributes.insert(attribute.id(), attribute);
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the information for convinience
|
// Parse the information for convinience
|
||||||
if (attribute.id() == AttributeMeasuredValue) {
|
if (attribute.id() == AttributeMeasuredValue) {
|
||||||
bool valueOk = false;
|
bool valueOk = false;
|
||||||
qint16 value = attribute.dataType().toInt16(&valueOk);
|
qint16 value = attribute.dataType().toInt16(&valueOk);
|
||||||
if (valueOk) {
|
if (valueOk) {
|
||||||
double pressure = value / 10.0;
|
m_pressure = value / 10.0;
|
||||||
qCDebug(dcZigbeeCluster()) << "Pressure changed on" << m_node << m_endpoint << this << pressure << "kPa";
|
qCDebug(dcZigbeeCluster()) << "Pressure changed on" << m_node << m_endpoint << this << m_pressure << "kPa";
|
||||||
emit pressureChanged(pressure);
|
emit pressureChanged(m_pressure);
|
||||||
}
|
}
|
||||||
} else if (attribute.id() == AttributeScaledValue) {
|
} else if (attribute.id() == AttributeScaledValue) {
|
||||||
bool valueOk = false;
|
bool valueOk = false;
|
||||||
qint16 value = attribute.dataType().toInt16(&valueOk);
|
qint16 value = attribute.dataType().toInt16(&valueOk);
|
||||||
if (valueOk) {
|
if (valueOk) {
|
||||||
double pressureScaled = value / 10.0;
|
m_pressureScaled = value / 10.0;
|
||||||
qCDebug(dcZigbeeCluster()) << "Pressure scaled changed on" << m_node << m_endpoint << this << pressureScaled << "Pa";
|
qCDebug(dcZigbeeCluster()) << "Pressure scaled changed on" << m_node << m_endpoint << this << m_pressureScaled << "Pa";
|
||||||
emit pressureScaledChanged(pressureScaled);
|
emit pressureScaledChanged(m_pressureScaled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,7 +62,12 @@ public:
|
|||||||
|
|
||||||
explicit ZigbeeClusterPressureMeasurement(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, Direction direction, QObject *parent = nullptr);
|
explicit ZigbeeClusterPressureMeasurement(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, Direction direction, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
double pressure() const;
|
||||||
|
double pressureScaled() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
double m_pressure = 0;
|
||||||
|
double m_pressureScaled = 0;
|
||||||
void setAttribute(const ZigbeeClusterAttribute &attribute) override;
|
void setAttribute(const ZigbeeClusterAttribute &attribute) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
@ -36,25 +36,24 @@ ZigbeeClusterRelativeHumidityMeasurement::ZigbeeClusterRelativeHumidityMeasureme
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double ZigbeeClusterRelativeHumidityMeasurement::humidity() const
|
||||||
|
{
|
||||||
|
return m_humidity;
|
||||||
|
}
|
||||||
|
|
||||||
void ZigbeeClusterRelativeHumidityMeasurement::setAttribute(const ZigbeeClusterAttribute &attribute)
|
void ZigbeeClusterRelativeHumidityMeasurement::setAttribute(const ZigbeeClusterAttribute &attribute)
|
||||||
{
|
{
|
||||||
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
||||||
if (hasAttribute(attribute.id())) {
|
updateOrAddAttribute(attribute);
|
||||||
m_attributes[attribute.id()] = attribute;
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
} else {
|
|
||||||
m_attributes.insert(attribute.id(), attribute);
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the information for convenience
|
// Parse the information for convenience
|
||||||
if (attribute.id() == AttributeMeasuredValue) {
|
if (attribute.id() == AttributeMeasuredValue) {
|
||||||
bool valueOk = false;
|
bool valueOk = false;
|
||||||
quint16 value = attribute.dataType().toUInt16(&valueOk);
|
quint16 value = attribute.dataType().toUInt16(&valueOk);
|
||||||
if (valueOk) {
|
if (valueOk) {
|
||||||
double humidity = value / 100.0;
|
m_humidity = value / 100.0;
|
||||||
qCDebug(dcZigbeeCluster()) << "Humidity changed on" << m_node << m_endpoint << this << humidity << "%";
|
qCDebug(dcZigbeeCluster()) << "Humidity changed on" << m_node << m_endpoint << this << m_humidity << "%";
|
||||||
emit humidityChanged(humidity);
|
emit humidityChanged(m_humidity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,7 +56,11 @@ public:
|
|||||||
|
|
||||||
explicit ZigbeeClusterRelativeHumidityMeasurement(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, Direction direction, QObject *parent = nullptr);
|
explicit ZigbeeClusterRelativeHumidityMeasurement(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, Direction direction, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
double humidity() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
double m_humidity = 0;
|
||||||
|
|
||||||
void setAttribute(const ZigbeeClusterAttribute &attribute) override;
|
void setAttribute(const ZigbeeClusterAttribute &attribute) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
@ -36,25 +36,24 @@ ZigbeeClusterTemperatureMeasurement::ZigbeeClusterTemperatureMeasurement(ZigbeeN
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double ZigbeeClusterTemperatureMeasurement::temperature() const
|
||||||
|
{
|
||||||
|
return m_temperature;
|
||||||
|
}
|
||||||
|
|
||||||
void ZigbeeClusterTemperatureMeasurement::setAttribute(const ZigbeeClusterAttribute &attribute)
|
void ZigbeeClusterTemperatureMeasurement::setAttribute(const ZigbeeClusterAttribute &attribute)
|
||||||
{
|
{
|
||||||
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
||||||
if (hasAttribute(attribute.id())) {
|
updateOrAddAttribute(attribute);
|
||||||
m_attributes[attribute.id()] = attribute;
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
} else {
|
|
||||||
m_attributes.insert(attribute.id(), attribute);
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the information for convenience
|
// Parse the information for convenience
|
||||||
if (attribute.id() == AttributeMeasuredValue) {
|
if (attribute.id() == AttributeMeasuredValue) {
|
||||||
bool valueOk = false;
|
bool valueOk = false;
|
||||||
qint16 value = attribute.dataType().toInt16(&valueOk);
|
qint16 value = attribute.dataType().toInt16(&valueOk);
|
||||||
if (valueOk) {
|
if (valueOk) {
|
||||||
double temperature = value / 100.0;
|
m_temperature = value / 100.0;
|
||||||
qCDebug(dcZigbeeCluster()) << "Temperature changed on" << m_node << m_endpoint << this << temperature << "°C";
|
qCDebug(dcZigbeeCluster()) << "Temperature changed on" << m_node << m_endpoint << this << m_temperature << "°C";
|
||||||
emit temperatureChanged(temperature);
|
emit temperatureChanged(m_temperature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,7 +56,11 @@ public:
|
|||||||
|
|
||||||
explicit ZigbeeClusterTemperatureMeasurement(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, Direction direction, QObject *parent = nullptr);
|
explicit ZigbeeClusterTemperatureMeasurement(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, Direction direction, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
double temperature() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
double m_temperature = 0;
|
||||||
|
|
||||||
void setAttribute(const ZigbeeClusterAttribute &attribute) override;
|
void setAttribute(const ZigbeeClusterAttribute &attribute) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
@ -42,13 +42,7 @@ ZigbeeClusterOta::ZigbeeClusterOta(ZigbeeNetwork *network, ZigbeeNode *node, Zig
|
|||||||
void ZigbeeClusterOta::setAttribute(const ZigbeeClusterAttribute &attribute)
|
void ZigbeeClusterOta::setAttribute(const ZigbeeClusterAttribute &attribute)
|
||||||
{
|
{
|
||||||
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
||||||
if (hasAttribute(attribute.id())) {
|
updateOrAddAttribute(attribute);
|
||||||
m_attributes[attribute.id()] = attribute;
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
} else {
|
|
||||||
m_attributes.insert(attribute.id(), attribute);
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ZigbeeClusterOta::FileVersion ZigbeeClusterOta::parseFileVersion(quint32 fileVersionValue)
|
ZigbeeClusterOta::FileVersion ZigbeeClusterOta::parseFileVersion(quint32 fileVersionValue)
|
||||||
|
|||||||
@ -42,13 +42,7 @@ ZigbeeClusterIasZone::ZigbeeClusterIasZone(ZigbeeNetwork *network, ZigbeeNode *n
|
|||||||
void ZigbeeClusterIasZone::setAttribute(const ZigbeeClusterAttribute &attribute)
|
void ZigbeeClusterIasZone::setAttribute(const ZigbeeClusterAttribute &attribute)
|
||||||
{
|
{
|
||||||
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
||||||
if (hasAttribute(attribute.id())) {
|
updateOrAddAttribute(attribute);
|
||||||
m_attributes[attribute.id()] = attribute;
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
} else {
|
|
||||||
m_attributes.insert(attribute.id(), attribute);
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZigbeeClusterIasZone::processDataIndication(ZigbeeClusterLibrary::Frame frame)
|
void ZigbeeClusterIasZone::processDataIndication(ZigbeeClusterLibrary::Frame frame)
|
||||||
|
|||||||
@ -97,7 +97,7 @@ public:
|
|||||||
ZoneStatusTest = 0x0100,
|
ZoneStatusTest = 0x0100,
|
||||||
ZoneStatusBatteryDefect = 0x0200
|
ZoneStatusBatteryDefect = 0x0200
|
||||||
};
|
};
|
||||||
Q_ENUM(ZoneStatus)
|
Q_FLAG(ZoneStatus)
|
||||||
Q_DECLARE_FLAGS(ZoneStatusFlags, ZoneStatus)
|
Q_DECLARE_FLAGS(ZoneStatusFlags, ZoneStatus)
|
||||||
|
|
||||||
enum EnrollResponseCode {
|
enum EnrollResponseCode {
|
||||||
@ -137,6 +137,4 @@ signals:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(ZigbeeClusterIasZone::ZoneStatusFlags)
|
|
||||||
|
|
||||||
#endif // ZIGBEECLUSTERIASZONE_H
|
#endif // ZIGBEECLUSTERIASZONE_H
|
||||||
|
|||||||
@ -93,13 +93,7 @@ ZigbeeClusterAttribute ZigbeeCluster::attribute(quint16 attributeId)
|
|||||||
void ZigbeeCluster::setAttribute(const ZigbeeClusterAttribute &attribute)
|
void ZigbeeCluster::setAttribute(const ZigbeeClusterAttribute &attribute)
|
||||||
{
|
{
|
||||||
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << attribute;
|
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << attribute;
|
||||||
if (hasAttribute(attribute.id())) {
|
updateOrAddAttribute(attribute);
|
||||||
m_attributes[attribute.id()] = attribute;
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
} else {
|
|
||||||
m_attributes.insert(attribute.id(), attribute);
|
|
||||||
emit attributeChanged(attribute);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ZigbeeClusterReply *ZigbeeCluster::readAttributes(QList<quint16> attributes)
|
ZigbeeClusterReply *ZigbeeCluster::readAttributes(QList<quint16> attributes)
|
||||||
@ -363,6 +357,17 @@ void ZigbeeCluster::processDataIndication(ZigbeeClusterLibrary::Frame frame)
|
|||||||
qCWarning(dcZigbeeCluster()) << "Unhandled ZCL indication in" << m_node << m_endpoint << this << frame;
|
qCWarning(dcZigbeeCluster()) << "Unhandled ZCL indication in" << m_node << m_endpoint << this << frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ZigbeeCluster::updateOrAddAttribute(const ZigbeeClusterAttribute &attribute)
|
||||||
|
{
|
||||||
|
if (hasAttribute(attribute.id())) {
|
||||||
|
m_attributes[attribute.id()] = attribute;
|
||||||
|
emit attributeChanged(attribute);
|
||||||
|
} else {
|
||||||
|
m_attributes.insert(attribute.id(), attribute);
|
||||||
|
emit attributeChanged(attribute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ZigbeeCluster::processApsDataIndication(const QByteArray &asdu, const ZigbeeClusterLibrary::Frame &frame)
|
void ZigbeeCluster::processApsDataIndication(const QByteArray &asdu, const ZigbeeClusterLibrary::Frame &frame)
|
||||||
{
|
{
|
||||||
// Check if this indication is for a pending reply
|
// Check if this indication is for a pending reply
|
||||||
|
|||||||
@ -114,7 +114,6 @@ protected:
|
|||||||
// Global commands
|
// Global commands
|
||||||
ZigbeeClusterReply *executeGlobalCommand(quint8 command, const QByteArray &payload = QByteArray());
|
ZigbeeClusterReply *executeGlobalCommand(quint8 command, const QByteArray &payload = QByteArray());
|
||||||
|
|
||||||
|
|
||||||
// Cluster specific
|
// Cluster specific
|
||||||
ZigbeeClusterReply *createClusterReply(const ZigbeeNetworkRequest &request, ZigbeeClusterLibrary::Frame frame);
|
ZigbeeClusterReply *createClusterReply(const ZigbeeNetworkRequest &request, ZigbeeClusterLibrary::Frame frame);
|
||||||
ZigbeeClusterReply *executeClusterCommand(quint8 command, const QByteArray &payload = QByteArray());
|
ZigbeeClusterReply *executeClusterCommand(quint8 command, const QByteArray &payload = QByteArray());
|
||||||
@ -126,6 +125,8 @@ protected:
|
|||||||
|
|
||||||
virtual void processDataIndication(ZigbeeClusterLibrary::Frame frame);
|
virtual void processDataIndication(ZigbeeClusterLibrary::Frame frame);
|
||||||
|
|
||||||
|
void updateOrAddAttribute(const ZigbeeClusterAttribute &attribute);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void setAttribute(const ZigbeeClusterAttribute &attribute);
|
virtual void setAttribute(const ZigbeeClusterAttribute &attribute);
|
||||||
|
|
||||||
|
|||||||
@ -628,6 +628,6 @@ 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() << ")";
|
debug.nospace().noquote() << ") ";
|
||||||
return debug.space();
|
return debug;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -285,6 +285,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.space();
|
return debug;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user