Skip to content

Commit

Permalink
Add a Test Cluster in order to validate the generation/implementation…
Browse files Browse the repository at this point in the history
… of the Data Model (#6445)

* Add a Test Cluster

* Activate the Test Cluster server into multiples ZAP configuration

* Update Darwin tests to use the Test Cluster

* Update gen/ folders
  • Loading branch information
vivien-apple authored May 4, 2021
1 parent 06a1db5 commit dab17fb
Show file tree
Hide file tree
Showing 115 changed files with 12,638 additions and 797 deletions.
1,104 changes: 889 additions & 215 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7846,6 +7846,44 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En

} // namespace Scenes

namespace TestCluster {

void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv)
{
{
switch (aCommandId)
{
case ZCL_TEST_COMMAND_ID: {

// TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
emberAfTestClusterClusterTestCallback(apCommandObj);
break;
}
case ZCL_TEST_NOT_HANDLED_COMMAND_ID: {

// TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
emberAfTestClusterClusterTestNotHandledCallback(apCommandObj);
break;
}
case ZCL_TEST_SPECIFIC_COMMAND_ID: {

// TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
emberAfTestClusterClusterTestSpecificCallback(apCommandObj);
break;
}
default: {
// Unrecognized command ID, error status will apply.
apCommandObj->AddStatusCode(nullptr, Protocols::SecureChannel::GeneralStatusCode::kNotFound,
Protocols::SecureChannel::Id, Protocols::SecureChannel::kProtocolCodeGeneralFailure);
ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, aCommandId, ZCL_TEST_CLUSTER_ID);
break;
}
}
}
}

} // namespace TestCluster

} // namespace clusters

void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aCommandId, chip::EndpointId aEndPointId,
Expand Down Expand Up @@ -7906,6 +7944,9 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC
case ZCL_SCENES_CLUSTER_ID:
clusters::Scenes::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
break;
case ZCL_TEST_CLUSTER_ID:
clusters::TestCluster::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
break;
default:
// Unrecognized cluster ID, error status will apply.
apCommandObj->AddStatusCode(nullptr, Protocols::SecureChannel::GeneralStatusCode::kNotFound, Protocols::SecureChannel::Id,
Expand Down
23 changes: 23 additions & 0 deletions examples/all-clusters-app/all-clusters-common/gen/attribute-id.h
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,29 @@

// Server attributes

// Attribute ids for cluster: Test Cluster

// Client attributes

// Server attributes
#define ZCL_BOOLEAN_ATTRIBUTE_ID (0x0000)
#define ZCL_BITMAP8_ATTRIBUTE_ID (0x0001)
#define ZCL_BITMAP16_ATTRIBUTE_ID (0x0002)
#define ZCL_BITMAP32_ATTRIBUTE_ID (0x0003)
#define ZCL_BITMAP64_ATTRIBUTE_ID (0x0004)
#define ZCL_INT8_U_ATTRIBUTE_ID (0x0005)
#define ZCL_INT16_U_ATTRIBUTE_ID (0x0006)
#define ZCL_INT32_U_ATTRIBUTE_ID (0x0008)
#define ZCL_INT64_U_ATTRIBUTE_ID (0x000C)
#define ZCL_INT8_S_ATTRIBUTE_ID (0x000D)
#define ZCL_INT16_S_ATTRIBUTE_ID (0x000E)
#define ZCL_INT32_S_ATTRIBUTE_ID (0x0010)
#define ZCL_INT64_S_ATTRIBUTE_ID (0x0014)
#define ZCL_ENUM8_ATTRIBUTE_ID (0x0015)
#define ZCL_ENUM16_ATTRIBUTE_ID (0x0016)
#define ZCL_OCTET_STRING_ATTRIBUTE_ID (0x0019)
#define ZCL_LIST_ATTRIBUTE_ID (0x001A)

// Attribute ids for cluster: Generic Tunnel

// Client attributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,26 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo
}
break;
}
case 0x050F: // Test Cluster Cluster
{
uint16_t entryOffset = kSizeLengthInBytes;
switch (am->attributeId)
{
case 0x001A: // list_int8u
{
entryLength = 1;
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));
copyListMember(dest, src, write, &entryOffset, entryLength); // INT8U
break;
}
}
break;
}
}

return entryLength;
Expand Down Expand Up @@ -281,6 +301,15 @@ uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attribut
break;
}
break;
case 0x050F: // Test Cluster Cluster
switch (attributeId)
{
case 0x001A: // list_int8u
// uint8_t
entryLength = 1;
break;
}
break;
}

uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ EmberAfStatus emberAfPumpConfigurationAndControlClusterServerCommandParse(EmberA
EmberAfStatus emberAfScenesClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfSwitchClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfTemperatureMeasurementClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfTestClusterClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfThermostatClusterServerCommandParse(EmberAfClusterCommand * cmd);

static EmberAfStatus status(bool wasHandled, bool clusterExists, bool mfgSpecific)
Expand Down Expand Up @@ -168,6 +169,9 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd)
// No commands are enabled for cluster Temperature Measurement
result = status(false, true, cmd->mfgSpecific);
break;
case ZCL_TEST_CLUSTER_ID:
result = emberAfTestClusterClusterServerCommandParse(cmd);
break;
case ZCL_THERMOSTAT_CLUSTER_ID:
// No commands are enabled for cluster Thermostat
result = status(false, true, cmd->mfgSpecific);
Expand Down Expand Up @@ -2525,3 +2529,31 @@ EmberAfStatus emberAfScenesClusterServerCommandParse(EmberAfClusterCommand * cmd
}
return status(wasHandled, true, cmd->mfgSpecific);
}
EmberAfStatus emberAfTestClusterClusterServerCommandParse(EmberAfClusterCommand * cmd)
{
bool wasHandled = false;

if (!cmd->mfgSpecific)
{
switch (cmd->commandId)
{
case ZCL_TEST_COMMAND_ID: {
wasHandled = emberAfTestClusterClusterTestCallback(nullptr);
break;
}
case ZCL_TEST_NOT_HANDLED_COMMAND_ID: {
wasHandled = emberAfTestClusterClusterTestNotHandledCallback(nullptr);
break;
}
case ZCL_TEST_SPECIFIC_COMMAND_ID: {
wasHandled = emberAfTestClusterClusterTestSpecificCallback(nullptr);
break;
}
default: {
// Unrecognized command ID, error status will apply.
break;
}
}
}
return status(wasHandled, true, cmd->mfgSpecific);
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId)
case ZCL_TEMP_MEASUREMENT_CLUSTER_ID:
emberAfTemperatureMeasurementClusterInitCallback(endpoint);
break;
case ZCL_TEST_CLUSTER_ID:
emberAfTestClusterClusterInitCallback(endpoint);
break;
case ZCL_THERMOSTAT_CLUSTER_ID:
emberAfThermostatClusterInitCallback(endpoint);
break;
Expand Down Expand Up @@ -222,6 +225,11 @@ void __attribute__((weak)) emberAfTemperatureMeasurementClusterInitCallback(Endp
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfTestClusterClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfThermostatClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
Expand Down
96 changes: 96 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 @@ -224,6 +224,14 @@ void emberAfSwitchClusterInitCallback(chip::EndpointId endpoint);
*/
void emberAfTemperatureMeasurementClusterInitCallback(chip::EndpointId endpoint);

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

/** @brief Thermostat Cluster Init
*
* Cluster Init
Expand Down Expand Up @@ -1851,6 +1859,76 @@ EmberAfStatus emberAfTemperatureMeasurementClusterServerPreAttributeChangedCallb
*/
void emberAfTemperatureMeasurementClusterServerTickCallback(chip::EndpointId endpoint);

//
// Test Cluster Cluster server
//

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

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

/** @brief Test Cluster 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 emberAfTestClusterClusterServerManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint,
chip::AttributeId attributeId,
uint16_t manufacturerCode);

/** @brief Test Cluster 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 emberAfTestClusterClusterServerMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination,
EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message,
EmberStatus status);

/** @brief Test Cluster 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 emberAfTestClusterClusterServerPreAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId,
EmberAfAttributeType attributeType, uint8_t size,
uint8_t * value);

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

//
// Thermostat Cluster server
//
Expand Down Expand Up @@ -2724,6 +2802,24 @@ bool emberAfScenesClusterStoreSceneCallback(chip::app::Command * commandObj, uin

bool emberAfScenesClusterViewSceneCallback(chip::app::Command * commandObj, uint16_t groupId, uint8_t sceneId);

/**
* @brief Test Cluster Cluster Test Command callback
*/

bool emberAfTestClusterClusterTestCallback(chip::app::Command * commandObj);

/**
* @brief Test Cluster Cluster TestNotHandled Command callback
*/

bool emberAfTestClusterClusterTestNotHandledCallback(chip::app::Command * commandObj);

/**
* @brief Test Cluster Cluster TestSpecific Command callback
*/

bool emberAfTestClusterClusterTestSpecificCallback(chip::app::Command * commandObj);

//
// Non-Cluster Related Callbacks
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3629,6 +3629,34 @@
\
ZCL_LOGIN_COMMAND_ID, "uu", tempAccountIdentifier, setupPIN);

/** @brief Command description for Test
*
* Command: Test
* @param returnValue INT8U
*/
#define emberAfFillCommandTest \
ClusterClusterTest(returnValue) emberAfFillExternalBuffer(mask, \
\
ZCL_TEST_COMMAND_ID, "u", returnValue);

/** @brief Command description for TestNotHandled
*
* Command: TestNotHandled
*/
#define emberAfFillCommandTest \
ClusterClusterTestNotHandled() emberAfFillExternalBuffer(mask, \
\
ZCL_TEST_NOT_HANDLED_COMMAND_ID, "", );

/** @brief Command description for TestSpecific
*
* Command: TestSpecific
*/
#define emberAfFillCommandTest \
ClusterClusterTestSpecific() emberAfFillExternalBuffer(mask, \
\
ZCL_TEST_SPECIFIC_COMMAND_ID, "", );

/** @brief Command description for MatchProtocolAddress
*
* Command: MatchProtocolAddress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@
// Definitions for cluster: Account Login
#define ZCL_ACCOUNT_LOGIN_CLUSTER_ID (0x050E)

// Definitions for cluster: Test Cluster
#define ZCL_TEST_CLUSTER_ID (0x050F)

// Definitions for cluster: Generic Tunnel
#define ZCL_GENERIC_TUNNEL_CLUSTER_ID (0x0600)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,12 @@
#define ZCL_GET_SETUP_PIN_RESPONSE_COMMAND_ID (0x00)
#define ZCL_LOGIN_COMMAND_ID (0x01)

// Commands for cluster: Test Cluster
#define ZCL_TEST_COMMAND_ID (0x00)
#define ZCL_TEST_SPECIFIC_RESPONSE_COMMAND_ID (0x00)
#define ZCL_TEST_NOT_HANDLED_COMMAND_ID (0x01)
#define ZCL_TEST_SPECIFIC_COMMAND_ID (0x02)

// Commands for cluster: Generic Tunnel
#define ZCL_MATCH_PROTOCOL_ADDRESS_COMMAND_ID (0x00)
#define ZCL_MATCH_PROTOCOL_ADDRESS_RESPONSE_COMMAND_ID (0x00)
Expand Down
Loading

0 comments on commit dab17fb

Please sign in to comment.