Skip to content

Commit

Permalink
[Ameba] Remove GetUniqueId in ConfigurationManagerImpl (#19033)
Browse files Browse the repository at this point in the history
* [ConfigurationManager] Remove GetUniqueId in ConfigurationManagerImpl
- Also removed CHIPSessionResumptionIndex key, and added CHIPGroupDataProvider key

* Restyled by clang-format

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Aug 21, 2023
1 parent 5d8e2c5 commit 2124700
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 47 deletions.
38 changes: 19 additions & 19 deletions src/platform/Ameba/AmebaConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,25 @@ namespace Internal {
// *** CAUTION ***: Changing the names or namespaces of these values will *break* existing devices.

// NVS namespaces used to store device configuration information.
const char AmebaConfig::kConfigNamespace_ChipFactory[] = "chip-factory";
const char AmebaConfig::kConfigNamespace_ChipConfig[] = "chip-config";
const char AmebaConfig::kConfigNamespace_ChipCounters[] = "chip-counters";
const char AmebaConfig::kConfigNamespace_ChipFabric1[] = "chip-fabric-1";
const char AmebaConfig::kConfigNamespace_ChipFabric2[] = "chip-fabric-2";
const char AmebaConfig::kConfigNamespace_ChipFabric3[] = "chip-fabric-3";
const char AmebaConfig::kConfigNamespace_ChipFabric4[] = "chip-fabric-4";
const char AmebaConfig::kConfigNamespace_ChipFabric5[] = "chip-fabric-5";
const char AmebaConfig::kConfigNamespace_ChipACL[] = "chip-acl";
const char AmebaConfig::kConfigNamespace_ChipGroupMessageCounters[] = "chip-groupmsgcounters";
const char AmebaConfig::kConfigNamespace_ChipAttributes[] = "chip-attributes";
const char AmebaConfig::kConfigNamespace_ChipBindingTable[] = "chip-bindingtable";
const char AmebaConfig::kConfigNamespace_ChipOTA[] = "chip-ota";
const char AmebaConfig::kConfigNamespace_ChipFailSafe[] = "chip-failsafe";
const char AmebaConfig::kConfigNamespace_ChipSessionResumptionIndex[] = "chip-sessionresumptionindex";
const char AmebaConfig::kConfigNamespace_ChipSessionResumption[] = "chip-sessionresumption";
const char AmebaConfig::kConfigNamespace_ChipDeviceInfoProvider[] = "chip-deviceinfoprovider";
const char AmebaConfig::kConfigNamespace_ChipOthers[] = "chip-others";
const char AmebaConfig::kConfigNamespace_ChipOthers2[] = "chip-others2";
const char AmebaConfig::kConfigNamespace_ChipFactory[] = "chip-factory";
const char AmebaConfig::kConfigNamespace_ChipConfig[] = "chip-config";
const char AmebaConfig::kConfigNamespace_ChipCounters[] = "chip-counters";
const char AmebaConfig::kConfigNamespace_ChipFabric1[] = "chip-fabric-1";
const char AmebaConfig::kConfigNamespace_ChipFabric2[] = "chip-fabric-2";
const char AmebaConfig::kConfigNamespace_ChipFabric3[] = "chip-fabric-3";
const char AmebaConfig::kConfigNamespace_ChipFabric4[] = "chip-fabric-4";
const char AmebaConfig::kConfigNamespace_ChipFabric5[] = "chip-fabric-5";
const char AmebaConfig::kConfigNamespace_ChipACL[] = "chip-acl";
const char AmebaConfig::kConfigNamespace_ChipGroupMessageCounters[] = "chip-groupmsgcounters";
const char AmebaConfig::kConfigNamespace_ChipAttributes[] = "chip-attributes";
const char AmebaConfig::kConfigNamespace_ChipBindingTable[] = "chip-bindingtable";
const char AmebaConfig::kConfigNamespace_ChipOTA[] = "chip-ota";
const char AmebaConfig::kConfigNamespace_ChipFailSafe[] = "chip-failsafe";
const char AmebaConfig::kConfigNamespace_ChipSessionResumption[] = "chip-sessionresumption";
const char AmebaConfig::kConfigNamespace_ChipDeviceInfoProvider[] = "chip-deviceinfoprovider";
const char AmebaConfig::kConfigNamespace_ChipGroupDataProvider[] = "chip-groupdataprovider";
const char AmebaConfig::kConfigNamespace_ChipOthers[] = "chip-others";
const char AmebaConfig::kConfigNamespace_ChipOthers2[] = "chip-others2";

// Keys stored in the chip-factory namespace
const AmebaConfig::Key AmebaConfig::kConfigKey_SerialNum = { kConfigNamespace_ChipFactory, "serial-num" };
Expand Down
2 changes: 1 addition & 1 deletion src/platform/Ameba/AmebaConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ class AmebaConfig
static const char kConfigNamespace_ChipBindingTable[];
static const char kConfigNamespace_ChipOTA[];
static const char kConfigNamespace_ChipFailSafe[];
static const char kConfigNamespace_ChipSessionResumptionIndex[];
static const char kConfigNamespace_ChipSessionResumption[];
static const char kConfigNamespace_ChipDeviceInfoProvider[];
static const char kConfigNamespace_ChipGroupDataProvider[];
static const char kConfigNamespace_ChipOthers[];
static const char kConfigNamespace_ChipOthers2[];

Expand Down
28 changes: 2 additions & 26 deletions src/platform/Ameba/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ CHIP_ERROR ConfigurationManagerImpl::Init()
SuccessOrExit(err);
err = AmebaConfig::EnsureNamespace(AmebaConfig::kConfigNamespace_ChipFailSafe);
SuccessOrExit(err);
err = AmebaConfig::EnsureNamespace2(AmebaConfig::kConfigNamespace_ChipSessionResumptionIndex);
SuccessOrExit(err);
err = AmebaConfig::EnsureNamespace(AmebaConfig::kConfigNamespace_ChipSessionResumption);
SuccessOrExit(err);
err = AmebaConfig::EnsureNamespace(AmebaConfig::kConfigNamespace_ChipDeviceInfoProvider);
SuccessOrExit(err);
err = AmebaConfig::EnsureNamespace(AmebaConfig::kConfigNamespace_ChipGroupDataProvider);
SuccessOrExit(err);
err = AmebaConfig::EnsureNamespace(AmebaConfig::kConfigNamespace_ChipOthers);
SuccessOrExit(err);
err = AmebaConfig::EnsureNamespace2(AmebaConfig::kConfigNamespace_ChipOthers2);
Expand Down Expand Up @@ -177,30 +177,6 @@ CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf)
return CHIP_NO_ERROR;
}

CHIP_ERROR ConfigurationManagerImpl::GetUniqueId(char * buf, size_t bufSize)
{
#ifdef CHIP_DEVICE_CONFIG_UNIQUE_ID
ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_UNIQUE_ID), CHIP_ERROR_BUFFER_TOO_SMALL);
strcpy(buf, CHIP_DEVICE_CONFIG_UNIQUE_ID);
return CHIP_NO_ERROR;
#else
ReturnErrorCodeIf(bufSize != 32, CHIP_ERROR_INVALID_MESSAGE_LENGTH);
char temp[32];
int i = 0, j = 0;

memset(&temp[0], 0, 32);
ReturnErrorCodeIf(wifi_get_mac_address(temp) != 0, CHIP_ERROR_INVALID_ARGUMENT);

for (i = 0; i < bufSize; i++)
{
if (temp[i] != ':')
buf[j++] = temp[i];
}

return CHIP_NO_ERROR;
#endif
}

bool ConfigurationManagerImpl::CanFactoryReset()
{
// TODO: query the application to determine if factory reset is allowed.
Expand Down
1 change: 0 additions & 1 deletion src/platform/Ameba/ConfigurationManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp
void InitiateFactoryReset(void) override;
CHIP_ERROR ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t & value) override;
CHIP_ERROR WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t value) override;
CHIP_ERROR GetUniqueId(char * buf, size_t bufSize) override;
// NOTE: Other public interface methods are implemented by GenericConfigurationManagerImpl<>.

// ===== Members that implement the GenericConfigurationManagerImpl protected interface.
Expand Down

0 comments on commit 2124700

Please sign in to comment.