Fix endpoint initialization order and move back to sorted list
parent
8105a9082b
commit
c565a25be2
|
|
@ -81,6 +81,8 @@ private:
|
||||||
protected:
|
protected:
|
||||||
void processDataIndication(ZigbeeClusterLibrary::Frame frame) override;
|
void processDataIndication(ZigbeeClusterLibrary::Frame frame) override;
|
||||||
|
|
||||||
|
// TODO: identifyQueryResponse signal
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ZIGBEECLUSTERIDENTIFY_H
|
#endif // ZIGBEECLUSTERIDENTIFY_H
|
||||||
|
|
|
||||||
|
|
@ -198,6 +198,16 @@ void ZigbeeClusterOnOff::setAttribute(const ZigbeeClusterAttribute &attribute)
|
||||||
m_attributes.insert(attribute.id(), attribute);
|
m_attributes.insert(attribute.id(), attribute);
|
||||||
emit attributeChanged(attribute);
|
emit attributeChanged(attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parse the information for convinience
|
||||||
|
if (attribute.id() == AttributeOnOff) {
|
||||||
|
bool valueOk = false;
|
||||||
|
bool value = attribute.dataType().toBool(&valueOk);
|
||||||
|
if (valueOk) {
|
||||||
|
qCDebug(dcZigbeeCluster()) << "OnOff state changed on" << m_node << m_endpoint << this << value;
|
||||||
|
emit powerChanged(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZigbeeClusterOnOff::processDataIndication(ZigbeeClusterLibrary::Frame frame)
|
void ZigbeeClusterOnOff::processDataIndication(ZigbeeClusterLibrary::Frame frame)
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,10 @@ protected:
|
||||||
void processDataIndication(ZigbeeClusterLibrary::Frame frame) override;
|
void processDataIndication(ZigbeeClusterLibrary::Frame frame) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
// Note: these signals will only be emitted if the cluster is a client
|
// Server cluster signals
|
||||||
|
void powerChanged(bool power);
|
||||||
|
|
||||||
|
// Client cluster signals
|
||||||
void commandSent(Command command);
|
void commandSent(Command command);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -365,7 +365,7 @@ void ZigbeeNetwork::loadNetwork()
|
||||||
}
|
}
|
||||||
settings.endArray(); // outputClusters
|
settings.endArray(); // outputClusters
|
||||||
|
|
||||||
node->m_endpoints.insert(endpoint->endpointId(), endpoint);
|
node->m_endpoints.append(endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.endArray(); // endpoints
|
settings.endArray(); // endpoints
|
||||||
|
|
|
||||||
|
|
@ -68,17 +68,23 @@ ZigbeeAddress ZigbeeNode::extendedAddress() const
|
||||||
|
|
||||||
QList<ZigbeeNodeEndpoint *> ZigbeeNode::endpoints() const
|
QList<ZigbeeNodeEndpoint *> ZigbeeNode::endpoints() const
|
||||||
{
|
{
|
||||||
return m_endpoints.values();
|
return m_endpoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZigbeeNode::hasEndpoint(quint8 endpointId) const
|
bool ZigbeeNode::hasEndpoint(quint8 endpointId) const
|
||||||
{
|
{
|
||||||
return m_endpoints.keys().contains(endpointId);
|
return getEndpoint(endpointId) != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZigbeeNodeEndpoint *ZigbeeNode::getEndpoint(quint8 endpointId) const
|
ZigbeeNodeEndpoint *ZigbeeNode::getEndpoint(quint8 endpointId) const
|
||||||
{
|
{
|
||||||
return m_endpoints.value(endpointId);
|
foreach (ZigbeeNodeEndpoint *ep, m_endpoints) {
|
||||||
|
if (ep->endpointId()== endpointId) {
|
||||||
|
return ep;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZigbeeNode::NodeType ZigbeeNode::nodeType() const
|
ZigbeeNode::NodeType ZigbeeNode::nodeType() const
|
||||||
|
|
@ -635,7 +641,7 @@ void ZigbeeNode::initEndpoint(quint8 endpointId)
|
||||||
ZigbeeNodeEndpoint *endpoint = nullptr;
|
ZigbeeNodeEndpoint *endpoint = nullptr;
|
||||||
if (!hasEndpoint(endpointId)) {
|
if (!hasEndpoint(endpointId)) {
|
||||||
endpoint = new ZigbeeNodeEndpoint(m_network, this, endpointId, this);
|
endpoint = new ZigbeeNodeEndpoint(m_network, this, endpointId, this);
|
||||||
m_endpoints.insert(endpoint->endpointId(), endpoint);
|
m_endpoints.append(endpoint);
|
||||||
} else {
|
} else {
|
||||||
endpoint = getEndpoint(endpointId);
|
endpoint = getEndpoint(endpointId);
|
||||||
}
|
}
|
||||||
|
|
@ -687,8 +693,22 @@ void ZigbeeNode::initEndpoint(quint8 endpointId)
|
||||||
|
|
||||||
void ZigbeeNode::initBasicCluster()
|
void ZigbeeNode::initBasicCluster()
|
||||||
{
|
{
|
||||||
// FIXME: check if we want to read from all endpoints the basic cluster information or only from the first
|
// Get the first endpoint which implements the basic cluster
|
||||||
ZigbeeClusterBasic *basicCluster = endpoints().first()->inputCluster<ZigbeeClusterBasic>(Zigbee::ClusterIdBasic);
|
ZigbeeNodeEndpoint *endpoint = nullptr;
|
||||||
|
foreach (ZigbeeNodeEndpoint *ep, endpoints()) {
|
||||||
|
if (ep->hasInputCluster(Zigbee::ClusterIdBasic)) {
|
||||||
|
endpoint = ep;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!endpoint) {
|
||||||
|
qCWarning(dcZigbeeNode()) << "Could not find any endpoint contiaining the basic cluster on" << this << "Set the node to initialized anyways.";
|
||||||
|
setState(StateInitialized);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZigbeeClusterBasic *basicCluster = endpoint->inputCluster<ZigbeeClusterBasic>(Zigbee::ClusterIdBasic);
|
||||||
if (!basicCluster) {
|
if (!basicCluster) {
|
||||||
qCWarning(dcZigbeeNode()) << "Could not find basic cluster on" << this << "Set the node to initialized anyways.";
|
qCWarning(dcZigbeeNode()) << "Could not find basic cluster on" << this << "Set the node to initialized anyways.";
|
||||||
// Set the device initialized any ways since this ist just for convinience
|
// Set the device initialized any ways since this ist just for convinience
|
||||||
|
|
@ -839,7 +859,7 @@ void ZigbeeNode::handleZigbeeClusterLibraryIndication(const Zigbee::ApsdeDataInd
|
||||||
endpoint = new ZigbeeNodeEndpoint(m_network, this, indication.sourceEndpoint, this);
|
endpoint = new ZigbeeNodeEndpoint(m_network, this, indication.sourceEndpoint, this);
|
||||||
endpoint->setProfile(static_cast<Zigbee::ZigbeeProfile>(indication.profileId));
|
endpoint->setProfile(static_cast<Zigbee::ZigbeeProfile>(indication.profileId));
|
||||||
// Note: the endpoint is not initializd yet, but keep it anyways
|
// Note: the endpoint is not initializd yet, but keep it anyways
|
||||||
m_endpoints.insert(endpoint->endpointId(), endpoint);
|
m_endpoints.append(endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
endpoint->handleZigbeeClusterLibraryIndication(indication);
|
endpoint->handleZigbeeClusterLibraryIndication(indication);
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ private:
|
||||||
|
|
||||||
ZigbeeNetwork *m_network;
|
ZigbeeNetwork *m_network;
|
||||||
ZigbeeDeviceObject *m_deviceObject = nullptr;
|
ZigbeeDeviceObject *m_deviceObject = nullptr;
|
||||||
QHash<quint8, ZigbeeNodeEndpoint *> m_endpoints;
|
QList<ZigbeeNodeEndpoint *> m_endpoints;
|
||||||
|
|
||||||
// Node descriptor information
|
// Node descriptor information
|
||||||
QByteArray m_nodeDescriptorRawData;
|
QByteArray m_nodeDescriptorRawData;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue