diff --git a/src/app/clusters/basic-information/basic-information.cpp b/src/app/clusters/basic-information/basic-information.cpp index d280c41e130d62..3e98375670d513 100644 --- a/src/app/clusters/basic-information/basic-information.cpp +++ b/src/app/clusters/basic-information/basic-information.cpp @@ -406,7 +406,7 @@ bool IsLocalConfigDisabled() } // namespace app } // namespace chip -void emberAfBasicClusterServerInitCallback(chip::EndpointId endpoint) {} +void emberAfBasicInformationClusterServerInitCallback(chip::EndpointId endpoint) {} void MatterBasicInformationPluginServerInitCallback() { diff --git a/src/app/clusters/basic-information/basic-information.h b/src/app/clusters/basic-information/basic-information.h index 4639c1c645df46..01a0b49df67795 100644 --- a/src/app/clusters/basic-information/basic-information.h +++ b/src/app/clusters/basic-information/basic-information.h @@ -33,12 +33,3 @@ bool IsLocalConfigDisabled(); } // namespace Clusters } // namespace app } // namespace chip - -/** @brief Basic Cluster Server Init - * - * This function is called at startup for a given endpoint to initialize - * attributes of the Basic Cluster. - * - * @param endpoint Endpoint that is being initialized Ver.: always - */ -void emberAfBasicClusterServerInitCallback(chip::EndpointId endpoint); diff --git a/src/credentials/GroupDataProviderImpl.cpp b/src/credentials/GroupDataProviderImpl.cpp index 87eb9d04d6ee4b..95764967dab051 100644 --- a/src/credentials/GroupDataProviderImpl.cpp +++ b/src/credentials/GroupDataProviderImpl.cpp @@ -33,7 +33,15 @@ using GroupEndpoint = GroupDataProvider::GroupEndpoint; using EpochKey = GroupDataProvider::EpochKey; using KeySet = GroupDataProvider::KeySet; using GroupSession = GroupDataProvider::GroupSession; -using FabricList = CommonPersistentData::FabricList; + +struct FabricList : public CommonPersistentData::FabricList +{ + CHIP_ERROR UpdateKey(StorageKeyName & key) override + { + key = DefaultStorageKeyAllocator::GroupFabricList(); + return CHIP_NO_ERROR; + } +}; constexpr size_t kPersistentBufferMax = 128; diff --git a/src/lib/support/CommonPersistentData.h b/src/lib/support/CommonPersistentData.h index 24c3e9a0354ce4..f04ba591959c4e 100644 --- a/src/lib/support/CommonPersistentData.h +++ b/src/lib/support/CommonPersistentData.h @@ -76,11 +76,8 @@ struct StoredDataList : public PersistentData constexpr size_t kPersistentFabricBufferMax = 32; struct FabricList : StoredDataList { - CHIP_ERROR UpdateKey(StorageKeyName & key) override - { - key = DefaultStorageKeyAllocator::FabricList(); - return CHIP_NO_ERROR; - } + // Subclasses need to define UpdateKey to be whatever fabric list key they + // care about. void Clear() override { diff --git a/src/lib/support/DefaultStorageKeyAllocator.h b/src/lib/support/DefaultStorageKeyAllocator.h index dd7098ecf607f9..6a4b906c2426b8 100644 --- a/src/lib/support/DefaultStorageKeyAllocator.h +++ b/src/lib/support/DefaultStorageKeyAllocator.h @@ -102,9 +102,6 @@ class DefaultStorageKeyAllocator static StorageKeyName FabricMetadata(FabricIndex fabric) { return StorageKeyName::Formatted("f/%x/m", fabric); } static StorageKeyName FabricOpKey(FabricIndex fabric) { return StorageKeyName::Formatted("f/%x/o", fabric); } - // Fabric List - static StorageKeyName FabricList() { return StorageKeyName::FromConst("g/fl"); } - // Fail-safe handling static StorageKeyName FailSafeCommitMarkerKey() { return StorageKeyName::FromConst("g/fs/c"); } static StorageKeyName FailSafeNetworkConfig() { return StorageKeyName::FromConst("g/fs/n"); } @@ -147,6 +144,7 @@ class DefaultStorageKeyAllocator // Group Data Provider // List of fabric indices that have endpoint-to-group associations defined. + static StorageKeyName GroupFabricList() { return StorageKeyName::FromConst("g/gfl"); } static StorageKeyName FabricGroups(chip::FabricIndex fabric) { return StorageKeyName::Formatted("f/%x/g", fabric); } static StorageKeyName FabricGroup(chip::FabricIndex fabric, chip::GroupId group) { diff --git a/src/platform/logging/BUILD.gn b/src/platform/logging/BUILD.gn index 402528315d5b81..505068535c748b 100644 --- a/src/platform/logging/BUILD.gn +++ b/src/platform/logging/BUILD.gn @@ -31,7 +31,11 @@ if (current_os == "android") { stdio_archive = "$root_out_dir/liblogging-stdio.a" static_library("stdio") { - sources = [ "impl/stdio/Logging.cpp" ] + if (chip_device_platform == "darwin") { + sources = [ "impl/stdio/darwin/Logging.cpp" ] + } else { + sources = [ "impl/stdio/Logging.cpp" ] + } deps = [ ":headers", diff --git a/src/platform/logging/impl/stdio/darwin/Logging.cpp b/src/platform/logging/impl/stdio/darwin/Logging.cpp new file mode 100644 index 00000000000000..f5599f5996b570 --- /dev/null +++ b/src/platform/logging/impl/stdio/darwin/Logging.cpp @@ -0,0 +1,72 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +namespace chip { +namespace Logging { +namespace Platform { + +void ENFORCE_FORMAT(3, 0) LogV(const char * module, uint8_t category, const char * msg, va_list v) +{ + timeval time; + gettimeofday(&time, nullptr); + long ms = (time.tv_sec * 1000) + (time.tv_usec / 1000); + + uint64_t ktid; + pthread_threadid_np(nullptr, &ktid); + + char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE]; + int32_t prefixLen = + snprintf(formattedMsg, sizeof(formattedMsg), "[%ld] [%lld:%lld] [%s] ", ms, (long long) getpid(), (long long) ktid, module); + if (prefixLen < 0) + { + // This should not happen + return; + } + + if (static_cast(prefixLen) >= sizeof(formattedMsg)) + { + prefixLen = sizeof(formattedMsg) - 1; + } + + vsnprintf(formattedMsg + prefixLen, sizeof(formattedMsg) - static_cast(prefixLen), msg, v); + + switch (category) + { + case kLogCategory_Error: + printf("\033[1;31m%s\033[0m\n", formattedMsg); + break; + case kLogCategory_Progress: + printf("\033[0;32m%s\033[0m\n", formattedMsg); + break; + case kLogCategory_Detail: + printf("\033[0;34m%s\033[0m\n", formattedMsg); + break; + } +} + +} // namespace Platform +} // namespace Logging +} // namespace chip