From 73a8f82bf0a1bc7342579c59507664bcd44f8230 Mon Sep 17 00:00:00 2001 From: Trevor Holbrook Date: Wed, 15 Sep 2021 22:34:16 +0000 Subject: [PATCH] print output file name at transfer end and edit README and remove dead code --- examples/ota-requestor-app/linux/README.md | 5 +---- examples/ota-requestor-app/linux/main.cpp | 5 ----- .../ota-requestor-common/BDXDownloader.cpp | 7 ++++--- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/examples/ota-requestor-app/linux/README.md b/examples/ota-requestor-app/linux/README.md index 293cd4abaaf57e..8d1089943852eb 100644 --- a/examples/ota-requestor-app/linux/README.md +++ b/examples/ota-requestor-app/linux/README.md @@ -32,17 +32,14 @@ In a second terminal: - 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 diff --git a/examples/ota-requestor-app/linux/main.cpp b/examples/ota-requestor-app/linux/main.cpp index 93c2b3a78f51da..87f559931f967c 100644 --- a/examples/ota-requestor-app/linux/main.cpp +++ b/examples/ota-requestor-app/linux/main.cpp @@ -278,11 +278,6 @@ int main(int argc, char * argv[]) err = providerDevice->EstablishConnectivity(&mConnectionCallback, &mConnectFailCallback); - /* - err = providerDevice->LoadSecureSessionParametersIfNeeded(); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(SoftwareUpdate, "LoadSecureSessionParametersIfNeeded() failed: %s", chip::ErrorStr(err)));*/ - chip::DeviceLayer::PlatformMgr().RunEventLoop(); exit: diff --git a/examples/ota-requestor-app/ota-requestor-common/BDXDownloader.cpp b/examples/ota-requestor-app/ota-requestor-common/BDXDownloader.cpp index b6e6d51d55a063..d3ccf55d4e7dbe 100644 --- a/examples/ota-requestor-app/ota-requestor-common/BDXDownloader.cpp +++ b/examples/ota-requestor-app/ota-requestor-common/BDXDownloader.cpp @@ -26,7 +26,8 @@ using namespace chip::bdx; -uint32_t numBlocksRead = 0; +uint32_t numBlocksRead = 0; +const char outFilePath[] = "test-ota-out.txt"; void BdxDownloader::SetInitialExchange(chip::Messaging::ExchangeContext * ec) { @@ -47,7 +48,7 @@ void BdxDownloader::HandleTransferSessionOutput(TransferSession::OutputEvent & e case TransferSession::OutputEventType::kNone: if (mIsTransferComplete) { - ChipLogDetail(BDX, "Transfer complete!"); + ChipLogDetail(BDX, "Transfer complete! Contents written/appended to %s", outFilePath); mTransfer.Reset(); mIsTransferComplete = false; } @@ -77,7 +78,7 @@ void BdxDownloader::HandleTransferSessionOutput(TransferSession::OutputEvent & e // TODO: something more elegant than appending to a local file // TODO: while convenient, we should not do a synchronous block write in our example application - this is bad practice - std::ofstream otaFile("test-ota-out.txt", std::ifstream::out | std::ifstream::ate | std::ifstream::app); + std::ofstream otaFile(outFilePath, std::ifstream::out | std::ifstream::ate | std::ifstream::app); otaFile.write(reinterpret_cast(event.blockdata.Data), event.blockdata.Length); if (event.blockdata.IsEof)