Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ota-requestor-app build and run #9740

Conversation

holbrookt
Copy link
Contributor

@holbrookt holbrookt commented Sep 15, 2021

Problem

We need an OTA Requestor reference app in order to validate ota-provider-app and other OTA Provider devices. This should also serve as a reference for how to add OTA Requestor functionality to other applications.

Change overview

  • add program argument for Provider Node ID to connect to
  • use Device::EstablishConnectivity() to connect to Provider device and define connection callbacks
    • call QueryImage if/when connection is successful
    • start BDX transfer when QueryImageResponse is received
  • initialize Controller with crypto info
  • set kExpectResponse flag for BDX exchange
  • error handling and logging fixes/improvements
  • remove OTA Requestor cluster from zap file (until [ota-requestor-app] Handle AnnounceOTAProvider #9522 is fixed)
  • edit README instructions
  • add ota-requestor-app build to CI

Testing

@todo
Copy link

todo bot commented Sep 15, 2021

would be nicer to encapsulate these globals and the callbacks in some sort of class

// TODO: would be nicer to encapsulate these globals and the callbacks in some sort of class
chip::Messaging::ExchangeContext * exchangeCtx = nullptr;
Device * providerDevice = nullptr;
BdxDownloader bdxDownloader;
void OnQueryImageResponse(void * context, uint8_t status, uint32_t delayedActionTime, uint8_t * imageURI, uint32_t softwareVersion,
chip::ByteSpan updateToken, bool userConsentNeeded, chip::ByteSpan metadataForRequestor)
{
ChipLogDetail(SoftwareUpdate, "%s", __FUNCTION__);
TransferSession::TransferInitData initOptions;
initOptions.TransferCtlFlags = chip::bdx::TransferControlFlags::kReceiverDrive;


This comment was generated by todo based on a TODO comment in 73a8f82 in #9740. cc @holbrookt.

@todo
Copy link

todo bot commented Sep 15, 2021

blocked because arrays are being generated as uint8_t

constexpr uint8_t testProtocolsSupported = 0; // TODO: blocked because arrays are being generated as uint8_t
uint8_t locationBuf[3] = { 'U', 'S', '\0' };
ByteSpan location(locationBuf);
constexpr bool clientCanConsent = false;
ByteSpan metadata(locationBuf);
err = cluster.Associate(device, kOtaProviderEndpoint);
if (err != CHIP_NO_ERROR)
{
ChipLogError(SoftwareUpdate, "Associate() failed: %s", chip::ErrorStr(err));
return;


This comment was generated by todo based on a TODO comment in 73a8f82 in #9740. cc @holbrookt.

@todo
Copy link

todo bot commented Sep 15, 2021

- OpCreds should only be generated for pairing command

// TODO - OpCreds should only be generated for pairing command
// store the credentials in persistent storage, and
// generate when not available in the storage.
err = mOpCredsIssuer.GenerateNOCChainAfterValidation(mStorage.GetLocalNodeId(), 0, ephemeralKey.Pubkey(), rcacSpan,
icacSpan, nocSpan);
SuccessOrExit(err);
initParams.ephemeralKeypair = &ephemeralKey;
initParams.controllerRCAC = rcacSpan;
initParams.controllerICAC = icacSpan;
initParams.controllerNOC = nocSpan;


This comment was generated by todo based on a TODO comment in 73a8f82 in #9740. cc @holbrookt.

@todo
Copy link

todo bot commented Sep 15, 2021

something more elegant than appending to a local file

// 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(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)
{
err = mTransfer.PrepareBlockAck();
VerifyOrReturn(err == CHIP_NO_ERROR,
ChipLogError(BDX, "%s: PrepareBlockAck failed: %s", __FUNCTION__, chip::ErrorStr(err)));
mIsTransferComplete = true;


This comment was generated by todo based on a TODO comment in 73a8f82 in #9740. cc @holbrookt.

@todo
Copy link

todo bot commented Sep 15, 2021

while convenient, we should not do a synchronous block write in our example application - this is bad practice

// TODO: while convenient, we should not do a synchronous block write in our example application - this is bad practice
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)
{
err = mTransfer.PrepareBlockAck();
VerifyOrReturn(err == CHIP_NO_ERROR,
ChipLogError(BDX, "%s: PrepareBlockAck failed: %s", __FUNCTION__, chip::ErrorStr(err)));
mIsTransferComplete = true;
}


This comment was generated by todo based on a TODO comment in 73a8f82 in #9740. cc @holbrookt.

- 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"
@todo
Copy link

todo bot commented Sep 17, 2021

support this as a list once ember adds list support

EMBER_ZCL_OTA_DOWNLOAD_PROTOCOL_BDX_SYNCHRONOUS; // TODO: support this as a list once ember adds list support
const uint8_t locationBuf[] = { 'U', 'S' };
ByteSpan exampleLocation(locationBuf);
constexpr bool kExampleClientCanConsent = false;
ByteSpan metadata;
err = cluster.Associate(device, kOtaProviderEndpoint);
if (err != CHIP_NO_ERROR)
{
ChipLogError(SoftwareUpdate, "Associate() failed: %s", chip::ErrorStr(err));
return;


This comment was generated by todo based on a TODO comment in dd13ad2 in #9740. cc @holbrookt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement OTA Software Update cluster (Client side)
5 participants