Skip to content

Commit

Permalink
Align Thread Network Diagnostics XML to the spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple committed May 26, 2023
1 parent 58420de commit 93d28f6
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 59 deletions.
10 changes: 5 additions & 5 deletions examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,12 @@ void AllClustersAppCommandHandler::OnGeneralFaultEventHandler(uint32_t eventId)
GeneralFaults<kMaxNetworkFaults> current;

// On Linux Simulation, set following radio faults statically.
ReturnOnFailure(previous.add(EMBER_ZCL_NETWORK_FAULT_ENUM_HARDWARE_FAILURE));
ReturnOnFailure(previous.add(EMBER_ZCL_NETWORK_FAULT_ENUM_NETWORK_JAMMED));
ReturnOnFailure(previous.add(to_underlying(Clusters::GeneralDiagnostics::NetworkFaultEnum::kHardwareFailure)));
ReturnOnFailure(previous.add(to_underlying(Clusters::GeneralDiagnostics::NetworkFaultEnum::kNetworkJammed)));

ReturnOnFailure(current.add(EMBER_ZCL_NETWORK_FAULT_ENUM_HARDWARE_FAILURE));
ReturnOnFailure(current.add(EMBER_ZCL_NETWORK_FAULT_ENUM_NETWORK_JAMMED));
ReturnOnFailure(current.add(EMBER_ZCL_NETWORK_FAULT_ENUM_CONNECTION_FAILED));
ReturnOnFailure(current.add(to_underlying(Clusters::GeneralDiagnostics::NetworkFaultEnum::kHardwareFailure)));
ReturnOnFailure(current.add(to_underlying(Clusters::GeneralDiagnostics::NetworkFaultEnum::kNetworkJammed)));
ReturnOnFailure(current.add(to_underlying(Clusters::GeneralDiagnostics::NetworkFaultEnum::kConnectionFailed)));
Clusters::GeneralDiagnosticsServer::Instance().OnNetworkFaultsDetect(previous, current);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ CHIP_ERROR GenericFaultTestEventTriggerDelegate::HandleEventTrigger(uint64_t eve
GeneralFaults<kMaxNetworkFaults> networkFaultsCurrent;

// Network faults injections
ReturnErrorOnFailure(networkFaultsPrevious.add(EMBER_ZCL_NETWORK_FAULT_ENUM_HARDWARE_FAILURE));
ReturnErrorOnFailure(networkFaultsPrevious.add(EMBER_ZCL_NETWORK_FAULT_ENUM_NETWORK_JAMMED));
using app::Clusters::GeneralDiagnostics::NetworkFaultEnum;
ReturnErrorOnFailure(networkFaultsPrevious.add(to_underlying(NetworkFaultEnum::kHardwareFailure)));
ReturnErrorOnFailure(networkFaultsPrevious.add(to_underlying(NetworkFaultEnum::kNetworkJammed)));

ReturnErrorOnFailure(networkFaultsCurrent.add(EMBER_ZCL_NETWORK_FAULT_ENUM_HARDWARE_FAILURE));
ReturnErrorOnFailure(networkFaultsCurrent.add(EMBER_ZCL_NETWORK_FAULT_ENUM_NETWORK_JAMMED));
ReturnErrorOnFailure(networkFaultsCurrent.add(EMBER_ZCL_NETWORK_FAULT_ENUM_CONNECTION_FAILED));
ReturnErrorOnFailure(networkFaultsCurrent.add(to_underlying(NetworkFaultEnum::kHardwareFailure)));
ReturnErrorOnFailure(networkFaultsCurrent.add(to_underlying(NetworkFaultEnum::kNetworkJammed)));
ReturnErrorOnFailure(networkFaultsCurrent.add(to_underlying(NetworkFaultEnum::kConnectionFailed)));

app::Clusters::GeneralDiagnosticsServer::Instance().OnNetworkFaultsDetect(networkFaultsPrevious, networkFaultsCurrent);
}
Expand Down
2 changes: 0 additions & 2 deletions src/app/common/templates/config-data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ WeakEnums:
- IdentifyIdentifyType
- InterfaceTypeEnum
- MoveMode
- NetworkFaultEnum
- PHYRateEnum
- RadioFaultEnum
- RoutingRole
- StepMode

DefineBitmaps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ limitations under the License.
-->
<configurator>
<domain name="CHIP"/>
<enum name="NetworkFault" type="ENUM8">
<enum name="NetworkFaultEnum" type="ENUM8">
<cluster code="0x0035"/>
<item name="Unspecified" value="0x00"/>
<item name="LinkDown" value="0x01"/>
<item name="HardwareFailure" value="0x02"/>
<item name="NetworkJammed" value="0x03"/>
</enum>
<enum name="RoutingRole" type="ENUM8">
<enum name="RoutingRoleEnum" type="ENUM8">
<cluster code="0x0035"/>
<item name="Unspecified" value="0x00"/>
<item name="Unassigned" value="0x01"/>
Expand All @@ -35,7 +35,7 @@ limitations under the License.
<item name="Connected" value="0x00"/>
<item name="NotConnected" value="0x01"/>
</enum>
<struct name="NeighborTable">
<struct name="NeighborTableStruct">
<cluster code="0x0035"/>
<item name="ExtAddress" type="INT64U"/>
<item name="Age" type="INT32U"/>
Expand All @@ -52,7 +52,7 @@ limitations under the License.
<item name="FullNetworkData" type="BOOLEAN"/>
<item name="IsChild" type="BOOLEAN"/>
</struct>
<struct name="RouteTable">
<struct name="RouteTableStruct">
<cluster code="0x0035"/>
<item name="ExtAddress" type="INT64U"/>
<item name="Rloc16" type="INT16U"/>
Expand Down Expand Up @@ -92,14 +92,14 @@ limitations under the License.
<define>THREAD_NETWORK_DIAGNOSTICS_CLUSTER</define>
<description>The Thread Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems</description>
<attribute side="server" code="0x00" define="CHANNEL" type="INT16U" min="0x00" max="0xFFFF" writable="false" isNullable="true" optional="false">Channel</attribute>
<attribute side="server" code="0x01" define="ROUTING_ROLE" type="RoutingRole" writable="false" isNullable="true" optional="false">RoutingRole</attribute>
<attribute side="server" code="0x01" define="ROUTING_ROLE" type="RoutingRoleEnum" writable="false" isNullable="true" optional="false">RoutingRole</attribute>
<attribute side="server" code="0x02" define="NETWORK_NAME" type="CHAR_STRING" length="16" writable="false" default="" isNullable="true" optional="false">NetworkName</attribute>
<attribute side="server" code="0x03" define="DIAG_PAN_ID" type="INT16U" min="0x0000" max="0xFFFF" writable="false" default="0x0000" isNullable="true" optional="false">PanId</attribute>
<attribute side="server" code="0x04" define="DIAG_EXTENDED_PAN_ID" type="INT64U" min="0x0000000000000000" max="0xFFFFFFFFFFFFFFFF" writable="false" default="0x0000000000000000" isNullable="true" optional="false">ExtendedPanId</attribute>
<attribute side="server" code="0x05" define="MESH_LOCAL_PREFIX" type="OCTET_STRING" length="17" writable="false" isNullable="true" optional="false">MeshLocalPrefix</attribute>
<attribute side="server" code="0x06" define="DIAG_OVERRUN_COUNT" type="INT64U" min="0x0000000000000000" max="0xFFFFFFFFFFFFFFFF" writable="false" default="0x0000000000000000" optional="true">OverrunCount</attribute>
<attribute side="server" code="0x07" define="NEIGHBOR_TABLE" type="ARRAY" entryType="NeighborTable" length="254" writable="false" optional="false">NeighborTable</attribute>
<attribute side="server" code="0x08" define="ROUTE_TABLE" type="ARRAY" entryType="RouteTable" length="254" writable="false" optional="false">RouteTable</attribute>
<attribute side="server" code="0x07" define="NEIGHBOR_TABLE" type="ARRAY" entryType="NeighborTableStruct" length="254" writable="false" optional="false">NeighborTable</attribute>
<attribute side="server" code="0x08" define="ROUTE_TABLE" type="ARRAY" entryType="RouteTableStruct" length="254" writable="false" optional="false">RouteTable</attribute>
<attribute side="server" code="0x09" define="PARTITION_ID" type="INT32U" min="0x00000000" max="0xFFFFFFFF" writable="false" isNullable="true" optional="false">PartitionId</attribute>
<attribute side="server" code="0x0A" define="WEIGHTING" type="INT8U" min="0x00" max="0xFF" writable="false" isNullable="true" optional="false">Weighting</attribute>
<attribute side="server" code="0x0B" define="DATA_VERSION" type="INT8U" min="0x00" max="0xFF" writable="false" isNullable="true" optional="false">DataVersion</attribute>
Expand Down Expand Up @@ -153,7 +153,7 @@ limitations under the License.
<attribute side="server" code="0x3B" define="SECURITY_POLICY" type="SecurityPolicy" writable="false" isNullable="true" optional="false">SecurityPolicy</attribute>
<attribute side="server" code="0x3C" define="DIAG_CHANNEL_MASK" type="OCTET_STRING" length="4" writable="false" isNullable="true" optional="false">ChannelPage0Mask</attribute>
<attribute side="server" code="0x3D" define="OPERATIONAL_DATASET_COMPONENTS" type="OperationalDatasetComponents" writable="false" isNullable="true" optional="false">OperationalDatasetComponents</attribute>
<attribute side="server" code="0x3E" define="ACTIVE_THREAD_NETWORK_FAULTS" type="ARRAY" entryType="NetworkFault" length="4" writable="false" optional="false">ActiveNetworkFaultsList</attribute>
<attribute side="server" code="0x3E" define="ACTIVE_THREAD_NETWORK_FAULTS" type="ARRAY" entryType="NetworkFaultEnum" length="4" writable="false" optional="false">ActiveNetworkFaultsList</attribute>
<command source="client" code="0x00" name="ResetCounts" optional="true" cli="chip thread_network_diagnostics resetcounts">
<description>Reception of this command SHALL reset the OverrunCount attributes to 0</description>
</command>
Expand All @@ -163,8 +163,8 @@ limitations under the License.
</event>
<event side="server" code="0x01" name="NetworkFaultChange" priority="info" optional="true">
<description>Indicate a change in the set of network faults currently detected by the Node</description>
<field id="0" name="Current" type="NetworkFault" array="true"/>
<field id="1" name="Previous" type="NetworkFault" array="true"/>
<field id="0" name="Current" type="NetworkFaultEnum" array="true"/>
<field id="1" name="Previous" type="NetworkFaultEnum" array="true"/>
</event>
</cluster>
<bitmap name="Feature" type="BITMAP32">
Expand Down
50 changes: 46 additions & 4 deletions src/darwin/Framework/CHIP/templates/availability.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3125,8 +3125,11 @@
- NetworkFaultType
- RadioFaultType
ThreadNetworkDiagnostics:
- NetworkFault
- RoutingRole
# NetworkFaultEnum and RoutingRoleEnum were originally just named
# NetworkFault and RoutingRole, but we generate the same API for
# both of those names, so the name can just change here.
- NetworkFaultEnum
- RoutingRoleEnum
- ThreadConnectionStatus
WiFiNetworkDiagnostics:
# AssociationFailureCauseEnum was originally just named
Expand Down Expand Up @@ -3519,12 +3522,15 @@
- BLEFault
- EthernetFault
ThreadNetworkDiagnostics:
NetworkFault:
# NetworkFaultEnum and RoutingRoleEnum were originally just named
# NetworkFault and RoutingRole, but we generate the same API for
# both of those names, so the name can just change here.
NetworkFaultEnum:
- Unspecified
- LinkDown
- HardwareFailure
- NetworkJammed
RoutingRole:
RoutingRoleEnum:
- Unspecified
- Unassigned
- SleepyEndDevice
Expand Down Expand Up @@ -7418,6 +7424,9 @@
- ProductAppearanceStruct
TemperatureControl:
- TemperatureLevelStruct
ThreadNetworkDiagnostics:
- NeighborTableStruct
- RouteTableStruct
struct fields:
AccessControl:
AccessControlTargetStruct:
Expand All @@ -7436,6 +7445,33 @@
TemperatureLevelStruct:
- label
- temperatureLevel
ThreadNetworkDiagnostics:
NeighborTableStruct:
- extAddress
- age
- rloc16
- linkFrameCounter
- mleFrameCounter
- lqi
- averageRssi
- lastRssi
- frameErrorRate
- messageErrorRate
- rxOnWhenIdle
- fullThreadDevice
- fullNetworkData
- isChild
RouteTableStruct:
- extAddress
- rloc16
- routerId
- nextHop
- pathCost
- lqiIn
- lqiOut
- age
- allocated
- linkEstablished
events:
RefrigeratorAlarm:
- Notify
Expand Down Expand Up @@ -7872,6 +7908,9 @@
structs:
AccessControl:
- Target
ThreadNetworkDiagnostics:
- NeighborTable
- RouteTable
bitmaps:
Groups:
- GroupClusterFeature
Expand All @@ -7891,6 +7930,9 @@
structs:
AccessControl:
AccessControlTargetStruct: Target
ThreadNetworkDiagnostics:
NeighborTableStruct: NeighborTable
RouteTableStruct: RouteTable
enum values:
TimeSynchronization:
TimeSourceEnum:
Expand Down
6 changes: 3 additions & 3 deletions src/platform/Linux/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,9 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetActiveNetworkFaults(GeneralFaults<kMax
{
#if CHIP_CONFIG_TEST
// On Linux Simulation, set following radio faults statically.
ReturnErrorOnFailure(networkFaults.add(EMBER_ZCL_NETWORK_FAULT_ENUM_HARDWARE_FAILURE));
ReturnErrorOnFailure(networkFaults.add(EMBER_ZCL_NETWORK_FAULT_ENUM_NETWORK_JAMMED));
ReturnErrorOnFailure(networkFaults.add(EMBER_ZCL_NETWORK_FAULT_ENUM_CONNECTION_FAILED));
ReturnErrorOnFailure(networkFaults.add(to_underlying(NetworkFaultEnum::kHardwareFailure)));
ReturnErrorOnFailure(networkFaults.add(to_underlying(NetworkFaultEnum::kNetworkJammed)));
ReturnErrorOnFailure(networkFaults.add(to_underlying(NetworkFaultEnum::kConnectionFailed)));
#endif

return CHIP_NO_ERROR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1061,42 +1061,43 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_WriteThreadNetw
break;

case ThreadNetworkDiagnostics::Attributes::RoutingRole::Id: {
ThreadNetworkDiagnostics::RoutingRole routingRole;
using ThreadNetworkDiagnostics::RoutingRoleEnum;
RoutingRoleEnum routingRole;
otDeviceRole otRole = otThreadGetDeviceRole(mOTInst);

if (otRole == OT_DEVICE_ROLE_DISABLED)
{
routingRole = EMBER_ZCL_ROUTING_ROLE_UNSPECIFIED;
routingRole = RoutingRoleEnum::kUnspecified;
}
else if (otRole == OT_DEVICE_ROLE_DETACHED)
{
routingRole = EMBER_ZCL_ROUTING_ROLE_UNASSIGNED;
routingRole = RoutingRoleEnum::kUnassigned;
}
else if (otRole == OT_DEVICE_ROLE_ROUTER)
{
routingRole = EMBER_ZCL_ROUTING_ROLE_ROUTER;
routingRole = RoutingRoleEnum::kRouter;
}
else if (otRole == OT_DEVICE_ROLE_LEADER)
{
routingRole = EMBER_ZCL_ROUTING_ROLE_LEADER;
routingRole = RoutingRoleEnum::kLeader;
}
else if (otRole == OT_DEVICE_ROLE_CHILD)
{
otLinkModeConfig linkMode = otThreadGetLinkMode(mOTInst);

if (linkMode.mRxOnWhenIdle)
{
routingRole = EMBER_ZCL_ROUTING_ROLE_END_DEVICE;
routingRole = RoutingRoleEnum::kEndDevice;
#if CHIP_DEVICE_CONFIG_THREAD_FTD
if (otThreadIsRouterEligible(mOTInst))
{
routingRole = EMBER_ZCL_ROUTING_ROLE_REED;
routingRole = RoutingRoleEnum::kReed;
}
#endif
}
else
{
routingRole = EMBER_ZCL_ROUTING_ROLE_SLEEPY_END_DEVICE;
routingRole = RoutingRoleEnum::kSleepyEndDevice;
}
}

Expand Down Expand Up @@ -1149,7 +1150,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_WriteThreadNetw

while (otThreadGetNextNeighborInfo(mOTInst, &iterator, &neighInfo) == OT_ERROR_NONE)
{
ThreadNetworkDiagnostics::Structs::NeighborTable::Type neighborTable;
ThreadNetworkDiagnostics::Structs::NeighborTableStruct::Type neighborTable;
app::DataModel::Nullable<int8_t> averageRssi;
app::DataModel::Nullable<int8_t> lastRssi;

Expand Down Expand Up @@ -1209,7 +1210,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_WriteThreadNetw
{
if (otThreadGetRouterInfo(mOTInst, i, &routerInfo) == OT_ERROR_NONE)
{
ThreadNetworkDiagnostics::Structs::RouteTable::Type routeTable;
ThreadNetworkDiagnostics::Structs::RouteTableStruct::Type routeTable;

routeTable.extAddress = Encoding::BigEndian::Get64(routerInfo.mExtAddress.m8);
routeTable.rloc16 = routerInfo.mRloc16;
Expand All @@ -1233,7 +1234,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_WriteThreadNetw
otError otErr = otThreadGetParentInfo(mOTInst, &routerInfo);
ReturnErrorOnFailure(MapOpenThreadError(otErr));

ThreadNetworkDiagnostics::Structs::RouteTable::Type routeTable;
ThreadNetworkDiagnostics::Structs::RouteTableStruct::Type routeTable;

routeTable.extAddress = Encoding::BigEndian::Get64(routerInfo.mExtAddress.m8);
routeTable.rloc16 = routerInfo.mRloc16;
Expand Down Expand Up @@ -1661,7 +1662,8 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_WriteThreadNetw
case ThreadNetworkDiagnostics::Attributes::ActiveNetworkFaultsList::Id: {
err = encoder.EncodeList([](const auto & aEncoder) -> CHIP_ERROR {
// TODO activeNetworkFaultsList isn't tracked. Encode the list of 4 entries at 0 none the less
ThreadNetworkDiagnostics::NetworkFault activeNetworkFaultsList[4] = { ThreadNetworkDiagnostics::NetworkFault(0) };
ThreadNetworkDiagnostics::NetworkFaultEnum activeNetworkFaultsList[4] = { ThreadNetworkDiagnostics::NetworkFaultEnum(
0) };
for (auto fault : activeNetworkFaultsList)
{
ReturnErrorOnFailure(aEncoder.Encode(fault));
Expand Down
6 changes: 3 additions & 3 deletions src/platform/bouffalolab/BL702/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetActiveRadioFaults(GeneralFaults<kMaxRa
CHIP_ERROR DiagnosticDataProviderImpl::GetActiveNetworkFaults(GeneralFaults<kMaxNetworkFaults> & networkFaults)
{
#if CHIP_CONFIG_TEST
ReturnErrorOnFailure(networkFaults.add(EMBER_ZCL_NETWORK_FAULT_ENUM_HARDWARE_FAILURE));
ReturnErrorOnFailure(networkFaults.add(EMBER_ZCL_NETWORK_FAULT_ENUM_NETWORK_JAMMED));
ReturnErrorOnFailure(networkFaults.add(EMBER_ZCL_NETWORK_FAULT_ENUM_CONNECTION_FAILED));
ReturnErrorOnFailure(networkFaults.add(to_underlying(NetworkFaultEnum::kHardwareFailure)));
ReturnErrorOnFailure(networkFaults.add(to_underlying(NetworkFaultEnum::kNetworkJammed)));
ReturnErrorOnFailure(networkFaults.add(to_underlying(NetworkFaultEnum::kConnectionFailed)));
#endif

return CHIP_NO_ERROR;
Expand Down
8 changes: 5 additions & 3 deletions src/platform/cc13xx_26xx/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,11 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetActiveRadioFaults(GeneralFaults<kMaxRa
CHIP_ERROR DiagnosticDataProviderImpl::GetActiveNetworkFaults(GeneralFaults<kMaxNetworkFaults> & networkFaults)
{
#if CHIP_CONFIG_TEST
ReturnErrorOnFailure(networkFaults.add(EMBER_ZCL_NETWORK_FAULT_ENUM_HARDWARE_FAILURE));
ReturnErrorOnFailure(networkFaults.add(EMBER_ZCL_NETWORK_FAULT_ENUM_NETWORK_JAMMED));
ReturnErrorOnFailure(networkFaults.add(EMBER_ZCL_NETWORK_FAULT_ENUM_CONNECTION_FAILED));
using app::Clusters::GeneralDiagnostics::NetworkFaultEnum;

ReturnErrorOnFailure(networkFaults.add(to_underlying(NetworkFaultEnum::kHardwareFailure)));
ReturnErrorOnFailure(networkFaults.add(to_underlying(NetworkFaultEnum::kNetworkJammed)));
ReturnErrorOnFailure(networkFaults.add(to_underlying(NetworkFaultEnum::kConnectionFailed)));
#endif

return CHIP_NO_ERROR;
Expand Down
6 changes: 3 additions & 3 deletions src/platform/mt793x/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetActiveRadioFaults(GeneralFaults<kMaxRa
CHIP_ERROR DiagnosticDataProviderImpl::GetActiveNetworkFaults(GeneralFaults<kMaxNetworkFaults> & networkFaults)
{
#if CHIP_CONFIG_TEST
ReturnErrorOnFailure(networkFaults.add(EMBER_ZCL_NETWORK_FAULT_ENUM_HARDWARE_FAILURE));
ReturnErrorOnFailure(networkFaults.add(EMBER_ZCL_NETWORK_FAULT_ENUM_NETWORK_JAMMED));
ReturnErrorOnFailure(networkFaults.add(EMBER_ZCL_NETWORK_FAULT_ENUM_CONNECTION_FAILED));
ReturnErrorOnFailure(networkFaults.add(to_underlying(NetworkFaultEnum::kHardwareFailure)));
ReturnErrorOnFailure(networkFaults.add(to_underlying(NetworkFaultEnum::kNetworkJammed)));
ReturnErrorOnFailure(networkFaults.add(to_underlying(NetworkFaultEnum::kConnectionFailed)));
#endif

return CHIP_NO_ERROR;
Expand Down
Loading

0 comments on commit 93d28f6

Please sign in to comment.