Matter SDK Coverage Report
Current view: top level - include/platform - ConfigurationManager.h (source / functions) Coverage Total Hit
Test: SHA:b879ecb8e99e175eea0a293a888bda853da2b19c Lines: 0.0 % 4 0
Test Date: 2025-01-17 19:00:11 Functions: 0.0 % 2 0

            Line data    Source code
       1              : /*
       2              :  *
       3              :  *    Copyright (c) 2020-2022 Project CHIP Authors
       4              :  *    Copyright (c) 2019-2020 Google LLC.
       5              :  *    Copyright (c) 2018 Nest Labs, Inc.
       6              :  *
       7              :  *    Licensed under the Apache License, Version 2.0 (the "License");
       8              :  *    you may not use this file except in compliance with the License.
       9              :  *    You may obtain a copy of the License at
      10              :  *
      11              :  *        http://www.apache.org/licenses/LICENSE-2.0
      12              :  *
      13              :  *    Unless required by applicable law or agreed to in writing, software
      14              :  *    distributed under the License is distributed on an "AS IS" BASIS,
      15              :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      16              :  *    See the License for the specific language governing permissions and
      17              :  *    limitations under the License.
      18              :  */
      19              : 
      20              : /**
      21              :  *    @file
      22              :  *          Defines the public interface for the Device Layer ConfigurationManager object.
      23              :  */
      24              : 
      25              : #pragma once
      26              : 
      27              : #include <cstdint>
      28              : 
      29              : #include <platform/CHIPDeviceConfig.h>
      30              : 
      31              : #if CHIP_HAVE_CONFIG_H
      32              : #include <setup_payload/CHIPAdditionalDataPayloadBuildConfig.h>
      33              : #endif
      34              : 
      35              : #include <lib/core/ClusterEnums.h>
      36              : #include <lib/support/Span.h>
      37              : #include <platform/PersistedStorage.h>
      38              : #include <platform/internal/CHIPDeviceLayerInternal.h>
      39              : 
      40              : namespace chip {
      41              : namespace Ble {
      42              : struct ChipBLEDeviceIdentificationInfo;
      43              : }
      44              : } // namespace chip
      45              : 
      46              : namespace chip {
      47              : namespace DeviceLayer {
      48              : 
      49              : class PlatformManagerImpl;
      50              : class ConfigurationManagerImpl;
      51              : namespace Internal {
      52              : template <class>
      53              : class GenericPlatformManagerImpl;
      54              : template <class>
      55              : class GenericPlatformManagerImpl_POSIX;
      56              : } // namespace Internal
      57              : 
      58              : /**
      59              :  * Provides access to runtime and build-time configuration information for a chip device.
      60              :  */
      61              : class ConfigurationManager
      62              : {
      63              : public:
      64              :     // ===== Members that define the public interface of the ConfigurationManager
      65              : 
      66              :     enum
      67              :     {
      68              :         kMaxVendorNameLength            = 32,
      69              :         kMaxProductNameLength           = 32,
      70              :         kMaxLocationLength              = 2,
      71              :         kMaxHardwareVersionStringLength = 64,
      72              :         kMaxSoftwareVersionStringLength = 64,
      73              :         kMaxManufacturingDateLength     = 16,
      74              :         kMaxPartNumberLength            = 32,
      75              :         kMaxProductURLLength            = 256,
      76              :         kMaxProductLabelLength          = 64,
      77              :         kMaxSerialNumberLength          = 32,
      78              :         kMaxUniqueIDLength              = 32,
      79              : #if CHIP_ENABLE_ROTATING_DEVICE_ID && defined(CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID)
      80              :         kMinRotatingDeviceIDUniqueIDLength = 16,
      81              :         kRotatingDeviceIDUniqueIDLength    = CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID_LENGTH,
      82              : #endif
      83              :         kEthernetMACAddressLength = 6,
      84              :         kThreadMACAddressLength   = 8,
      85              : #if CHIP_DEVICE_CONFIG_ENABLE_THREAD
      86              :         kPrimaryMACAddressLength = kThreadMACAddressLength,
      87              : #else
      88              :         kPrimaryMACAddressLength = kEthernetMACAddressLength,
      89              : #endif
      90              :         kMaxMACAddressLength  = 8,
      91              :         kMaxLanguageTagLength = 5 // ISO 639-1 standard language codes
      92              :     };
      93              : 
      94              :     // Copies the primary MAC into a mutable span, which must be of size kPrimaryMACAddressLength.
      95              :     // Upon success, the span will be reduced to the size of the MAC address being returned, which
      96              :     // can be less than kPrimaryMACAddressLength on a device that supports Thread.
      97              :     virtual CHIP_ERROR GetPrimaryMACAddress(MutableByteSpan buf) = 0;
      98              : 
      99              :     // Copies the primary WiFi MAC into a buffer of size kEthernetMACAddressLength
     100              :     virtual CHIP_ERROR GetPrimaryWiFiMACAddress(uint8_t * buf) = 0;
     101              : 
     102              :     // Copies the primary Thread (802.15.4) MAC into a buffer of size kThreadMACAddressLength
     103              :     virtual CHIP_ERROR GetPrimary802154MACAddress(uint8_t * buf)                           = 0;
     104              :     virtual CHIP_ERROR GetSoftwareVersionString(char * buf, size_t bufSize)                = 0;
     105              :     virtual CHIP_ERROR GetSoftwareVersion(uint32_t & softwareVer)                          = 0;
     106              :     virtual CHIP_ERROR GetFirmwareBuildChipEpochTime(System::Clock::Seconds32 & buildTime) = 0;
     107            0 :     virtual CHIP_ERROR SetFirmwareBuildChipEpochTime(System::Clock::Seconds32 buildTime) { return CHIP_ERROR_NOT_IMPLEMENTED; }
     108              : #if CHIP_ENABLE_ROTATING_DEVICE_ID && defined(CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID)
     109              :     // Lifetime counter is monotonic counter that is incremented upon each commencement of advertising
     110              :     virtual CHIP_ERROR GetLifetimeCounter(uint16_t & lifetimeCounter)              = 0;
     111              :     virtual CHIP_ERROR IncrementLifetimeCounter()                                  = 0;
     112              :     virtual CHIP_ERROR SetRotatingDeviceIdUniqueId(const ByteSpan & uniqueIdSpan)  = 0;
     113              :     virtual CHIP_ERROR GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) = 0;
     114              : #endif
     115              :     virtual CHIP_ERROR GetRegulatoryLocation(uint8_t & location)                       = 0;
     116              :     virtual CHIP_ERROR GetCountryCode(char * buf, size_t bufSize, size_t & codeLen)    = 0;
     117              :     virtual CHIP_ERROR StoreSerialNumber(const char * serialNum, size_t serialNumLen)  = 0;
     118              :     virtual CHIP_ERROR StoreManufacturingDate(const char * mfgDate, size_t mfgDateLen) = 0;
     119              :     virtual CHIP_ERROR StoreSoftwareVersion(uint32_t softwareVer)                      = 0;
     120              :     virtual CHIP_ERROR StoreHardwareVersion(uint16_t hardwareVer)                      = 0;
     121              :     virtual CHIP_ERROR StoreRegulatoryLocation(uint8_t location)                       = 0;
     122              :     virtual CHIP_ERROR StoreCountryCode(const char * code, size_t codeLen)             = 0;
     123              :     virtual CHIP_ERROR GetRebootCount(uint32_t & rebootCount)                          = 0;
     124              :     virtual CHIP_ERROR StoreRebootCount(uint32_t rebootCount)                          = 0;
     125              :     virtual CHIP_ERROR GetTotalOperationalHours(uint32_t & totalOperationalHours)      = 0;
     126              :     virtual CHIP_ERROR StoreTotalOperationalHours(uint32_t totalOperationalHours)      = 0;
     127              :     virtual CHIP_ERROR GetBootReason(uint32_t & bootReason)                            = 0;
     128              :     virtual CHIP_ERROR StoreBootReason(uint32_t bootReason)                            = 0;
     129              :     virtual CHIP_ERROR GetUniqueId(char * buf, size_t bufSize)                         = 0;
     130              :     virtual CHIP_ERROR StoreUniqueId(const char * uniqueId, size_t uniqueIdLen)        = 0;
     131              :     virtual CHIP_ERROR GenerateUniqueId(char * buf, size_t bufSize)                    = 0;
     132              :     virtual CHIP_ERROR GetFailSafeArmed(bool & val)                                    = 0;
     133              :     virtual CHIP_ERROR SetFailSafeArmed(bool val)                                      = 0;
     134              : 
     135              :     virtual CHIP_ERROR GetBLEDeviceIdentificationInfo(Ble::ChipBLEDeviceIdentificationInfo & deviceIdInfo) = 0;
     136              : 
     137              : #if CHIP_CONFIG_TEST
     138              :     virtual void RunUnitTests() = 0;
     139              : #endif
     140              : 
     141              :     virtual bool IsFullyProvisioned()   = 0;
     142              :     virtual void InitiateFactoryReset() = 0;
     143              : 
     144              :     // Gets called when starting BLE/DNS-SD advertisement
     145              : #if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING
     146              :     virtual void NotifyOfAdvertisementStart() {}
     147              : #else
     148              :     void NotifyOfAdvertisementStart() {}
     149              : #endif
     150              : 
     151              :     virtual void LogDeviceConfig() = 0;
     152              : 
     153              :     virtual bool IsCommissionableDeviceTypeEnabled()                              = 0;
     154              :     virtual CHIP_ERROR GetDeviceTypeId(uint32_t & deviceType)                     = 0;
     155              :     virtual bool IsCommissionableDeviceNameEnabled()                              = 0;
     156              :     virtual CHIP_ERROR GetCommissionableDeviceName(char * buf, size_t bufSize)    = 0;
     157              :     virtual CHIP_ERROR GetInitialPairingHint(uint16_t & pairingHint)              = 0;
     158              :     virtual CHIP_ERROR GetInitialPairingInstruction(char * buf, size_t bufSize)   = 0;
     159              :     virtual CHIP_ERROR GetSecondaryPairingHint(uint16_t & pairingHint)            = 0;
     160              :     virtual CHIP_ERROR GetSecondaryPairingInstruction(char * buf, size_t bufSize) = 0;
     161              : 
     162              :     virtual CHIP_ERROR GetLocationCapability(uint8_t & location);
     163              : 
     164              : protected:
     165              :     // ===== Members for internal use by the following friends.
     166              : 
     167              :     friend class ::chip::DeviceLayer::PlatformManagerImpl;
     168              :     template <class>
     169              :     friend class ::chip::DeviceLayer::Internal::GenericPlatformManagerImpl;
     170              :     template <class>
     171              :     friend class ::chip::DeviceLayer::Internal::GenericPlatformManagerImpl_POSIX;
     172              :     // Parentheses used to fix clang parsing issue with these declarations
     173              :     friend CHIP_ERROR(::chip::Platform::PersistedStorage::Read)(::chip::Platform::PersistedStorage::Key key, uint32_t & value);
     174              :     friend CHIP_ERROR(::chip::Platform::PersistedStorage::Write)(::chip::Platform::PersistedStorage::Key key, uint32_t value);
     175              : 
     176              :     virtual CHIP_ERROR Init()                                                                                   = 0;
     177              :     virtual bool CanFactoryReset()                                                                              = 0;
     178              :     virtual CHIP_ERROR ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t & value) = 0;
     179              :     virtual CHIP_ERROR WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t value)  = 0;
     180              : 
     181              :     // Construction/destruction limited to subclasses.
     182              :     ConfigurationManager()          = default;
     183              :     virtual ~ConfigurationManager() = default;
     184              : 
     185              :     // No copy, move or assignment.
     186              :     ConfigurationManager(const ConfigurationManager &)             = delete;
     187              :     ConfigurationManager(const ConfigurationManager &&)            = delete;
     188              :     ConfigurationManager & operator=(const ConfigurationManager &) = delete;
     189              : };
     190              : 
     191              : /**
     192              :  * Returns a reference to a ConfigurationManager object.
     193              :  *
     194              :  * Applications should use this to access features of the ConfigurationManager object
     195              :  * that are common to all platforms.
     196              :  */
     197              : ConfigurationManager & ConfigurationMgr();
     198              : 
     199              : /**
     200              :  * Returns the platform-specific implementation of the ConfigurationManager object.
     201              :  *
     202              :  * Applications can use this to gain access to features of the ConfigurationManager
     203              :  * that are specific to the selected platform.
     204              :  */
     205              : extern ConfigurationManager & ConfigurationMgrImpl();
     206              : 
     207              : /**
     208              :  * Sets a reference to a ConfigurationManager object.
     209              :  *
     210              :  * This must be called before any calls to ConfigurationMgr. If a nullptr is passed in,
     211              :  * no changes will be made.
     212              :  */
     213              : void SetConfigurationMgr(ConfigurationManager * configurationManager);
     214              : 
     215            0 : inline CHIP_ERROR ConfigurationManager::GetLocationCapability(uint8_t & location)
     216              : {
     217            0 :     location = to_underlying(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum::kIndoor);
     218            0 :     return CHIP_NO_ERROR;
     219              : }
     220              : 
     221              : } // namespace DeviceLayer
     222              : } // namespace chip
     223              : 
     224              : /* Include a header file containing the implementation of the ConfigurationManager
     225              :  * object for the selected platform.
     226              :  */
     227              : #ifdef EXTERNAL_CONFIGURATIONMANAGERIMPL_HEADER
     228              : #include EXTERNAL_CONFIGURATIONMANAGERIMPL_HEADER
     229              : #elif defined(CHIP_DEVICE_LAYER_TARGET)
     230              : #define CONFIGURATIONMANAGERIMPL_HEADER <platform/CHIP_DEVICE_LAYER_TARGET/ConfigurationManagerImpl.h>
     231              : #include CONFIGURATIONMANAGERIMPL_HEADER
     232              : #endif // defined(CHIP_DEVICE_LAYER_TARGET)
        

Generated by: LCOV version 2.0-1