From 6762d0e0078fa4f91d132b6f3f9d0c74467e743e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Thu, 26 Nov 2020 12:58:52 +0100 Subject: [PATCH] Add binary input cluster --- libnymea-zigbee/libnymea-zigbee.pro | 2 + .../zcl/general/zigbeeclusterbinaryinput.cpp | 41 ++++++++++++ .../zcl/general/zigbeeclusterbinaryinput.h | 63 +++++++++++++++++++ libnymea-zigbee/zigbeenodeendpoint.cpp | 2 + libnymea-zigbee/zigbeenodeendpoint.h | 1 + 5 files changed, 109 insertions(+) create mode 100644 libnymea-zigbee/zcl/general/zigbeeclusterbinaryinput.cpp create mode 100644 libnymea-zigbee/zcl/general/zigbeeclusterbinaryinput.h diff --git a/libnymea-zigbee/libnymea-zigbee.pro b/libnymea-zigbee/libnymea-zigbee.pro index 869d183..b62b1ff 100644 --- a/libnymea-zigbee/libnymea-zigbee.pro +++ b/libnymea-zigbee/libnymea-zigbee.pro @@ -20,6 +20,7 @@ SOURCES += \ zcl/general/zigbeeclusteranaloginput.cpp \ zcl/general/zigbeeclusteranalogoutput.cpp \ zcl/general/zigbeeclusteranalogvalue.cpp \ + zcl/general/zigbeeclusterbinaryinput.cpp \ zcl/general/zigbeeclustergroups.cpp \ zcl/general/zigbeeclusteridentify.cpp \ zcl/general/zigbeeclusterlevelcontrol.cpp \ @@ -81,6 +82,7 @@ HEADERS += \ zcl/general/zigbeeclusteranaloginput.h \ zcl/general/zigbeeclusteranalogoutput.h \ zcl/general/zigbeeclusteranalogvalue.h \ + zcl/general/zigbeeclusterbinaryinput.h \ zcl/general/zigbeeclustergroups.h \ zcl/general/zigbeeclusteridentify.h \ zcl/general/zigbeeclusterlevelcontrol.h \ diff --git a/libnymea-zigbee/zcl/general/zigbeeclusterbinaryinput.cpp b/libnymea-zigbee/zcl/general/zigbeeclusterbinaryinput.cpp new file mode 100644 index 0000000..4450eae --- /dev/null +++ b/libnymea-zigbee/zcl/general/zigbeeclusterbinaryinput.cpp @@ -0,0 +1,41 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +* +* Copyright 2013 - 2020, nymea GmbH +* Contact: contact@nymea.io +* +* This file is part of nymea-zigbee. +* This project including source code and documentation is protected by copyright law, and +* remains the property of nymea GmbH. All rights, including reproduction, publication, +* editing and translation, are reserved. The use of this project is subject to the terms of a +* license agreement to be concluded with nymea GmbH in accordance with the terms +* of use of nymea GmbH, available under https://nymea.io/license +* +* GNU Lesser General Public License Usage +* Alternatively, this project may be redistributed and/or modified under the terms of the GNU +* Lesser General Public License as published by the Free Software Foundation; version 3. +* this project is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* See the GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License along with this project. +* If not, see . +* +* For any further details and any questions please contact us under contact@nymea.io +* or see our FAQ/Licensing Information on https://nymea.io/license/faq +* +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include "zigbeeclusterbinaryinput.h" +#include "loggingcategory.h" + +ZigbeeClusterBinaryInput::ZigbeeClusterBinaryInput(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, Direction direction, QObject *parent) : + ZigbeeCluster(network, node, endpoint, ZigbeeClusterLibrary::ClusterIdBinaryInput, direction, parent) +{ + +} + +void ZigbeeClusterBinaryInput::setAttribute(const ZigbeeClusterAttribute &attribute) +{ + qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast(attribute.id()) << attribute.dataType(); + updateOrAddAttribute(attribute); +} diff --git a/libnymea-zigbee/zcl/general/zigbeeclusterbinaryinput.h b/libnymea-zigbee/zcl/general/zigbeeclusterbinaryinput.h new file mode 100644 index 0000000..95a2755 --- /dev/null +++ b/libnymea-zigbee/zcl/general/zigbeeclusterbinaryinput.h @@ -0,0 +1,63 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +* +* Copyright 2013 - 2020, nymea GmbH +* Contact: contact@nymea.io +* +* This file is part of nymea-zigbee. +* This project including source code and documentation is protected by copyright law, and +* remains the property of nymea GmbH. All rights, including reproduction, publication, +* editing and translation, are reserved. The use of this project is subject to the terms of a +* license agreement to be concluded with nymea GmbH in accordance with the terms +* of use of nymea GmbH, available under https://nymea.io/license +* +* GNU Lesser General Public License Usage +* Alternatively, this project may be redistributed and/or modified under the terms of the GNU +* Lesser General Public License as published by the Free Software Foundation; version 3. +* this project is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* See the GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License along with this project. +* If not, see . +* +* For any further details and any questions please contact us under contact@nymea.io +* or see our FAQ/Licensing Information on https://nymea.io/license/faq +* +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef ZIGBEECLUSTERBINARYINPUT_H +#define ZIGBEECLUSTERBINARYINPUT_H + +#include + +#include "zcl/zigbeecluster.h" + +class ZigbeeClusterBinaryInput : public ZigbeeCluster +{ + Q_OBJECT + + friend class ZigbeeNode; + friend class ZigbeeNetwork; + +public: + enum Attribute { + AttributeActiveText = 0x0004, + AttributeDescription = 0x001C, + AttributeInactiveText = 0x002E, + AttributeOutOfService = 0x0051, + AttributePolarity = 0x0054, + AttributePresentValue = 0x0055, + AttributeReliability = 0x0067, + AttributeStatusFlags = 0x006F, + AttributeApplicationType = 0x0100 + }; + Q_ENUM(Attribute) + + explicit ZigbeeClusterBinaryInput(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, Direction direction, QObject *parent = nullptr); + +private: + void setAttribute(const ZigbeeClusterAttribute &attribute) override; + +}; + +#endif // ZIGBEECLUSTERBINARYINPUT_H diff --git a/libnymea-zigbee/zigbeenodeendpoint.cpp b/libnymea-zigbee/zigbeenodeendpoint.cpp index 7da5dc4..2aba456 100644 --- a/libnymea-zigbee/zigbeenodeendpoint.cpp +++ b/libnymea-zigbee/zigbeenodeendpoint.cpp @@ -183,6 +183,8 @@ ZigbeeCluster *ZigbeeNodeEndpoint::createCluster(ZigbeeClusterLibrary::ClusterId return new ZigbeeClusterAnalogOutput(m_network, m_node, this, direction, this); case ZigbeeClusterLibrary::ClusterIdAnalogValue: return new ZigbeeClusterAnalogValue(m_network, m_node, this, direction, this); + case ZigbeeClusterLibrary::ClusterIdBinaryInput: + return new ZigbeeClusterBinaryInput(m_network, m_node, this, direction, this); case ZigbeeClusterLibrary::ClusterIdMultistateInput: return new ZigbeeClusterMultistateInput(m_network, m_node, this, direction, this); diff --git a/libnymea-zigbee/zigbeenodeendpoint.h b/libnymea-zigbee/zigbeenodeendpoint.h index 51cced5..37c0fc5 100644 --- a/libnymea-zigbee/zigbeenodeendpoint.h +++ b/libnymea-zigbee/zigbeenodeendpoint.h @@ -46,6 +46,7 @@ #include "zcl/general/zigbeeclusteranaloginput.h" #include "zcl/general/zigbeeclusteranalogoutput.h" #include "zcl/general/zigbeeclusteranalogvalue.h" +#include "zcl/general/zigbeeclusterbinaryinput.h" #include "zcl/general/zigbeeclustermultistateinput.h" #include "zcl/closures/zigbeeclusterdoorlock.h"