diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni index 09d11860c7fed5..d4d4913a120ca6 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -356,6 +356,12 @@ template("chip_data_model") { "${_app_root}/clusters/${cluster}/${cluster}.h", "${_app_root}/clusters/${cluster}/EnergyReportingTestEventTriggerHandler.h", ] + } else if (cluster == "thread-network-diagnostics-server") { + sources += [ + "${_app_root}/clusters/${cluster}/${cluster}.cpp", + "${_app_root}/clusters/${cluster}/thread-network-diagnostics-provider.cpp", + "${_app_root}/clusters/${cluster}/thread-network-diagnostics-provider.h", + ] } else { sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp" ] } diff --git a/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-provider.cpp b/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-provider.cpp new file mode 100644 index 00000000000000..26a988b1c51450 --- /dev/null +++ b/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-provider.cpp @@ -0,0 +1,861 @@ +/* + * Copyright (c) 2024 Project CHIP Authors + * All rights reserved. + * + * 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. + */ + +#include "thread-network-diagnostics-provider.h" + +#include +#include +#include +#include + +#if (CHIP_DEVICE_CONFIG_ENABLE_THREAD && !CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK) +#include +#include + +#if CHIP_DEVICE_CONFIG_THREAD_FTD +#include +#endif // CHIP_DEVICE_CONFIG_THREAD_FTD +#endif // (CHIP_DEVICE_CONFIG_ENABLE_THREAD && !CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK) + +using namespace chip::DeviceLayer; + +namespace chip { +namespace app { +namespace Clusters { +namespace ThreadNetworkDiagnostics { + +/* + * @brief Get runtime value from the thread network based on the given attribute ID. + * The info is encoded via the AttributeValueEncoder. + * + * @param attributeId Id of the attribute for the requested info. + * @param aEncoder Encoder to encode the attribute value. + * + * @return CHIP_NO_ERROR = Succes. + * CHIP_ERROR_NOT_IMPLEMENTED = Runtime value for this attribute not yet available to send as reply + * Use standard read. + * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE = Is not a Runtime readable attribute. Use standard read + * All other errors should be treated as a read error and reported as such. + * + * @note This function implementation can compile in 3 different outcomes + * (1) CHIP_DEVICE_CONFIG_ENABLE_THREAD && !CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK: + * - Generic implementation fetching the valid thread network data from the thread stack and encoding it respectively to + * the attributeID received. + * (2) CHIP_DEVICE_CONFIG_ENABLE_THREAD && CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK: + * - Encode a NULL value for nullable attributes or 0 for the others. + * - Devices using the ot-br-posix dbus stack have not yet provided the API to fetch the needed thread informations. + * (3) None of the conditions above + * - returns CHIP_ERROR_NOT_IMPLEMENTED. + */ +CHIP_ERROR WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder) +{ + CHIP_ERROR err; +#if (CHIP_DEVICE_CONFIG_ENABLE_THREAD && !CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK) + otInstance * otInst = ThreadStackMgrImpl().OTInstance(); + + if (!otDatasetIsCommissioned(otInst)) + { + // For the following nullable attributes of the cluster, encodeNull since + // thread instance cannot provide the relevant data when it is not currently configured. + // + // Note that RoutingRole is nullable but not listed here as thread provides + // valid data even when disabled or detached + switch (attributeId) + { + case Attributes::Channel::Id: + case Attributes::NetworkName::Id: + case Attributes::PanId::Id: + case Attributes::ExtendedPanId::Id: + case Attributes::MeshLocalPrefix::Id: + case Attributes::PartitionId::Id: + case Attributes::Weighting::Id: + case Attributes::DataVersion::Id: + case Attributes::StableDataVersion::Id: + case Attributes::LeaderRouterId::Id: + case Attributes::ActiveTimestamp::Id: + case Attributes::PendingTimestamp::Id: + case Attributes::Delay::Id: + case Attributes::SecurityPolicy::Id: + case Attributes::ChannelPage0Mask::Id: + case Attributes::OperationalDatasetComponents::Id: + return encoder.EncodeNull(); + } + } + + switch (attributeId) + { + case Attributes::Channel::Id: { + uint16_t channel = otLinkGetChannel(otInst); + err = encoder.Encode(channel); + } + break; + + case Attributes::RoutingRole::Id: { + using ThreadNetworkDiagnostics::RoutingRoleEnum; + RoutingRoleEnum routingRole; + otDeviceRole otRole = otThreadGetDeviceRole(otInst); + + if (otRole == OT_DEVICE_ROLE_DISABLED) + { + routingRole = RoutingRoleEnum::kUnspecified; + } + else if (otRole == OT_DEVICE_ROLE_DETACHED) + { + routingRole = RoutingRoleEnum::kUnassigned; + } + else if (otRole == OT_DEVICE_ROLE_ROUTER) + { + routingRole = RoutingRoleEnum::kRouter; + } + else if (otRole == OT_DEVICE_ROLE_LEADER) + { + routingRole = RoutingRoleEnum::kLeader; + } + else if (otRole == OT_DEVICE_ROLE_CHILD) + { + otLinkModeConfig linkMode = otThreadGetLinkMode(otInst); + + if (linkMode.mRxOnWhenIdle) + { + routingRole = RoutingRoleEnum::kEndDevice; +#if CHIP_DEVICE_CONFIG_THREAD_FTD + if (otThreadIsRouterEligible(otInst)) + { + routingRole = RoutingRoleEnum::kReed; + } +#endif + } + else + { + routingRole = RoutingRoleEnum::kSleepyEndDevice; + } + } + + err = encoder.Encode(routingRole); + } + break; + + case Attributes::NetworkName::Id: { + const char * networkName = otThreadGetNetworkName(otInst); + err = encoder.Encode(CharSpan::fromCharString(networkName)); + } + break; + + case Attributes::PanId::Id: { + uint16_t panId = otLinkGetPanId(otInst); + err = encoder.Encode(panId); + } + break; + + case Attributes::ExtendedPanId::Id: { + const otExtendedPanId * pExtendedPanid = otThreadGetExtendedPanId(otInst); + err = encoder.Encode(Encoding::BigEndian::Get64(pExtendedPanid->m8)); + } + break; + + case Attributes::MeshLocalPrefix::Id: { + uint8_t meshLocaPrefix[OT_MESH_LOCAL_PREFIX_SIZE + 1] = { 0 }; // + 1 to encode prefix Len in the octstr + + const otMeshLocalPrefix * pMeshLocalPrefix = otThreadGetMeshLocalPrefix(otInst); + meshLocaPrefix[0] = OT_IP6_PREFIX_BITSIZE; + + memcpy(&meshLocaPrefix[1], pMeshLocalPrefix->m8, OT_MESH_LOCAL_PREFIX_SIZE); + err = encoder.Encode(ByteSpan(meshLocaPrefix)); + } + break; + + case Attributes::OverrunCount::Id: { + uint64_t overrunCount = 0; // mOverrunCount; + err = encoder.Encode(overrunCount); + } + break; + + case Attributes::NeighborTable::Id: { + err = encoder.EncodeList([otInst](const auto & aEncoder) -> CHIP_ERROR { + constexpr uint16_t kFrameErrorRate100Percent = 0xffff; + constexpr uint16_t kMessageErrorRate100Percent = 0xffff; + + otNeighborInfo neighInfo; + otNeighborInfoIterator iterator = OT_NEIGHBOR_INFO_ITERATOR_INIT; + + while (otThreadGetNextNeighborInfo(otInst, &iterator, &neighInfo) == OT_ERROR_NONE) + { + Structs::NeighborTableStruct::Type neighborTable; + app::DataModel::Nullable averageRssi; + app::DataModel::Nullable lastRssi; + + if (neighInfo.mAverageRssi == OT_RADIO_RSSI_INVALID) + { + averageRssi.SetNull(); + } + else + { + // Thread average calculation already restrict mAverageRssi to be between -128 and 0 + averageRssi.SetNonNull(neighInfo.mAverageRssi); + } + + if (neighInfo.mLastRssi == OT_RADIO_RSSI_INVALID) + { + lastRssi.SetNull(); + } + else + { + lastRssi.SetNonNull(min(static_cast(0), neighInfo.mLastRssi)); + } + + neighborTable.averageRssi = averageRssi; + neighborTable.lastRssi = lastRssi; + neighborTable.extAddress = Encoding::BigEndian::Get64(neighInfo.mExtAddress.m8); + neighborTable.age = neighInfo.mAge; + neighborTable.rloc16 = neighInfo.mRloc16; + neighborTable.linkFrameCounter = neighInfo.mLinkFrameCounter; + neighborTable.mleFrameCounter = neighInfo.mMleFrameCounter; + neighborTable.lqi = neighInfo.mLinkQualityIn; + neighborTable.frameErrorRate = + static_cast((static_cast(neighInfo.mFrameErrorRate) * 100) / kFrameErrorRate100Percent); + neighborTable.messageErrorRate = + static_cast((static_cast(neighInfo.mMessageErrorRate) * 100) / kMessageErrorRate100Percent); + neighborTable.rxOnWhenIdle = neighInfo.mRxOnWhenIdle; + neighborTable.fullThreadDevice = neighInfo.mFullThreadDevice; + neighborTable.fullNetworkData = neighInfo.mFullNetworkData; + neighborTable.isChild = neighInfo.mIsChild; + + ReturnErrorOnFailure(aEncoder.Encode(neighborTable)); + } + + return CHIP_NO_ERROR; + }); + } + break; + + case Attributes::RouteTable::Id: { + err = encoder.EncodeList([otInst](const auto & aEncoder) -> CHIP_ERROR { + otRouterInfo routerInfo; + +#if CHIP_DEVICE_CONFIG_THREAD_FTD + uint8_t maxRouterId = otThreadGetMaxRouterId(otInst); + CHIP_ERROR chipErr = CHIP_ERROR_INCORRECT_STATE; + + for (uint8_t i = 0; i <= maxRouterId; i++) + { + if (otThreadGetRouterInfo(otInst, i, &routerInfo) == OT_ERROR_NONE) + { + Structs::RouteTableStruct::Type routeTable; + + routeTable.extAddress = Encoding::BigEndian::Get64(routerInfo.mExtAddress.m8); + routeTable.rloc16 = routerInfo.mRloc16; + routeTable.routerId = routerInfo.mRouterId; + routeTable.nextHop = routerInfo.mNextHop; + routeTable.pathCost = routerInfo.mPathCost; + routeTable.LQIIn = routerInfo.mLinkQualityIn; + routeTable.LQIOut = routerInfo.mLinkQualityOut; + routeTable.age = routerInfo.mAge; + routeTable.allocated = routerInfo.mAllocated; + routeTable.linkEstablished = routerInfo.mLinkEstablished; + + ReturnErrorOnFailure(aEncoder.Encode(routeTable)); + chipErr = CHIP_NO_ERROR; + } + } + + return chipErr; + +#else // OPENTHREAD_MTD + otError otErr = otThreadGetParentInfo(otInst, &routerInfo); + ReturnErrorOnFailure(Internal::MapOpenThreadError(otErr)); + + Structs::RouteTableStruct::Type routeTable; + + routeTable.extAddress = Encoding::BigEndian::Get64(routerInfo.mExtAddress.m8); + routeTable.rloc16 = routerInfo.mRloc16; + routeTable.routerId = routerInfo.mRouterId; + routeTable.nextHop = routerInfo.mNextHop; + routeTable.pathCost = routerInfo.mPathCost; + routeTable.LQIIn = routerInfo.mLinkQualityIn; + routeTable.LQIOut = routerInfo.mLinkQualityOut; + routeTable.age = routerInfo.mAge; + routeTable.allocated = routerInfo.mAllocated; + routeTable.linkEstablished = routerInfo.mLinkEstablished; + + ReturnErrorOnFailure(aEncoder.Encode(routeTable)); + return CHIP_NO_ERROR; +#endif + }); + } + break; + + case Attributes::PartitionId::Id: { + uint32_t partitionId = otThreadGetPartitionId(otInst); + err = encoder.Encode(partitionId); + } + break; + + case Attributes::Weighting::Id: { + uint8_t weight = otThreadGetLeaderWeight(otInst); + err = encoder.Encode(weight); + } + break; + + case Attributes::DataVersion::Id: { + uint8_t dataVersion = otNetDataGetVersion(otInst); + err = encoder.Encode(dataVersion); + } + break; + + case Attributes::StableDataVersion::Id: { + uint8_t stableVersion = otNetDataGetStableVersion(otInst); + err = encoder.Encode(stableVersion); + } + break; + + case Attributes::LeaderRouterId::Id: { + uint8_t leaderRouterId = otThreadGetLeaderRouterId(otInst); + err = encoder.Encode(leaderRouterId); + } + break; + + case Attributes::DetachedRoleCount::Id: { + uint16_t detachedRole = otThreadGetMleCounters(otInst)->mDetachedRole; + err = encoder.Encode(detachedRole); + } + break; + + case Attributes::ChildRoleCount::Id: { + uint16_t childRole = otThreadGetMleCounters(otInst)->mChildRole; + err = encoder.Encode(childRole); + } + break; + + case Attributes::RouterRoleCount::Id: { + uint16_t routerRole = otThreadGetMleCounters(otInst)->mRouterRole; + err = encoder.Encode(routerRole); + } + break; + + case Attributes::LeaderRoleCount::Id: { + uint16_t leaderRole = otThreadGetMleCounters(otInst)->mLeaderRole; + err = encoder.Encode(leaderRole); + } + break; + + case Attributes::AttachAttemptCount::Id: { + uint16_t attachAttempts = otThreadGetMleCounters(otInst)->mAttachAttempts; + err = encoder.Encode(attachAttempts); + } + break; + + case Attributes::PartitionIdChangeCount::Id: { + uint16_t partitionIdChanges = otThreadGetMleCounters(otInst)->mPartitionIdChanges; + err = encoder.Encode(partitionIdChanges); + } + break; + + case Attributes::BetterPartitionAttachAttemptCount::Id: { + uint16_t betterPartitionAttachAttempts = otThreadGetMleCounters(otInst)->mBetterPartitionAttachAttempts; + err = encoder.Encode(betterPartitionAttachAttempts); + } + break; + + case Attributes::ParentChangeCount::Id: { + uint16_t parentChanges = otThreadGetMleCounters(otInst)->mParentChanges; + err = encoder.Encode(parentChanges); + } + break; + + case Attributes::TxTotalCount::Id: { + uint32_t txTotal = otLinkGetCounters(otInst)->mTxTotal; + err = encoder.Encode(txTotal); + } + break; + + case Attributes::TxUnicastCount::Id: { + uint32_t txUnicast = otLinkGetCounters(otInst)->mTxUnicast; + err = encoder.Encode(txUnicast); + } + break; + + case Attributes::TxBroadcastCount::Id: { + uint32_t txBroadcast = otLinkGetCounters(otInst)->mTxBroadcast; + err = encoder.Encode(txBroadcast); + } + break; + + case Attributes::TxAckRequestedCount::Id: { + uint32_t txAckRequested = otLinkGetCounters(otInst)->mTxAckRequested; + err = encoder.Encode(txAckRequested); + } + break; + + case Attributes::TxAckedCount::Id: { + uint32_t txAcked = otLinkGetCounters(otInst)->mTxAcked; + err = encoder.Encode(txAcked); + } + break; + + case Attributes::TxNoAckRequestedCount::Id: { + uint32_t txNoAckRequested = otLinkGetCounters(otInst)->mTxNoAckRequested; + err = encoder.Encode(txNoAckRequested); + } + break; + + case Attributes::TxDataCount::Id: { + uint32_t txData = otLinkGetCounters(otInst)->mTxData; + err = encoder.Encode(txData); + } + break; + + case Attributes::TxDataPollCount::Id: { + uint32_t txDataPoll = otLinkGetCounters(otInst)->mTxDataPoll; + err = encoder.Encode(txDataPoll); + } + break; + + case Attributes::TxBeaconCount::Id: { + uint32_t txBeacon = otLinkGetCounters(otInst)->mTxBeacon; + err = encoder.Encode(txBeacon); + } + break; + + case Attributes::TxBeaconRequestCount::Id: { + uint32_t txBeaconRequest = otLinkGetCounters(otInst)->mTxBeaconRequest; + err = encoder.Encode(txBeaconRequest); + } + break; + + case Attributes::TxOtherCount::Id: { + uint32_t txOther = otLinkGetCounters(otInst)->mTxOther; + err = encoder.Encode(txOther); + } + break; + + case Attributes::TxRetryCount::Id: { + uint32_t txRetry = otLinkGetCounters(otInst)->mTxRetry; + err = encoder.Encode(txRetry); + } + break; + + case Attributes::TxDirectMaxRetryExpiryCount::Id: { + uint32_t txDirectMaxRetryExpiry = otLinkGetCounters(otInst)->mTxDirectMaxRetryExpiry; + err = encoder.Encode(txDirectMaxRetryExpiry); + } + break; + + case Attributes::TxIndirectMaxRetryExpiryCount::Id: { + uint32_t txIndirectMaxRetryExpiry = otLinkGetCounters(otInst)->mTxIndirectMaxRetryExpiry; + err = encoder.Encode(txIndirectMaxRetryExpiry); + } + break; + + case Attributes::TxErrCcaCount::Id: { + uint32_t txErrCca = otLinkGetCounters(otInst)->mTxErrCca; + err = encoder.Encode(txErrCca); + } + break; + + case Attributes::TxErrAbortCount::Id: { + uint32_t TxErrAbort = otLinkGetCounters(otInst)->mTxErrAbort; + err = encoder.Encode(TxErrAbort); + } + break; + + case Attributes::TxErrBusyChannelCount::Id: { + uint32_t TxErrBusyChannel = otLinkGetCounters(otInst)->mTxErrBusyChannel; + err = encoder.Encode(TxErrBusyChannel); + } + break; + + case Attributes::RxTotalCount::Id: { + uint32_t rxTotal = otLinkGetCounters(otInst)->mRxTotal; + err = encoder.Encode(rxTotal); + } + break; + + case Attributes::RxUnicastCount::Id: { + uint32_t rxUnicast = otLinkGetCounters(otInst)->mRxUnicast; + err = encoder.Encode(rxUnicast); + } + break; + + case Attributes::RxBroadcastCount::Id: { + uint32_t rxBroadcast = otLinkGetCounters(otInst)->mRxBroadcast; + err = encoder.Encode(rxBroadcast); + } + break; + + case Attributes::RxDataCount::Id: { + uint32_t rxData = otLinkGetCounters(otInst)->mRxData; + err = encoder.Encode(rxData); + } + break; + + case Attributes::RxDataPollCount::Id: { + uint32_t rxDataPoll = otLinkGetCounters(otInst)->mRxDataPoll; + err = encoder.Encode(rxDataPoll); + } + break; + + case Attributes::RxBeaconCount::Id: { + uint32_t rxBeacon = otLinkGetCounters(otInst)->mRxBeacon; + err = encoder.Encode(rxBeacon); + } + break; + + case Attributes::RxBeaconRequestCount::Id: { + uint32_t rxBeaconRequest = otLinkGetCounters(otInst)->mRxBeaconRequest; + err = encoder.Encode(rxBeaconRequest); + } + break; + + case Attributes::RxOtherCount::Id: { + uint32_t rxOther = otLinkGetCounters(otInst)->mRxOther; + err = encoder.Encode(rxOther); + } + break; + + case Attributes::RxAddressFilteredCount::Id: { + uint32_t rxAddressFiltered = otLinkGetCounters(otInst)->mRxAddressFiltered; + err = encoder.Encode(rxAddressFiltered); + } + break; + + case Attributes::RxDestAddrFilteredCount::Id: { + uint32_t rxDestAddrFiltered = otLinkGetCounters(otInst)->mRxDestAddrFiltered; + err = encoder.Encode(rxDestAddrFiltered); + } + break; + + case Attributes::RxDuplicatedCount::Id: { + uint32_t rxDuplicated = otLinkGetCounters(otInst)->mRxDuplicated; + err = encoder.Encode(rxDuplicated); + } + break; + + case Attributes::RxErrNoFrameCount::Id: { + uint32_t rxErrNoFrame = otLinkGetCounters(otInst)->mRxErrNoFrame; + err = encoder.Encode(rxErrNoFrame); + } + break; + + case Attributes::RxErrUnknownNeighborCount::Id: { + uint32_t rxErrUnknownNeighbor = otLinkGetCounters(otInst)->mRxErrUnknownNeighbor; + err = encoder.Encode(rxErrUnknownNeighbor); + } + break; + + case Attributes::RxErrInvalidSrcAddrCount::Id: { + uint32_t rxErrInvalidSrcAddr = otLinkGetCounters(otInst)->mRxErrInvalidSrcAddr; + err = encoder.Encode(rxErrInvalidSrcAddr); + } + break; + + case Attributes::RxErrSecCount::Id: { + uint32_t rxErrSec = otLinkGetCounters(otInst)->mRxErrSec; + err = encoder.Encode(rxErrSec); + } + break; + + case Attributes::RxErrFcsCount::Id: { + uint32_t rxErrFcs = otLinkGetCounters(otInst)->mRxErrFcs; + err = encoder.Encode(rxErrFcs); + } + break; + + case Attributes::RxErrOtherCount::Id: { + uint32_t rxErrOther = otLinkGetCounters(otInst)->mRxErrOther; + err = encoder.Encode(rxErrOther); + } + break; + + case Attributes::ActiveTimestamp::Id: { + otOperationalDataset activeDataset; + otError otErr = otDatasetGetActive(otInst, &activeDataset); + VerifyOrReturnError(otErr == OT_ERROR_NONE, Internal::MapOpenThreadError(otErr)); + uint64_t activeTimestamp = (activeDataset.mActiveTimestamp.mSeconds << 16) | (activeDataset.mActiveTimestamp.mTicks << 1) | + activeDataset.mActiveTimestamp.mAuthoritative; + err = encoder.Encode(activeTimestamp); + } + break; + + case Attributes::PendingTimestamp::Id: { + otOperationalDataset activeDataset; + otError otErr = otDatasetGetActive(otInst, &activeDataset); + VerifyOrReturnError(otErr == OT_ERROR_NONE, Internal::MapOpenThreadError(otErr)); + uint64_t pendingTimestamp = (activeDataset.mPendingTimestamp.mSeconds << 16) | + (activeDataset.mPendingTimestamp.mTicks << 1) | activeDataset.mPendingTimestamp.mAuthoritative; + err = encoder.Encode(pendingTimestamp); + } + break; + + case Attributes::Delay::Id: { + otOperationalDataset activeDataset; + otError otErr = otDatasetGetActive(otInst, &activeDataset); + VerifyOrReturnError(otErr == OT_ERROR_NONE, Internal::MapOpenThreadError(otErr)); + uint32_t delay = activeDataset.mDelay; + err = encoder.Encode(delay); + } + break; + + case Attributes::SecurityPolicy::Id: { + otOperationalDataset activeDataset; + otError otErr = otDatasetGetActive(otInst, &activeDataset); + VerifyOrReturnError(otErr == OT_ERROR_NONE, Internal::MapOpenThreadError(otErr)); + + Structs::SecurityPolicy::Type securityPolicy; + static_assert(sizeof(securityPolicy) == sizeof(activeDataset.mSecurityPolicy), + "securityPolicy Struct do not match otSecurityPolicy"); + uint16_t policyAsInts[2]; + static_assert(sizeof(policyAsInts) == sizeof(activeDataset.mSecurityPolicy), + "We're missing some members of otSecurityPolicy?"); + memcpy(&policyAsInts, &activeDataset.mSecurityPolicy, sizeof(policyAsInts)); + securityPolicy.rotationTime = policyAsInts[0]; + securityPolicy.flags = policyAsInts[1]; + err = encoder.Encode(securityPolicy); + } + break; + + case Attributes::ChannelPage0Mask::Id: { + otOperationalDataset activeDataset; + otError otErr = otDatasetGetActive(otInst, &activeDataset); + VerifyOrReturnError(otErr == OT_ERROR_NONE, Internal::MapOpenThreadError(otErr)); + + // In the resultant Octet string, the most significant bit of the left-most byte indicates channel 0 + // We have to bitswap the entire uint32_t before converting to octet string + uint32_t bitSwappedChannelMask = 0; + for (int i = 0, j = 31; i < 32; i++, j--) + { + bitSwappedChannelMask |= ((activeDataset.mChannelMask >> j) & 1) << i; + } + + uint8_t buffer[sizeof(uint32_t)] = { 0 }; + Encoding::BigEndian::Put32(buffer, bitSwappedChannelMask); + err = encoder.Encode(ByteSpan(buffer)); + } + break; + + case Attributes::OperationalDatasetComponents::Id: { + otOperationalDataset activeDataset; + otError otErr = otDatasetGetActive(otInst, &activeDataset); + VerifyOrReturnError(otErr == OT_ERROR_NONE, Internal::MapOpenThreadError(otErr)); + Structs::OperationalDatasetComponents::Type OpDatasetComponents; + + OpDatasetComponents.activeTimestampPresent = activeDataset.mComponents.mIsActiveTimestampPresent; + OpDatasetComponents.pendingTimestampPresent = activeDataset.mComponents.mIsPendingTimestampPresent; + OpDatasetComponents.masterKeyPresent = activeDataset.mComponents.mIsNetworkKeyPresent; + OpDatasetComponents.networkNamePresent = activeDataset.mComponents.mIsNetworkNamePresent; + OpDatasetComponents.extendedPanIdPresent = activeDataset.mComponents.mIsExtendedPanIdPresent; + OpDatasetComponents.meshLocalPrefixPresent = activeDataset.mComponents.mIsMeshLocalPrefixPresent; + OpDatasetComponents.delayPresent = activeDataset.mComponents.mIsDelayPresent; + OpDatasetComponents.panIdPresent = activeDataset.mComponents.mIsPanIdPresent; + OpDatasetComponents.channelPresent = activeDataset.mComponents.mIsChannelPresent; + OpDatasetComponents.pskcPresent = activeDataset.mComponents.mIsPskcPresent; + OpDatasetComponents.securityPolicyPresent = activeDataset.mComponents.mIsSecurityPolicyPresent; + OpDatasetComponents.channelMaskPresent = activeDataset.mComponents.mIsChannelMaskPresent; + + err = encoder.Encode(OpDatasetComponents); + } + break; + + case 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 + NetworkFaultEnum activeNetworkFaultsList[4] = { NetworkFaultEnum(0) }; + for (auto fault : activeNetworkFaultsList) + { + ReturnErrorOnFailure(aEncoder.Encode(fault)); + } + + return CHIP_NO_ERROR; + }); + } + break; + + default: { + err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; + } + break; + } + +#elif (CHIP_DEVICE_CONFIG_ENABLE_THREAD && CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK) + switch (attributeId) + { + case Attributes::NeighborTable::Id: + case Attributes::RouteTable::Id: + case Attributes::ActiveNetworkFaultsList::Id: + err = encoder.EncodeEmptyList(); + break; + case Attributes::Channel::Id: + case Attributes::RoutingRole::Id: + case Attributes::NetworkName::Id: + case Attributes::PanId::Id: + case Attributes::ExtendedPanId::Id: + case Attributes::MeshLocalPrefix::Id: + case Attributes::PartitionId::Id: + case Attributes::Weighting::Id: + case Attributes::DataVersion::Id: + case Attributes::StableDataVersion::Id: + case Attributes::LeaderRouterId::Id: + case Attributes::ActiveTimestamp::Id: + case Attributes::PendingTimestamp::Id: + case Attributes::Delay::Id: + case Attributes::ChannelPage0Mask::Id: + case Attributes::SecurityPolicy::Id: + case Attributes::OperationalDatasetComponents::Id: + err = encoder.EncodeNull(); + break; + case Attributes::OverrunCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::DetachedRoleCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::ChildRoleCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RouterRoleCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::LeaderRoleCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::AttachAttemptCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::PartitionIdChangeCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::BetterPartitionAttachAttemptCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::ParentChangeCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxTotalCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxUnicastCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxBroadcastCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxAckRequestedCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxAckedCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxNoAckRequestedCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxDataCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxDataPollCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxBeaconCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxBeaconRequestCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxOtherCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxRetryCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxDirectMaxRetryExpiryCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxIndirectMaxRetryExpiryCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxErrCcaCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxErrAbortCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxErrBusyChannelCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxTotalCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxUnicastCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxBroadcastCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxDataCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxDataPollCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxBeaconCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxBeaconRequestCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxOtherCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxAddressFilteredCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxDestAddrFilteredCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxDuplicatedCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxErrNoFrameCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxErrUnknownNeighborCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxErrInvalidSrcAddrCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxErrSecCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxErrFcsCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxErrOtherCount::Id: + err = encoder.Encode(static_cast(0)); + break; + default: + err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; + break; + } +#else + err = CHIP_ERROR_NOT_IMPLEMENTED; +#endif // (CHIP_DEVICE_CONFIG_ENABLE_THREAD && !CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK) + return err; +} + +} // namespace ThreadNetworkDiagnostics +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-provider.h b/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-provider.h new file mode 100644 index 00000000000000..8b1a2a5640ce38 --- /dev/null +++ b/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-provider.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Project CHIP Authors + * All rights reserved. + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include + +namespace chip { +namespace app { +namespace Clusters { +namespace ThreadNetworkDiagnostics { + +CHIP_ERROR WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder); + +} // namespace ThreadNetworkDiagnostics +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp b/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp index 9908fc77c91334..cae2948e8e970e 100644 --- a/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp +++ b/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -29,7 +30,6 @@ #include #include #include -#include using namespace chip; using namespace chip::app; @@ -125,7 +125,7 @@ CHIP_ERROR ThreadDiagosticsAttrAccess::Read(const ConcreteReadAttributePath & aP case ThreadNetworkDiagnostics::Attributes::PendingTimestamp::Id: case ThreadNetworkDiagnostics::Attributes::Delay::Id: case ThreadNetworkDiagnostics::Attributes::ChannelPage0Mask::Id: - return ConnectivityMgr().WriteThreadNetworkDiagnosticAttributeToTlv(aPath.mAttributeId, aEncoder); + return WriteThreadNetworkDiagnosticAttributeToTlv(aPath.mAttributeId, aEncoder); default: break; } diff --git a/src/include/platform/CHIPDeviceConfig.h b/src/include/platform/CHIPDeviceConfig.h index b203c997db8ff8..6ee7d9c9634999 100644 --- a/src/include/platform/CHIPDeviceConfig.h +++ b/src/include/platform/CHIPDeviceConfig.h @@ -953,6 +953,17 @@ static_assert(CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MIN < CHIP_DEVICE_ #ifndef CHIP_DEVICE_CONFIG_THREAD_BORDER_ROUTER #define CHIP_DEVICE_CONFIG_THREAD_BORDER_ROUTER 0 #endif + +/** + * CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK + * + * Indicate if the matter device thread stack is implemented using the ot-br-posix dbus API + * Rather than the standard openthread stack api + * + */ +#ifndef CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK +#define CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK 0 +#endif /** * CHIP_DEVICE_CONFIG_THREAD_TASK_NAME * diff --git a/src/include/platform/ConnectivityManager.h b/src/include/platform/ConnectivityManager.h index e874773886e51b..70f9d48a6bef07 100644 --- a/src/include/platform/ConnectivityManager.h +++ b/src/include/platform/ConnectivityManager.h @@ -202,7 +202,6 @@ class ConnectivityManager bool IsThreadProvisioned(); void ErasePersistentInfo(); void ResetThreadNetworkDiagnosticsCounts(); - CHIP_ERROR WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder); CHIP_ERROR SetPollingInterval(System::Clock::Milliseconds32 pollingInterval); @@ -477,25 +476,6 @@ inline void ConnectivityManager::ResetThreadNetworkDiagnosticsCounts() static_cast(this)->_ResetThreadNetworkDiagnosticsCounts(); } -/* - * @brief Get runtime value from the thread network based on the given attribute ID. - * The info is encoded via the AttributeValueEncoder. - * - * @param attributeId Id of the attribute for the requested info. - * @param aEncoder Encoder to encode the attribute value. - * - * @return CHIP_NO_ERROR = Succes. - * CHIP_ERROR_NOT_IMPLEMENTED = Runtime value for this attribute to yet available to send as reply - * Use standard read. - * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE = Is not a Runtime readable attribute. Use standard read - * All other errors should be treated as a read error and reported as such. - */ -inline CHIP_ERROR ConnectivityManager::WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, - app::AttributeValueEncoder & encoder) -{ - return static_cast(this)->_WriteThreadNetworkDiagnosticAttributeToTlv(attributeId, encoder); -} - inline Ble::BleLayer * ConnectivityManager::GetBleLayer() { return static_cast(this)->_GetBleLayer(); diff --git a/src/include/platform/ThreadStackManager.h b/src/include/platform/ThreadStackManager.h index b6c9a7e38dd7d5..86d895ec1cfe52 100644 --- a/src/include/platform/ThreadStackManager.h +++ b/src/include/platform/ThreadStackManager.h @@ -132,7 +132,6 @@ class ThreadStackManager #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT void ResetThreadNetworkDiagnosticsCounts(void); - CHIP_ERROR WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder); private: // ===== Members for internal use by the following friends. @@ -425,24 +424,5 @@ inline void ThreadStackManager::ResetThreadNetworkDiagnosticsCounts() static_cast(this)->_ResetThreadNetworkDiagnosticsCounts(); } -/* - * @brief Get runtime value from the thread network based on the given attribute ID. - * The info is encoded via the AttributeValueEncoder. - * - * @param attributeId Id of the attribute for the requested info. - * @param aEncoder Encoder to encode the attribute value. - * - * @return CHIP_NO_ERROR = Succes. - * CHIP_ERROR_NOT_IMPLEMENTED = Runtime value for this attribute to yet available to send as reply - * Use standard read. - * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE = Is not a Runtime readable attribute. Use standard read - * All other errors should be treated as a read error and reported as such. - */ -inline CHIP_ERROR ThreadStackManager::WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, - app::AttributeValueEncoder & encoder) -{ - return static_cast(this)->_WriteThreadNetworkDiagnosticAttributeToTlv(attributeId, encoder); -} - } // namespace DeviceLayer } // namespace chip diff --git a/src/include/platform/internal/GenericConnectivityManagerImpl_NoThread.h b/src/include/platform/internal/GenericConnectivityManagerImpl_NoThread.h index e7af04965182fa..c84f2160a1457b 100755 --- a/src/include/platform/internal/GenericConnectivityManagerImpl_NoThread.h +++ b/src/include/platform/internal/GenericConnectivityManagerImpl_NoThread.h @@ -54,8 +54,6 @@ class GenericConnectivityManagerImpl_NoThread bool _IsThreadProvisioned(void); void _ErasePersistentInfo(void); void _ResetThreadNetworkDiagnosticsCounts(void); - CHIP_ERROR _WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder); - ImplClass * Impl() { return static_cast(this); } }; @@ -116,100 +114,6 @@ template inline void GenericConnectivityManagerImpl_NoThread::_ResetThreadNetworkDiagnosticsCounts() {} -template -inline CHIP_ERROR GenericConnectivityManagerImpl_NoThread::_WriteThreadNetworkDiagnosticAttributeToTlv( - AttributeId attributeId, app::AttributeValueEncoder & encoder) -{ - // If we get here the Thread Network Diagnostic cluster is enabled on the device but doesn't run thread. - // Encode Null or default values for all attributes of the cluster. - CHIP_ERROR err = CHIP_NO_ERROR; - switch (attributeId) - { - // Encode EmptyList - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RouteTable::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::NeighborTable::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::ActiveNetworkFaultsList::Id: - err = encoder.EncodeEmptyList(); - break; - // Encode Null - case app::Clusters::ThreadNetworkDiagnostics::Attributes::Channel::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RoutingRole::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::NetworkName::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::PanId::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::ExtendedPanId::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::MeshLocalPrefix::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::PartitionId::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::Weighting::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::DataVersion::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::StableDataVersion::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::LeaderRouterId::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::ActiveTimestamp::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::PendingTimestamp::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::Delay::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::ChannelPage0Mask::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::SecurityPolicy::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::OperationalDatasetComponents::Id: - err = encoder.EncodeNull(); - break; - // Encode UINT64_T 0 - case app::Clusters::ThreadNetworkDiagnostics::Attributes::OverrunCount::Id: - err = encoder.Encode(static_cast(0)); - break; - // Encode UINT16_T 0 - case app::Clusters::ThreadNetworkDiagnostics::Attributes::DetachedRoleCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::ChildRoleCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RouterRoleCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::LeaderRoleCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::AttachAttemptCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::PartitionIdChangeCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::BetterPartitionAttachAttemptCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::ParentChangeCount::Id: - err = encoder.Encode(static_cast(0)); - break; - // Encode UINT32_T 0 - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxTotalCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxUnicastCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxBroadcastCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxAckedCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxAckRequestedCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxNoAckRequestedCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxDataCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxDataPollCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxBeaconCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxBeaconRequestCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxOtherCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxRetryCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxDirectMaxRetryExpiryCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxIndirectMaxRetryExpiryCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxErrCcaCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxErrAbortCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxErrBusyChannelCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxTotalCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxUnicastCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxBroadcastCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxDataCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxDataPollCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxBeaconCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxBeaconRequestCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxOtherCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxAddressFilteredCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxDestAddrFilteredCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxDuplicatedCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrNoFrameCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrUnknownNeighborCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrInvalidSrcAddrCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrSecCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrFcsCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrOtherCount::Id: - err = encoder.Encode(static_cast(0)); - break; - default: - err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; - break; - } - - return err; -} } // namespace Internal } // namespace DeviceLayer } // namespace chip diff --git a/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.h b/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.h index a1d24c2e1c80d4..456d843c488224 100755 --- a/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.h +++ b/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.h @@ -70,7 +70,6 @@ class GenericConnectivityManagerImpl_Thread bool _IsThreadProvisioned(); void _ErasePersistentInfo(); void _ResetThreadNetworkDiagnosticsCounts(); - CHIP_ERROR _WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder); // ===== Members for use by the implementation subclass. @@ -154,14 +153,6 @@ inline void GenericConnectivityManagerImpl_Thread::_ResetThreadNetwor ThreadStackMgrImpl().ResetThreadNetworkDiagnosticsCounts(); } -template -inline CHIP_ERROR -GenericConnectivityManagerImpl_Thread::_WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, - app::AttributeValueEncoder & encoder) -{ - return ThreadStackMgrImpl().WriteThreadNetworkDiagnosticAttributeToTlv(attributeId, encoder); -} - } // namespace Internal } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index c81a268849fa1e..f8dcd3b9d5f1e6 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -111,11 +111,20 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { chip_enable_wifi && chip_device_platform != "darwin" chip_stack_lock_tracking_log = chip_stack_lock_tracking != "none" chip_stack_lock_tracking_fatal = chip_stack_lock_tracking == "fatal" + + # This is used to identify which platforms implement their ThreadStackManager + # with the otbr posix dbus api. + chip_device_uses_otbr_posix_dbus = + chip_enable_openthread && + (chip_device_platform == "linux" || chip_device_platform == "tizen" || + chip_device_platform == "webos") + defines = [ "CHIP_DEVICE_CONFIG_ENABLE_WPA=${chip_device_config_enable_wpa}", "CHIP_ENABLE_OPENTHREAD=${chip_enable_openthread}", "CHIP_DEVICE_CONFIG_THREAD_FTD=${chip_device_config_thread_ftd}", "CHIP_DEVICE_CONFIG_THREAD_BORDER_ROUTER=${chip_openthread_border_router}", + "CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK=${chip_device_uses_otbr_posix_dbus}", "CHIP_STACK_LOCK_TRACKING_ENABLED=${chip_stack_lock_tracking_log}", "CHIP_STACK_LOCK_TRACKING_ERROR_FATAL=${chip_stack_lock_tracking_fatal}", "CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING=${chip_enable_additional_data_advertising}", diff --git a/src/platform/Linux/ThreadStackManagerImpl.cpp b/src/platform/Linux/ThreadStackManagerImpl.cpp index 1eb5958bef17af..20bfe905144b8f 100644 --- a/src/platform/Linux/ThreadStackManagerImpl.cpp +++ b/src/platform/Linux/ThreadStackManagerImpl.cpp @@ -715,174 +715,6 @@ void ThreadStackManagerImpl::_OnNetworkScanFinished(GAsyncResult * res) void ThreadStackManagerImpl::_ResetThreadNetworkDiagnosticsCounts() {} -CHIP_ERROR ThreadStackManagerImpl::_WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, - app::AttributeValueEncoder & encoder) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - - switch (attributeId) - { - case ThreadNetworkDiagnostics::Attributes::NeighborTable::Id: - case ThreadNetworkDiagnostics::Attributes::RouteTable::Id: - case ThreadNetworkDiagnostics::Attributes::ActiveNetworkFaultsList::Id: - err = encoder.EncodeEmptyList(); - break; - case ThreadNetworkDiagnostics::Attributes::Channel::Id: - case ThreadNetworkDiagnostics::Attributes::RoutingRole::Id: - case ThreadNetworkDiagnostics::Attributes::NetworkName::Id: - case ThreadNetworkDiagnostics::Attributes::PanId::Id: - case ThreadNetworkDiagnostics::Attributes::ExtendedPanId::Id: - case ThreadNetworkDiagnostics::Attributes::MeshLocalPrefix::Id: - case ThreadNetworkDiagnostics::Attributes::PartitionId::Id: - case ThreadNetworkDiagnostics::Attributes::Weighting::Id: - case ThreadNetworkDiagnostics::Attributes::DataVersion::Id: - case ThreadNetworkDiagnostics::Attributes::StableDataVersion::Id: - case ThreadNetworkDiagnostics::Attributes::LeaderRouterId::Id: - case ThreadNetworkDiagnostics::Attributes::ActiveTimestamp::Id: - case ThreadNetworkDiagnostics::Attributes::PendingTimestamp::Id: - case ThreadNetworkDiagnostics::Attributes::Delay::Id: - case ThreadNetworkDiagnostics::Attributes::ChannelPage0Mask::Id: - case ThreadNetworkDiagnostics::Attributes::SecurityPolicy::Id: - case ThreadNetworkDiagnostics::Attributes::OperationalDatasetComponents::Id: - err = encoder.EncodeNull(); - break; - case ThreadNetworkDiagnostics::Attributes::OverrunCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::DetachedRoleCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::ChildRoleCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RouterRoleCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::LeaderRoleCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::AttachAttemptCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::PartitionIdChangeCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::BetterPartitionAttachAttemptCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::ParentChangeCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxTotalCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxUnicastCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxBroadcastCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxAckRequestedCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxAckedCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxNoAckRequestedCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxDataCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxDataPollCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxBeaconCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxBeaconRequestCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxOtherCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxRetryCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxDirectMaxRetryExpiryCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxIndirectMaxRetryExpiryCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxErrCcaCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxErrAbortCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxErrBusyChannelCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxTotalCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxUnicastCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxBroadcastCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxDataCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxDataPollCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxBeaconCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxBeaconRequestCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxOtherCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxAddressFilteredCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxDestAddrFilteredCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxDuplicatedCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrNoFrameCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrUnknownNeighborCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrInvalidSrcAddrCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrSecCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrFcsCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrOtherCount::Id: - err = encoder.Encode(static_cast(0)); - break; - default: - err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; - break; - } - - return err; -} - CHIP_ERROR ThreadStackManagerImpl::_AttachToThreadNetwork(const Thread::OperationalDataset & dataset, NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * callback) diff --git a/src/platform/Linux/ThreadStackManagerImpl.h b/src/platform/Linux/ThreadStackManagerImpl.h index 5e077cba3bd1fe..977c6b94d0027f 100755 --- a/src/platform/Linux/ThreadStackManagerImpl.h +++ b/src/platform/Linux/ThreadStackManagerImpl.h @@ -115,8 +115,6 @@ class ThreadStackManagerImpl : public ThreadStackManager void _ResetThreadNetworkDiagnosticsCounts(); - CHIP_ERROR _WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder); - CHIP_ERROR _StartThreadScan(NetworkCommissioning::ThreadDriver::ScanCallback * callback); ~ThreadStackManagerImpl() = default; diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h index ccc3f65e3f6cad..161c2b202a8310 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h @@ -37,7 +37,6 @@ #include #endif -#include #include #include #include @@ -111,7 +110,6 @@ class GenericThreadStackManagerImpl_OpenThread CHIP_ERROR _GetPrimary802154MACAddress(uint8_t * buf); CHIP_ERROR _GetExternalIPv6Address(chip::Inet::IPAddress & addr); void _ResetThreadNetworkDiagnosticsCounts(void); - CHIP_ERROR _WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder); CHIP_ERROR _GetPollPeriod(uint32_t & buf); void _OnWoBLEAdvertisingStart(void); void _OnWoBLEAdvertisingStop(void); diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp index c1fd8635d33eb0..acc0c78d0c8eb7 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp @@ -45,7 +45,6 @@ #include #endif -#include #include #include #include @@ -59,11 +58,6 @@ #include #include -#include -#include -#include -#include - #include extern "C" void otSysProcessDrivers(otInstance * aInstance); @@ -1036,652 +1030,6 @@ void GenericThreadStackManagerImpl_OpenThread::_ResetThreadNetworkDia // Based on the spec, only OverrunCount should be resetted. mOverrunCount = 0; } -/* - * @brief Get runtime value from the thread network based on the given attribute ID. - * The info is encoded via the AttributeValueEncoder. - * - * @param attributeId Id of the attribute for the requested info. - * @param aEncoder Encoder to encode the attribute value. - * - * @return CHIP_NO_ERROR = Succes. - * CHIP_ERROR_NOT_IMPLEMENTED = Runtime value for this attribute to yet available to send as reply - * Use standard read. - * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE = Is not a Runtime readable attribute. Use standard read - * All other errors should be treated as a read error and reported as such. - */ -template -CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_WriteThreadNetworkDiagnosticAttributeToTlv( - AttributeId attributeId, app::AttributeValueEncoder & encoder) -{ - CHIP_ERROR err; - - namespace ThreadNetworkDiagnostics = app::Clusters::ThreadNetworkDiagnostics; - - if (!otDatasetIsCommissioned(mOTInst)) - { - // For the following nullable attributes of the cluster, encodeNull since - // thread instance cannot provide the related data when it is not currently configured. - // - // Note that RoutingRole is nullable but not listed here as thread provides - // valid data even when disabled or detached - switch (attributeId) - { - case ThreadNetworkDiagnostics::Attributes::Channel::Id: - case ThreadNetworkDiagnostics::Attributes::NetworkName::Id: - case ThreadNetworkDiagnostics::Attributes::PanId::Id: - case ThreadNetworkDiagnostics::Attributes::ExtendedPanId::Id: - case ThreadNetworkDiagnostics::Attributes::MeshLocalPrefix::Id: - case ThreadNetworkDiagnostics::Attributes::PartitionId::Id: - case ThreadNetworkDiagnostics::Attributes::Weighting::Id: - case ThreadNetworkDiagnostics::Attributes::DataVersion::Id: - case ThreadNetworkDiagnostics::Attributes::StableDataVersion::Id: - case ThreadNetworkDiagnostics::Attributes::LeaderRouterId::Id: - case ThreadNetworkDiagnostics::Attributes::ActiveTimestamp::Id: - case ThreadNetworkDiagnostics::Attributes::PendingTimestamp::Id: - case ThreadNetworkDiagnostics::Attributes::Delay::Id: - case ThreadNetworkDiagnostics::Attributes::SecurityPolicy::Id: - case ThreadNetworkDiagnostics::Attributes::ChannelPage0Mask::Id: - case ThreadNetworkDiagnostics::Attributes::OperationalDatasetComponents::Id: - return encoder.EncodeNull(); - } - } - - switch (attributeId) - { - case ThreadNetworkDiagnostics::Attributes::Channel::Id: { - uint16_t channel = otLinkGetChannel(mOTInst); - err = encoder.Encode(channel); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RoutingRole::Id: { - using ThreadNetworkDiagnostics::RoutingRoleEnum; - RoutingRoleEnum routingRole; - otDeviceRole otRole = otThreadGetDeviceRole(mOTInst); - - if (otRole == OT_DEVICE_ROLE_DISABLED) - { - routingRole = RoutingRoleEnum::kUnspecified; - } - else if (otRole == OT_DEVICE_ROLE_DETACHED) - { - routingRole = RoutingRoleEnum::kUnassigned; - } - else if (otRole == OT_DEVICE_ROLE_ROUTER) - { - routingRole = RoutingRoleEnum::kRouter; - } - else if (otRole == OT_DEVICE_ROLE_LEADER) - { - routingRole = RoutingRoleEnum::kLeader; - } - else if (otRole == OT_DEVICE_ROLE_CHILD) - { - otLinkModeConfig linkMode = otThreadGetLinkMode(mOTInst); - - if (linkMode.mRxOnWhenIdle) - { - routingRole = RoutingRoleEnum::kEndDevice; -#if CHIP_DEVICE_CONFIG_THREAD_FTD - if (otThreadIsRouterEligible(mOTInst)) - { - routingRole = RoutingRoleEnum::kReed; - } -#endif - } - else - { - routingRole = RoutingRoleEnum::kSleepyEndDevice; - } - } - - err = encoder.Encode(routingRole); - } - break; - - case ThreadNetworkDiagnostics::Attributes::NetworkName::Id: { - const char * networkName = otThreadGetNetworkName(mOTInst); - err = encoder.Encode(CharSpan::fromCharString(networkName)); - } - break; - - case ThreadNetworkDiagnostics::Attributes::PanId::Id: { - uint16_t panId = otLinkGetPanId(mOTInst); - err = encoder.Encode(panId); - } - break; - - case ThreadNetworkDiagnostics::Attributes::ExtendedPanId::Id: { - const otExtendedPanId * pExtendedPanid = otThreadGetExtendedPanId(mOTInst); - err = encoder.Encode(Encoding::BigEndian::Get64(pExtendedPanid->m8)); - } - break; - - case ThreadNetworkDiagnostics::Attributes::MeshLocalPrefix::Id: { - uint8_t meshLocaPrefix[OT_MESH_LOCAL_PREFIX_SIZE + 1] = { 0 }; // + 1 to encode prefix Len in the octstr - - const otMeshLocalPrefix * pMeshLocalPrefix = otThreadGetMeshLocalPrefix(mOTInst); - meshLocaPrefix[0] = OT_IP6_PREFIX_BITSIZE; - - memcpy(&meshLocaPrefix[1], pMeshLocalPrefix->m8, OT_MESH_LOCAL_PREFIX_SIZE); - err = encoder.Encode(ByteSpan(meshLocaPrefix)); - } - break; - - case ThreadNetworkDiagnostics::Attributes::OverrunCount::Id: { - uint64_t overrunCount = mOverrunCount; - err = encoder.Encode(overrunCount); - } - break; - - case ThreadNetworkDiagnostics::Attributes::NeighborTable::Id: { - err = encoder.EncodeList([this](const auto & aEncoder) -> CHIP_ERROR { - constexpr uint16_t kFrameErrorRate100Percent = 0xffff; - constexpr uint16_t kMessageErrorRate100Percent = 0xffff; - - otNeighborInfo neighInfo; - otNeighborInfoIterator iterator = OT_NEIGHBOR_INFO_ITERATOR_INIT; - - while (otThreadGetNextNeighborInfo(mOTInst, &iterator, &neighInfo) == OT_ERROR_NONE) - { - ThreadNetworkDiagnostics::Structs::NeighborTableStruct::Type neighborTable; - app::DataModel::Nullable averageRssi; - app::DataModel::Nullable lastRssi; - - if (neighInfo.mAverageRssi == OT_RADIO_RSSI_INVALID) - { - averageRssi.SetNull(); - } - else - { - // Thread average calculation already restrict mAverageRssi to be between -128 and 0 - averageRssi.SetNonNull(neighInfo.mAverageRssi); - } - - if (neighInfo.mLastRssi == OT_RADIO_RSSI_INVALID) - { - lastRssi.SetNull(); - } - else - { - lastRssi.SetNonNull(min(static_cast(0), neighInfo.mLastRssi)); - } - - neighborTable.averageRssi = averageRssi; - neighborTable.lastRssi = lastRssi; - neighborTable.extAddress = Encoding::BigEndian::Get64(neighInfo.mExtAddress.m8); - neighborTable.age = neighInfo.mAge; - neighborTable.rloc16 = neighInfo.mRloc16; - neighborTable.linkFrameCounter = neighInfo.mLinkFrameCounter; - neighborTable.mleFrameCounter = neighInfo.mMleFrameCounter; - neighborTable.lqi = neighInfo.mLinkQualityIn; - neighborTable.frameErrorRate = - static_cast((static_cast(neighInfo.mFrameErrorRate) * 100) / kFrameErrorRate100Percent); - neighborTable.messageErrorRate = - static_cast((static_cast(neighInfo.mMessageErrorRate) * 100) / kMessageErrorRate100Percent); - neighborTable.rxOnWhenIdle = neighInfo.mRxOnWhenIdle; - neighborTable.fullThreadDevice = neighInfo.mFullThreadDevice; - neighborTable.fullNetworkData = neighInfo.mFullNetworkData; - neighborTable.isChild = neighInfo.mIsChild; - - ReturnErrorOnFailure(aEncoder.Encode(neighborTable)); - } - - return CHIP_NO_ERROR; - }); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RouteTable::Id: { - err = encoder.EncodeList([this](const auto & aEncoder) -> CHIP_ERROR { - otRouterInfo routerInfo; - -#if CHIP_DEVICE_CONFIG_THREAD_FTD - uint8_t maxRouterId = otThreadGetMaxRouterId(mOTInst); - CHIP_ERROR chipErr = CHIP_ERROR_INCORRECT_STATE; - - for (uint8_t i = 0; i <= maxRouterId; i++) - { - if (otThreadGetRouterInfo(mOTInst, i, &routerInfo) == OT_ERROR_NONE) - { - ThreadNetworkDiagnostics::Structs::RouteTableStruct::Type routeTable; - - routeTable.extAddress = Encoding::BigEndian::Get64(routerInfo.mExtAddress.m8); - routeTable.rloc16 = routerInfo.mRloc16; - routeTable.routerId = routerInfo.mRouterId; - routeTable.nextHop = routerInfo.mNextHop; - routeTable.pathCost = routerInfo.mPathCost; - routeTable.LQIIn = routerInfo.mLinkQualityIn; - routeTable.LQIOut = routerInfo.mLinkQualityOut; - routeTable.age = routerInfo.mAge; - routeTable.allocated = routerInfo.mAllocated; - routeTable.linkEstablished = routerInfo.mLinkEstablished; - - ReturnErrorOnFailure(aEncoder.Encode(routeTable)); - chipErr = CHIP_NO_ERROR; - } - } - - return chipErr; - -#else // OPENTHREAD_MTD - otError otErr = otThreadGetParentInfo(mOTInst, &routerInfo); - ReturnErrorOnFailure(MapOpenThreadError(otErr)); - - ThreadNetworkDiagnostics::Structs::RouteTableStruct::Type routeTable; - - routeTable.extAddress = Encoding::BigEndian::Get64(routerInfo.mExtAddress.m8); - routeTable.rloc16 = routerInfo.mRloc16; - routeTable.routerId = routerInfo.mRouterId; - routeTable.nextHop = routerInfo.mNextHop; - routeTable.pathCost = routerInfo.mPathCost; - routeTable.LQIIn = routerInfo.mLinkQualityIn; - routeTable.LQIOut = routerInfo.mLinkQualityOut; - routeTable.age = routerInfo.mAge; - routeTable.allocated = routerInfo.mAllocated; - routeTable.linkEstablished = routerInfo.mLinkEstablished; - - ReturnErrorOnFailure(aEncoder.Encode(routeTable)); - return CHIP_NO_ERROR; -#endif - }); - } - break; - - case ThreadNetworkDiagnostics::Attributes::PartitionId::Id: { - uint32_t partitionId = otThreadGetPartitionId(mOTInst); - err = encoder.Encode(partitionId); - } - break; - - case ThreadNetworkDiagnostics::Attributes::Weighting::Id: { - uint8_t weight = otThreadGetLeaderWeight(mOTInst); - err = encoder.Encode(weight); - } - break; - - case ThreadNetworkDiagnostics::Attributes::DataVersion::Id: { - uint8_t dataVersion = otNetDataGetVersion(mOTInst); - err = encoder.Encode(dataVersion); - } - break; - - case ThreadNetworkDiagnostics::Attributes::StableDataVersion::Id: { - uint8_t stableVersion = otNetDataGetStableVersion(mOTInst); - err = encoder.Encode(stableVersion); - } - break; - - case ThreadNetworkDiagnostics::Attributes::LeaderRouterId::Id: { - uint8_t leaderRouterId = otThreadGetLeaderRouterId(mOTInst); - err = encoder.Encode(leaderRouterId); - } - break; - - case ThreadNetworkDiagnostics::Attributes::DetachedRoleCount::Id: { - uint16_t detachedRole = otThreadGetMleCounters(mOTInst)->mDetachedRole; - err = encoder.Encode(detachedRole); - } - break; - - case ThreadNetworkDiagnostics::Attributes::ChildRoleCount::Id: { - uint16_t childRole = otThreadGetMleCounters(mOTInst)->mChildRole; - err = encoder.Encode(childRole); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RouterRoleCount::Id: { - uint16_t routerRole = otThreadGetMleCounters(mOTInst)->mRouterRole; - err = encoder.Encode(routerRole); - } - break; - - case ThreadNetworkDiagnostics::Attributes::LeaderRoleCount::Id: { - uint16_t leaderRole = otThreadGetMleCounters(mOTInst)->mLeaderRole; - err = encoder.Encode(leaderRole); - } - break; - - case ThreadNetworkDiagnostics::Attributes::AttachAttemptCount::Id: { - uint16_t attachAttempts = otThreadGetMleCounters(mOTInst)->mAttachAttempts; - err = encoder.Encode(attachAttempts); - } - break; - - case ThreadNetworkDiagnostics::Attributes::PartitionIdChangeCount::Id: { - uint16_t partitionIdChanges = otThreadGetMleCounters(mOTInst)->mPartitionIdChanges; - err = encoder.Encode(partitionIdChanges); - } - break; - - case ThreadNetworkDiagnostics::Attributes::BetterPartitionAttachAttemptCount::Id: { - uint16_t betterPartitionAttachAttempts = otThreadGetMleCounters(mOTInst)->mBetterPartitionAttachAttempts; - err = encoder.Encode(betterPartitionAttachAttempts); - } - break; - - case ThreadNetworkDiagnostics::Attributes::ParentChangeCount::Id: { - uint16_t parentChanges = otThreadGetMleCounters(mOTInst)->mParentChanges; - err = encoder.Encode(parentChanges); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxTotalCount::Id: { - uint32_t txTotal = otLinkGetCounters(mOTInst)->mTxTotal; - err = encoder.Encode(txTotal); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxUnicastCount::Id: { - uint32_t txUnicast = otLinkGetCounters(mOTInst)->mTxUnicast; - err = encoder.Encode(txUnicast); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxBroadcastCount::Id: { - uint32_t txBroadcast = otLinkGetCounters(mOTInst)->mTxBroadcast; - err = encoder.Encode(txBroadcast); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxAckRequestedCount::Id: { - uint32_t txAckRequested = otLinkGetCounters(mOTInst)->mTxAckRequested; - err = encoder.Encode(txAckRequested); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxAckedCount::Id: { - uint32_t txAcked = otLinkGetCounters(mOTInst)->mTxAcked; - err = encoder.Encode(txAcked); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxNoAckRequestedCount::Id: { - uint32_t txNoAckRequested = otLinkGetCounters(mOTInst)->mTxNoAckRequested; - err = encoder.Encode(txNoAckRequested); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxDataCount::Id: { - uint32_t txData = otLinkGetCounters(mOTInst)->mTxData; - err = encoder.Encode(txData); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxDataPollCount::Id: { - uint32_t txDataPoll = otLinkGetCounters(mOTInst)->mTxDataPoll; - err = encoder.Encode(txDataPoll); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxBeaconCount::Id: { - uint32_t txBeacon = otLinkGetCounters(mOTInst)->mTxBeacon; - err = encoder.Encode(txBeacon); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxBeaconRequestCount::Id: { - uint32_t txBeaconRequest = otLinkGetCounters(mOTInst)->mTxBeaconRequest; - err = encoder.Encode(txBeaconRequest); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxOtherCount::Id: { - uint32_t txOther = otLinkGetCounters(mOTInst)->mTxOther; - err = encoder.Encode(txOther); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxRetryCount::Id: { - uint32_t txRetry = otLinkGetCounters(mOTInst)->mTxRetry; - err = encoder.Encode(txRetry); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxDirectMaxRetryExpiryCount::Id: { - uint32_t txDirectMaxRetryExpiry = otLinkGetCounters(mOTInst)->mTxDirectMaxRetryExpiry; - err = encoder.Encode(txDirectMaxRetryExpiry); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxIndirectMaxRetryExpiryCount::Id: { - uint32_t txIndirectMaxRetryExpiry = otLinkGetCounters(mOTInst)->mTxIndirectMaxRetryExpiry; - err = encoder.Encode(txIndirectMaxRetryExpiry); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxErrCcaCount::Id: { - uint32_t txErrCca = otLinkGetCounters(mOTInst)->mTxErrCca; - err = encoder.Encode(txErrCca); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxErrAbortCount::Id: { - uint32_t TxErrAbort = otLinkGetCounters(mOTInst)->mTxErrAbort; - err = encoder.Encode(TxErrAbort); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxErrBusyChannelCount::Id: { - uint32_t TxErrBusyChannel = otLinkGetCounters(mOTInst)->mTxErrBusyChannel; - err = encoder.Encode(TxErrBusyChannel); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxTotalCount::Id: { - uint32_t rxTotal = otLinkGetCounters(mOTInst)->mRxTotal; - err = encoder.Encode(rxTotal); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxUnicastCount::Id: { - uint32_t rxUnicast = otLinkGetCounters(mOTInst)->mRxUnicast; - err = encoder.Encode(rxUnicast); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxBroadcastCount::Id: { - uint32_t rxBroadcast = otLinkGetCounters(mOTInst)->mRxBroadcast; - err = encoder.Encode(rxBroadcast); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxDataCount::Id: { - uint32_t rxData = otLinkGetCounters(mOTInst)->mRxData; - err = encoder.Encode(rxData); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxDataPollCount::Id: { - uint32_t rxDataPoll = otLinkGetCounters(mOTInst)->mRxDataPoll; - err = encoder.Encode(rxDataPoll); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxBeaconCount::Id: { - uint32_t rxBeacon = otLinkGetCounters(mOTInst)->mRxBeacon; - err = encoder.Encode(rxBeacon); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxBeaconRequestCount::Id: { - uint32_t rxBeaconRequest = otLinkGetCounters(mOTInst)->mRxBeaconRequest; - err = encoder.Encode(rxBeaconRequest); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxOtherCount::Id: { - uint32_t rxOther = otLinkGetCounters(mOTInst)->mRxOther; - err = encoder.Encode(rxOther); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxAddressFilteredCount::Id: { - uint32_t rxAddressFiltered = otLinkGetCounters(mOTInst)->mRxAddressFiltered; - err = encoder.Encode(rxAddressFiltered); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxDestAddrFilteredCount::Id: { - uint32_t rxDestAddrFiltered = otLinkGetCounters(mOTInst)->mRxDestAddrFiltered; - err = encoder.Encode(rxDestAddrFiltered); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxDuplicatedCount::Id: { - uint32_t rxDuplicated = otLinkGetCounters(mOTInst)->mRxDuplicated; - err = encoder.Encode(rxDuplicated); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxErrNoFrameCount::Id: { - uint32_t rxErrNoFrame = otLinkGetCounters(mOTInst)->mRxErrNoFrame; - err = encoder.Encode(rxErrNoFrame); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxErrUnknownNeighborCount::Id: { - uint32_t rxErrUnknownNeighbor = otLinkGetCounters(mOTInst)->mRxErrUnknownNeighbor; - err = encoder.Encode(rxErrUnknownNeighbor); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxErrInvalidSrcAddrCount::Id: { - uint32_t rxErrInvalidSrcAddr = otLinkGetCounters(mOTInst)->mRxErrInvalidSrcAddr; - err = encoder.Encode(rxErrInvalidSrcAddr); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxErrSecCount::Id: { - uint32_t rxErrSec = otLinkGetCounters(mOTInst)->mRxErrSec; - err = encoder.Encode(rxErrSec); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxErrFcsCount::Id: { - uint32_t rxErrFcs = otLinkGetCounters(mOTInst)->mRxErrFcs; - err = encoder.Encode(rxErrFcs); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxErrOtherCount::Id: { - uint32_t rxErrOther = otLinkGetCounters(mOTInst)->mRxErrOther; - err = encoder.Encode(rxErrOther); - } - break; - - case ThreadNetworkDiagnostics::Attributes::ActiveTimestamp::Id: { - otOperationalDataset activeDataset; - otError otErr = otDatasetGetActive(mOTInst, &activeDataset); - VerifyOrReturnError(otErr == OT_ERROR_NONE, MapOpenThreadError(otErr)); - uint64_t activeTimestamp = (activeDataset.mActiveTimestamp.mSeconds << 16) | (activeDataset.mActiveTimestamp.mTicks << 1) | - activeDataset.mActiveTimestamp.mAuthoritative; - err = encoder.Encode(activeTimestamp); - } - break; - - case ThreadNetworkDiagnostics::Attributes::PendingTimestamp::Id: { - otOperationalDataset activeDataset; - otError otErr = otDatasetGetActive(mOTInst, &activeDataset); - VerifyOrReturnError(otErr == OT_ERROR_NONE, MapOpenThreadError(otErr)); - uint64_t pendingTimestamp = (activeDataset.mPendingTimestamp.mSeconds << 16) | - (activeDataset.mPendingTimestamp.mTicks << 1) | activeDataset.mPendingTimestamp.mAuthoritative; - err = encoder.Encode(pendingTimestamp); - } - break; - - case ThreadNetworkDiagnostics::Attributes::Delay::Id: { - otOperationalDataset activeDataset; - otError otErr = otDatasetGetActive(mOTInst, &activeDataset); - VerifyOrReturnError(otErr == OT_ERROR_NONE, MapOpenThreadError(otErr)); - uint32_t delay = activeDataset.mDelay; - err = encoder.Encode(delay); - } - break; - - case ThreadNetworkDiagnostics::Attributes::SecurityPolicy::Id: { - otOperationalDataset activeDataset; - otError otErr = otDatasetGetActive(mOTInst, &activeDataset); - VerifyOrReturnError(otErr == OT_ERROR_NONE, MapOpenThreadError(otErr)); - - ThreadNetworkDiagnostics::Structs::SecurityPolicy::Type securityPolicy; - static_assert(sizeof(securityPolicy) == sizeof(activeDataset.mSecurityPolicy), - "securityPolicy Struct do not match otSecurityPolicy"); - uint16_t policyAsInts[2]; - static_assert(sizeof(policyAsInts) == sizeof(activeDataset.mSecurityPolicy), - "We're missing some members of otSecurityPolicy?"); - memcpy(&policyAsInts, &activeDataset.mSecurityPolicy, sizeof(policyAsInts)); - securityPolicy.rotationTime = policyAsInts[0]; - securityPolicy.flags = policyAsInts[1]; - err = encoder.Encode(securityPolicy); - } - break; - - case ThreadNetworkDiagnostics::Attributes::ChannelPage0Mask::Id: { - otOperationalDataset activeDataset; - otError otErr = otDatasetGetActive(mOTInst, &activeDataset); - VerifyOrReturnError(otErr == OT_ERROR_NONE, MapOpenThreadError(otErr)); - - // In the resultant Octet string, the most significant bit of the left-most byte indicates channel 0 - // We have to bitswap the entire uint32_t before converting to octet string - uint32_t bitSwappedChannelMask = 0; - for (int i = 0, j = 31; i < 32; i++, j--) - { - bitSwappedChannelMask |= ((activeDataset.mChannelMask >> j) & 1) << i; - } - - uint8_t buffer[sizeof(uint32_t)] = { 0 }; - Encoding::BigEndian::Put32(buffer, bitSwappedChannelMask); - err = encoder.Encode(ByteSpan(buffer)); - } - break; - - case ThreadNetworkDiagnostics::Attributes::OperationalDatasetComponents::Id: { - otOperationalDataset activeDataset; - otError otErr = otDatasetGetActive(mOTInst, &activeDataset); - VerifyOrReturnError(otErr == OT_ERROR_NONE, MapOpenThreadError(otErr)); - ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::Type OpDatasetComponents; - - OpDatasetComponents.activeTimestampPresent = activeDataset.mComponents.mIsActiveTimestampPresent; - OpDatasetComponents.pendingTimestampPresent = activeDataset.mComponents.mIsPendingTimestampPresent; - OpDatasetComponents.masterKeyPresent = activeDataset.mComponents.mIsNetworkKeyPresent; - OpDatasetComponents.networkNamePresent = activeDataset.mComponents.mIsNetworkNamePresent; - OpDatasetComponents.extendedPanIdPresent = activeDataset.mComponents.mIsExtendedPanIdPresent; - OpDatasetComponents.meshLocalPrefixPresent = activeDataset.mComponents.mIsMeshLocalPrefixPresent; - OpDatasetComponents.delayPresent = activeDataset.mComponents.mIsDelayPresent; - OpDatasetComponents.panIdPresent = activeDataset.mComponents.mIsPanIdPresent; - OpDatasetComponents.channelPresent = activeDataset.mComponents.mIsChannelPresent; - OpDatasetComponents.pskcPresent = activeDataset.mComponents.mIsPskcPresent; - OpDatasetComponents.securityPolicyPresent = activeDataset.mComponents.mIsSecurityPolicyPresent; - OpDatasetComponents.channelMaskPresent = activeDataset.mComponents.mIsChannelMaskPresent; - - err = encoder.Encode(OpDatasetComponents); - } - break; - - 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::NetworkFaultEnum activeNetworkFaultsList[4] = { ThreadNetworkDiagnostics::NetworkFaultEnum( - 0) }; - for (auto fault : activeNetworkFaultsList) - { - ReturnErrorOnFailure(aEncoder.Encode(fault)); - } - - return CHIP_NO_ERROR; - }); - } - break; - - default: { - err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; - } - break; - } - - return err; -} template CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_GetPollPeriod(uint32_t & buf) diff --git a/src/platform/Tizen/ThreadStackManagerImpl.cpp b/src/platform/Tizen/ThreadStackManagerImpl.cpp index a5169d462c0209..47a4548507e332 100644 --- a/src/platform/Tizen/ThreadStackManagerImpl.cpp +++ b/src/platform/Tizen/ThreadStackManagerImpl.cpp @@ -535,13 +535,6 @@ CHIP_ERROR ThreadStackManagerImpl::_StartThreadScan(NetworkCommissioning::Thread void ThreadStackManagerImpl::_ResetThreadNetworkDiagnosticsCounts() {} -CHIP_ERROR ThreadStackManagerImpl::_WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, - app::AttributeValueEncoder & encoder) -{ - ChipLogError(DeviceLayer, "Not implemented"); - return CHIP_ERROR_NOT_IMPLEMENTED; -} - CHIP_ERROR ThreadStackManagerImpl::_AttachToThreadNetwork(const Thread::OperationalDataset & dataset, NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * callback) diff --git a/src/platform/Tizen/ThreadStackManagerImpl.h b/src/platform/Tizen/ThreadStackManagerImpl.h index efa2c84e93252a..05b300f574114b 100644 --- a/src/platform/Tizen/ThreadStackManagerImpl.h +++ b/src/platform/Tizen/ThreadStackManagerImpl.h @@ -102,8 +102,6 @@ class ThreadStackManagerImpl : public ThreadStackManager void _ResetThreadNetworkDiagnosticsCounts(); - CHIP_ERROR _WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder); - CHIP_ERROR _StartThreadScan(NetworkCommissioning::ThreadDriver::ScanCallback * callback); ~ThreadStackManagerImpl() = default; diff --git a/src/platform/webos/ThreadStackManagerImpl.cpp b/src/platform/webos/ThreadStackManagerImpl.cpp index 6acb542d78a3c1..79ad2e408857fb 100644 --- a/src/platform/webos/ThreadStackManagerImpl.cpp +++ b/src/platform/webos/ThreadStackManagerImpl.cpp @@ -647,174 +647,6 @@ void ThreadStackManagerImpl::_OnNetworkScanFinished(GAsyncResult * res) void ThreadStackManagerImpl::_ResetThreadNetworkDiagnosticsCounts() {} -CHIP_ERROR ThreadStackManagerImpl::_WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, - app::AttributeValueEncoder & encoder) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - - switch (attributeId) - { - case ThreadNetworkDiagnostics::Attributes::NeighborTable::Id: - case ThreadNetworkDiagnostics::Attributes::RouteTable::Id: - case ThreadNetworkDiagnostics::Attributes::ActiveNetworkFaultsList::Id: - err = encoder.EncodeEmptyList(); - break; - case ThreadNetworkDiagnostics::Attributes::Channel::Id: - case ThreadNetworkDiagnostics::Attributes::RoutingRole::Id: - case ThreadNetworkDiagnostics::Attributes::NetworkName::Id: - case ThreadNetworkDiagnostics::Attributes::PanId::Id: - case ThreadNetworkDiagnostics::Attributes::ExtendedPanId::Id: - case ThreadNetworkDiagnostics::Attributes::MeshLocalPrefix::Id: - case ThreadNetworkDiagnostics::Attributes::PartitionId::Id: - case ThreadNetworkDiagnostics::Attributes::Weighting::Id: - case ThreadNetworkDiagnostics::Attributes::DataVersion::Id: - case ThreadNetworkDiagnostics::Attributes::StableDataVersion::Id: - case ThreadNetworkDiagnostics::Attributes::LeaderRouterId::Id: - case ThreadNetworkDiagnostics::Attributes::ActiveTimestamp::Id: - case ThreadNetworkDiagnostics::Attributes::PendingTimestamp::Id: - case ThreadNetworkDiagnostics::Attributes::Delay::Id: - case ThreadNetworkDiagnostics::Attributes::ChannelPage0Mask::Id: - case ThreadNetworkDiagnostics::Attributes::SecurityPolicy::Id: - case ThreadNetworkDiagnostics::Attributes::OperationalDatasetComponents::Id: - err = encoder.EncodeNull(); - break; - case ThreadNetworkDiagnostics::Attributes::OverrunCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::DetachedRoleCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::ChildRoleCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RouterRoleCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::LeaderRoleCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::AttachAttemptCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::PartitionIdChangeCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::BetterPartitionAttachAttemptCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::ParentChangeCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxTotalCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxUnicastCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxBroadcastCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxAckRequestedCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxAckedCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxNoAckRequestedCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxDataCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxDataPollCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxBeaconCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxBeaconRequestCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxOtherCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxRetryCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxDirectMaxRetryExpiryCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxIndirectMaxRetryExpiryCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxErrCcaCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxErrAbortCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxErrBusyChannelCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxTotalCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxUnicastCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxBroadcastCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxDataCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxDataPollCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxBeaconCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxBeaconRequestCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxOtherCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxAddressFilteredCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxDestAddrFilteredCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxDuplicatedCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrNoFrameCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrUnknownNeighborCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrInvalidSrcAddrCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrSecCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrFcsCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrOtherCount::Id: - err = encoder.Encode(static_cast(0)); - break; - default: - err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; - break; - } - - return err; -} - CHIP_ERROR ThreadStackManagerImpl::_AttachToThreadNetwork(const Thread::OperationalDataset & dataset, NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * callback) diff --git a/src/platform/webos/ThreadStackManagerImpl.h b/src/platform/webos/ThreadStackManagerImpl.h index 330e601f75a7fd..876c339cceb6ae 100644 --- a/src/platform/webos/ThreadStackManagerImpl.h +++ b/src/platform/webos/ThreadStackManagerImpl.h @@ -104,8 +104,6 @@ class ThreadStackManagerImpl : public ThreadStackManager void _ResetThreadNetworkDiagnosticsCounts(); - CHIP_ERROR _WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder); - CHIP_ERROR _StartThreadScan(NetworkCommissioning::ThreadDriver::ScanCallback * callback); ~ThreadStackManagerImpl() = default;