Skip to content

Commit

Permalink
Removed dacProvider parameter from ChipLinuxAppMainLoop (#17621)
Browse files Browse the repository at this point in the history
  • Loading branch information
vijs authored and pull[bot] committed Aug 25, 2023
1 parent 04d65ce commit cedcfbb
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
3 changes: 2 additions & 1 deletion examples/all-clusters-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ int main(int argc, char * argv[])
VerifyOrDie(ChipLinuxAppInit(argc, argv, AppOptions::GetOptions()) == 0);
VerifyOrDie(InitBindingHandlers() == CHIP_NO_ERROR);

ChipLinuxAppMainLoop(AppOptions::GetDACProvider());
LinuxDeviceOptions::GetInstance().dacProvider = AppOptions::GetDACProvider();
ChipLinuxAppMainLoop();
return 0;
}
3 changes: 2 additions & 1 deletion examples/placeholder/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ int main(int argc, char * argv[])
test->NextTest();
}

ChipLinuxAppMainLoop(AppOptions::GetDACProvider());
LinuxDeviceOptions::GetInstance().dacProvider = AppOptions::GetDACProvider();
ChipLinuxAppMainLoop();
return 0;
}
6 changes: 3 additions & 3 deletions examples/platform/linux/AppMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
#include <lib/core/NodeId.h>
#include <lib/support/logging/CHIPLogging.h>

#include <credentials/DeviceAttestationCredsProvider.h>
#include <credentials/GroupDataProviderImpl.h>
#include <credentials/attestation_verifier/DefaultDeviceAttestationVerifier.h>
#include <credentials/attestation_verifier/DeviceAttestationVerifier.h>
#include <credentials/examples/DeviceAttestationCredsExample.h>

#include <lib/support/CHIPMem.h>
#include <lib/support/ScopedBuffer.h>
Expand Down Expand Up @@ -389,7 +389,7 @@ int ChipLinuxAppInit(int argc, char ** argv, OptionSet * customOptions)
return 0;
}

void ChipLinuxAppMainLoop(DeviceAttestationCredentialsProvider * dacProvider)
void ChipLinuxAppMainLoop()
{
static chip::CommonCaseDeviceServerInitParams initParams;
VerifyOrDie(initParams.InitializeStaticResourcesBeforeServerInit() == CHIP_NO_ERROR);
Expand Down Expand Up @@ -422,7 +422,7 @@ void ChipLinuxAppMainLoop(DeviceAttestationCredentialsProvider * dacProvider)
PrintOnboardingCodes(LinuxDeviceOptions::GetInstance().payload);

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(dacProvider == nullptr ? Examples::GetExampleDACProvider() : dacProvider);
SetDeviceAttestationCredentialsProvider(LinuxDeviceOptions::GetInstance().dacProvider);

#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
ChipLogProgress(AppServer, "Starting commissioner");
Expand Down
3 changes: 1 addition & 2 deletions examples/platform/linux/AppMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include <controller/CHIPDeviceController.h>
#include <controller/CommissionerDiscoveryController.h>
#include <credentials/DeviceAttestationCredsProvider.h>
#include <lib/core/CHIPError.h>
#include <platform/CHIPDeviceLayer.h>
#include <platform/PlatformManager.h>
Expand All @@ -29,7 +28,7 @@
#include "Options.h"

int ChipLinuxAppInit(int argc, char ** argv, chip::ArgParser::OptionSet * customOptions = nullptr);
void ChipLinuxAppMainLoop(chip::Credentials::DeviceAttestationCredentialsProvider * dacProvider = nullptr);
void ChipLinuxAppMainLoop();

#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE

Expand Down
6 changes: 6 additions & 0 deletions examples/platform/linux/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <lib/core/CHIPError.h>
#include <lib/support/Base64.h>

#include <credentials/examples/DeviceAttestationCredsExample.h>

using namespace chip;
using namespace chip::ArgParser;

Expand Down Expand Up @@ -413,5 +415,9 @@ CHIP_ERROR ParseArguments(int argc, char * argv[], OptionSet * customOptions)

LinuxDeviceOptions & LinuxDeviceOptions::GetInstance()
{
if (gDeviceOptions.dacProvider == nullptr)
{
gDeviceOptions.dacProvider = chip::Credentials::Examples::GetExampleDACProvider();
}
return gDeviceOptions;
}
3 changes: 3 additions & 0 deletions examples/platform/linux/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include <lib/support/CHIPArgParser.hpp>
#include <setup_payload/SetupPayload.h>

#include <credentials/DeviceAttestationCredsProvider.h>

struct LinuxDeviceOptions
{
chip::SetupPayload payload;
Expand All @@ -53,6 +55,7 @@ struct LinuxDeviceOptions
chip::Inet::InterfaceId interfaceId = chip::Inet::InterfaceId::Null();
bool traceStreamToLogEnabled = false;
chip::Optional<std::string> traceStreamFilename;
chip::Credentials::DeviceAttestationCredentialsProvider * dacProvider = nullptr;

static LinuxDeviceOptions & GetInstance();
};
Expand Down

0 comments on commit cedcfbb

Please sign in to comment.