Add multistate input cluster and improve internal endpoint initialization
parent
e245f7c845
commit
a651ece1cf
|
|
@ -20,6 +20,7 @@ SOURCES += \
|
||||||
zcl/general/zigbeeclustergroups.cpp \
|
zcl/general/zigbeeclustergroups.cpp \
|
||||||
zcl/general/zigbeeclusteridentify.cpp \
|
zcl/general/zigbeeclusteridentify.cpp \
|
||||||
zcl/general/zigbeeclusterlevelcontrol.cpp \
|
zcl/general/zigbeeclusterlevelcontrol.cpp \
|
||||||
|
zcl/general/zigbeeclustermultistateinput.cpp \
|
||||||
zcl/general/zigbeeclusteronoff.cpp \
|
zcl/general/zigbeeclusteronoff.cpp \
|
||||||
zcl/general/zigbeeclusterpowerconfiguration.cpp \
|
zcl/general/zigbeeclusterpowerconfiguration.cpp \
|
||||||
zcl/hvac/zigbeeclusterthermostat.cpp \
|
zcl/hvac/zigbeeclusterthermostat.cpp \
|
||||||
|
|
@ -77,6 +78,7 @@ HEADERS += \
|
||||||
zcl/general/zigbeeclustergroups.h \
|
zcl/general/zigbeeclustergroups.h \
|
||||||
zcl/general/zigbeeclusteridentify.h \
|
zcl/general/zigbeeclusteridentify.h \
|
||||||
zcl/general/zigbeeclusterlevelcontrol.h \
|
zcl/general/zigbeeclusterlevelcontrol.h \
|
||||||
|
zcl/general/zigbeeclustermultistateinput.h \
|
||||||
zcl/general/zigbeeclusteronoff.h \
|
zcl/general/zigbeeclusteronoff.h \
|
||||||
zcl/general/zigbeeclusterpowerconfiguration.h \
|
zcl/general/zigbeeclusterpowerconfiguration.h \
|
||||||
zcl/hvac/zigbeeclusterthermostat.h \
|
zcl/hvac/zigbeeclusterthermostat.h \
|
||||||
|
|
|
||||||
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* 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 "zigbeeclustermultistateinput.h"
|
||||||
|
#include "loggingcategory.h"
|
||||||
|
|
||||||
|
ZigbeeClusterMultistateInput::ZigbeeClusterMultistateInput(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, ZigbeeCluster::Direction direction, QObject *parent) :
|
||||||
|
ZigbeeCluster(network, node, endpoint, ZigbeeClusterLibrary::ClusterIdMultistateInput, direction, parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZigbeeClusterMultistateInput::setAttribute(const ZigbeeClusterAttribute &attribute)
|
||||||
|
{
|
||||||
|
qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast<Attribute>(attribute.id()) << attribute.dataType();
|
||||||
|
updateOrAddAttribute(attribute);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* 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 ZIGBEECLUSTERMULTISTATEINPUT_H
|
||||||
|
#define ZIGBEECLUSTERMULTISTATEINPUT_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "zcl/zigbeecluster.h"
|
||||||
|
|
||||||
|
class ZigbeeClusterMultistateInput : public ZigbeeCluster
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
|
||||||
|
friend class ZigbeeNode;
|
||||||
|
friend class ZigbeeNetwork;
|
||||||
|
|
||||||
|
enum Attribute {
|
||||||
|
AttributeDescription = 0x001C,
|
||||||
|
AttributeOutOfService = 0x0051,
|
||||||
|
AttributePresentValue = 0x0055,
|
||||||
|
AttributePriorityArray = 0x0057,
|
||||||
|
AttributeReliability = 0x0067,
|
||||||
|
AttributeRelinquishDefault = 0x0068,
|
||||||
|
AttributeStatusFlags = 0x006F,
|
||||||
|
AttributeEngineeringUnits = 0x0075,
|
||||||
|
AttributeApplicationType = 0x0100
|
||||||
|
};
|
||||||
|
Q_ENUM(Attribute)
|
||||||
|
|
||||||
|
explicit ZigbeeClusterMultistateInput(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, Direction direction, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setAttribute(const ZigbeeClusterAttribute &attribute) override;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ZIGBEECLUSTERMULTISTATEINPUT_H
|
||||||
|
|
@ -120,15 +120,15 @@ public:
|
||||||
ClusterIdAlarms = 0x0009,
|
ClusterIdAlarms = 0x0009,
|
||||||
ClusterIdTime = 0x000A,
|
ClusterIdTime = 0x000A,
|
||||||
ClusterIdRssiLocation = 0x000B,
|
ClusterIdRssiLocation = 0x000B,
|
||||||
ClusterIdAnalogInputBasic = 0x000C,
|
ClusterIdAnalogInput = 0x000C,
|
||||||
ClusterIdAnalogOutputBasic = 0x000D,
|
ClusterIdAnalogOutput = 0x000D,
|
||||||
ClusterIdValueBasic = 0x000E,
|
ClusterIdAnalogValue = 0x000E,
|
||||||
ClusterIdBinaryInputBasic = 0x000F,
|
ClusterIdBinaryInput = 0x000F,
|
||||||
ClusterIdBinaryOutputBasic = 0x0010,
|
ClusterIdBinaryOutput = 0x0010,
|
||||||
ClusterIdBinaryValueBasic = 0x0011,
|
ClusterIdBinaryValue = 0x0011,
|
||||||
ClusterIdMultiStateInputBasic = 0x0012,
|
ClusterIdMultistateInput = 0x0012,
|
||||||
ClusterIdMultiStateOutputBasic = 0x0013,
|
ClusterIdMultistateOutput = 0x0013,
|
||||||
ClusterIdMultiStateValueBasic = 0x0014,
|
ClusterIdMultistateValue = 0x0014,
|
||||||
ClusterIdCommissoning = 0x0015,
|
ClusterIdCommissoning = 0x0015,
|
||||||
|
|
||||||
// Over the air uppgrade (OTA)
|
// Over the air uppgrade (OTA)
|
||||||
|
|
|
||||||
|
|
@ -167,10 +167,7 @@ QList<ZigbeeNode *> ZigbeeNetworkDatabase::loadNodes()
|
||||||
}
|
}
|
||||||
|
|
||||||
node->m_endpoints.append(endpoint);
|
node->m_endpoints.append(endpoint);
|
||||||
|
node->setupEndpointInternal(endpoint);
|
||||||
// Connect after initialization for out of spec nodes
|
|
||||||
connect(endpoint, &ZigbeeNodeEndpoint::inputClusterAdded, node, &ZigbeeNode::clusterAdded);
|
|
||||||
connect(endpoint, &ZigbeeNodeEndpoint::outputClusterAdded, node, &ZigbeeNode::clusterAdded);
|
|
||||||
}
|
}
|
||||||
nodes.append(node);
|
nodes.append(node);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -427,9 +427,7 @@ void ZigbeeNode::initEndpoint(quint8 endpointId)
|
||||||
m_uninitializedEndpoints.removeAll(endpointId);
|
m_uninitializedEndpoints.removeAll(endpointId);
|
||||||
endpoint->m_initialized = true;
|
endpoint->m_initialized = true;
|
||||||
|
|
||||||
// Connect after initialization for out of spec nodes
|
setupEndpointInternal(endpoint);
|
||||||
connect(endpoint, &ZigbeeNodeEndpoint::inputClusterAdded, this, &ZigbeeNode::clusterAdded);
|
|
||||||
connect(endpoint, &ZigbeeNodeEndpoint::outputClusterAdded, this, &ZigbeeNode::clusterAdded);
|
|
||||||
|
|
||||||
if (m_uninitializedEndpoints.isEmpty()) {
|
if (m_uninitializedEndpoints.isEmpty()) {
|
||||||
// Note: if we are initializing the coordinator, we can stop here
|
// Note: if we are initializing the coordinator, we can stop here
|
||||||
|
|
@ -472,6 +470,16 @@ void ZigbeeNode::removeNextBinding(ZigbeeReply *reply)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ZigbeeNode::setupEndpointInternal(ZigbeeNodeEndpoint *endpoint)
|
||||||
|
{
|
||||||
|
// Connect after initialization for out of spec nodes
|
||||||
|
connect(endpoint, &ZigbeeNodeEndpoint::inputClusterAdded, this, &ZigbeeNode::clusterAdded);
|
||||||
|
connect(endpoint, &ZigbeeNodeEndpoint::outputClusterAdded, this, &ZigbeeNode::clusterAdded);
|
||||||
|
connect(endpoint, &ZigbeeNodeEndpoint::clusterAttributeChanged, this, [this, endpoint](ZigbeeCluster *cluster, const ZigbeeClusterAttribute &attribute){
|
||||||
|
emit endpointClusterAttributeChanged(endpoint, cluster, attribute);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void ZigbeeNode::initBasicCluster()
|
void ZigbeeNode::initBasicCluster()
|
||||||
{
|
{
|
||||||
// Get the first endpoint which implements the basic cluster
|
// Get the first endpoint which implements the basic cluster
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,8 @@ private:
|
||||||
|
|
||||||
void removeNextBinding(ZigbeeReply *reply);
|
void removeNextBinding(ZigbeeReply *reply);
|
||||||
|
|
||||||
|
void setupEndpointInternal(ZigbeeNodeEndpoint *endpoint);
|
||||||
|
|
||||||
// For convenience and having base information about the first endpoint
|
// For convenience and having base information about the first endpoint
|
||||||
void initBasicCluster();
|
void initBasicCluster();
|
||||||
void readManufacturerName(ZigbeeClusterBasic *basicCluster);
|
void readManufacturerName(ZigbeeClusterBasic *basicCluster);
|
||||||
|
|
@ -142,7 +144,7 @@ signals:
|
||||||
void reachableChanged(bool reachable);
|
void reachableChanged(bool reachable);
|
||||||
void bindingTableRecordsChanged();
|
void bindingTableRecordsChanged();
|
||||||
void clusterAdded(ZigbeeCluster *cluster);
|
void clusterAdded(ZigbeeCluster *cluster);
|
||||||
void clusterAttributeChanged(ZigbeeCluster *cluster, const ZigbeeClusterAttribute &attribute);
|
void endpointClusterAttributeChanged(ZigbeeNodeEndpoint *endpoint, ZigbeeCluster *cluster, const ZigbeeClusterAttribute &attribute);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void handleZigbeeClusterLibraryIndication(const Zigbee::ApsdeDataIndication &indication);
|
void handleZigbeeClusterLibraryIndication(const Zigbee::ApsdeDataIndication &indication);
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,8 @@ ZigbeeCluster *ZigbeeNodeEndpoint::createCluster(ZigbeeClusterLibrary::ClusterId
|
||||||
return new ZigbeeClusterLevelControl(m_network, m_node, this, direction, this);
|
return new ZigbeeClusterLevelControl(m_network, m_node, this, direction, this);
|
||||||
case ZigbeeClusterLibrary::ClusterIdGroups:
|
case ZigbeeClusterLibrary::ClusterIdGroups:
|
||||||
return new ZigbeeClusterGroups(m_network, m_node, this, direction, this);
|
return new ZigbeeClusterGroups(m_network, m_node, this, direction, this);
|
||||||
|
case ZigbeeClusterLibrary::ClusterIdMultistateInput:
|
||||||
|
return new ZigbeeClusterMultistateInput(m_network, m_node, this, direction, this);
|
||||||
|
|
||||||
// Measurement
|
// Measurement
|
||||||
case ZigbeeClusterLibrary::ClusterIdIlluminanceMeasurement:
|
case ZigbeeClusterLibrary::ClusterIdIlluminanceMeasurement:
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@
|
||||||
#include "zcl/general/zigbeeclusterlevelcontrol.h"
|
#include "zcl/general/zigbeeclusterlevelcontrol.h"
|
||||||
#include "zcl/general/zigbeeclusterpowerconfiguration.h"
|
#include "zcl/general/zigbeeclusterpowerconfiguration.h"
|
||||||
#include "zcl/general/zigbeeclustergroups.h"
|
#include "zcl/general/zigbeeclustergroups.h"
|
||||||
|
#include "zcl/general/zigbeeclustermultistateinput.h"
|
||||||
|
|
||||||
#include "zcl/closures/zigbeeclusterdoorlock.h"
|
#include "zcl/closures/zigbeeclusterdoorlock.h"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue