Skip to content

Commit

Permalink
Update gen/ folder
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple committed Apr 7, 2021
1 parent 8a18259 commit 8e9ab5c
Show file tree
Hide file tree
Showing 56 changed files with 5,397 additions and 200 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
*/

// THIS FILE IS GENERATED BY ZAP

// List specific responses
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,15 @@ typedef struct _GroupInformationRecord
uint8_t groupType;
} EmberAfGroupInformationRecord;

// Struct for GroupKeys
typedef struct _GroupKeys
// Struct for GroupKey
typedef struct _GroupKey
{
uint16_t VendorId;
uint16_t GroupKeyIndex;
/* TYPE WARNING: array array defaults to */ uint8_t * GroupKeyRoot;
uint8_t * GroupKeyRoot;
uint64_t GroupKeyEpochStartTime;
uint8_t GroupKeySecurityPolicy;
} EmberAfGroupKeys;
} EmberAfGroupKey;

// Struct for GroupState
typedef struct _GroupState
Expand Down
218 changes: 218 additions & 0 deletions examples/all-clusters-app/all-clusters-common/gen/attribute-size.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
/*
*
* Copyright (c) 2021 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// THIS FILE IS GENERATED BY ZAP

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

#include "gen/af-structs.h"

using namespace chip;

// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid
// and data is undefined.
constexpr uint16_t kSizeLengthInBytes = 2u;

void copyListMember(uint8_t * dest, uint8_t * src, bool write, uint16_t * offset, uint16_t length)
{
if (write)
{
memmove(dest + *offset, src, length);
}
else
{
memmove(dest, src + *offset, length);
}

*offset = static_cast<uint16_t>(*offset + length);
}

uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src,
int32_t index)
{
if (index == -1)
{
memmove(dest, src, am->size);
return am->size;
}

if (index == 0)
{
uint16_t entryCount = emberAfGetInt16u(src, 0, kSizeLengthInBytes);
emberAfCopyInt16u(dest, 0, entryCount);
return kSizeLengthInBytes;
}

if (!chip::CanCastTo<uint16_t>(index))
{
ChipLogError(Zcl, "Index %l is invalid. Should be between 1 and 65534", index);
return 0;
}

uint16_t entryLength = 0;
switch (clusterId)
{
case 0x001D: // Descriptor Cluster
{
uint16_t entryOffset = kSizeLengthInBytes;
switch (am->attributeId)
{
case 0x0000: // device list
{
entryLength = 6;
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _DeviceType
_DeviceType * entry = reinterpret_cast<_DeviceType *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *) &entry->type, write ? (uint8_t *) &entry->type : src, write, &entryOffset,
sizeof(entry->type)); // DEVICE_TYPE_ID
copyListMember(write ? dest : (uint8_t *) &entry->revision, write ? (uint8_t *) &entry->revision : src, write,
&entryOffset, sizeof(entry->revision)); // INT16U
break;
}
case 0x0001: // server list
{
entryLength = 2;
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
copyListMember(dest, src, write, &entryOffset, entryLength); //
break;
}
case 0x0002: // client list
{
entryLength = 2;
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
copyListMember(dest, src, write, &entryOffset, entryLength); //
break;
}
case 0x0003: // parts list
{
entryLength = 1;
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
copyListMember(dest, src, write, &entryOffset, entryLength); //
break;
}
}
break;
}
case 0xF004: // Group Key Management Cluster
{
uint16_t entryOffset = kSizeLengthInBytes;
switch (am->attributeId)
{
case 0x0000: // groups
{
entryLength = 6;
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _GroupState
_GroupState * entry = reinterpret_cast<_GroupState *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write,
&entryOffset, sizeof(entry->VendorId)); // INT16U
copyListMember(write ? dest : (uint8_t *) &entry->VendorGroupId, write ? (uint8_t *) &entry->VendorGroupId : src, write,
&entryOffset, sizeof(entry->VendorGroupId)); // INT16U
copyListMember(write ? dest : (uint8_t *) &entry->GroupKeySetIndex, write ? (uint8_t *) &entry->GroupKeySetIndex : src,
write, &entryOffset, sizeof(entry->GroupKeySetIndex)); // INT16U
break;
}
case 0x0001: // group keys
{
entryLength = 29;
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _GroupKey
_GroupKey * entry = reinterpret_cast<_GroupKey *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write,
&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
copyListMember(write ? dest : (uint8_t *) &entry->GroupKeyEpochStartTime,
write ? (uint8_t *) &entry->GroupKeyEpochStartTime : src, write, &entryOffset,
sizeof(entry->GroupKeyEpochStartTime)); // INT64U
copyListMember(write ? dest : (uint8_t *) &entry->GroupKeySecurityPolicy,
write ? (uint8_t *) &entry->GroupKeySecurityPolicy : src, write, &entryOffset,
sizeof(entry->GroupKeySecurityPolicy)); // GroupKeySecurityPolicy
break;
}
}
break;
}
}

return entryLength;
}

// A list is a collection of entries of the same data type. The data type may be any defined data type.
uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attributeId, const uint8_t * buffer)
{
// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid
// and data is undefined.
uint16_t entryCount = emberAfGetInt16u(buffer, 0, kSizeLengthInBytes);
if (entryCount == 0xFFFF)
{
return 0;
}

uint16_t entryLength = 0;
switch (clusterId)
{
case 0x001D: // Descriptor Cluster
switch (attributeId)
{
case 0x0000: // device list
// Struct _DeviceType
entryLength = 6;
break;
case 0x0001: // server list
//
entryLength = 2;
break;
case 0x0002: // client list
//
entryLength = 2;
break;
case 0x0003: // parts list
//
entryLength = 1;
break;
}
break;
case 0xF004: // Group Key Management Cluster
switch (attributeId)
{
case 0x0000: // groups
// Struct _GroupState
entryLength = 6;
break;
case 0x0001: // group keys
// Struct _GroupKey
entryLength = 29;
break;
}
break;
}

uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength);
if (!chip::CanCastTo<uint16_t>(totalSize))
{
ChipLogError(Zcl, "Cluster 0x%04x: Size of attribute 0x%02x is too large.", clusterId, attributeId);
return 0;
}

return static_cast<uint16_t>(totalSize);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ EmberAfStatus emberAfBarrierControlClusterServerCommandParse(EmberAfClusterComma
EmberAfStatus emberAfBasicClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfBindingClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfColorControlClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfDescriptorClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfDoorLockClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfGeneralCommissioningClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfGroupKeyManagementClusterServerCommandParse(EmberAfClusterCommand * cmd);
Expand Down Expand Up @@ -101,6 +102,10 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd)
case ZCL_COLOR_CONTROL_CLUSTER_ID:
result = emberAfColorControlClusterServerCommandParse(cmd);
break;
case ZCL_DESCRIPTOR_CLUSTER_ID:
// No commands are enabled for cluster Descriptor
result = status(false, true, cmd->mfgSpecific);
break;
case ZCL_DOOR_LOCK_CLUSTER_ID:
result = emberAfDoorLockClusterServerCommandParse(cmd);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId)
case ZCL_COLOR_CONTROL_CLUSTER_ID:
emberAfColorControlClusterInitCallback(endpoint);
break;
case ZCL_DESCRIPTOR_CLUSTER_ID:
emberAfDescriptorClusterInitCallback(endpoint);
break;
case ZCL_DOOR_LOCK_CLUSTER_ID:
emberAfDoorLockClusterInitCallback(endpoint);
break;
Expand Down Expand Up @@ -111,6 +114,11 @@ void __attribute__((weak)) emberAfColorControlClusterInitCallback(EndpointId end
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfDescriptorClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfDoorLockClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
Expand Down
78 changes: 78 additions & 0 deletions examples/all-clusters-app/all-clusters-common/gen/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ void emberAfBindingClusterInitCallback(chip::EndpointId endpoint);
*/
void emberAfColorControlClusterInitCallback(chip::EndpointId endpoint);

/** @brief Descriptor Cluster Init
*
* Cluster Init
*
* @param endpoint Endpoint that is being initialized
*/
void emberAfDescriptorClusterInitCallback(chip::EndpointId endpoint);

/** @brief Door Lock Cluster Init
*
* Cluster Init
Expand Down Expand Up @@ -527,6 +535,76 @@ EmberAfStatus emberAfColorControlClusterServerPreAttributeChangedCallback(chip::
*/
void emberAfColorControlClusterServerTickCallback(chip::EndpointId endpoint);

//
// Descriptor Cluster server
//

/** @brief Descriptor Cluster Server Init
*
* Server Init
*
* @param endpoint Endpoint that is being initialized
*/
void emberAfDescriptorClusterServerInitCallback(chip::EndpointId endpoint);

/** @brief Descriptor Cluster Server Attribute Changed
*
* Server Attribute Changed
*
* @param endpoint Endpoint that is being initialized
* @param attributeId Attribute that changed
*/
void emberAfDescriptorClusterServerAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId);

/** @brief Descriptor Cluster Server Manufacturer Specific Attribute Changed
*
* Server Manufacturer Specific Attribute Changed
*
* @param endpoint Endpoint that is being initialized
* @param attributeId Attribute that changed
* @param manufacturerCode Manufacturer Code of the attribute that changed
*/
void emberAfDescriptorClusterServerManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint,
chip::AttributeId attributeId,
uint16_t manufacturerCode);

/** @brief Descriptor Cluster Server Message Sent
*
* Server Message Sent
*
* @param type The type of message sent
* @param indexOrDestination The destination or address to which the message was sent
* @param apsFrame The APS frame for the message
* @param msgLen The length of the message
* @param message The message that was sent
* @param status The status of the sent message
*/
void emberAfDescriptorClusterServerMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination,
EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message,
EmberStatus status);

/** @brief Descriptor Cluster Server Pre Attribute Changed
*
* server Pre Attribute Changed
*
* @param endpoint Endpoint that is being initialized
* @param attributeId Attribute to be changed
* @param attributeType Attribute type
* @param size Attribute size
* @param value Attribute value
*/
EmberAfStatus emberAfDescriptorClusterServerPreAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId,
EmberAfAttributeType attributeType, uint8_t size,
uint8_t * value);

/** @brief Descriptor Cluster Server Tick
*
* server Tick
*
* @param endpoint Endpoint that is being served
*/
void emberAfDescriptorClusterServerTickCallback(chip::EndpointId endpoint);

//
// Door Lock Cluster server
//
Expand Down
Loading

0 comments on commit 8e9ab5c

Please sign in to comment.