-
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.
Make ota-requestor-app build and run (#9740)
* add build changes and program arguments to make requestor work * remove requestor cluster and regen * fix SystemLayer reference * print output file name at transfer end and edit README and remove dead code * add ota-requestor-app to CI * apply changes from Tennessee: - move self-commissioning code into its own file - rename example args for QueryImage - remove location param null-terminator - leave metadata empty - change "peerId" to "providerLocation" * add new file for slef-commissioning code
- Loading branch information
Showing
12 changed files
with
307 additions
and
343 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,6 +116,14 @@ jobs: | |
linux debug ota-provider-app \ | ||
out/ota_provider_debug/chip-ota-provider-app \ | ||
/tmp/bloat_reports/ | ||
- name: Build example OTA Requestor | ||
timeout-minutes: 5 | ||
run: | | ||
scripts/examples/gn_build_example.sh examples/ota-requestor-app/linux out/ota_requestor_debug | ||
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ | ||
linux debug ota-requestor-app \ | ||
out/ota_requestor_debug/chip-ota-requestor-app \ | ||
/tmp/bloat_reports/ | ||
- name: Binary artifact suffix | ||
id: outsuffix | ||
uses: haya14busa/[email protected] | ||
|
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
78 changes: 78 additions & 0 deletions
78
examples/ota-requestor-app/linux/ExampleSelfCommissioning.h
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,78 @@ | ||
/* | ||
* | ||
* 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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <controller/CHIPDeviceController.h> | ||
#include <controller/ExampleOperationalCredentialsIssuer.h> | ||
#include <crypto/CHIPCryptoPAL.h> | ||
#include <lib/core/CHIPError.h> | ||
#include <lib/core/CHIPPersistentStorageDelegate.h> | ||
#include <lib/support/ScopedBuffer.h> | ||
|
||
using chip::PersistentStorageDelegate; | ||
using chip::Controller::DeviceController; | ||
using chip::Controller::ExampleOperationalCredentialsIssuer; | ||
|
||
CHIP_ERROR DoExampleSelfCommissioning(DeviceController & controller, ExampleOperationalCredentialsIssuer * opCredsIssuer, | ||
PersistentStorageDelegate * storage, chip::NodeId localNodeId) | ||
{ | ||
CHIP_ERROR err = CHIP_NO_ERROR; | ||
chip::Platform::ScopedMemoryBuffer<uint8_t> noc; | ||
chip::Platform::ScopedMemoryBuffer<uint8_t> icac; | ||
chip::Platform::ScopedMemoryBuffer<uint8_t> rcac; | ||
chip::Controller::ControllerInitParams initParams; | ||
|
||
VerifyOrExit(storage != nullptr && opCredsIssuer != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT); | ||
|
||
err = opCredsIssuer->Initialize(*storage); | ||
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Init failure! Operational Cred Issuer: %s", chip::ErrorStr(err))); | ||
|
||
VerifyOrExit(rcac.Alloc(chip::Controller::kMaxCHIPDERCertLength), err = CHIP_ERROR_NO_MEMORY); | ||
VerifyOrExit(noc.Alloc(chip::Controller::kMaxCHIPDERCertLength), err = CHIP_ERROR_NO_MEMORY); | ||
VerifyOrExit(icac.Alloc(chip::Controller::kMaxCHIPDERCertLength), err = CHIP_ERROR_NO_MEMORY); | ||
|
||
{ | ||
chip::MutableByteSpan nocSpan(noc.Get(), chip::Controller::kMaxCHIPDERCertLength); | ||
chip::MutableByteSpan icacSpan(icac.Get(), chip::Controller::kMaxCHIPDERCertLength); | ||
chip::MutableByteSpan rcacSpan(rcac.Get(), chip::Controller::kMaxCHIPDERCertLength); | ||
|
||
chip::Crypto::P256Keypair ephemeralKey; | ||
SuccessOrExit(err = ephemeralKey.Initialize()); | ||
|
||
// TODO - OpCreds should only be generated for pairing command | ||
// store the credentials in persistent storage, and | ||
// generate when not available in the storage. | ||
err = opCredsIssuer->GenerateNOCChainAfterValidation(localNodeId, 0, ephemeralKey.Pubkey(), rcacSpan, icacSpan, nocSpan); | ||
SuccessOrExit(err); | ||
|
||
initParams.ephemeralKeypair = &ephemeralKey; | ||
initParams.controllerRCAC = rcacSpan; | ||
initParams.controllerICAC = icacSpan; | ||
initParams.controllerNOC = nocSpan; | ||
initParams.operationalCredentialsDelegate = opCredsIssuer; | ||
|
||
initParams.storageDelegate = storage; | ||
|
||
err = controller.Init(initParams); | ||
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Controller init failure! %s", chip::ErrorStr(err))); | ||
} | ||
|
||
exit: | ||
return err; | ||
} |
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 |
---|---|---|
@@ -1,29 +1,45 @@ | ||
# ota-requestor-app (Linux) | ||
|
||
WARNING: this app currently does not build successfully. It is being submitted | ||
as a starting point for further OTA Requestor development. | ||
|
||
This is a reference application that is both a server for the OTA Requestor | ||
Cluster, as well as a client of the OTA Provider Cluster. It should initiate a | ||
Software Update with a given OTA Provider node, and download a file. | ||
|
||
## Usage | ||
|
||
Due to #9518, this app must pretend to be `chip-tool` in order to establish a | ||
connection to the OTA Provider. It does this by reading the CASE session and | ||
other necessary credentials stored in persistent memory on startup. | ||
|
||
Therefore, to use this app you should call these commands in the following | ||
order: | ||
|
||
In one terminal: | ||
|
||
``` | ||
./chip-ota-provider-app [-f <filepath>] | ||
``` | ||
|
||
In a second terminal: | ||
|
||
``` | ||
./chip-tool pairing onnetwork 0 20202021 3840 ::1 5540 | ||
./chip-ota-requestor-app [-p <provider node id>] | ||
``` | ||
|
||
## Current Features / Limitations | ||
|
||
### Features | ||
|
||
- Code for running a full BDX download exists in BDX | ||
- Sends QueryImage command | ||
- Takes a peer Node ID as an argument | ||
|
||
### Limitations | ||
|
||
- needs chip-tool to pair to the Provider device first, so it can steal the | ||
CASE session from persisted memory | ||
- uses Controller class to load the CASE session | ||
- Controller does not provide any way to access a new ExchangeContext for the | ||
BDX exchange | ||
- doesn't wait for QueryImageResponse to begin the BDX exchange | ||
- does not verify QueryImageResponse message contents | ||
- stores the downloaded file at a hardcoded filepath | ||
- doesn't close the BDX ExchangeContext when the exchange is over | ||
- only uses hardcoded node IDs | ||
- does not support AnnounceOTAProvider command or OTA Requestor attributes |
Oops, something went wrong.