Skip to content

Commit

Permalink
Adding FactoryDataProvider class to QPG platform
Browse files Browse the repository at this point in the history
  • Loading branch information
lucicop committed Sep 30, 2022
1 parent 2a1f9ef commit 16df929
Show file tree
Hide file tree
Showing 12 changed files with 482 additions and 7 deletions.
13 changes: 13 additions & 0 deletions examples/lighting-app/qpg/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ qpg_executable("lighting_app") {
]

deps = [
":factorydata_lib",
":sdk",
"${chip_root}/examples/lighting-app/lighting-common",
"${chip_root}/examples/lighting-app/lighting-common:color-format",
Expand Down Expand Up @@ -153,3 +154,15 @@ group("qpg") {
group("default") {
deps = [ ":qpg" ]
}

static_library("factorydata_lib") {
libs = [ "${qpg_sdk_root}/Binaries/FactoryData/FactoryData_example/FactoryData_example.a" ]
public_configs = [ ":qpg_retain_factorydata" ]
}

config("qpg_retain_factorydata") {
ldflags = [
"-Wl,-u_binary_factory_data_bin_start",
"-Wl,-u_binary_factory_data_start",
]
}
4 changes: 4 additions & 0 deletions examples/lighting-app/qpg/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "timers.h" // provides FreeRTOS timer support
#include <platform/CHIPDeviceLayer.h>

#include <platform/qpg/FactoryDataProvider.h>

#define APP_NAME "Lighting-app"

class AppTask
Expand Down Expand Up @@ -78,6 +80,8 @@ class AppTask
bool mFunctionTimerActive;
bool mSyncClusterToButtonAction;

chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider;

static AppTask sAppTask;
};

Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/qpg/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* 0xFFF1: Test Vendor.
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0x10D0
#endif // CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID

/**
Expand Down
7 changes: 5 additions & 2 deletions examples/lighting-app/qpg/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,11 @@ CHIP_ERROR AppTask::Init()
// Init ZCL Data Model and start server
PlatformMgr().ScheduleWork(InitServer, 0);

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
ReturnErrorOnFailure(mFactoryDataProvider.Init());
SetDeviceInstanceInfoProvider(&mFactoryDataProvider);
SetCommissionableDataProvider(&mFactoryDataProvider);

SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider);

// Setup light
err = LightingMgr().Init();
Expand Down
13 changes: 13 additions & 0 deletions examples/lock-app/qpg/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ qpg_executable("lock_app") {
]

deps = [
":factorydata_lib",
":sdk",
"${chip_root}/examples/lock-app/lock-common",
"${chip_root}/examples/providers:device_info_provider",
Expand Down Expand Up @@ -151,3 +152,15 @@ group("qpg") {
group("default") {
deps = [ ":qpg" ]
}

static_library("factorydata_lib") {
libs = [ "${qpg_sdk_root}/Binaries/FactoryData/FactoryData_example/FactoryData_example.a" ]
public_configs = [ ":qpg_retain_factorydata" ]
}

config("qpg_retain_factorydata") {
ldflags = [
"-Wl,-u_binary_factory_data_bin_start",
"-Wl,-u_binary_factory_data_start",
]
}
4 changes: 4 additions & 0 deletions examples/lock-app/qpg/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <lib/core/CHIPError.h>
#include <platform/CHIPDeviceLayer.h>

#include <platform/qpg/FactoryDataProvider.h>

// Application-defined error codes in the CHIP_ERROR space.
#define APP_ERROR_CREATE_TIMER_FAILED CHIP_APPLICATION_ERROR(0x01)

Expand Down Expand Up @@ -82,6 +84,8 @@ class AppTask
bool mFunctionTimerActive;
bool mSyncClusterToButtonAction;

chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider;

static AppTask sAppTask;
};

Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/qpg/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
* 0xFFF1: Test vendor.
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0x10D0
#endif // CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID

/**
Expand Down
7 changes: 5 additions & 2 deletions examples/lock-app/qpg/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ CHIP_ERROR AppTask::Init()
// Init ZCL Data Model and start server
PlatformMgr().ScheduleWork(InitServer, 0);

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
ReturnErrorOnFailure(mFactoryDataProvider.Init());
SetDeviceInstanceInfoProvider(&mFactoryDataProvider);
SetCommissionableDataProvider(&mFactoryDataProvider);

SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider);

// Setup Bolt
err = BoltLockMgr().Init();
Expand Down
4 changes: 4 additions & 0 deletions src/platform/qpg/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ static_library("qpg") {
"DeviceNetworkProvisioningDelegateImpl.h",
"DiagnosticDataProviderImpl.cpp",
"DiagnosticDataProviderImpl.h",
"FactoryDataProvider.cpp",
"FactoryDataProvider.h",
"InetPlatformConfig.h",
"Logging.cpp",
"OTAImageProcessorImpl.cpp",
Expand All @@ -52,6 +54,8 @@ static_library("qpg") {

deps = []

public = [ "${chip_root}/src/credentials/DeviceAttestationCredsProvider.h" ]

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

public_configs = []
Expand Down
Loading

0 comments on commit 16df929

Please sign in to comment.