2727#include < functional>
2828#include < platform/CHIPDeviceError.h>
2929
30- #ifndef SL_COMMON_TOKEN_MANAGER_ENABLE_DYNAMIC_TOKENS
30+ #ifdef SL_TOKEN_MANAGER_DEFINES_H
31+ #include < sl_token_manager_defines.h>
32+ #else
3133#include " nvm3.h"
3234#include " nvm3_hal_flash.h"
33- #else
34- #include < sl_token_manager_defines.h>
3535#endif
3636
3737#ifndef KVS_MAX_ENTRIES
@@ -61,7 +61,22 @@ namespace Internal {
6161 * the template class (e.g. the ReadConfigValue() method).
6262 */
6363
64- #ifndef SL_COMMON_TOKEN_MANAGER_ENABLE_DYNAMIC_TOKENS
64+ #ifdef SL_TOKEN_MANAGER_DEFINES_H
65+ inline constexpr uint32_t kUserNvm3KeyDomainLoLimit = SL_TOKEN_NVM3_REGION_USER;
66+ inline constexpr uint32_t kUserNvm3KeyDomainHiLimit = SL_TOKEN_NVM3_REGION_ZIGBEE - 1 ;
67+
68+ // Only keep the MSBs of the Matter Region. The LSB of the region is determined by the keyBaseOffset.
69+ // with SilabsConfigKey Helper function.
70+ inline constexpr uint32_t kMatterNvm3KeyDomain = (SL_TOKEN_NVM3_REGION_MATTER & 0xFFFF000 );
71+ // TODO: Determine what valuee to use for the static key domain to avoid collision between matter / Zigbee
72+ inline constexpr uint32_t kMatterStaticKeyDomain = (SL_TOKEN_NVM3_REGION_MATTER & 0xFFFF000 );
73+
74+ constexpr inline uint32_t SilabsConfigKey (uint8_t keyBaseOffset, uint8_t id)
75+ {
76+ return SL_TOKEN_TYPE_NVM3 | kMatterNvm3KeyDomain | static_cast <uint32_t >(keyBaseOffset) << 8 | id;
77+ }
78+
79+ #else
6580// Silabs NVM3 objects use a 20-bit number,
6681// NVM3 Key 19:16 Stack region
6782// NVM3 Key 15:0 Available NVM3 keys 0x0000 -> 0xFFFF.
@@ -77,24 +92,6 @@ constexpr inline uint32_t SilabsConfigKey(uint8_t keyBaseOffset, uint8_t id)
7792{
7893 return kMatterNvm3KeyDomain | static_cast <uint32_t >(keyBaseOffset) << 8 | id;
7994}
80- #else
81-
82- inline constexpr uint32_t kUserNvm3KeyDomainLoLimit = SL_TOKEN_NVM3_REGION_USER;
83- inline constexpr uint32_t kUserNvm3KeyDomainHiLimit = SL_TOKEN_NVM3_REGION_ZIGBEE - 1 ;
84-
85- // Only keep the MSBs of the Matter Region. The LSB of the region is determined by the keyBaseOffset.
86- // with SilabsConfigKey Helper function.
87- inline constexpr uint32_t kMatterNvm3KeyDomain = (SL_TOKEN_NVM3_REGION_MATTER & 0xFFFF000 );
88-
89- constexpr inline uint32_t SilabsConfigKey (uint8_t keyBaseOffset, uint8_t id)
90- {
91- return SL_TOKEN_TYPE_NVM3 | kMatterNvm3KeyDomain | static_cast <uint32_t >(keyBaseOffset) << 8 | id;
92- }
93-
94- constexpr inline uint32_t SilabsSecureTokenKey (uint8_t keyBaseOffset, uint8_t id)
95- {
96- return SL_TOKEN_TYPE_STATIC_SECURE | static_cast <uint32_t >(keyBaseOffset) << 8 | id;
97- }
9895#endif
9996
10097inline constexpr uint32_t kMatterNvm3KeyLoLimit = 0x087200U ; // Do not modify without Silabs GSDK team approval
@@ -151,16 +148,23 @@ class SilabsConfig
151148 // SHALL NOT be the same as the UniqueID attribute exposed in the Basic Information cluster.
152149 static constexpr Key kConfigKey_PersistentUniqueId = SilabsConfigKey(kMatterFactory_KeyBase , 0x1F );
153150 static constexpr Key kConfigKey_Creds_KeyId = SilabsConfigKey(kMatterFactory_KeyBase , 0x20 );
154- static constexpr Key kConfigKey_Creds_Base_Addr = SilabsConfigKey(kMatterFactory_KeyBase , 0x21 );
155- static constexpr Key kConfigKey_Creds_DAC_Offset = SilabsConfigKey(kMatterFactory_KeyBase , 0x22 );
156- static constexpr Key kConfigKey_Creds_DAC_Size = SilabsConfigKey(kMatterFactory_KeyBase , 0x23 );
157- static constexpr Key kConfigKey_Creds_PAI_Offset = SilabsConfigKey(kMatterFactory_KeyBase , 0x24 );
158- static constexpr Key kConfigKey_Creds_PAI_Size = SilabsConfigKey(kMatterFactory_KeyBase , 0x25 );
159- static constexpr Key kConfigKey_Creds_CD_Offset = SilabsConfigKey(kMatterFactory_KeyBase , 0x26 );
160- static constexpr Key kConfigKey_Creds_CD_Size = SilabsConfigKey(kMatterFactory_KeyBase , 0x27 );
161- static constexpr Key kConfigKey_Provision_Request = SilabsConfigKey(kMatterFactory_KeyBase , 0x28 );
162- static constexpr Key kConfigKey_Provision_Version = SilabsConfigKey(kMatterFactory_KeyBase , 0x29 );
163- static constexpr Key kOtaTlvEncryption_KeyId = SilabsConfigKey(kMatterFactory_KeyBase , 0x30 );
151+
152+ // DEPRECATED KEYS : BEGIN
153+ static constexpr Key kConfigKey_Creds_Base_Addr = SilabsConfigKey(kMatterFactory_KeyBase , 0x21 );
154+ static constexpr Key kConfigKey_Creds_DAC_Offset = SilabsConfigKey(kMatterFactory_KeyBase , 0x22 );
155+ static constexpr Key kConfigKey_Creds_PAI_Offset = SilabsConfigKey(kMatterFactory_KeyBase , 0x24 );
156+ static constexpr Key kConfigKey_Creds_CD_Offset = SilabsConfigKey(kMatterFactory_KeyBase , 0x26 );
157+ // DEPRECATED KEYS : END
158+
159+ static constexpr Key kConfigKey_Creds_DAC_Size = SilabsConfigKey(kMatterFactory_KeyBase , 0x23 );
160+ static constexpr Key kConfigKey_Creds_PAI_Size = SilabsConfigKey(kMatterFactory_KeyBase , 0x25 );
161+ static constexpr Key kConfigKey_Creds_CD_Size = SilabsConfigKey(kMatterFactory_KeyBase , 0x27 );
162+ static constexpr Key kConfigKey_Provision_Request = SilabsConfigKey(kMatterFactory_KeyBase , 0x28 );
163+ static constexpr Key kConfigKey_Provision_Version = SilabsConfigKey(kMatterFactory_KeyBase , 0x29 );
164+ static constexpr Key kOtaTlvEncryption_KeyId = SilabsConfigKey(kMatterFactory_KeyBase , 0x30 );
165+ static constexpr Key kConfigKey_Creds_Dac = SilabsConfigKey(kMatterFactory_KeyBase , 0x31 );
166+ static constexpr Key kConfigKey_Creds_Pai = SilabsConfigKey(kMatterFactory_KeyBase , 0x32 );
167+ static constexpr Key kConfigKey_Creds_CD = SilabsConfigKey(kMatterFactory_KeyBase , 0x33 );
164168
165169 // Matter Config Keys
166170 static constexpr Key kConfigKey_ServiceConfig = SilabsConfigKey(kMatterConfig_KeyBase , 0x01 );
0 commit comments