From cedcfbb3354bc56bd56529a331f85fa4772fc46f Mon Sep 17 00:00:00 2001 From: Vijay Selvaraj Date: Fri, 22 Apr 2022 13:41:49 -0400 Subject: [PATCH] Removed dacProvider parameter from ChipLinuxAppMainLoop (#17621) --- examples/all-clusters-app/linux/main.cpp | 3 ++- examples/placeholder/linux/main.cpp | 3 ++- examples/platform/linux/AppMain.cpp | 6 +++--- examples/platform/linux/AppMain.h | 3 +-- examples/platform/linux/Options.cpp | 6 ++++++ examples/platform/linux/Options.h | 3 +++ 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/examples/all-clusters-app/linux/main.cpp b/examples/all-clusters-app/linux/main.cpp index 3558e6556dc846..c44c7061d7685b 100644 --- a/examples/all-clusters-app/linux/main.cpp +++ b/examples/all-clusters-app/linux/main.cpp @@ -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; } diff --git a/examples/placeholder/linux/main.cpp b/examples/placeholder/linux/main.cpp index 4c5c73b62db2f3..627d24464e2bab 100644 --- a/examples/placeholder/linux/main.cpp +++ b/examples/placeholder/linux/main.cpp @@ -32,6 +32,7 @@ int main(int argc, char * argv[]) test->NextTest(); } - ChipLinuxAppMainLoop(AppOptions::GetDACProvider()); + LinuxDeviceOptions::GetInstance().dacProvider = AppOptions::GetDACProvider(); + ChipLinuxAppMainLoop(); return 0; } diff --git a/examples/platform/linux/AppMain.cpp b/examples/platform/linux/AppMain.cpp index ccb7ae524659d2..0ada93be2049a9 100644 --- a/examples/platform/linux/AppMain.cpp +++ b/examples/platform/linux/AppMain.cpp @@ -27,10 +27,10 @@ #include #include +#include #include #include #include -#include #include #include @@ -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); @@ -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"); diff --git a/examples/platform/linux/AppMain.h b/examples/platform/linux/AppMain.h index 5bb29f77b895c0..584da5d099041f 100644 --- a/examples/platform/linux/AppMain.h +++ b/examples/platform/linux/AppMain.h @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -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 diff --git a/examples/platform/linux/Options.cpp b/examples/platform/linux/Options.cpp index 80853bff83109d..1740967bc3a872 100644 --- a/examples/platform/linux/Options.cpp +++ b/examples/platform/linux/Options.cpp @@ -28,6 +28,8 @@ #include #include +#include + using namespace chip; using namespace chip::ArgParser; @@ -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; } diff --git a/examples/platform/linux/Options.h b/examples/platform/linux/Options.h index 833cc3bf5a3b63..d0624dd682b708 100644 --- a/examples/platform/linux/Options.h +++ b/examples/platform/linux/Options.h @@ -34,6 +34,8 @@ #include #include +#include + struct LinuxDeviceOptions { chip::SetupPayload payload; @@ -53,6 +55,7 @@ struct LinuxDeviceOptions chip::Inet::InterfaceId interfaceId = chip::Inet::InterfaceId::Null(); bool traceStreamToLogEnabled = false; chip::Optional traceStreamFilename; + chip::Credentials::DeviceAttestationCredentialsProvider * dacProvider = nullptr; static LinuxDeviceOptions & GetInstance(); };