From 54ffcc80989a8f06998cead97fc9be0c9f8309d8 Mon Sep 17 00:00:00 2001 From: Doru Gucea Date: Thu, 18 Nov 2021 05:17:27 -0800 Subject: [PATCH 1/3] [K32W0] Read General Diagnostics cluster attribute at runtime Signed-off-by: Doru Gucea --- .../k32w/k32w0/ConfigurationManagerImpl.cpp | 44 +++++++ .../nxp/k32w/k32w0/ConfigurationManagerImpl.h | 6 + src/platform/nxp/k32w/k32w0/K32W0Config.cpp | 5 + src/platform/nxp/k32w/k32w0/K32W0Config.h | 25 +--- .../nxp/k32w/k32w0/PlatformManagerImpl.cpp | 107 ++++++++++++++++++ .../nxp/k32w/k32w0/PlatformManagerImpl.h | 7 ++ 6 files changed, 173 insertions(+), 21 deletions(-) diff --git a/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp index a5bbaffcecd011..49cf415ca98b10 100644 --- a/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp @@ -46,8 +46,31 @@ ConfigurationManagerImpl ConfigurationManagerImpl::sInstance; CHIP_ERROR ConfigurationManagerImpl::Init() { CHIP_ERROR err; + uint32_t rebootCount; bool failSafeArmed; + + if (ConfigValueExists(kCounterKey_RebootCount)) + { + err = GetRebootCount(rebootCount); + SuccessOrExit(err); + + err = StoreRebootCount(rebootCount + 1); + SuccessOrExit(err); + } + else + { + // The first boot after factory reset of the Node. + err = StoreRebootCount(1); + SuccessOrExit(err); + } + + if (!ConfigValueExists(kCounterKey_TotalOperationalHours)) + { + err = StoreTotalOperationalHours(0); + SuccessOrExit(err); + } + // Initialize the generic implementation base class. err = Internal::GenericConfigurationManagerImpl::Init(); SuccessOrExit(err); @@ -66,6 +89,27 @@ CHIP_ERROR ConfigurationManagerImpl::Init() return err; } +CHIP_ERROR ConfigurationManagerImpl::GetRebootCount(uint32_t & rebootCount) +{ + return ReadConfigValue(kCounterKey_RebootCount, rebootCount); +} + +CHIP_ERROR ConfigurationManagerImpl::StoreRebootCount(uint32_t rebootCount) +{ + return WriteConfigValue(kCounterKey_RebootCount, rebootCount); +} + +CHIP_ERROR ConfigurationManagerImpl::GetTotalOperationalHours(uint32_t & totalOperationalHours) +{ + return ReadConfigValue(kCounterKey_TotalOperationalHours, totalOperationalHours); +} + +CHIP_ERROR ConfigurationManagerImpl::StoreTotalOperationalHours(uint32_t totalOperationalHours) +{ + return WriteConfigValue(kCounterKey_TotalOperationalHours, totalOperationalHours); +} + + bool ConfigurationManagerImpl::CanFactoryReset() { // TODO: query the application to determine if factory reset is allowed. diff --git a/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.h b/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.h index 14ea2c923f8d3b..29a9b316740402 100644 --- a/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.h +++ b/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.h @@ -37,6 +37,12 @@ namespace DeviceLayer { class ConfigurationManagerImpl final : public Internal::GenericConfigurationManagerImpl, private Internal::K32WConfig { +public: + CHIP_ERROR GetRebootCount(uint32_t & rebootCount); + CHIP_ERROR StoreRebootCount(uint32_t rebootCount); + CHIP_ERROR GetTotalOperationalHours(uint32_t & totalOperationalHours); + CHIP_ERROR StoreTotalOperationalHours(uint32_t totalOperationalHours); + // Allow the GenericConfigurationManagerImpl base class to access helper methods and types // defined on this class. #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/src/platform/nxp/k32w/k32w0/K32W0Config.cpp b/src/platform/nxp/k32w/k32w0/K32W0Config.cpp index 8cb9da2ff26185..1bdc010d89a7f3 100644 --- a/src/platform/nxp/k32w/k32w0/K32W0Config.cpp +++ b/src/platform/nxp/k32w/k32w0/K32W0Config.cpp @@ -371,6 +371,11 @@ CHIP_ERROR K32WConfig::FactoryResetConfig(void) if (err == CHIP_NO_ERROR) { err = FactoryResetConfigInternal(kMinConfigKey_KVS, kMaxConfigKey_KVS); + + if (err == CHIP_NO_ERROR) + { + FactoryResetConfigInternal(kMinConfigKey_ChipCounter, kMaxConfigKey_ChipCounter); + } } return err; diff --git a/src/platform/nxp/k32w/k32w0/K32W0Config.h b/src/platform/nxp/k32w/k32w0/K32W0Config.h index aa33eabd9b7cb4..ae076f5c993a7d 100644 --- a/src/platform/nxp/k32w/k32w0/K32W0Config.h +++ b/src/platform/nxp/k32w/k32w0/K32W0Config.h @@ -88,27 +88,10 @@ class K32WConfig static constexpr Key kConfigKey_CountryCode = K32WConfigKey(kPDMId_ChipConfig, 0x08); static constexpr Key kConfigKey_Breadcrumb = K32WConfigKey(kPDMId_ChipConfig, 0x09); - static constexpr Key kConfigKey_GroupKey = K32WConfigKey(kPDMId_ChipConfig, 0x0A); - static constexpr Key kConfigKey_GroupKey0 = K32WConfigKey(kPDMId_ChipConfig, 0x0B); - static constexpr Key kConfigKey_GroupKey1 = K32WConfigKey(kPDMId_ChipConfig, 0x0C); - static constexpr Key kConfigKey_GroupKey2 = K32WConfigKey(kPDMId_ChipConfig, 0x0D); - static constexpr Key kConfigKey_GroupKey3 = K32WConfigKey(kPDMId_ChipConfig, 0x0E); - static constexpr Key kConfigKey_GroupKey4 = K32WConfigKey(kPDMId_ChipConfig, 0x0F); - static constexpr Key kConfigKey_GroupKey5 = K32WConfigKey(kPDMId_ChipConfig, 0x10); - static constexpr Key kConfigKey_GroupKey6 = K32WConfigKey(kPDMId_ChipConfig, 0x11); - static constexpr Key kConfigKey_GroupKey7 = K32WConfigKey(kPDMId_ChipConfig, 0x12); - static constexpr Key kConfigKey_GroupKey8 = K32WConfigKey(kPDMId_ChipConfig, 0x13); - static constexpr Key kConfigKey_GroupKey9 = K32WConfigKey(kPDMId_ChipConfig, 0x14); - static constexpr Key kConfigKey_GroupKey10 = K32WConfigKey(kPDMId_ChipConfig, 0x15); - static constexpr Key kConfigKey_GroupKey11 = K32WConfigKey(kPDMId_ChipConfig, 0x16); - static constexpr Key kConfigKey_GroupKey12 = K32WConfigKey(kPDMId_ChipConfig, 0x17); - static constexpr Key kConfigKey_GroupKey13 = K32WConfigKey(kPDMId_ChipConfig, 0x18); - static constexpr Key kConfigKey_GroupKey14 = K32WConfigKey(kPDMId_ChipConfig, 0x19); - static constexpr Key kConfigKey_GroupKey15 = K32WConfigKey(kPDMId_ChipConfig, 0x1A); - - static constexpr Key kConfigKey_GroupKeyBase = kConfigKey_GroupKey0; - static constexpr Key kConfigKey_GroupKeyMax = K32WConfigKey(kPDMId_ChipConfig, 0x1E); - ; // Allows 16 Group Keys to be created. + // CHIP Counter Keys + static constexpr Key kCounterKey_RebootCount = K32WConfigKey(kPDMId_ChipConfig, 0x0A); + static constexpr Key kCounterKey_UpTime = K32WConfigKey(kPDMId_ChipConfig, 0x0B); + static constexpr Key kCounterKey_TotalOperationalHours = K32WConfigKey(kPDMId_ChipConfig, 0x0C); // Set key id limits for each group. static constexpr Key kMinConfigKey_ChipFactory = K32WConfigKey(kPDMId_ChipFactory, 0x00); diff --git a/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp index cfcc6ad007e264..ab6aec738d947e 100644 --- a/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp @@ -25,6 +25,7 @@ /* this file behaves like a config.h, comes first */ #include +#include #include #include #include @@ -33,6 +34,8 @@ #include +#include "fsl_power.h" + namespace chip { namespace DeviceLayer { @@ -55,6 +58,8 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) { CHIP_ERROR err; + mStartTimeMilliseconds = System::SystemClock().GetMonotonicMilliseconds(); + // Initialize the configuration system. err = Internal::K32WConfig::Init(); SuccessOrExit(err); @@ -74,6 +79,108 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) return err; } +CHIP_ERROR PlatformManagerImpl::_Shutdown() +{ + uint64_t upTime = 0; + + if (_GetUpTime(upTime) == CHIP_NO_ERROR) + { + uint32_t totalOperationalHours = 0; + + if (ConfigurationMgrImpl().GetTotalOperationalHours(totalOperationalHours) == CHIP_NO_ERROR) + { + ConfigurationMgrImpl().StoreTotalOperationalHours(totalOperationalHours + static_cast(upTime / 3600)); + } + else + { + ChipLogError(DeviceLayer, "Failed to get total operational hours of the Node"); + } + } + else + { + ChipLogError(DeviceLayer, "Failed to get current uptime since the Node’s last reboot"); + } + + return Internal::GenericPlatformManagerImpl_FreeRTOS::_Shutdown(); +} + +CHIP_ERROR PlatformManagerImpl::_GetRebootCount(uint16_t & rebootCount) +{ + uint32_t count = 0; + + CHIP_ERROR err = ConfigurationMgrImpl().GetRebootCount(count); + + if (err == CHIP_NO_ERROR) + { + VerifyOrReturnError(count <= UINT16_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE); + rebootCount = static_cast(count); + } + + return err; +} + +CHIP_ERROR PlatformManagerImpl::_GetUpTime(uint64_t & upTime) +{ + uint64_t currentTimeMilliseconds = System::SystemClock().GetMonotonicMilliseconds(); + + if (currentTimeMilliseconds >= mStartTimeMilliseconds) + { + upTime = (currentTimeMilliseconds - mStartTimeMilliseconds) / 1000; + return CHIP_NO_ERROR; + } + + return CHIP_ERROR_INVALID_TIME; +} + +CHIP_ERROR PlatformManagerImpl::_GetTotalOperationalHours(uint32_t & totalOperationalHours) +{ + uint64_t upTime = 0; + + if (_GetUpTime(upTime) == CHIP_NO_ERROR) + { + uint32_t totalHours = 0; + if (ConfigurationMgrImpl().GetTotalOperationalHours(totalHours) == CHIP_NO_ERROR) + { + VerifyOrReturnError(upTime / 3600 <= UINT32_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE); + totalOperationalHours = totalHours + static_cast(upTime / 3600); + return CHIP_NO_ERROR; + } + } + + return CHIP_ERROR_INVALID_TIME; +} + +CHIP_ERROR PlatformManagerImpl::_GetBootReasons(uint8_t & bootReason) +{ + bootReason = EMBER_ZCL_BOOT_REASON_TYPE_UNSPECIFIED; + uint8_t reason; + reason = POWER_GetResetCause(); + + if (reason == RESET_UNDEFINED) + { + bootReason = EMBER_ZCL_BOOT_REASON_TYPE_UNSPECIFIED; + } + else if ((reason == RESET_POR) || (reason == RESET_EXT_PIN)) + { + bootReason = EMBER_ZCL_BOOT_REASON_TYPE_POWER_ON_REBOOT; + } + else if (reason == RESET_BOR) + { + bootReason = EMBER_ZCL_BOOT_REASON_TYPE_BROWN_OUT_RESET; + } + else if (reason == RESET_SW_REQ) + { + bootReason = EMBER_ZCL_BOOT_REASON_TYPE_SOFTWARE_RESET; + } + else if (reason == RESET_WDT) + { + bootReason = EMBER_ZCL_BOOT_REASON_TYPE_SOFTWARE_WATCHDOG_RESET; + /* Reboot can be due to hardware or software watchdog*/ + } + + return CHIP_NO_ERROR; +} + CHIP_ERROR PlatformManagerImpl::_GetCurrentHeapFree(uint64_t & currentHeapFree) { size_t freeHeapSize; diff --git a/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.h b/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.h index 29c17d6f9cdbcc..d3bbf01edfe560 100644 --- a/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.h +++ b/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.h @@ -54,16 +54,23 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener // ===== Methods that implement the PlatformManager abstract interface. CHIP_ERROR _InitChipStack(void); + CHIP_ERROR _Shutdown(); CHIP_ERROR _GetCurrentHeapFree(uint64_t & currentHeapFree); CHIP_ERROR _GetCurrentHeapUsed(uint64_t & currentHeapUsed); CHIP_ERROR _GetCurrentHeapHighWatermark(uint64_t & currentHeapHighWatermark); + CHIP_ERROR _GetRebootCount(uint16_t & rebootCount); + CHIP_ERROR _GetUpTime(uint64_t & upTime); + CHIP_ERROR _GetTotalOperationalHours(uint32_t & totalOperationalHours); + CHIP_ERROR _GetBootReasons(uint8_t & bootReasons);; // ===== Members for internal use by the following friends. friend PlatformManager & PlatformMgr(void); friend PlatformManagerImpl & PlatformMgrImpl(void); friend class Internal::BLEManagerImpl; + uint64_t mStartTimeMilliseconds = 0; + static PlatformManagerImpl sInstance; using Internal::GenericPlatformManagerImpl_FreeRTOS::PostEventFromISR; From d950620229dde9dec5dfed4a070b63d780e6bbff Mon Sep 17 00:00:00 2001 From: Doru Gucea Date: Tue, 23 Nov 2021 01:25:06 -0800 Subject: [PATCH 2/3] [K32W0] Fix shell app * fix linkage error by disabling the ping functionality * fix deadlock in Thread implementation * fix printing by adding CR This commit relates to https://github.com/project-chip/connectedhomeip/pull/11346 Signed-off-by: Doru Gucea --- examples/shell/nxp/k32w/k32w0/main/main.cpp | 2 +- src/lib/shell/commands/Dns.cpp | 52 +++++++++---------- ...nericThreadStackManagerImpl_OpenThread.cpp | 7 --- .../nxp/k32w/k32w0/CHIPDevicePlatformConfig.h | 2 + .../k32w_sdk/nxp/k32w/k32w0/k32w0_sdk.gni | 2 + 5 files changed, 31 insertions(+), 34 deletions(-) diff --git a/examples/shell/nxp/k32w/k32w0/main/main.cpp b/examples/shell/nxp/k32w/k32w0/main/main.cpp index da20f798e4cca7..9b737049c9d113 100644 --- a/examples/shell/nxp/k32w/k32w0/main/main.cpp +++ b/examples/shell/nxp/k32w/k32w0/main/main.cpp @@ -134,7 +134,7 @@ extern "C" void main_task(void const * argument) } // cmd_otcli_init(); - cmd_ping_init(); + //cmd_ping_init(); cmd_send_init(); shellTaskHandle = xTaskCreate(shell_task, "shell_task", shell_task_size / sizeof(StackType_t), NULL, shell_task_priority, NULL); diff --git a/src/lib/shell/commands/Dns.cpp b/src/lib/shell/commands/Dns.cpp index 0cc91037c95409..e378bdf13784d6 100644 --- a/src/lib/shell/commands/Dns.cpp +++ b/src/lib/shell/commands/Dns.cpp @@ -42,23 +42,23 @@ class DnsShellResolverDelegate : public Dnssd::ResolverDelegate public: void OnNodeIdResolved(const Dnssd::ResolvedNodeData & nodeData) override { - streamer_printf(streamer_get(), "DNS resolve for " ChipLogFormatX64 "-" ChipLogFormatX64 " succeeded:\n", + streamer_printf(streamer_get(), "DNS resolve for " ChipLogFormatX64 "-" ChipLogFormatX64 " succeeded:\r\n", ChipLogValueX64(nodeData.mPeerId.GetCompressedFabricId()), ChipLogValueX64(nodeData.mPeerId.GetNodeId())); - streamer_printf(streamer_get(), " Hostname: %s\n", nodeData.mHostName); - streamer_printf(streamer_get(), " IP address: %s\n", nodeData.mAddress.ToString(ipAddressBuf)); - streamer_printf(streamer_get(), " Port: %" PRIu16 "\n", nodeData.mPort); + streamer_printf(streamer_get(), " Hostname: %s\r\n", nodeData.mHostName); + streamer_printf(streamer_get(), " IP address: %s\r\n", nodeData.mAddress.ToString(ipAddressBuf)); + streamer_printf(streamer_get(), " Port: %" PRIu16 "\r\n", nodeData.mPort); auto retryInterval = nodeData.GetMrpRetryIntervalIdle(); if (retryInterval.HasValue()) - streamer_printf(streamer_get(), " MRP retry interval (idle): %" PRIu32 "ms\n", retryInterval.Value()); + streamer_printf(streamer_get(), " MRP retry interval (idle): %" PRIu32 "ms\r\n", retryInterval.Value()); retryInterval = nodeData.GetMrpRetryIntervalActive(); if (retryInterval.HasValue()) - streamer_printf(streamer_get(), " MRP retry interval (active): %" PRIu32 "ms\n", retryInterval.Value()); + streamer_printf(streamer_get(), " MRP retry interval (active): %" PRIu32 "ms\r\n", retryInterval.Value()); - streamer_printf(streamer_get(), " Supports TCP: %s\n", nodeData.mSupportsTcp ? "yes" : "no"); + streamer_printf(streamer_get(), " Supports TCP: %s\r\n", nodeData.mSupportsTcp ? "yes" : "no"); } void OnNodeIdResolutionFailed(const PeerId & peerId, CHIP_ERROR error) override {} @@ -75,33 +75,33 @@ class DnsShellResolverDelegate : public Dnssd::ResolverDelegate Encoding::BytesToUppercaseHexString(nodeData.rotatingId, nodeData.rotatingIdLen, rotatingId, sizeof(rotatingId)); streamer_printf(streamer_get(), "DNS browse succeeded: \n"); - streamer_printf(streamer_get(), " Hostname: %s\n", nodeData.hostName); - streamer_printf(streamer_get(), " Vendor ID: %" PRIu16 "\n", nodeData.vendorId); - streamer_printf(streamer_get(), " Product ID: %" PRIu16 "\n", nodeData.productId); - streamer_printf(streamer_get(), " Long discriminator: %" PRIu16 "\n", nodeData.longDiscriminator); + streamer_printf(streamer_get(), " Hostname: %s\r\n", nodeData.hostName); + streamer_printf(streamer_get(), " Vendor ID: %" PRIu16 "\r\n", nodeData.vendorId); + streamer_printf(streamer_get(), " Product ID: %" PRIu16 "\r\n", nodeData.productId); + streamer_printf(streamer_get(), " Long discriminator: %" PRIu16 "\r\n", nodeData.longDiscriminator); streamer_printf(streamer_get(), " Device type: %" PRIu16 "\n", nodeData.deviceType); - streamer_printf(streamer_get(), " Device name: %s\n", nodeData.deviceName); - streamer_printf(streamer_get(), " Commissioning mode: %d\n", static_cast(nodeData.commissioningMode)); - streamer_printf(streamer_get(), " Pairing hint: %" PRIu16 "\n", nodeData.pairingHint); - streamer_printf(streamer_get(), " Pairing instruction: %s\n", nodeData.pairingInstruction); - streamer_printf(streamer_get(), " Rotating ID %s\n", rotatingId); + streamer_printf(streamer_get(), " Device name: %s\r\n", nodeData.deviceName); + streamer_printf(streamer_get(), " Commissioning mode: %d\r\n", static_cast(nodeData.commissioningMode)); + streamer_printf(streamer_get(), " Pairing hint: %" PRIu16 "\r\n", nodeData.pairingHint); + streamer_printf(streamer_get(), " Pairing instruction: %s\r\n", nodeData.pairingInstruction); + streamer_printf(streamer_get(), " Rotating ID %s\r\n", rotatingId); auto retryInterval = nodeData.GetMrpRetryIntervalIdle(); if (retryInterval.HasValue()) - streamer_printf(streamer_get(), " MRP retry interval (idle): %" PRIu32 "ms\n", retryInterval.Value()); + streamer_printf(streamer_get(), " MRP retry interval (idle): %" PRIu32 "ms\r\n", retryInterval.Value()); retryInterval = nodeData.GetMrpRetryIntervalActive(); if (retryInterval.HasValue()) - streamer_printf(streamer_get(), " MRP retry interval (active): %" PRIu32 "ms\n", retryInterval.Value()); + streamer_printf(streamer_get(), " MRP retry interval (active): %" PRIu32 "ms\r\n", retryInterval.Value()); - streamer_printf(streamer_get(), " Supports TCP: %s\n", nodeData.supportsTcp ? "yes" : "no"); - streamer_printf(streamer_get(), " IP addresses:\n"); + streamer_printf(streamer_get(), " Supports TCP: %s\r\n", nodeData.supportsTcp ? "yes" : "no"); + streamer_printf(streamer_get(), " IP addresses:\r\n"); for (uint8_t i = 0; i < nodeData.kMaxIPAddresses; i++) { if (nodeData.ipAddress[i] != Inet::IPAddress::Any) - streamer_printf(streamer_get(), " %s\n", nodeData.ipAddress[i].ToString(ipAddressBuf)); + streamer_printf(streamer_get(), " %s\r\n", nodeData.ipAddress[i].ToString(ipAddressBuf)); } } @@ -115,7 +115,7 @@ CHIP_ERROR ResolveHandler(int argc, char ** argv) { VerifyOrReturnError(argc == 2, CHIP_ERROR_INVALID_ARGUMENT); - streamer_printf(streamer_get(), "Resolving ...\n"); + streamer_printf(streamer_get(), "Resolving ...\r\n"); PeerId peerId; peerId.SetCompressedFabricId(strtoull(argv[0], NULL, 10)); @@ -175,11 +175,11 @@ CHIP_ERROR BrowseCommissionableHandler(int argc, char ** argv) if (!ParseSubType(argc, argv, filter)) { - streamer_printf(streamer_get(), "Invalid argument\n"); + streamer_printf(streamer_get(), "Invalid argument\r\n"); return CHIP_ERROR_INVALID_ARGUMENT; } - streamer_printf(streamer_get(), "Browsing commissionable nodes...\n"); + streamer_printf(streamer_get(), "Browsing commissionable nodes...\r\n"); return Dnssd::Resolver::Instance().FindCommissionableNodes(filter); } @@ -190,11 +190,11 @@ CHIP_ERROR BrowseCommissionerHandler(int argc, char ** argv) if (!ParseSubType(argc, argv, filter)) { - streamer_printf(streamer_get(), "Invalid argument\n"); + streamer_printf(streamer_get(), "Invalid argument\r\n"); return CHIP_ERROR_INVALID_ARGUMENT; } - streamer_printf(streamer_get(), "Browsing commissioners...\n"); + streamer_printf(streamer_get(), "Browsing commissioners...\r\n"); return Dnssd::Resolver::Instance().FindCommissioners(filter); } diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp index ecb045460dc754..786e6f2b456236 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp @@ -1971,8 +1971,6 @@ void GenericThreadStackManagerImpl_OpenThread::OnDnsBrowseResult(otEr return; } - ThreadStackMgrImpl().LockThreadStack(); - VerifyOrExit(aError == OT_ERROR_NONE, error = MapOpenThreadError(aError)); error = MapOpenThreadError(otDnsBrowseResponseGetServiceName(aResponse, type, sizeof(type))); @@ -2005,8 +2003,6 @@ void GenericThreadStackManagerImpl_OpenThread::OnDnsBrowseResult(otEr exit: - ThreadStackMgrImpl().UnlockThreadStack(); - // In case no service was found invoke callback to notify about failure. In other case it was already called before. if (!wasAnythingBrowsed) ThreadStackMgrImpl().mDnsBrowseCallback(aContext, nullptr, 0, error); @@ -2059,8 +2055,6 @@ void GenericThreadStackManagerImpl_OpenThread::OnDnsResolveResult(otE return; } - ThreadStackMgrImpl().LockThreadStack(); - VerifyOrExit(aError == OT_ERROR_NONE, error = MapOpenThreadError(aError)); error = MapOpenThreadError(otDnsServiceResponseGetServiceName(aResponse, resolveResult.mMdnsService.mName, @@ -2081,7 +2075,6 @@ void GenericThreadStackManagerImpl_OpenThread::OnDnsResolveResult(otE exit: - ThreadStackMgrImpl().UnlockThreadStack(); ThreadStackMgrImpl().mDnsResolveCallback(aContext, &(resolveResult.mMdnsService), error); } diff --git a/src/platform/nxp/k32w/k32w0/CHIPDevicePlatformConfig.h b/src/platform/nxp/k32w/k32w0/CHIPDevicePlatformConfig.h index 41e467d61a0d43..bf1d3ee8199b68 100644 --- a/src/platform/nxp/k32w/k32w0/CHIPDevicePlatformConfig.h +++ b/src/platform/nxp/k32w/k32w0/CHIPDevicePlatformConfig.h @@ -101,6 +101,8 @@ #define CHIP_DEVICE_CONFIG_ENABLE_THREAD 1 #define CHIP_DEVICE_CONFIG_ENABLE_DNSSD 1 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT 1 +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT 1 #define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1 #define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DISCOVERY 1 + #endif diff --git a/third_party/k32w_sdk/nxp/k32w/k32w0/k32w0_sdk.gni b/third_party/k32w_sdk/nxp/k32w/k32w0/k32w0_sdk.gni index 4ba8446ea3a80a..8bd7b5a991235f 100644 --- a/third_party/k32w_sdk/nxp/k32w/k32w0/k32w0_sdk.gni +++ b/third_party/k32w_sdk/nxp/k32w/k32w0/k32w0_sdk.gni @@ -175,6 +175,8 @@ template("k32w0_sdk") { defines += [ "OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE=1", "OPENTHREAD_CONFIG_ECDSA_ENABLE=1", + "OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE=1", + "OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE=1", ] } From 92c4035659406dd74cf846a82fc038b20096ee4d Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 23 Nov 2021 09:39:53 +0000 Subject: [PATCH 3/3] Restyled by clang-format --- examples/shell/nxp/k32w/k32w0/main/main.cpp | 2 +- src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp | 2 -- src/platform/nxp/k32w/k32w0/K32W0Config.h | 6 +++--- src/platform/nxp/k32w/k32w0/PlatformManagerImpl.h | 3 ++- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/shell/nxp/k32w/k32w0/main/main.cpp b/examples/shell/nxp/k32w/k32w0/main/main.cpp index 9b737049c9d113..b244faf69a46b9 100644 --- a/examples/shell/nxp/k32w/k32w0/main/main.cpp +++ b/examples/shell/nxp/k32w/k32w0/main/main.cpp @@ -134,7 +134,7 @@ extern "C" void main_task(void const * argument) } // cmd_otcli_init(); - //cmd_ping_init(); + // cmd_ping_init(); cmd_send_init(); shellTaskHandle = xTaskCreate(shell_task, "shell_task", shell_task_size / sizeof(StackType_t), NULL, shell_task_priority, NULL); diff --git a/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp index 49cf415ca98b10..e74959d4b00625 100644 --- a/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp @@ -49,7 +49,6 @@ CHIP_ERROR ConfigurationManagerImpl::Init() uint32_t rebootCount; bool failSafeArmed; - if (ConfigValueExists(kCounterKey_RebootCount)) { err = GetRebootCount(rebootCount); @@ -109,7 +108,6 @@ CHIP_ERROR ConfigurationManagerImpl::StoreTotalOperationalHours(uint32_t totalOp return WriteConfigValue(kCounterKey_TotalOperationalHours, totalOperationalHours); } - bool ConfigurationManagerImpl::CanFactoryReset() { // TODO: query the application to determine if factory reset is allowed. diff --git a/src/platform/nxp/k32w/k32w0/K32W0Config.h b/src/platform/nxp/k32w/k32w0/K32W0Config.h index ae076f5c993a7d..1f0511fe81bb5a 100644 --- a/src/platform/nxp/k32w/k32w0/K32W0Config.h +++ b/src/platform/nxp/k32w/k32w0/K32W0Config.h @@ -89,9 +89,9 @@ class K32WConfig static constexpr Key kConfigKey_Breadcrumb = K32WConfigKey(kPDMId_ChipConfig, 0x09); // CHIP Counter Keys - static constexpr Key kCounterKey_RebootCount = K32WConfigKey(kPDMId_ChipConfig, 0x0A); - static constexpr Key kCounterKey_UpTime = K32WConfigKey(kPDMId_ChipConfig, 0x0B); - static constexpr Key kCounterKey_TotalOperationalHours = K32WConfigKey(kPDMId_ChipConfig, 0x0C); + static constexpr Key kCounterKey_RebootCount = K32WConfigKey(kPDMId_ChipConfig, 0x0A); + static constexpr Key kCounterKey_UpTime = K32WConfigKey(kPDMId_ChipConfig, 0x0B); + static constexpr Key kCounterKey_TotalOperationalHours = K32WConfigKey(kPDMId_ChipConfig, 0x0C); // Set key id limits for each group. static constexpr Key kMinConfigKey_ChipFactory = K32WConfigKey(kPDMId_ChipFactory, 0x00); diff --git a/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.h b/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.h index d3bbf01edfe560..18516e768e07a0 100644 --- a/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.h +++ b/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.h @@ -62,7 +62,8 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener CHIP_ERROR _GetRebootCount(uint16_t & rebootCount); CHIP_ERROR _GetUpTime(uint64_t & upTime); CHIP_ERROR _GetTotalOperationalHours(uint32_t & totalOperationalHours); - CHIP_ERROR _GetBootReasons(uint8_t & bootReasons);; + CHIP_ERROR _GetBootReasons(uint8_t & bootReasons); + ; // ===== Members for internal use by the following friends. friend PlatformManager & PlatformMgr(void);