Skip to content

Commit 2a1c630

Browse files
selissiarestyled-commits
authored andcommitted
OTA Requestor Refactoring -- Part 1 (#12119)
* 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]>
1 parent 14ad651 commit 2a1c630

20 files changed

+809
-401
lines changed

.github/.wordlist.txt

+8
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ lightin
549549
LightingColor
550550
LightingState
551551
LinkSoftwareAndDocumentationPack
552+
LinuxOTARequestorDriver
552553
LocalConfigDisabled
553554
localhost
554555
localstatedir
@@ -701,9 +702,13 @@ optionsMask
701702
optionsOverride
702703
orgs
703704
OTA
705+
OTADownloader
706+
OTAImageProcessorDriver
704707
OTAProviderIpAddress
705708
OTAProviderNodeId
706709
OTAProviderSerialPort
710+
OTARequestor
711+
OTARequestorDriver
707712
OTARequesterImpl
708713
OTARequestorSerialPort
709714
OTBR
@@ -860,7 +865,10 @@ SERIALDEVICE
860865
SerialNumber
861866
ServiceId
862867
SetDns
868+
SetImageProcessorDelegate
869+
SetOtaRequestorDriver
863870
SetpointRaiseLower
871+
SetRequestorInstance
864872
SetUpPINCode
865873
SetupQRCode
866874
sexualized

examples/ota-requestor-app/linux/BUILD.gn

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ import("//build_overrides/build.gni")
1616
import("//build_overrides/chip.gni")
1717

1818
executable("chip-ota-requestor-app") {
19-
sources = [ "main.cpp" ]
19+
sources = [
20+
"LinuxOTARequestorDriver.cpp",
21+
"main.cpp",
22+
]
2023

2124
deps = [
2225
"${chip_root}/examples/ota-requestor-app/ota-requestor-common",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
*
3+
* Copyright (c) 2021 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/* This file contains the decalarions for the Linux implementation of the
20+
* the OTAImageProcessorDriver interface class
21+
*/
22+
23+
#include "app/clusters/ota-requestor/OTAImageProcessor.h"
24+
25+
class LinuxOTAImageProcessor : public OTAImageProcessorDriver
26+
{
27+
28+
// Virtuial functions from OTAImageProcessorDriver -- start
29+
// Open file, find block of space in persistent memory, or allocate a buffer, etc.
30+
CHIP_ERROR PrepareDownload() { return CHIP_NO_ERROR; }
31+
32+
// Must not be a blocking call to support cases that require IO to elements such as // external peripherals/radios
33+
CHIP_ERROR ProcessBlock(chip::ByteSpan & data) { return CHIP_NO_ERROR; }
34+
35+
// Close file, close persistent storage, etc
36+
CHIP_ERROR Finalize() { return CHIP_NO_ERROR; }
37+
38+
chip::Optional<uint8_t> PercentComplete() { return chip::Optional<uint8_t>(0); }
39+
40+
// Clean up the download which could mean erasing everything that was written,
41+
// releasing buffers, etc.
42+
CHIP_ERROR Abort() { return CHIP_NO_ERROR; }
43+
44+
// Virtuial functions from OTAImageProcessorDriver -- end
45+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
*
3+
* Copyright (c) 2021 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/* This file contains the Linux implementation of the OTAImageProcessorDriver
20+
* interface class
21+
*/
22+
23+
#include "LinuxOTARequestorDriver.h"
24+
25+
// A call into the application logic to give it a chance to allow or stop the Requestor
26+
// from proceeding with actual image download. Returning TRUE will allow the download
27+
// to proceed, returning FALSE will abort the download process.
28+
bool LinuxOTARequestorDriver::CheckImageDownloadAllowed()
29+
{
30+
return true;
31+
}
32+
33+
// Notify the application that the download is complete and the image can be applied
34+
void LinuxOTARequestorDriver::ImageDownloadComplete() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
*
3+
* Copyright (c) 2021 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/* This file contains the decalarions for the Linux implementation of the
20+
* the OTARequestorDriver interface class
21+
*/
22+
#include "app/clusters/ota-requestor/OTARequestorDriver.h"
23+
24+
class LinuxOTARequestorDriver : public OTARequestorDriver
25+
{
26+
27+
// Virtual functions from OTARequestorDriver -- start
28+
29+
// A call into the application logic to give it a chance to allow or stop the Requestor
30+
// from proceeding with actual image download. Returning TRUE will allow the download
31+
// to proceed, returning FALSE will abort the download process.
32+
bool CheckImageDownloadAllowed();
33+
34+
// Notify the application that the download is complete and the image can be applied
35+
void ImageDownloadComplete();
36+
37+
// Virtual functions from OTARequestorDriver -- end
38+
};

0 commit comments

Comments
 (0)