Skip to content

Commit

Permalink
OTA: Add SetMetadataForProvider to requestor
Browse files Browse the repository at this point in the history
Add a setter for the OTA MetadataForProvider, which is provided
during the QueryImageRequest.
  • Loading branch information
Rob Oliver committed Aug 22, 2022
1 parent 9713e10 commit 4711f98
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/app/clusters/ota-requestor/DefaultOTARequestor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,7 @@ CHIP_ERROR DefaultOTARequestor::SendQueryImageRequest(Messaging::ExchangeManager
args.location.SetValue(CharSpan("XX", strlen("XX")));
}

args.metadataForProvider = mMetadataForProvider;
Controller::OtaSoftwareUpdateProviderCluster cluster(exchangeMgr, sessionHandle, mProviderLocation.Value().endpoint);

return cluster.InvokeCommand(args, this, OnQueryImageResponse, OnQueryImageFailure);
Expand Down
5 changes: 5 additions & 0 deletions src/app/clusters/ota-requestor/DefaultOTARequestor.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ class DefaultOTARequestor : public OTARequestorInterface, public BDXDownloader::

void GetProviderLocation(Optional<ProviderLocationType> & providerLocation) override { providerLocation = mProviderLocation; }

// Set the metadata value for the provider to be used in the next query and OTA update process
// NOTE: Does not persist across reboot.
void SetMetadataForProvider(ByteSpan metadataForProvider) override { mMetadataForProvider.SetValue(metadataForProvider); }

// Add a default OTA provider to the cached list
CHIP_ERROR AddDefaultOtaProvider(const ProviderLocationType & providerLocation) override;

Expand Down Expand Up @@ -319,6 +323,7 @@ class DefaultOTARequestor : public OTARequestorInterface, public BDXDownloader::
BDXDownloader * mBdxDownloader = nullptr; // TODO: this should be OTADownloader
BDXMessenger mBdxMessenger; // TODO: ideally this is held by the application
uint8_t mUpdateTokenBuffer[kMaxUpdateTokenLen];
Optional<ByteSpan> mMetadataForProvider;
ByteSpan mUpdateToken;
uint32_t mCurrentVersion = 0;
uint32_t mTargetVersion = 0;
Expand Down
3 changes: 3 additions & 0 deletions src/app/clusters/ota-requestor/OTARequestorInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ class OTARequestorInterface
// Set the provider location to be used in the next query and OTA update process
virtual void SetCurrentProviderLocation(ProviderLocationType providerLocation) = 0;

// Set the metadata value for the provider to be used in the next query and OTA update process
virtual void SetMetadataForProvider(chip::ByteSpan metadataForProvider) = 0;

// If there is an OTA update in progress, returns the provider location for the current OTA update, otherwise, returns the
// provider location that was last used
virtual void GetProviderLocation(Optional<ProviderLocationType> & providerLocation) = 0;
Expand Down

0 comments on commit 4711f98

Please sign in to comment.