Skip to content

Commit

Permalink
Fix CI, Fix KConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
erjiaqing committed Jul 21, 2020
1 parent 6cdd178 commit 39945b6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
4 changes: 2 additions & 2 deletions config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ menu "CHIP Device Layer"
range 0 99999999
default 12345678
help
Specifies a hard-coded device pairing code to be used if none is found in CHIP NV storage.
Specifies a hard-coded device setup pin code to be used if none is found in CHIP NV storage.
Setting the value to 0 disables the feature.

Note that any decimal integer number between 00000000 and 99999999 can be used here.
Expand All @@ -672,7 +672,7 @@ menu "CHIP Device Layer"
range 0x000 0xFFF
default 0xF00
help
Specifies a hard-coded device pairing code to be used if none is found in CHIP NV storage.
Specifies a hard-coded device discriminator to be used if none is found in CHIP NV storage.
Setting the value to 0x0 disables the feature.

Note that any integer number between 0x000 and 0xFFF can be used here.
Expand Down
6 changes: 4 additions & 2 deletions examples/shell/README_DEVICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ ProductRevision: 0001
SerialNumber: <None>
ServiceId: <None>
FabricId: <None>
PairingCode: <None>
PinCode: <None>
Discriminator: <None>
DeviceId: <None>
DeviceCert: <None>
DeviceCaCerts: <None>
Expand All @@ -61,7 +62,8 @@ Where valid parameter names include:
- mfrdeviceid: Manufacturer Device Identification Number
- mfrcert: Manufacturer Device Certificate
- mfrcacerts: Manufacturer Device CA Certs
- pairingcode: Pairing Code
- pincode: Setup Pin Code
- discriminator: Setup Discriminator
- serviceid: Service Identifier
- fabricid: Fabric Identifier

Expand Down
6 changes: 3 additions & 3 deletions examples/shell/cmd_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ static CHIP_ERROR ConfigGetSetupPinCode(bool printHeader)

if (printHeader)
{
streamer_printf(sout, "SetupPinCode: ");
streamer_printf(sout, "PinCode: ");
}
SuccessOrExit(error = ConfigurationMgr().GetSetupPinCode(setupPinCode));
streamer_printf(sout, "%08u", setupPinCode);
Expand All @@ -344,7 +344,7 @@ static CHIP_ERROR ConfigGetSetupDiscriminator(bool printHeader)

if (printHeader)
{
streamer_printf(sout, "SetupDiscriminator:");
streamer_printf(sout, "Discriminator: ");
}
SuccessOrExit(error = ConfigurationMgr().GetSetupDiscriminator(setupDiscriminator));
streamer_printf(sout, "%03x", setupDiscriminator & 0xFFF);
Expand Down Expand Up @@ -465,7 +465,7 @@ int cmd_device_get(int argc, char ** argv)
{
SuccessOrExit(error = ConfigGetManufacturerDeviceCaCerts(false));
}
else if (strcmp(argv[0], "pairingcode") == 0)
else if (strcmp(argv[0], "pincode") == 0)
{
SuccessOrExit(error = ConfigGetSetupPinCode(false));
}
Expand Down
30 changes: 22 additions & 8 deletions src/platform/tests/TestConfigurationMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,22 +273,36 @@ static void TestConfigurationMgr_ServiceConfig(nlTestSuite * inSuite, void * inC
NL_TEST_ASSERT(inSuite, memcmp(buf, serviceConfig, serviceConfigLen) == 0);
}

static void TestConfigurationMgr_PairingCode(nlTestSuite * inSuite, void * inContext)
static void TestConfigurationMgr_SetupPinCode(nlTestSuite * inSuite, void * inContext)
{
CHIP_ERROR err = CHIP_NO_ERROR;

char buf[64];
size_t pairingCodeLen = 0;
const char * pairingCode = "016CB664A86A888D";
const uint32_t setSetupPinCode = 34567890;
uint32_t getSetupPinCode = 0;

err = ConfigurationMgr().StoreSetupPinCode(setSetupPinCode);
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

err = ConfigurationMgr().GetSetupPinCode(getSetupPinCode);
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

NL_TEST_ASSERT(inSuite, getSetupPinCode == setSetupPinCode);
}

static void TestConfigurationMgr_SetupDiscriminator(nlTestSuite * inSuite, void * inContext)
{
CHIP_ERROR err = CHIP_NO_ERROR;

const uint32_t setSetupDiscriminator = 0xBA0;
uint32_t getSetupDiscriminator = 0;

err = ConfigurationMgr().StorePairingCode(pairingCode, strlen(pairingCode));
err = ConfigurationMgr().StoreSetupDiscriminator(setSetupDiscriminator);
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

err = ConfigurationMgr().GetPairingCode(buf, 64, pairingCodeLen);
err = ConfigurationMgr().GetSetupDiscriminator(getSetupDiscriminator);
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

NL_TEST_ASSERT(inSuite, pairingCodeLen == strlen(pairingCode));
NL_TEST_ASSERT(inSuite, strcmp(buf, "016CB664A86A888D") == 0);
NL_TEST_ASSERT(inSuite, getSetupDiscriminator == setSetupDiscriminator);
}

static void TestConfigurationMgr_PairedAccountId(nlTestSuite * inSuite, void * inContext)
Expand Down

0 comments on commit 39945b6

Please sign in to comment.