Line data Source code
1 : /*
2 : *
3 : * Copyright (c) 2022 Project CHIP Authors
4 : *
5 : * Licensed under the Apache License, Version 2.0 (the "License");
6 : * you may not use this file except in compliance with the License.
7 : * You may obtain a copy of the License at
8 : *
9 : * http://www.apache.org/licenses/LICENSE-2.0
10 : *
11 : * Unless required by applicable law or agreed to in writing, software
12 : * distributed under the License is distributed on an "AS IS" BASIS,
13 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 : * See the License for the specific language governing permissions and
15 : * limitations under the License.
16 : */
17 :
18 : #pragma once
19 :
20 : #include <platform/ConfigurationManager.h>
21 : #include <platform/DeviceInstanceInfoProvider.h>
22 :
23 : namespace chip {
24 : namespace DeviceLayer {
25 : namespace Internal {
26 :
27 : template <class ConfigClass>
28 : class GenericConfigurationManagerImpl;
29 :
30 : template <class ConfigClass>
31 : class GenericDeviceInstanceInfoProvider : public DeviceInstanceInfoProvider
32 : {
33 :
34 : public:
35 : // GenericConfigurationManagerImpl will own a GenericDeviceInstanceInfoProvider which
36 : // *refers back to that GenericConfigurationManagerImpl*, due to how CRTP-based
37 : // storage APIs are defined.
38 : // This circular dependency is NOT needed by DeviceInstanceInfoProvider, but required
39 : // to keep generic code running.
40 82 : GenericDeviceInstanceInfoProvider(GenericConfigurationManagerImpl<ConfigClass> & configManager) :
41 82 : mGenericConfigManager(configManager)
42 82 : {}
43 :
44 : CHIP_ERROR GetVendorName(char * buf, size_t bufSize) override;
45 : CHIP_ERROR GetVendorId(uint16_t & vendorId) override;
46 : CHIP_ERROR GetProductName(char * buf, size_t bufSize) override;
47 : CHIP_ERROR GetProductId(uint16_t & productId) override;
48 : CHIP_ERROR GetPartNumber(char * buf, size_t bufSize) override;
49 : CHIP_ERROR GetProductURL(char * buf, size_t bufSize) override;
50 : CHIP_ERROR GetProductLabel(char * buf, size_t bufSize) override;
51 : CHIP_ERROR GetSerialNumber(char * buf, size_t bufSize) override;
52 : CHIP_ERROR GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & day) override;
53 : CHIP_ERROR GetHardwareVersion(uint16_t & hardwareVersion) override;
54 : CHIP_ERROR GetHardwareVersionString(char * buf, size_t bufSize) override;
55 : CHIP_ERROR GetSoftwareVersionString(char * buf, size_t bufSize) override;
56 : CHIP_ERROR GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) override;
57 :
58 : private:
59 : GenericConfigurationManagerImpl<ConfigClass> & mGenericConfigManager;
60 : };
61 :
62 : } // namespace Internal
63 : } // namespace DeviceLayer
64 : } // namespace chip
|