Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Config Manager on the Darwin platform to store Discriminator in RAM #10584

Merged
merged 9 commits into from
Oct 20, 2021
16 changes: 12 additions & 4 deletions src/platform/Darwin/PosixConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ const PosixConfig::Key PosixConfig::kConfigKey_Breadcrumb = { kConfigNam
// Prefix used for NVS keys that contain Chip group encryption keys.
const char PosixConfig::kGroupKeyNamePrefix[] = "gk-";

uint16_t PosixConfig::mPosixSetupDiscriminator = 0xF00; // CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR

CHIP_ERROR PosixConfig::Init()
{
CHIP_ERROR err = CHIP_NO_ERROR;
Expand All @@ -88,9 +90,12 @@ CHIP_ERROR PosixConfig::ReadConfigValue(Key key, bool & val)
CHIP_ERROR PosixConfig::ReadConfigValue(Key key, uint32_t & val)
{
CHIP_ERROR err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND;
SuccessOrExit(err);

exit:
if (key == kConfigKey_SetupDiscriminator)
{
val = mPosixSetupDiscriminator;
return CHIP_NO_ERROR;
}
return err;
}

Expand Down Expand Up @@ -133,9 +138,12 @@ CHIP_ERROR PosixConfig::WriteConfigValue(Key key, bool val)
CHIP_ERROR PosixConfig::WriteConfigValue(Key key, uint32_t val)
{
CHIP_ERROR err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND;
SuccessOrExit(err);

exit:
if (key == kConfigKey_SetupDiscriminator)
{
mPosixSetupDiscriminator = val;
return CHIP_NO_ERROR;
}
return err;
}

Expand Down
4 changes: 4 additions & 0 deletions src/platform/Darwin/PosixConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ class PosixConfig
// NVS Namespace helper functions.
static CHIP_ERROR EnsureNamespace(const char * ns);
static CHIP_ERROR ClearNamespace(const char * ns);

private:
// TODO: This is temporary until Darwin implements a proper ReadConfigValue
static uint16_t mPosixSetupDiscriminator;
selissia marked this conversation as resolved.
Show resolved Hide resolved
};

struct PosixConfig::Key
Expand Down