Skip to content

Commit

Permalink
Expose only fitting manufacturer specific commands (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
SwoopX authored Sep 30, 2024
1 parent eb85630 commit 5ade3f5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/zm_cluster_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void zmClusterInfo::showCluster(quint16 id, deCONZ::ZclClusterSide clusterSide)
ui->clusterGroupBox->setTitle(cluster->name() + " Cluster");
ui->clusterDescription->setText(cluster->description());
showAttributes();
ui->commandInfo->setCluster(sd->profileId(), *cluster, m_clusterSide);
ui->commandInfo->setCluster(sd->profileId(), *cluster, m_clusterSide, m_node);
return;
}

Expand Down Expand Up @@ -189,7 +189,7 @@ void zmClusterInfo::refresh()
if (cluster)
{
showAttributes();
ui->commandInfo->setCluster(sd->profileId(), *cluster, m_clusterSide);
ui->commandInfo->setCluster(sd->profileId(), *cluster, m_clusterSide, m_node);
}
}
}
Expand Down Expand Up @@ -218,7 +218,7 @@ void zmClusterInfo::refreshNodeCommands(deCONZ::zmNode *node, deCONZ::ZclCluster

if (sd && cl)
{
ui->commandInfo->setCluster(sd->profileId(), *cl, m_clusterSide);
ui->commandInfo->setCluster(sd->profileId(), *cl, m_clusterSide, m_node);
}
}
}
Expand Down
24 changes: 18 additions & 6 deletions src/zm_command_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "deconz/dbg_trace.h"
#include "zm_cluster_info.h"
#include "zm_command_info.h"
#include "zm_node.h"
#include "ui_zm_command_info.h"
#include "zcl_private.h"

Expand Down Expand Up @@ -54,13 +55,15 @@ zmCommandInfo::~zmCommandInfo()
delete ui;
}

void zmCommandInfo::setCluster(quint16 profileId, const deCONZ::ZclCluster &cluster, deCONZ::ZclClusterSide side)
void zmCommandInfo::setCluster(quint16 profileId, const deCONZ::ZclCluster &cluster, deCONZ::ZclClusterSide side, deCONZ::zmNode *node)
{
bool changed = false;

if (m_profileId != profileId
|| m_cluster.id() != cluster.id()
|| m_cluster.isServer() != cluster.isServer())
if (m_profileId != profileId || m_cluster.id() != cluster.id() || m_cluster.isServer() != cluster.isServer())
{
changed = true;
}
else if (node && m_node && node->nodeDescriptor().manufacturerCode() != m_node->nodeDescriptor().manufacturerCode())
{
changed = true;
}
Expand All @@ -70,15 +73,16 @@ void zmCommandInfo::setCluster(quint16 profileId, const deCONZ::ZclCluster &clus
m_side = side;
m_cluster = cluster;

// Gets general and cluster specific commands while providing an mfc != 0
if (changed)
{
if (m_cluster.isServer())
{
m_clusterOpposite = deCONZ::zclDataBase()->outCluster(m_profileId, m_cluster.oppositeId(), m_cluster.manufacturerCode());
m_clusterOpposite = deCONZ::zclDataBase()->outCluster(m_profileId, m_cluster.oppositeId(), node->nodeDescriptor().manufacturerCode());
}
else
{
m_clusterOpposite = deCONZ::zclDataBase()->inCluster(m_profileId, m_cluster.oppositeId(), m_cluster.manufacturerCode());
m_clusterOpposite = deCONZ::zclDataBase()->inCluster(m_profileId, m_cluster.oppositeId(), node->nodeDescriptor().manufacturerCode());
}
}

Expand All @@ -101,6 +105,12 @@ void zmCommandInfo::setCluster(quint16 profileId, const deCONZ::ZclCluster &clus
}
}
}

// Clear cache to ensure all relevant commands are exposed any bypass the following widget check
if (m_cache.size() != m_cluster.commands().size())
{
m_cache.clear();
}

// check if the widgets for this cluster already exist
bool found = false;
Expand Down Expand Up @@ -132,6 +142,8 @@ void zmCommandInfo::setCluster(quint16 profileId, const deCONZ::ZclCluster &clus
// done
return;
}

m_node = node;

// create new widgets
std::vector<deCONZ::ZclCommand>::const_iterator i;
Expand Down
4 changes: 3 additions & 1 deletion src/zm_command_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace deCONZ
class ApsDataIndication;
}

class zmNode;
class QPushButton;
class QLabel;
class QVBoxLayout;
Expand All @@ -36,7 +37,7 @@ class zmCommandInfo : public QWidget
public:
explicit zmCommandInfo(QWidget *parent = 0);
~zmCommandInfo();
void setCluster(quint16 profileId, const deCONZ::ZclCluster &cluster, deCONZ::ZclClusterSide side);
void setCluster(quint16 profileId, const deCONZ::ZclCluster &cluster, deCONZ::ZclClusterSide side, deCONZ::zmNode *node);

public Q_SLOTS:
void onExec(int commandId);
Expand Down Expand Up @@ -98,6 +99,7 @@ public Q_SLOTS:
deCONZ::ZclCluster m_clusterOpposite;
QList<CommandDescriptor> m_cache;
QSignalMapper *m_execMapper;
deCONZ::zmNode *m_node = nullptr;
};

#endif // ZM_COMMAND_INFO_H

0 comments on commit 5ade3f5

Please sign in to comment.