Skip to content

Commit

Permalink
Update OTA queues to use the matter work queue. (#20628) (#20690)
Browse files Browse the repository at this point in the history
Co-authored-by: krypton36 <[email protected]>
  • Loading branch information
woody-apple and krypton36 authored Jul 13, 2022
1 parent 1d4973d commit 0390a8d
Showing 1 changed file with 30 additions and 28 deletions.
58 changes: 30 additions & 28 deletions src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#import "MTROTAProviderDelegateBridge.h"

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

static NSInteger const kOtaProviderEndpoint = 0;

Expand All @@ -30,13 +31,8 @@

void MTROTAProviderDelegateBridge::setDelegate(id<MTROTAProviderDelegate> delegate, dispatch_queue_t queue)
{
if (delegate && queue) {
mDelegate = delegate;
mQueue = queue;
} else {
mDelegate = nil;
mQueue = nil;
}
mDelegate = delegate ?: nil;
mQueue = queue ?: nil;

chip::app::Clusters::OTAProvider::SetDelegate(kOtaProviderEndpoint, this);
}
Expand All @@ -60,14 +56,16 @@
[strongDelegate handleQueryImage:commandParams
completionHandler:^(MTROtaSoftwareUpdateProviderClusterQueryImageResponseParams * _Nullable data,
NSError * _Nullable error) {
chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::QueryImageResponse::Type response;
ConvertFromQueryImageResponseParms(data, response);

chip::app::CommandHandler * handler = handle.Get();
if (handler) {
handler->AddResponse(cachedCommandPath, response);
handle.Release();
}
dispatch_async(chip::DeviceLayer::PlatformMgrImpl().GetWorkQueue(), ^{
chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::QueryImageResponse::Type response;
ConvertFromQueryImageResponseParms(data, response);

chip::app::CommandHandler * handler = handle.Get();
if (handler) {
handler->AddResponse(cachedCommandPath, response);
handle.Release();
}
});
}];
});
}
Expand All @@ -94,14 +92,16 @@
handleApplyUpdateRequest:commandParams
completionHandler:^(MTROtaSoftwareUpdateProviderClusterApplyUpdateResponseParams * _Nullable data,
NSError * _Nullable error) {
chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::ApplyUpdateResponse::Type response;
ConvertFromApplyUpdateRequestResponseParms(data, response);

chip::app::CommandHandler * handler = handle.Get();
if (handler) {
handler->AddResponse(cachedCommandPath, response);
handle.Release();
}
dispatch_async(chip::DeviceLayer::PlatformMgrImpl().GetWorkQueue(), ^{
chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::ApplyUpdateResponse::Type response;
ConvertFromApplyUpdateRequestResponseParms(data, response);

chip::app::CommandHandler * handler = handle.Get();
if (handler) {
handler->AddResponse(cachedCommandPath, response);
handle.Release();
}
});
}];
});
}
Expand All @@ -127,11 +127,13 @@
[strongDelegate
handleNotifyUpdateApplied:commandParams
completionHandler:^(NSError * _Nullable error) {
chip::app::CommandHandler * handler = handle.Get();
if (handler) {
handler->AddStatus(cachedCommandPath, chip::Protocols::InteractionModel::Status::Success);
handle.Release();
}
dispatch_async(chip::DeviceLayer::PlatformMgrImpl().GetWorkQueue(), ^{
chip::app::CommandHandler * handler = handle.Get();
if (handler) {
handler->AddStatus(cachedCommandPath, chip::Protocols::InteractionModel::Status::Success);
handle.Release();
}
});
}];
});
}
Expand Down

0 comments on commit 0390a8d

Please sign in to comment.