Skip to content

Commit eb31e14

Browse files
authored
DDF support "cmd": "any" wildcard (dresden-elektronik#7452)
Mainly for "zcl:cmd" the command is still filtered for ClusterID but javascript can parse more than one CommandID.
1 parent 7254a51 commit eb31e14

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

device_access_fn.cpp

+34-7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "resource.h"
1717
#include "zcl/zcl.h"
1818

19+
20+
#define CMD_ID_ANY 0x100
1921
#define TIME_CLUSTER_ID 0x000A
2022

2123
#define TIME_ATTRID_TIME 0x0000
@@ -199,8 +201,16 @@ static ZCL_Param getZclParam(const QVariantMap &param)
199201

200202
if (param.contains(QLatin1String("cmd"))) // optional
201203
{
202-
result.commandId = variantToUint(param["cmd"], UINT8_MAX, &ok);
203-
result.hasCommandId = ok ? 1 : 0;
204+
if (param["cmd"].toString() == QLatin1String("any"))
205+
{
206+
result.commandId = CMD_ID_ANY;
207+
result.hasCommandId = 1;
208+
}
209+
else
210+
{
211+
result.commandId = variantToUint(param["cmd"], UINT32_MAX, &ok);
212+
result.hasCommandId = ok ? 1 : 0;
213+
}
204214
}
205215
else
206216
{
@@ -525,9 +535,16 @@ bool parseZclAttribute(Resource *r, ResourceItem *item, const deCONZ::ApsDataInd
525535
return result;
526536
}
527537

528-
if (param.hasCommandId && param.commandId != zclFrame.commandId())
538+
if (param.hasCommandId)
529539
{
530-
return result;
540+
if (param.commandId == CMD_ID_ANY)
541+
{
542+
543+
}
544+
else if (param.commandId != zclFrame.commandId())
545+
{
546+
return result;
547+
}
531548
}
532549
else if (!param.hasCommandId && param.attributeCount == 0)
533550
{
@@ -564,7 +581,10 @@ bool parseZclAttribute(Resource *r, ResourceItem *item, const deCONZ::ApsDataInd
564581
return result;
565582
}
566583

567-
if (!zclParam.hasCommandId && zclFrame.commandId() != deCONZ::ZclReadAttributesResponseId && zclFrame.commandId() != deCONZ::ZclReportAttributesId)
584+
if (!zclParam.hasCommandId &&
585+
zclFrame.isProfileWideCommand() &&
586+
zclFrame.commandId() != deCONZ::ZclReadAttributesResponseId &&
587+
zclFrame.commandId() != deCONZ::ZclReportAttributesId)
568588
{
569589
return result;
570590
}
@@ -581,9 +601,16 @@ bool parseZclAttribute(Resource *r, ResourceItem *item, const deCONZ::ApsDataInd
581601

582602
if (zclParam.attributeCount == 0) // attributes are optional
583603
{
584-
if (zclParam.hasCommandId && zclParam.commandId != zclFrame.commandId())
604+
if (zclParam.hasCommandId)
585605
{
586-
return result;
606+
if (zclParam.commandId == CMD_ID_ANY)
607+
{
608+
609+
}
610+
else if (zclParam.commandId != zclFrame.commandId())
611+
{
612+
return result;
613+
}
587614
}
588615

589616
if (evalZclFrame(r, item, ind, zclFrame, parseParameters))

zcl/zcl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ struct ZCL_Param
2727
std::array<uint16_t, MaxAttributes> attributes;
2828
uint16_t clusterId = 0;
2929
uint16_t manufacturerCode = 0;
30+
uint16_t commandId = 0;
3031
uint8_t endpoint = 0;
31-
uint8_t commandId = 0;
3232
struct {
3333
uint8_t valid : 1;
3434
uint8_t hasCommandId : 1;

0 commit comments

Comments
 (0)