Skip to content

Commit

Permalink
print output file name at transfer end and edit README
Browse files Browse the repository at this point in the history
and remove dead code
  • Loading branch information
holbrookt committed Sep 15, 2021
1 parent db62a32 commit 73a8f82
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
5 changes: 1 addition & 4 deletions examples/ota-requestor-app/linux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 0 additions & 5 deletions examples/ota-requestor-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
}
Expand Down Expand Up @@ -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<const char *>(event.blockdata.Data), event.blockdata.Length);

if (event.blockdata.IsEof)
Expand Down

0 comments on commit 73a8f82

Please sign in to comment.