diff --git a/src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.h b/src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.h index fe1554df4723bd..f502dbff081d26 100644 --- a/src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.h +++ b/src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.h @@ -53,7 +53,7 @@ class MTROTAProviderDelegateBridge : public chip::app::Clusters::OTAProviderDele static CHIP_ERROR ConvertToQueryImageParams( const chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::QueryImage::DecodableType & commandData, MTROTASoftwareUpdateProviderClusterQueryImageParams * commandParams); - static void ConvertFromQueryImageResponseParms( + static void ConvertFromQueryImageResponseParams( const MTROTASoftwareUpdateProviderClusterQueryImageResponseParams * responseParams, chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::QueryImageResponse::Type & response); static void ConvertToApplyUpdateRequestParams( diff --git a/src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm b/src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm index b1c8c88b78a8c2..43969deb2a7c51 100644 --- a/src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm +++ b/src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm @@ -461,9 +461,7 @@ CHIP_ERROR ConfigureState(chip::FabricIndex fabricIndex, chip::NodeId nodeId) CHIP_ERROR err = mSystemLayer->StartTimer(kBdxInitReceivedTimeout, HandleBdxInitReceivedTimeoutExpired, this); LogErrorOnFailure(err); - // The caller of this method maps CHIP_ERROR to specific BDX Status Codes (see GetBdxStatusCodeFromChipError) - // and those are used by the BDX session to prepare the status report. - VerifyOrReturnError(err == CHIP_NO_ERROR, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(err == CHIP_NO_ERROR, err); mFabricIndex.SetValue(fabricIndex); mNodeId.SetValue(nodeId); @@ -615,7 +613,7 @@ bool GetPeerNodeInfo(CommandHandler * commandHandler, const ConcreteCommandPath auto * commandParams = [[MTROTASoftwareUpdateProviderClusterQueryImageParams alloc] init]; CHIP_ERROR err = ConvertToQueryImageParams(commandData, commandParams); if (err != CHIP_NO_ERROR) { - commandObj->AddStatus(commandPath, Protocols::InteractionModel::Status::InvalidCommand); + commandObj->AddStatus(commandPath, StatusIB(err).mStatus); return; } @@ -657,7 +655,7 @@ bool GetPeerNodeInfo(CommandHandler * commandHandler, const ConcreteCommandPath } Commands::QueryImageResponse::Type delegateResponse; - ConvertFromQueryImageResponseParms(data, delegateResponse); + ConvertFromQueryImageResponseParams(data, delegateResponse); // If update is not available, return the delegate response if (!hasUpdate) { @@ -685,6 +683,8 @@ bool GetPeerNodeInfo(CommandHandler * commandHandler, const ConcreteCommandPath LogErrorOnFailure(err); handler->AddStatus(cachedCommandPath, StatusIB(err).mStatus); handle.Release(); + // We need to reset state here to clean up any initialization we might have done including starting the timer + // while preparing for transfer if any failure occurs afterwards. gOtaSender.ResetState(); return; } @@ -878,7 +878,7 @@ bool GetPeerNodeInfo(CommandHandler * commandHandler, const ConcreteCommandPath return CHIP_NO_ERROR; } -void MTROTAProviderDelegateBridge::ConvertFromQueryImageResponseParms( +void MTROTAProviderDelegateBridge::ConvertFromQueryImageResponseParams( const MTROTASoftwareUpdateProviderClusterQueryImageResponseParams * responseParams, Commands::QueryImageResponse::Type & response) {