Skip to content

Commit

Permalink
Add List[OCTET_STRING] and List[Struct{N, OCTET_STRING] support (#6596)
Browse files Browse the repository at this point in the history
* Add List[OCTET_STRING] and List[Struct{N, OCTET_STRING] support

* Fix template

* Add some Lists to test-cluster

* Update zap files

* Update gen/ folders
  • Loading branch information
vivien-apple authored and pull[bot] committed Jul 3, 2021
1 parent e4d7e17 commit 126b84a
Show file tree
Hide file tree
Showing 81 changed files with 1,786 additions and 298 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3984,7 +3984,7 @@
"mfgCode": null,
"define": "TEST_CLUSTER",
"side": "server",
"enabled": 1,
"enabled": 0,
"commands": [
{
"name": "TestSpecificResponse",
Expand Down Expand Up @@ -4251,6 +4251,36 @@
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "list_octet_string",
"code": 27,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "list_struct_octet_string",
"code": 28,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "cluster revision",
"code": 65533,
Expand Down Expand Up @@ -8981,6 +9011,36 @@
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "list_octet_string",
"code": 27,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "list_struct_octet_string",
"code": 28,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "cluster revision",
"code": 65533,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,13 @@ typedef struct _SpecialDay
uint8_t dayIdRef;
} EmberAfSpecialDay;

// Struct for TestListStructOctet
typedef struct _TestListStructOctet
{
uint64_t fabricIndex;
chip::ByteSpan operationalCert;
} EmberAfTestListStructOctet;

// Struct for ThreadInterfaceScanResult
typedef struct _ThreadInterfaceScanResult
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,8 @@
#define ZCL_ENUM16_ATTRIBUTE_ID (0x0016)
#define ZCL_OCTET_STRING_ATTRIBUTE_ID (0x0019)
#define ZCL_LIST_ATTRIBUTE_ID (0x001A)
#define ZCL_LIST_OCTET_STRING_ATTRIBUTE_ID (0x001B)
#define ZCL_LIST_STRUCT_OCTET_STRING_ATTRIBUTE_ID (0x001C)

// Attribute ids for cluster: Generic Tunnel

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
// THIS FILE IS GENERATED BY ZAP

#include <app/util/af.h>
#include <app/util/attribute-list-byte-span.h>
#include <app/util/basic-types.h>
#include <support/SafeInt.h>
#include <support/logging/CHIPLogging.h>

#include "gen/af-structs.h"

using namespace chip;
using namespace chip::app::List;

// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid
// and data is undefined.
Expand Down Expand Up @@ -164,7 +166,7 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo
}
case 0x0001: // group keys
{
entryLength = 29;
entryLength = 31;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %l is invalid.", index);
Expand All @@ -177,8 +179,15 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo
&entryOffset, sizeof(entry->VendorId)); // INT16U
copyListMember(write ? dest : (uint8_t *) &entry->GroupKeyIndex, write ? (uint8_t *) &entry->GroupKeyIndex : src, write,
&entryOffset, sizeof(entry->GroupKeyIndex)); // INT16U
copyListMember(write ? dest : (uint8_t *) &entry->GroupKeyRoot, write ? (uint8_t *) &entry->GroupKeyRoot : src, write,
&entryOffset, 16); // OCTET_STRING
chip::ByteSpan * GroupKeyRootSpan = &entry->GroupKeyRoot; // OCTET_STRING
if (CHIP_NO_ERROR !=
(write ? WriteByteSpan(dest + entryOffset, 18, GroupKeyRootSpan)
: ReadByteSpan(src + entryOffset, 18, GroupKeyRootSpan)))
{
ChipLogError(Zcl, "Index %l is invalid. Not enough remaining space", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + 18);
copyListMember(write ? dest : (uint8_t *) &entry->GroupKeyEpochStartTime,
write ? (uint8_t *) &entry->GroupKeyEpochStartTime : src, write, &entryOffset,
sizeof(entry->GroupKeyEpochStartTime)); // INT64U
Expand Down Expand Up @@ -234,6 +243,52 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo
copyListMember(dest, src, write, &entryOffset, entryLength); // INT8U
break;
}
case 0x001B: // list_octet_string
{
entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, index - 1);
if (entryOffset == 0)
{
ChipLogError(Zcl, "Index %l is invalid.", index);
return 0;
}

chip::ByteSpan * list_octet_stringSpan = reinterpret_cast<chip::ByteSpan *>(write ? src : dest); // OCTET_STRING
uint16_t list_octet_stringRemainingSpace = static_cast<uint16_t>(am->size - entryOffset);
if (CHIP_NO_ERROR !=
(write ? WriteByteSpan(dest + entryOffset, list_octet_stringRemainingSpace, list_octet_stringSpan)
: ReadByteSpan(src + entryOffset, list_octet_stringRemainingSpace, list_octet_stringSpan)))
{
ChipLogError(Zcl, "Index %l is invalid. Not enough remaining space", index);
return 0;
}

entryLength = list_octet_stringSpan->size();
break;
}
case 0x001C: // list_struct_octet_string
{
entryLength = 42;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %l is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _TestListStructOctet
_TestListStructOctet * entry = reinterpret_cast<_TestListStructOctet *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *) &entry->fabricIndex, write ? (uint8_t *) &entry->fabricIndex : src, write,
&entryOffset, sizeof(entry->fabricIndex)); // INT64U
chip::ByteSpan * operationalCertSpan = &entry->operationalCert; // OCTET_STRING
if (CHIP_NO_ERROR !=
(write ? WriteByteSpan(dest + entryOffset, 34, operationalCertSpan)
: ReadByteSpan(src + entryOffset, 34, operationalCertSpan)))
{
ChipLogError(Zcl, "Index %l is invalid. Not enough remaining space", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + 34);
break;
}
}
break;
}
Expand Down Expand Up @@ -286,7 +341,7 @@ uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attribut
break;
case 0x0001: // group keys
// Struct _GroupKey
entryLength = 29;
entryLength = 31;
break;
}
break;
Expand All @@ -306,6 +361,14 @@ uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attribut
// uint8_t
entryLength = 1;
break;
case 0x001B: // list_octet_string
// chip::ByteSpan
return GetByteSpanOffsetFromIndex(buffer, 256, entryCount);
break;
case 0x001C: // list_struct_octet_string
// Struct _TestListStructOctet
entryLength = 42;
break;
}
break;
}
Expand Down
Loading

0 comments on commit 126b84a

Please sign in to comment.