Skip to content

Commit

Permalink
OTA Requestor Refactoring -- Part 1 (#12119)
Browse files Browse the repository at this point in the history
* Introduce ota-requestor.h containing Requestor API declarations

* Split OTA Requestor class declarations into multiple headers

* Restyled by whitespace

* Restyled by clang-format

* Clean up comments and function names

* Misc API format changes based on PR comments

* Restyled by clang-format

* First take at moving the core Requestor logic out of the Linux example

* Further OTA Requestor refactoring -- moving logic out of Linux example app

* Further changes for OTA Rerquestor refactoring

* More OTA Requestor refactoring changes

* Refactoring OTA Requestor. Code compiles and links with this commit

* Further OTA Requestor refactoring. Requestor and chip-tool build successfully.

The top-level build fails for all-cluster app.

* OTA Refactor:Only build clusters/ota-requestor in the context of Requestor app

Update .gn files so that clusters/ota-requestor is not built for all example apps (this is different from the rest of the clusters). Instead, explicitly specify clusters/ota-requestor sources in the OTA-Requestor example app

* OTA-Requestor: Initialize mOtaStartDelayMs

* Restyled by whitespace

* Restyled by clang-format

* Restyled by gn

* Push submodule pointers

* Clean up an extra statement introduced by mistake

* Remove ExampleOTARequestor.cpp/h as they are replaced by the OTARequestor.cpp/h

* Add OTA Requestor README

* OTARequestor refactoring. With this the image transfer scenario works on Linux:

rm -r /tmp/chip_*
./out/debug/chip-ota-provider-app -f /tmp/ota.txt
./out/chip-tool pairing onnetwork 1 20202021
./out/debug/chip-ota-requestor-app -u 5560 -d 42 -i ::1
./out/chip-tool pairing onnetwork-long 2 20202021 42
./out/chip-tool otasoftwareupdaterequestor announce-ota-provider 1 0 0 2 0

* Requestor refactoring: Enable automatic ImageQuery in Test Mode

* OTA Requestor refactoring -- add LinuxOTARequestorDriver.cpp, comments

* Requestor refactor: Rename and clean up files

* Restyled by whitespace

* Restyled by clang-format

* Restyled by gn

* Restyled by prettier-markdown

* OTA Requestor changes

* Remove unused variable

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jul 16, 2022
1 parent cbd1919 commit 4088995
Show file tree
Hide file tree
Showing 20 changed files with 809 additions and 401 deletions.
8 changes: 8 additions & 0 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ lightin
LightingColor
LightingState
LinkSoftwareAndDocumentationPack
LinuxOTARequestorDriver
LocalConfigDisabled
localhost
localstatedir
Expand Down Expand Up @@ -701,9 +702,13 @@ optionsMask
optionsOverride
orgs
OTA
OTADownloader
OTAImageProcessorDriver
OTAProviderIpAddress
OTAProviderNodeId
OTAProviderSerialPort
OTARequestor
OTARequestorDriver
OTARequesterImpl
OTARequestorSerialPort
OTBR
Expand Down Expand Up @@ -860,7 +865,10 @@ SERIALDEVICE
SerialNumber
ServiceId
SetDns
SetImageProcessorDelegate
SetOtaRequestorDriver
SetpointRaiseLower
SetRequestorInstance
SetUpPINCode
SetupQRCode
sexualized
Expand Down
5 changes: 4 additions & 1 deletion examples/ota-requestor-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")

executable("chip-ota-requestor-app") {
sources = [ "main.cpp" ]
sources = [
"LinuxOTARequestorDriver.cpp",
"main.cpp",
]

deps = [
"${chip_root}/examples/ota-requestor-app/ota-requestor-common",
Expand Down
45 changes: 45 additions & 0 deletions examples/ota-requestor-app/linux/LinuxOTAImageProcessor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
*
* Copyright (c) 2021 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.
*/

/* This file contains the decalarions for the Linux implementation of the
* the OTAImageProcessorDriver interface class
*/

#include "app/clusters/ota-requestor/OTAImageProcessor.h"

class LinuxOTAImageProcessor : public OTAImageProcessorDriver
{

// Virtuial functions from OTAImageProcessorDriver -- start
// Open file, find block of space in persistent memory, or allocate a buffer, etc.
CHIP_ERROR PrepareDownload() { return CHIP_NO_ERROR; }

// Must not be a blocking call to support cases that require IO to elements such as // external peripherals/radios
CHIP_ERROR ProcessBlock(chip::ByteSpan & data) { return CHIP_NO_ERROR; }

// Close file, close persistent storage, etc
CHIP_ERROR Finalize() { return CHIP_NO_ERROR; }

chip::Optional<uint8_t> PercentComplete() { return chip::Optional<uint8_t>(0); }

// Clean up the download which could mean erasing everything that was written,
// releasing buffers, etc.
CHIP_ERROR Abort() { return CHIP_NO_ERROR; }

// Virtuial functions from OTAImageProcessorDriver -- end
};
34 changes: 34 additions & 0 deletions examples/ota-requestor-app/linux/LinuxOTARequestorDriver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
*
* Copyright (c) 2021 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.
*/

/* This file contains the Linux implementation of the OTAImageProcessorDriver
* interface class
*/

#include "LinuxOTARequestorDriver.h"

// A call into the application logic to give it a chance to allow or stop the Requestor
// from proceeding with actual image download. Returning TRUE will allow the download
// to proceed, returning FALSE will abort the download process.
bool LinuxOTARequestorDriver::CheckImageDownloadAllowed()
{
return true;
}

// Notify the application that the download is complete and the image can be applied
void LinuxOTARequestorDriver::ImageDownloadComplete() {}
38 changes: 38 additions & 0 deletions examples/ota-requestor-app/linux/LinuxOTARequestorDriver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
*
* Copyright (c) 2021 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.
*/

/* This file contains the decalarions for the Linux implementation of the
* the OTARequestorDriver interface class
*/
#include "app/clusters/ota-requestor/OTARequestorDriver.h"

class LinuxOTARequestorDriver : public OTARequestorDriver
{

// Virtual functions from OTARequestorDriver -- start

// A call into the application logic to give it a chance to allow or stop the Requestor
// from proceeding with actual image download. Returning TRUE will allow the download
// to proceed, returning FALSE will abort the download process.
bool CheckImageDownloadAllowed();

// Notify the application that the download is complete and the image can be applied
void ImageDownloadComplete();

// Virtual functions from OTARequestorDriver -- end
};
Loading

0 comments on commit 4088995

Please sign in to comment.