Skip to content

Commit

Permalink
[Ameba] FactoryDataProvider implementation (project-chip#21849)
Browse files Browse the repository at this point in the history
* [Credentials] Implement FactoryDataProvider for Ameba
- Temporarily hardcode certs and keys inside FactorydataProvider.cpp
- TODO: Move to flash/efuse region, then read from there

* [Build] Fix compile error

* [Credentials] Dont let Matter set its own CommissionableDataProvider inside GenericConfigurationManagerImpl
- Added gn arg chip_use_transitional_commissionable_data_provider in chip.cmake
- Update the kDacPublic and kDacPrivate keys with the correct ones
- Using VID - FFF1, PID - 8001
- Change the sequence of data providers

* [Credentials] Let lighting-app, light-switch-app, and ota-requestor-app use Amebas own data providers

* [Restyle] Fix styling
  • Loading branch information
pankore authored and isiu-apple committed Sep 16, 2022
1 parent 57a1c00 commit 7b964ed
Show file tree
Hide file tree
Showing 8 changed files with 488 additions and 8 deletions.
1 change: 1 addition & 0 deletions config/ameba/chip.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ string(APPEND CHIP_GN_ARGS "ameba_cc = \"arm-none-eabi-gcc\"\n")
string(APPEND CHIP_GN_ARGS "ameba_cxx = \"arm-none-eabi-c++\"\n")
string(APPEND CHIP_GN_ARGS "ameba_cpu = \"ameba\"\n")
string(APPEND CHIP_GN_ARGS "chip_inet_config_enable_ipv4 = false\n")
string(APPEND CHIP_GN_ARGS "chip_use_transitional_commissionable_data_provider = false\n")

# Enable persistent storage audit
if (matter_enable_persistentstorage_audit)
Expand Down
9 changes: 7 additions & 2 deletions examples/all-clusters-app/ameba/main/chipinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <credentials/examples/DeviceAttestationCredsExample.h>
#include <lib/support/ErrorStr.h>
#include <platform/Ameba/AmebaConfig.h>
#include <platform/Ameba/FactoryDataProvider.h>
#include <platform/Ameba/NetworkCommissioningDriver.h>
#include <platform/CHIPDeviceLayer.h>
#include <setup_payload/ManualSetupPayloadGenerator.h>
Expand Down Expand Up @@ -96,6 +97,7 @@ Identify gIdentify1 = {

static DeviceCallbacks EchoCallbacks;
chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;
chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider;

static void InitServer(intptr_t context)
{
Expand All @@ -106,8 +108,6 @@ static void InitServer(intptr_t context)
gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage());
chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
NetWorkCommissioningInstInit();

if (RTW_SUCCESS != wifi_is_connected_to_ap())
Expand All @@ -130,6 +130,11 @@ extern "C" void ChipTest(void)

initPref();

// Initialize device attestation, commissionable data and device instance info
// TODO: Use our own DeviceInstanceInfoProvider
// SetDeviceInstanceInfoProvider(&mFactoryDataProvider);
SetCommissionableDataProvider(&mFactoryDataProvider);
SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider);
CHIPDeviceManager & deviceMgr = CHIPDeviceManager::GetInstance();

err = deviceMgr.Init(&EchoCallbacks);
Expand Down
9 changes: 7 additions & 2 deletions examples/light-switch-app/ameba/main/chipinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <credentials/examples/DeviceAttestationCredsExample.h>
#include <lib/support/ErrorStr.h>
#include <platform/Ameba/AmebaConfig.h>
#include <platform/Ameba/FactoryDataProvider.h>
#include <platform/Ameba/NetworkCommissioningDriver.h>
#include <platform/CHIPDeviceLayer.h>
#include <setup_payload/ManualSetupPayloadGenerator.h>
Expand Down Expand Up @@ -96,6 +97,7 @@ Identify gIdentify1 = {

static DeviceCallbacks EchoCallbacks;
chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;
chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider;

static void InitServer(intptr_t context)
{
Expand All @@ -106,8 +108,6 @@ static void InitServer(intptr_t context)
gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage());
chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
NetWorkCommissioningInstInit();

if (RTW_SUCCESS != wifi_is_connected_to_ap())
Expand All @@ -130,6 +130,11 @@ extern "C" void ChipTest(void)

initPref();

// Initialize device attestation, commissionable data and device instance info
// TODO: Use our own DeviceInstanceInfoProvider
// SetDeviceInstanceInfoProvider(&mFactoryDataProvider);
SetCommissionableDataProvider(&mFactoryDataProvider);
SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider);
CHIPDeviceManager & deviceMgr = CHIPDeviceManager::GetInstance();

err = deviceMgr.Init(&EchoCallbacks);
Expand Down
9 changes: 7 additions & 2 deletions examples/lighting-app/ameba/main/chipinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <app/util/af.h>
#include <lib/support/ErrorStr.h>
#include <platform/Ameba/AmebaConfig.h>
#include <platform/Ameba/FactoryDataProvider.h>
#include <platform/Ameba/NetworkCommissioningDriver.h>
#include <platform/CHIPDeviceLayer.h>
#include <setup_payload/ManualSetupPayloadGenerator.h>
Expand Down Expand Up @@ -80,6 +81,7 @@ void NetWorkCommissioningInstInit()

static DeviceCallbacks EchoCallbacks;
chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;
chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider;

void OnIdentifyStart(Identify *)
{
Expand Down Expand Up @@ -126,8 +128,6 @@ static void InitServer(intptr_t context)
gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage());
chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
NetWorkCommissioningInstInit();

if (RTW_SUCCESS != wifi_is_connected_to_ap())
Expand All @@ -148,6 +148,11 @@ extern "C" void ChipTest(void)

initPref();

// Initialize device attestation, commissionable data and device instance info
// TODO: Use our own DeviceInstanceInfoProvider
// SetDeviceInstanceInfoProvider(&mFactoryDataProvider);
SetCommissionableDataProvider(&mFactoryDataProvider);
SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider);
CHIPDeviceManager & deviceMgr = CHIPDeviceManager::GetInstance();

err = deviceMgr.Init(&EchoCallbacks);
Expand Down
10 changes: 8 additions & 2 deletions examples/ota-requestor-app/ameba/main/chipinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <lib/support/ErrorStr.h>
#include <platform/Ameba/AmebaConfig.h>
#include <platform/Ameba/FactoryDataProvider.h>
#include <platform/Ameba/NetworkCommissioningDriver.h>
#include <platform/CHIPDeviceLayer.h>
#include <support/CHIPMem.h>
Expand Down Expand Up @@ -75,6 +76,7 @@ void NetWorkCommissioningInstInit()

static DeviceCallbacks EchoCallbacks;
chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;
chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider;

static void InitServer(intptr_t context)
{
Expand All @@ -85,8 +87,6 @@ static void InitServer(intptr_t context)
gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage());
chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
NetWorkCommissioningInstInit();
}

Expand All @@ -97,6 +97,12 @@ extern "C" void ChipTest(void)

initPref();

// Initialize device attestation, commissionable data and device instance info
// TODO: Use our own DeviceInstanceInfoProvider
// SetDeviceInstanceInfoProvider(&mFactoryDataProvider);
SetCommissionableDataProvider(&mFactoryDataProvider);
SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider);

CHIPDeviceManager & deviceMgr = CHIPDeviceManager::GetInstance();
err = deviceMgr.Init(&EchoCallbacks);
if (err != CHIP_NO_ERROR)
Expand Down
4 changes: 4 additions & 0 deletions src/platform/Ameba/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ static_library("Ameba") {
"DeviceNetworkProvisioningDelegateImpl.h",
"DiagnosticDataProviderImpl.cpp",
"DiagnosticDataProviderImpl.h",
"FactoryDataProvider.cpp",
"FactoryDataProvider.h",
"KeyValueStoreManagerImpl.cpp",
"KeyValueStoreManagerImpl.h",
"Logging.cpp",
Expand All @@ -55,6 +57,8 @@ static_library("Ameba") {
"${chip_root}/src/setup_payload",
]

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

public_deps = [
"${chip_root}/src/crypto",
"${chip_root}/src/platform:platform_base",
Expand Down
Loading

0 comments on commit 7b964ed

Please sign in to comment.