From 39945b67c5f3922e103a479cbd365c7526f335ee Mon Sep 17 00:00:00 2001 From: Song Guo Date: Tue, 21 Jul 2020 12:34:13 +0800 Subject: [PATCH] Fix CI, Fix KConfig --- config/esp32/components/chip/Kconfig | 4 +-- examples/shell/README_DEVICE.md | 6 +++-- examples/shell/cmd_device.cpp | 6 ++--- src/platform/tests/TestConfigurationMgr.cpp | 30 +++++++++++++++------ 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index 9c0bbc8c45266d..c1a1dafcebe408 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -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. @@ -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. diff --git a/examples/shell/README_DEVICE.md b/examples/shell/README_DEVICE.md index 1d9db72f218bad..aa4371bf13e0bc 100644 --- a/examples/shell/README_DEVICE.md +++ b/examples/shell/README_DEVICE.md @@ -36,7 +36,8 @@ ProductRevision: 0001 SerialNumber: ServiceId: FabricId: -PairingCode: +PinCode: +Discriminator: DeviceId: DeviceCert: DeviceCaCerts: @@ -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 diff --git a/examples/shell/cmd_device.cpp b/examples/shell/cmd_device.cpp index 257629dd49f158..0a47eb52cab75f 100644 --- a/examples/shell/cmd_device.cpp +++ b/examples/shell/cmd_device.cpp @@ -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); @@ -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); @@ -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)); } diff --git a/src/platform/tests/TestConfigurationMgr.cpp b/src/platform/tests/TestConfigurationMgr.cpp index a8177bd9f63eff..d31900be1bba60 100644 --- a/src/platform/tests/TestConfigurationMgr.cpp +++ b/src/platform/tests/TestConfigurationMgr.cpp @@ -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)