diff --git a/examples/ota-provider-app/linux/main.cpp b/examples/ota-provider-app/linux/main.cpp index 641c06ed0888a8..349acd5bd94d0c 100644 --- a/examples/ota-provider-app/linux/main.cpp +++ b/examples/ota-provider-app/linux/main.cpp @@ -30,8 +30,8 @@ #include #include #include - #include +#include #include #include @@ -54,12 +54,14 @@ constexpr uint16_t kOptionFilepath = 'f'; constexpr uint16_t kOptionOtaImageList = 'o'; constexpr uint16_t kOptionQueryImageBehavior = 'q'; constexpr uint16_t kOptionDelayedActionTimeSec = 'd'; +constexpr uint16_t kOptionUserConsent = 'u'; // Global variables used for passing the CLI arguments to the OTAProviderExample object -static OTAProviderExample::QueryImageBehaviorType gQueryImageBehavior = OTAProviderExample::kRespondWithUpdateAvailable; +static OTAProviderExample::QueryImageBehaviorType gQueryImageBehavior = OTAProviderExample::kRespondWithUnknown; static uint32_t gDelayedActionTimeSec = 0; static const char * gOtaFilepath = nullptr; static const char * gOtaImageListFilepath = nullptr; +static chip::ota::UserConsentState gUserConsentState = chip::ota::UserConsentState::kUnknown; // Parses the JSON filepath and extracts DeviceSoftwareVersionModel parameters static bool ParseJsonFileAndPopulateCandidates(const char * filepath, @@ -183,6 +185,30 @@ bool HandleOptions(const char * aProgram, OptionSet * aOptions, int aIdentifier, case kOptionDelayedActionTimeSec: gDelayedActionTimeSec = static_cast(strtol(aValue, NULL, 0)); break; + case kOptionUserConsent: + if (aValue == NULL) + { + PrintArgError("%s: ERROR: NULL UserConsent parameter\n", aProgram); + retval = false; + } + else if (strcmp(aValue, "granted") == 0) + { + gUserConsentState = chip::ota::UserConsentState::kGranted; + } + else if (strcmp(aValue, "denied") == 0) + { + gUserConsentState = chip::ota::UserConsentState::kDenied; + } + else if (strcmp(aValue, "deferred") == 0) + { + gUserConsentState = chip::ota::UserConsentState::kObtaining; + } + else + { + PrintArgError("%s: ERROR: Invalid UserConsent parameter: %s\n", aProgram, aValue); + retval = false; + } + break; default: PrintArgError("%s: INTERNAL ERROR: Unhandled option: %s\n", aProgram, aName); retval = false; @@ -197,6 +223,7 @@ OptionDef cmdLineOptionsDef[] = { { "otaImageList", chip::ArgParser::kArgumentRequired, kOptionOtaImageList }, { "QueryImageBehavior", chip::ArgParser::kArgumentRequired, kOptionQueryImageBehavior }, { "DelayedActionTimeSec", chip::ArgParser::kArgumentRequired, kOptionDelayedActionTimeSec }, + { "UserConsent", chip::ArgParser::kArgumentRequired, kOptionUserConsent }, {}, }; @@ -209,7 +236,12 @@ OptionSet cmdLineOptions = { HandleOptions, cmdLineOptionsDef, "PROGRAM OPTIONS" " Status value in the Query Image Response\n" " -d/--DelayedActionTimeSec