Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial version of the General Diagnostics Cluster #6690

Merged
merged 3 commits into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -1510,6 +1510,88 @@
}
]
},
{
"name": "General Diagnostics",
"code": 51,
"mfgCode": null,
"define": "GENERAL_DIAGNOSTICS_CLUSTER",
"side": "client",
"enabled": 0,
"commands": [],
"attributes": [
{
"name": "cluster revision",
"code": 65533,
"mfgCode": null,
"side": "client",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x0001",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
}
]
},
{
"name": "General Diagnostics",
"code": 51,
"mfgCode": null,
"define": "GENERAL_DIAGNOSTICS_CLUSTER",
"side": "server",
"enabled": 1,
"commands": [],
"attributes": [
{
"name": "NetworkInterfaces",
"code": 0,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "RebootCount",
"code": 1,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x0000",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "cluster revision",
"code": 65533,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x0001",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
}
]
},
{
"name": "WiFi Network Diagnostics",
"code": 54,
Expand Down
11 changes: 11 additions & 0 deletions examples/all-clusters-app/all-clusters-common/gen/af-structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,17 @@ typedef struct _NeighborInfo
uint8_t numberRssiMeasurements;
} EmberAfNeighborInfo;

// Struct for NetworkInterfaceType
typedef struct _NetworkInterfaceType
{
uint8_t * Name;
uint8_t FabricConnected;
uint8_t OffPremiseServicesReachableIPv4;
uint8_t OffPremiseServicesReachableIPv6;
uint64_t HardwareAddress;
uint8_t Type;
} EmberAfNetworkInterfaceType;

// Struct for NodeInformation
typedef struct _NodeInformation
{
Expand Down
14 changes: 14 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 @@ -421,6 +421,20 @@

// Server attributes

// Attribute ids for cluster: General Diagnostics

// Client attributes

// Server attributes
#define ZCL_NETWORK_INTERFACES_ATTRIBUTE_ID (0x0000)
#define ZCL_REBOOT_COUNT_ATTRIBUTE_ID (0x0001)
#define ZCL_UPTIME_ATTRIBUTE_ID (0x0002)
#define ZCL_TOTAL_OPERATIONAL_HOURS_ATTRIBUTE_ID (0x0003)
#define ZCL_BOOT_REASONS_ATTRIBUTE_ID (0x0004)
#define ZCL_ACTIVE_HARDWARE_FAULTS_ATTRIBUTE_ID (0x0005)
#define ZCL_ACTIVE_RADIO_FAULTS_ATTRIBUTE_ID (0x0006)
#define ZCL_ACTIVE_NETWORK_FAULTS_ATTRIBUTE_ID (0x0007)

// Attribute ids for cluster: WiFi Network Diagnostics

// Client attributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,47 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo
}
break;
}
case 0x0033: // General Diagnostics Cluster
{
uint16_t entryOffset = kSizeLengthInBytes;
switch (am->attributeId)
{
case 0x0000: // NetworkInterfaces
{
entryLength = 46;
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 _NetworkInterfaceType
_NetworkInterfaceType * entry = reinterpret_cast<_NetworkInterfaceType *>(write ? src : dest);
chip::ByteSpan * NameSpan = reinterpret_cast<chip::ByteSpan *>(&entry->Name); // CHAR_STRING
if (CHIP_NO_ERROR !=
(write ? WriteByteSpan(dest + entryOffset, 34, NameSpan) : ReadByteSpan(src + entryOffset, 34, NameSpan)))
{
ChipLogError(Zcl, "Index %l is invalid. Not enough remaining space", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + 34);
copyListMember(write ? dest : (uint8_t *) &entry->FabricConnected, write ? (uint8_t *) &entry->FabricConnected : src,
write, &entryOffset, sizeof(entry->FabricConnected)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv4,
write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv4 : src, write, &entryOffset,
sizeof(entry->OffPremiseServicesReachableIPv4)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv6,
write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv6 : src, write, &entryOffset,
sizeof(entry->OffPremiseServicesReachableIPv6)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *) &entry->HardwareAddress, write ? (uint8_t *) &entry->HardwareAddress : src,
write, &entryOffset, sizeof(entry->HardwareAddress)); // IEEE_ADDRESS
copyListMember(write ? dest : (uint8_t *) &entry->Type, write ? (uint8_t *) &entry->Type : src, write, &entryOffset,
sizeof(entry->Type)); // ENUM8
break;
}
}
break;
}
case 0xF004: // Group Key Management Cluster
{
uint16_t entryOffset = kSizeLengthInBytes;
Expand Down Expand Up @@ -178,8 +219,8 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo
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
chip::ByteSpan * GroupKeyRootSpan = &entry->GroupKeyRoot; // OCTET_STRING
&entryOffset, sizeof(entry->GroupKeyIndex)); // INT16U
chip::ByteSpan * GroupKeyRootSpan = reinterpret_cast<chip::ByteSpan *>(&entry->GroupKeyRoot); // OCTET_STRING
if (CHIP_NO_ERROR !=
(write ? WriteByteSpan(dest + entryOffset, 18, GroupKeyRootSpan)
: ReadByteSpan(src + entryOffset, 18, GroupKeyRootSpan)))
Expand Down Expand Up @@ -277,8 +318,8 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo
// 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
&entryOffset, sizeof(entry->fabricIndex)); // INT64U
chip::ByteSpan * operationalCertSpan = reinterpret_cast<chip::ByteSpan *>(&entry->operationalCert); // OCTET_STRING
if (CHIP_NO_ERROR !=
(write ? WriteByteSpan(dest + entryOffset, 34, operationalCertSpan)
: ReadByteSpan(src + entryOffset, 34, operationalCertSpan)))
Expand Down Expand Up @@ -332,6 +373,15 @@ uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attribut
break;
}
break;
case 0x0033: // General Diagnostics Cluster
switch (attributeId)
{
case 0x0000: // NetworkInterfaces
// Struct _NetworkInterfaceType
entryLength = 46;
break;
}
break;
case 0xF004: // Group Key Management Cluster
switch (attributeId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ EmberAfStatus emberAfColorControlClusterServerCommandParse(EmberAfClusterCommand
EmberAfStatus emberAfDescriptorClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfDoorLockClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfGeneralCommissioningClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfGeneralDiagnosticsClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfGroupKeyManagementClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfGroupsClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfIasZoneClusterServerCommandParse(EmberAfClusterCommand * cmd);
Expand Down Expand Up @@ -121,6 +122,10 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd)
case ZCL_GENERAL_COMMISSIONING_CLUSTER_ID:
result = emberAfGeneralCommissioningClusterServerCommandParse(cmd);
break;
case ZCL_GENERAL_DIAGNOSTICS_CLUSTER_ID:
// No commands are enabled for cluster General Diagnostics
result = status(false, true, cmd->mfgSpecific);
break;
case ZCL_GROUP_KEY_MANAGEMENT_CLUSTER_ID:
// No commands are enabled for cluster Group Key Management
result = status(false, true, cmd->mfgSpecific);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId)
case ZCL_GENERAL_COMMISSIONING_CLUSTER_ID:
emberAfGeneralCommissioningClusterInitCallback(endpoint);
break;
case ZCL_GENERAL_DIAGNOSTICS_CLUSTER_ID:
emberAfGeneralDiagnosticsClusterInitCallback(endpoint);
break;
case ZCL_GROUP_KEY_MANAGEMENT_CLUSTER_ID:
emberAfGroupKeyManagementClusterInitCallback(endpoint);
break;
Expand Down Expand Up @@ -156,6 +159,11 @@ void __attribute__((weak)) emberAfGeneralCommissioningClusterInitCallback(Endpoi
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfGeneralDiagnosticsClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfGroupKeyManagementClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
Expand Down
79 changes: 79 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 @@ -104,6 +104,14 @@ void emberAfDoorLockClusterInitCallback(chip::EndpointId endpoint);
*/
void emberAfGeneralCommissioningClusterInitCallback(chip::EndpointId endpoint);

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

/** @brief Group Key Management Cluster Init
*
* Cluster Init
Expand Down Expand Up @@ -819,6 +827,77 @@ EmberAfStatus emberAfGeneralCommissioningClusterServerPreAttributeChangedCallbac
*/
void emberAfGeneralCommissioningClusterServerTickCallback(chip::EndpointId endpoint);

//
// General Diagnostics Cluster server
//

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

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

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

/** @brief General Diagnostics Cluster Server Message Sent
*
* Server Message Sent
*
* @param type The type of message sent
* @param destination The destination 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 emberAfGeneralDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type,
chip::MessageSendDestination destination, EmberApsFrame * apsFrame,
uint16_t msgLen, uint8_t * message, EmberStatus status);

/** @brief General Diagnostics 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 emberAfGeneralDiagnosticsClusterServerPreAttributeChangedCallback(chip::EndpointId endpoint,
chip::AttributeId attributeId,
EmberAfAttributeType attributeType, uint16_t size,
uint8_t * value);

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

//
// Group Key Management Cluster server
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@
// Definitions for cluster: Network Commissioning
#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0x0031)

// Definitions for cluster: General Diagnostics
#define ZCL_GENERAL_DIAGNOSTICS_CLUSTER_ID (0x0033)

// Definitions for cluster: WiFi Network Diagnostics
#define ZCL_WIFI_NETWORK_DIAGNOSTICS_CLUSTER_ID (0x0036)

Expand Down
Loading