-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nrfconnect] Fix OTA initialization order (#16609)
Recent OTA changes impose an assumption that OTA Requestor must be initialized prior to the OTA Requestor driver. Fix the order and extract OTA requestor initialization to a common function to reduce code duplication in the future.
- Loading branch information
1 parent
d679606
commit f718ff1
Showing
18 changed files
with
119 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2022 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include <app/clusters/ota-requestor/BDXDownloader.h> | ||
#include <app/clusters/ota-requestor/DefaultOTARequestorStorage.h> | ||
#include <app/clusters/ota-requestor/GenericOTARequestorDriver.h> | ||
#include <app/clusters/ota-requestor/OTARequestor.h> | ||
#include <app/server/Server.h> | ||
#include <platform/nrfconnect/OTAImageProcessorImpl.h> | ||
|
||
using namespace chip; | ||
using namespace chip::DeviceLayer; | ||
|
||
namespace { | ||
|
||
DefaultOTARequestorStorage sOTARequestorStorage; | ||
GenericOTARequestorDriver sOTARequestorDriver; | ||
chip::BDXDownloader sBDXDownloader; | ||
chip::OTARequestor sOTARequestor; | ||
|
||
} // namespace | ||
|
||
// compile-time factory method | ||
OTAImageProcessorImpl & GetOTAImageProcessor() | ||
{ | ||
#if CONFIG_PM_DEVICE && CONFIG_NORDIC_QSPI_NOR | ||
static ExtFlashHandler sQSPIHandler; | ||
static OTAImageProcessorImplPMDevice sOTAImageProcessor{ sQSPIHandler }; | ||
#else | ||
static OTAImageProcessorImpl sOTAImageProcessor; | ||
#endif | ||
return sOTAImageProcessor; | ||
} | ||
|
||
void InitBasicOTARequestor() | ||
{ | ||
OTAImageProcessorImpl & imageProcessor = GetOTAImageProcessor(); | ||
imageProcessor.SetOTADownloader(&sBDXDownloader); | ||
sBDXDownloader.SetImageProcessorDelegate(&imageProcessor); | ||
sOTARequestorStorage.Init(Server::GetInstance().GetPersistentStorage()); | ||
sOTARequestor.Init(Server::GetInstance(), sOTARequestorStorage, sOTARequestorDriver, sBDXDownloader); | ||
sOTARequestorDriver.Init(&sOTARequestor, &imageProcessor); | ||
chip::SetRequestorInstance(&sOTARequestor); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.