Skip to content

Commit

Permalink
[EFR32] Implement the CommisionableData Provider (#22705)
Browse files Browse the repository at this point in the history
* WIP

* WIP Add the Commisionable Data provide to the ligthing-app

* Fix reading potential garbage bytes. Create python script to inject commissionable data to a efr32 device

* Add EFR32CommissinableDataProvider to all silabs examples. Add a fallback to use TEST_SETUP_VALUES if credentials are not found in nvm3. Add a Readme for the provider script.

* Fix typo and add a subscript in the readme.md

* Create a class and remove the use of global variables. Fix other comments

* fix merge conflict, run restyle

* Remove Passcode storing, Instead store qrcode bitset payload. Support deviceInstanceInfoProvider, augment FactoryDataProvider and add checks

* Add commissioning flow and rendez-vous flag args to the factoryDataProvider script

* fix build issue

* Enable EFR32DeviceDataProvider for the wifi platform examples also

* address last few comments
  • Loading branch information
jmartinez-silabs authored and pull[bot] committed Jul 11, 2023
1 parent 6ed2436 commit 1582780
Show file tree
Hide file tree
Showing 31 changed files with 6,566 additions and 74 deletions.
11 changes: 5 additions & 6 deletions examples/chef/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ declare_args() {
# Dump memory usage at link time.
chip_print_memory_usage = false

# PIN code for PASE session establishment.
setupPinCode = 20202021
setupDiscriminator = 3840

# Monitor & log memory usage at runtime.
enable_heap_monitoring = false

Expand Down Expand Up @@ -136,8 +132,6 @@ efr32_sdk("sdk") {

defines = [
"BOARD_ID=${silabs_board}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}",
"OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}",
]

Expand Down Expand Up @@ -341,6 +335,11 @@ efr32_executable("chef_app") {
deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ]
}

# Factory Data Provider
if (use_efr32_factory_data_provider) {
deps += [ "${examples_plat_dir}:efr32-factory-data-provider" ]
}

output_dir = root_out_dir
}

Expand Down
11 changes: 5 additions & 6 deletions examples/light-switch-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ declare_args() {
# Dump memory usage at link time.
chip_print_memory_usage = false

# PIN code for PASE session establishment.
setupPinCode = 20202021
setupDiscriminator = 3840

# Monitor & log memory usage at runtime.
enable_heap_monitoring = false

Expand Down Expand Up @@ -129,8 +125,6 @@ efr32_sdk("sdk") {

defines = [
"BOARD_ID=${silabs_board}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}",
"OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}",
]

Expand Down Expand Up @@ -216,6 +210,11 @@ efr32_executable("light_switch_app") {
deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ]
}

# Factory Data Provider
if (use_efr32_factory_data_provider) {
deps += [ "${examples_plat_dir}:efr32-factory-data-provider" ]
}

if (chip_enable_ota_requestor) {
defines += [ "EFR32_OTA_ENABLED" ]
sources += [ "${examples_plat_dir}/OTAConfig.cpp" ]
Expand Down
2 changes: 1 addition & 1 deletion examples/light-switch-app/efr32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Silicon Labs platform.

or use gn as previously mentioned but adding the following arguments:

$ gn gen out/debug '--args=efr32_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false chip_build_libshell=true'
$ gn gen out/debug '--args=silabs_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false chip_build_libshell=true'

* Build the example with pigweed RCP

Expand Down
11 changes: 5 additions & 6 deletions examples/lighting-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ declare_args() {
# Dump memory usage at link time.
chip_print_memory_usage = false

# PIN code for PASE session establishment.
setupPinCode = 20202021
setupDiscriminator = 3840

# Monitor & log memory usage at runtime.
enable_heap_monitoring = false

Expand Down Expand Up @@ -134,8 +130,6 @@ efr32_sdk("sdk") {

defines = [
"BOARD_ID=${silabs_board}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}",
"OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}",
]

Expand Down Expand Up @@ -353,6 +347,11 @@ efr32_executable("lighting_app") {
deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ]
}

# Factory Data Provider
if (use_efr32_factory_data_provider) {
deps += [ "${examples_plat_dir}:efr32-factory-data-provider" ]
}

output_dir = root_out_dir
}

Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/efr32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Silicon Labs platform.

or use gn as previously mentioned but adding the following arguments:

$ gn gen out/debug '--args=efr32_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false'
$ gn gen out/debug '--args=silabs_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false'

* Build the example with pigweed RPC

Expand Down
11 changes: 5 additions & 6 deletions examples/lock-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ declare_args() {
# Dump memory usage at link time.
chip_print_memory_usage = false

# PIN code for PASE session establishment.
setupPinCode = 20202021
setupDiscriminator = 3840

# Monitor & log memory usage at runtime.
enable_heap_monitoring = false

Expand Down Expand Up @@ -129,8 +125,6 @@ efr32_sdk("sdk") {

defines = [
"BOARD_ID=${silabs_board}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}",
"OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}",
]

Expand Down Expand Up @@ -344,6 +338,11 @@ efr32_executable("lock_app") {
deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ]
}

# Factory Data Provider
if (use_efr32_factory_data_provider) {
deps += [ "${examples_plat_dir}:efr32-factory-data-provider" ]
}

output_dir = root_out_dir
}
group("efr32") {
Expand Down
4 changes: 2 additions & 2 deletions examples/lock-app/efr32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Silicon Labs platform.
$ git submodule update --init
$ source third_party/connectedhomeip/scripts/activate.sh
$ export EFR32_BOARD=BRD4161A
$ gn gen out/debug --args="efr32_sdk_root=\"${EFR32_SDK_ROOT}\" efr32_board=\"${EFR32_BOARD}\""
$ gn gen out/debug --args="efr32_sdk_root=\"${EFR32_SDK_ROOT}\" silabs_board=\"${EFR32_BOARD}\""
$ ninja -C out/debug
```

Expand All @@ -125,7 +125,7 @@ Silicon Labs platform.
or use gn as previously mentioned but adding the following arguments:

```
$ gn gen out/debug '--args=efr32_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false'
$ gn gen out/debug '--args=silabs_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false'
```

* Build the example with pigweed RCP
Expand Down
2 changes: 1 addition & 1 deletion examples/persistent-storage/efr32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ OR use GN/Ninja directly
$ git submodule update --init
$ source third_party/connectedhomeip/scripts/activate.sh
$ export EFR32_BOARD=BRD4161A
$ gn gen out/debug --args="efr32_sdk_root=\"${EFR32_SDK_ROOT}\" efr32_board=\"${EFR32_BOARD}\""
$ gn gen out/debug --args="efr32_sdk_root=\"${EFR32_SDK_ROOT}\" silabs_board=\"${EFR32_BOARD}\""
$ ninja -C out/debug

- To delete generated executable, libraries and object files use:
Expand Down
15 changes: 15 additions & 0 deletions examples/platform/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,18 @@ source_set("efr32-attestation-credentials") {

public_configs = [ ":attestation-credentials-config" ]
}

source_set("efr32-factory-data-provider") {
sources = [
"EFR32DeviceDataProvider.cpp",
"EFR32DeviceDataProvider.h",
]

public_deps = [
"${chip_root}/src/credentials",
"${chip_root}/src/platform:platform_base",
"${chip_root}/src/setup_payload",
]

#public_configs = [ "" ]
}
13 changes: 7 additions & 6 deletions examples/platform/efr32/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#endif // QR_CODE_ENABLED
#endif // DISPLAY_ENABLED

#include "EFR32DeviceDataProvider.h"
#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/attribute-type.h>
#include <app-common/zap-generated/cluster-id.h>
Expand Down Expand Up @@ -218,24 +219,24 @@ CHIP_ERROR BaseApplication::Init(Identify * identifyObj)

ConfigurationMgr().LogDeviceConfig();

// Print setup info on LCD if available
#ifdef QR_CODE_ENABLED
// Create buffer for QR code that can fit max size and null terminator.
char qrCodeBuffer[chip::QRCodeBasicSetupPayloadGenerator::kMaxQRCodeBase38RepresentationLength + 1];
chip::MutableCharSpan QRCode(qrCodeBuffer);

if (GetQRCode(QRCode, chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)) == CHIP_NO_ERROR)
if (EFR32::EFR32DeviceDataProvider::GetDeviceDataProvider().GetSetupPayload(QRCode) == CHIP_NO_ERROR)
{
// Print setup info on LCD if available
#ifdef QR_CODE_ENABLED
slLCD.SetQRCode((uint8_t *) QRCode.data(), QRCode.size());
slLCD.ShowQRCode(true, true);
#else
PrintQrCodeURL(QRCode);
#endif // QR_CODE_ENABLED
}
else
{
EFR32_LOG("Getting QR code failed!");
}
#else
PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));
#endif // QR_CODE_ENABLED

return err;
}
Expand Down
Loading

0 comments on commit 1582780

Please sign in to comment.