Skip to content

Commit

Permalink
[OTA] Add Darwin Framework APIs for OTA Provider delegate (#20295)
Browse files Browse the repository at this point in the history
  • Loading branch information
carol-apple authored and pull[bot] committed Feb 28, 2024
1 parent 86f66d8 commit 2447504
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/app/clusters/ota-provider/ota-provider-delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace Clusters {
/** @brief
* Defines methods for implementing application-specific logic for the OTA Provider Cluster.
*/
class OTAProviderDelegate
class DLL_EXPORT OTAProviderDelegate
{
public:
/**
Expand Down
55 changes: 55 additions & 0 deletions src/darwin/Framework/CHIP/MTROTAProviderDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
*
* Copyright (c) 2022 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#import <Foundation/Foundation.h>
#import <Matter/Matter.h>

NS_ASSUME_NONNULL_BEGIN

/**
* The protocol definition for the MTROTAProviderDelegate
*
* All delegate methods will be called on the supplied Delegate Queue.
*/
@protocol MTROTAProviderDelegate <NSObject>
@optional
/**
* Notify the delegate when query image command is received
*
*/
- (void)handleQueryImage:(MTROtaSoftwareUpdateProviderClusterQueryImageParams *)params
completionHandler:(void (^)(MTROtaSoftwareUpdateProviderClusterQueryImageResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler;

/**
* Notify the delegate when apply update request command is received
*
*/
- (void)handleApplyUpdateRequest:(MTROtaSoftwareUpdateProviderClusterApplyUpdateRequestParams *)params
completionHandler:(void (^)(MTROtaSoftwareUpdateProviderClusterApplyUpdateResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler;

/**
* Notify the delegate when notify update applied command is received
*
*/
- (void)handleNotifyUpdateApplied:(MTROtaSoftwareUpdateProviderClusterNotifyUpdateAppliedParams *)params
completionHandler:(StatusCompletion)completionHandler;

@end

NS_ASSUME_NONNULL_END
49 changes: 49 additions & 0 deletions src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
*
* Copyright (c) 2022 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#import "MTROTAProviderDelegate.h"

#include <app/clusters/ota-provider/ota-provider-delegate.h>

NS_ASSUME_NONNULL_BEGIN

class MTROTAProviderDelegateBridge : public chip::app::Clusters::OTAProviderDelegate
{
public:
MTROTAProviderDelegateBridge();
~MTROTAProviderDelegateBridge();

void setDelegate(id<MTROTAProviderDelegate> delegate, dispatch_queue_t queue);

void HandleQueryImage(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::QueryImage::DecodableType & commandData) override;

void HandleApplyUpdateRequest(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::ApplyUpdateRequest::DecodableType & commandData) override;

void HandleNotifyUpdateApplied(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::NotifyUpdateApplied::DecodableType & commandData) override;

private:
_Nullable id<MTROTAProviderDelegate> mDelegate;
_Nullable dispatch_queue_t mQueue;
};

NS_ASSUME_NONNULL_END
1 change: 1 addition & 0 deletions src/darwin/Framework/CHIP/Matter.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#import <Matter/MTRError.h>
#import <Matter/MTRKeypair.h>
#import <Matter/MTRManualSetupPayloadParser.h>
#import <Matter/MTROTAProviderDelegate.h>
#import <Matter/MTRPersistentStorageDelegate.h>
#import <Matter/MTRQRCodeSetupPayloadParser.h>
#import <Matter/MTRSetupPayload.h>
Expand Down
8 changes: 8 additions & 0 deletions src/darwin/Framework/Matter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
99AECC802798A57F00B6355B /* MTRCommissioningParameters.m in Sources */ = {isa = PBXBuildFile; fileRef = 99AECC7F2798A57E00B6355B /* MTRCommissioningParameters.m */; };
99C65E10267282F1003402F6 /* MTRControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 99C65E0F267282F1003402F6 /* MTRControllerTests.m */; };
99D466E12798936D0089A18F /* MTRCommissioningParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 99D466E02798936D0089A18F /* MTRCommissioningParameters.h */; settings = {ATTRIBUTES = (Public, ); }; };
AF1CB86E2874B03B00865A96 /* MTROTAProviderDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = AF1CB86D2874B03B00865A96 /* MTROTAProviderDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
AF1CB8702874B04C00865A96 /* MTROTAProviderDelegateBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = AF1CB86F2874B04C00865A96 /* MTROTAProviderDelegateBridge.h */; };
B20252972459E34F00F97062 /* Matter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B202528D2459E34F00F97062 /* Matter.framework */; };
B289D4212639C0D300D4E314 /* MTROnboardingPayloadParser.h in Headers */ = {isa = PBXBuildFile; fileRef = B289D41F2639C0D300D4E314 /* MTROnboardingPayloadParser.h */; settings = {ATTRIBUTES = (Public, ); }; };
B289D4222639C0D300D4E314 /* MTROnboardingPayloadParser.m in Sources */ = {isa = PBXBuildFile; fileRef = B289D4202639C0D300D4E314 /* MTROnboardingPayloadParser.m */; };
Expand Down Expand Up @@ -205,6 +207,8 @@
99AECC7F2798A57E00B6355B /* MTRCommissioningParameters.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MTRCommissioningParameters.m; sourceTree = "<group>"; };
99C65E0F267282F1003402F6 /* MTRControllerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MTRControllerTests.m; sourceTree = "<group>"; };
99D466E02798936D0089A18F /* MTRCommissioningParameters.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRCommissioningParameters.h; sourceTree = "<group>"; };
AF1CB86D2874B03B00865A96 /* MTROTAProviderDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTROTAProviderDelegate.h; sourceTree = "<group>"; };
AF1CB86F2874B04C00865A96 /* MTROTAProviderDelegateBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTROTAProviderDelegateBridge.h; sourceTree = "<group>"; };
B202528D2459E34F00F97062 /* Matter.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Matter.framework; sourceTree = BUILT_PRODUCTS_DIR; };
B20252912459E34F00F97062 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
B20252962459E34F00F97062 /* MatterTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MatterTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -336,6 +340,8 @@
2CB7163E252F731E0026E2BB /* MTRDevicePairingDelegate.h */,
2CB71638252E8A7B0026E2BB /* MTRDevicePairingDelegateBridge.h */,
2CB71639252E8A7B0026E2BB /* MTRDevicePairingDelegateBridge.mm */,
AF1CB86F2874B04C00865A96 /* MTROTAProviderDelegateBridge.h */,
AF1CB86D2874B03B00865A96 /* MTROTAProviderDelegate.h */,
B2E0D7A8245B0B5C003C5B48 /* Matter.h */,
B2E0D7AB245B0B5C003C5B48 /* MTRError_Internal.h */,
5129BCFC26A9EE3300122DDF /* MTRError.h */,
Expand Down Expand Up @@ -438,6 +444,7 @@
88EBF8CE27FABDD500686BC1 /* MTRDeviceAttestationDelegate.h in Headers */,
2C222AD0255C620600E446B9 /* MTRDevice.h in Headers */,
991DC0842475F45400C13860 /* MTRDeviceController.h in Headers */,
AF1CB86E2874B03B00865A96 /* MTROTAProviderDelegate.h in Headers */,
754F3DF427FBB94B00E60580 /* MTREventTLVValueDecoder_Internal.h in Headers */,
B2E0D7B2245B0B5C003C5B48 /* MTRManualSetupPayloadParser.h in Headers */,
B2E0D7B1245B0B5C003C5B48 /* Matter.h in Headers */,
Expand All @@ -455,6 +462,7 @@
5A6FEC9A27B5C89300F25F42 /* MTRDeviceControllerXPCConnection.h in Headers */,
5129BCFD26A9EE3300122DDF /* MTRError.h in Headers */,
2C8C8FC1253E0C2100797F05 /* MTRPersistentStorageDelegate.h in Headers */,
AF1CB8702874B04C00865A96 /* MTROTAProviderDelegateBridge.h in Headers */,
B2E0D7B5245B0B5C003C5B48 /* MTRQRCodeSetupPayloadParser.h in Headers */,
1EC4CE6425CC276600D7304F /* MTRClustersObjc.h in Headers */,
2C5EEEF6268A85C400CAE3D3 /* MTRDeviceConnectionBridge.h in Headers */,
Expand Down

0 comments on commit 2447504

Please sign in to comment.