diff --git a/examples/lock-app/efr32/include/CHIPProjectConfig.h b/examples/lock-app/efr32/include/CHIPProjectConfig.h index 89a1e51773efee..13430f551b24f2 100644 --- a/examples/lock-app/efr32/include/CHIPProjectConfig.h +++ b/examples/lock-app/efr32/include/CHIPProjectConfig.h @@ -40,8 +40,13 @@ #define CHIP_DEVICE_CONFIG_ENABLE_TEST_DEVICE_IDENTITY 34 // Use a default pairing code if one hasn't been provisioned in flash. +#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 12345678 +#endif + +#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 +#endif // For convenience, Chip Security Test Mode can be enabled and the // requirement for authentication in various protocols can be disabled. diff --git a/examples/lock-app/nrfconnect/main/include/CHIPProjectConfig.h b/examples/lock-app/nrfconnect/main/include/CHIPProjectConfig.h index 082fe0d5532ddd..a43151c719954b 100644 --- a/examples/lock-app/nrfconnect/main/include/CHIPProjectConfig.h +++ b/examples/lock-app/nrfconnect/main/include/CHIPProjectConfig.h @@ -29,7 +29,12 @@ #define CHIP_PROJECT_CONFIG_H // Use a default pairing code if one hasn't been provisioned in flash. +#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 12345678 +#endif + +#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 +#endif #endif // CHIP_PROJECT_CONFIG_H diff --git a/examples/platform/nrf528xx/app/project_include/CHIPProjectConfig.h b/examples/platform/nrf528xx/app/project_include/CHIPProjectConfig.h index d9ceed270ced63..1fcaa3bf31f476 100644 --- a/examples/platform/nrf528xx/app/project_include/CHIPProjectConfig.h +++ b/examples/platform/nrf528xx/app/project_include/CHIPProjectConfig.h @@ -50,8 +50,13 @@ #define CHIP_DEVICE_CONFIG_ENABLE_TEST_DEVICE_IDENTITY 34 // Use a default pairing code if one hasn't been provisioned in flash. +#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 12345678 +#endif + +#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 +#endif /** * CHIP_DEVICE_CONFIG_USE_TEST_SERIAL_NUMBER diff --git a/gn_build.sh b/gn_build.sh index 13baa92a1a3d74..98a3dec566612a 100755 --- a/gn_build.sh +++ b/gn_build.sh @@ -71,7 +71,6 @@ echo ninja -C "$CHIP_ROOT/out/custom" # nRF5 SDK setup nrf5_sdk_args="" -extra_args="" if [[ -d "$NRF5_SDK_ROOT/components/libraries" ]]; then nrf5_sdk_args+="nrf5_sdk_root=\"$NRF5_SDK_ROOT\"" @@ -103,8 +102,8 @@ echo _chip_banner "Build: GN configure" -gn --root="$CHIP_ROOT" gen --check "$CHIP_ROOT/out/debug" --args='target_os="all"'"$extra_args" -gn --root="$CHIP_ROOT" gen --check "$CHIP_ROOT/out/release" --args='target_os="all" is_debug=false'"$extra_args" +gn --root="$CHIP_ROOT" gen --check "$CHIP_ROOT/out/debug" --args='target_os="all"'" $extra_args" +gn --root="$CHIP_ROOT" gen --check "$CHIP_ROOT/out/release" --args='target_os="all" is_debug=false'" $extra_args" _chip_banner "Build: Ninja build" diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index 82d332befa88a3..c96e75ed13e02c 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -37,6 +37,12 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { # Time the firmware was built. chip_device_config_firmware_build_time = "" + + # Test setup pincode + chip_device_test_setup_pincode = "" + + # Test setup discriminator + chip_device_test_setup_discriminator = "" } config("platform_config") { @@ -58,6 +64,13 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { defines += [ "CHIP_DEVICE_CONFIG_FIRMWARE_BUILD_TIME=\"${chip_device_config_firmware_build_time}\"" ] } + if (chip_device_test_setup_pincode != "") { + defines += [ "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${chip_device_test_setup_pincode}" ] + } + if (chip_device_test_setup_discriminator != "") { + defines += [ "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${chip_device_test_setup_discriminator}" ] + } + if (chip_device_platform == "darwin") { frameworks = [ "CoreFoundation.framework", diff --git a/src/platform/nRF5/BLEManagerImpl.cpp b/src/platform/nRF5/BLEManagerImpl.cpp index 126a27140cbb08..ef560339bd1b1c 100644 --- a/src/platform/nRF5/BLEManagerImpl.cpp +++ b/src/platform/nRF5/BLEManagerImpl.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -253,8 +254,10 @@ CHIP_ERROR BLEManagerImpl::_SetDeviceName(const char * devName) } else { - // FIXME: the name should be derived from factory data - snprintf(devNameBuf, sizeof(devNameBuf), "%s%04" PRIX32, CHIP_DEVICE_CONFIG_BLE_DEVICE_NAME_PREFIX, (uint32_t) 0); + uint32_t discriminator = 0; + + ConfigurationMgr().GetSetupDiscriminator(discriminator); + snprintf(devNameBuf, sizeof(devNameBuf), "%s%04" PRIX32, CHIP_DEVICE_CONFIG_BLE_DEVICE_NAME_PREFIX, discriminator); devNameBuf[kMaxDeviceNameLength] = 0; }