From 66333a9693e47456c806e9caad7c3c8784426a05 Mon Sep 17 00:00:00 2001 From: pankore <86098180+pankore@users.noreply.github.com> Date: Wed, 20 Apr 2022 09:30:31 +0800 Subject: [PATCH] [Ameba] Enable OTA user intent (#17496) * [OTA] Enable OTA user intent - Set UserConsentState to be kGranted by default * Restyled by clang-format Co-authored-by: Restyled.io --- .../all-clusters-app/ameba/main/chipinterface.cpp | 12 +++++++++++- examples/lighting-app/ameba/main/chipinterface.cpp | 12 +++++++++++- .../ota-requestor-app/ameba/main/chipinterface.cpp | 12 +++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/examples/all-clusters-app/ameba/main/chipinterface.cpp b/examples/all-clusters-app/ameba/main/chipinterface.cpp index 0588e9a8bf62ae..7a89291eafb3f3 100644 --- a/examples/all-clusters-app/ameba/main/chipinterface.cpp +++ b/examples/all-clusters-app/ameba/main/chipinterface.cpp @@ -44,6 +44,8 @@ #include #include #include +#include +#include #include #endif @@ -101,9 +103,11 @@ static DeviceCallbacks EchoCallbacks; #if CONFIG_ENABLE_OTA_REQUESTOR DefaultOTARequestor gRequestorCore; DefaultOTARequestorStorage gRequestorStorage; -DefaultOTARequestorDriver gRequestorUser; +ExtendedOTARequestorDriver gRequestorUser; BDXDownloader gDownloader; AmebaOTAImageProcessor gImageProcessor; +chip::ota::DefaultOTARequestorUserConsent gUserConsentProvider; +static chip::ota::UserConsentState gUserConsentState = chip::ota::UserConsentState::kGranted; #endif #if CONFIG_ENABLE_OTA_REQUESTOR @@ -135,6 +139,12 @@ static void InitOTARequestor(void) gDownloader.SetImageProcessorDelegate(&gImageProcessor); gRequestorUser.Init(&gRequestorCore, &gImageProcessor); + if (gUserConsentState != chip::ota::UserConsentState::kUnknown) + { + gUserConsentProvider.SetUserConsentState(gUserConsentState); + gRequestorUser.SetUserConsentDelegate(&gUserConsentProvider); + } + // Initialize and interconnect the Requestor and Image Processor objects -- END } #endif // CONFIG_ENABLE_OTA_REQUESTOR diff --git a/examples/lighting-app/ameba/main/chipinterface.cpp b/examples/lighting-app/ameba/main/chipinterface.cpp index a0668e2b3db9bd..cc0082864f3001 100644 --- a/examples/lighting-app/ameba/main/chipinterface.cpp +++ b/examples/lighting-app/ameba/main/chipinterface.cpp @@ -47,6 +47,8 @@ #include #include #include +#include +#include #include #endif @@ -86,9 +88,11 @@ static DeviceCallbacks EchoCallbacks; #if CONFIG_ENABLE_OTA_REQUESTOR DefaultOTARequestor gRequestorCore; DefaultOTARequestorStorage gRequestorStorage; -DefaultOTARequestorDriver gRequestorUser; +ExtendedOTARequestorDriver gRequestorUser; BDXDownloader gDownloader; AmebaOTAImageProcessor gImageProcessor; +chip::ota::DefaultOTARequestorUserConsent gUserConsentProvider; +static chip::ota::UserConsentState gUserConsentState = chip::ota::UserConsentState::kGranted; #endif #if CONFIG_ENABLE_OTA_REQUESTOR @@ -120,6 +124,12 @@ static void InitOTARequestor(void) gDownloader.SetImageProcessorDelegate(&gImageProcessor); gRequestorUser.Init(&gRequestorCore, &gImageProcessor); + if (gUserConsentState != chip::ota::UserConsentState::kUnknown) + { + gUserConsentProvider.SetUserConsentState(gUserConsentState); + gRequestorUser.SetUserConsentDelegate(&gUserConsentProvider); + } + // Initialize and interconnect the Requestor and Image Processor objects -- END } #endif // CONFIG_ENABLE_OTA_REQUESTOR diff --git a/examples/ota-requestor-app/ameba/main/chipinterface.cpp b/examples/ota-requestor-app/ameba/main/chipinterface.cpp index 0a940e922ea586..df6cf6a71b9f82 100644 --- a/examples/ota-requestor-app/ameba/main/chipinterface.cpp +++ b/examples/ota-requestor-app/ameba/main/chipinterface.cpp @@ -37,6 +37,8 @@ #include #include #include +#include +#include #include void * __dso_handle = 0; @@ -87,9 +89,11 @@ static DeviceCallbacks EchoCallbacks; DefaultOTARequestor gRequestorCore; DefaultOTARequestorStorage gRequestorStorage; -DefaultOTARequestorDriver gRequestorUser; +ExtendedOTARequestorDriver gRequestorUser; BDXDownloader gDownloader; AmebaOTAImageProcessor gImageProcessor; +chip::ota::DefaultOTARequestorUserConsent gUserConsentProvider; +static chip::ota::UserConsentState gUserConsentState = chip::ota::UserConsentState::kGranted; extern "C" void amebaQueryImageCmdHandler() { @@ -119,6 +123,12 @@ static void InitOTARequestor(void) gDownloader.SetImageProcessorDelegate(&gImageProcessor); gRequestorUser.Init(&gRequestorCore, &gImageProcessor); + if (gUserConsentState != chip::ota::UserConsentState::kUnknown) + { + gUserConsentProvider.SetUserConsentState(gUserConsentState); + gRequestorUser.SetUserConsentDelegate(&gUserConsentProvider); + } + // Initialize and interconnect the Requestor and Image Processor objects -- END }