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

Restyle [OTA] Use CASESessionManager to establish CASE sessions from OTARequestor class #12759

Closed
wants to merge 3 commits into from

Conversation

restyled-io[bot]
Copy link
Contributor

@restyled-io restyled-io bot commented Dec 8, 2021

A duplicate of #12636 with additional commits that automatically address
incorrect style, created by Restyled.

⚠️ Even though this PR is not a Fork, it contains outside contributions.
Please review accordingly.

Since the original Pull Request was opened as a fork in a contributor's
repository, we are unable to create a Pull Request branching from it with only
the style fixes.

The following Restylers made fixes:

To incorporate these changes, you can either:

  1. Merge this Pull Request instead of the original, or

  2. Ask your contributor to locally incorporate these commits and push them to
    the original Pull Request

    Expand for example instructions
    ```console
    git remote add upstream https://github.com/project-chip/connectedhomeip.git
    git fetch upstream pull/<this PR number>/head
    git merge --ff-only FETCH_HEAD
    git push
    ```
    

NOTE: As work continues on the original Pull Request, this process will
re-run and update (force-push) this Pull Request with updated style fixes as
necessary. If the style is fixed manually at any point (i.e. this process finds
no fixes to make), this Pull Request will be closed automatically.

Sorry if this was unexpected. To disable it, see our documentation.

carol-apple and others added 3 commits December 8, 2021 10:35
- Use Reader to parse BDX URI
- Pass in server instance for CASE sessions and BDX transfer usage
@restyled-io restyled-io bot added the restyled label Dec 8, 2021
@todo
Copy link

todo bot commented Dec 8, 2021

This uses the current node as the provider to supply the OTA image. This can be configurable such that the provider

// TODO: This uses the current node as the provider to supply the OTA image. This can be configurable such that the provider
// supplying the response is not the provider supplying the OTA image.
FabricIndex fabricIndex = commandObj->GetExchangeContext()->GetSessionHandle().GetFabricIndex();
FabricInfo * fabricInfo = Server::GetInstance().GetFabricTable().FindFabricWithIndex(fabricIndex);
NodeId nodeId = fabricInfo->GetPeerId().GetNodeId();
// Only doing BDX transport for now
MutableCharSpan uri(uriBuf, kUriMaxLen);
GenerateBdxUri(nodeId, CharSpan(mOTAFilePath, strlen(mOTAFilePath)), uri);
ChipLogDetail(SoftwareUpdate, "Generated URI: %.*s", static_cast<int>(uri.size()), uri.data());
}


This comment was generated by todo based on a TODO comment in ea2bf6e in #12759. cc @project-chip.

@todo
Copy link

todo bot commented Dec 8, 2021

Revisit who should be set as the resolver delegate

// TODO: Revisit who should be set as the resolver delegate
Dnssd::Resolver::Instance().SetResolverDelegate(this);
}
virtual ~CASESessionManager() {}


This comment was generated by todo based on a TODO comment in ea2bf6e in #12759. cc @project-chip.

@todo
Copy link

todo bot commented Dec 8, 2021

Add unit tests for parsing BDX URI

// TODO: Add unit tests for parsing BDX URI
CHIP_ERROR BDXDownloader::ParseBdxUri(CharSpan uri, NodeId & nodeId, MutableCharSpan fileDesignator)
{
// Check against minimum length of a valid BDX URI
if (uri.size() < kValidBdxUriMinLen)
{
return CHIP_ERROR_INVALID_STRING_LENGTH;
}
uint8_t readValue[kUriMaxLen];
Encoding::LittleEndian::Reader uriReader(reinterpret_cast<const uint8_t *>(uri.data()), uri.size());


This comment was generated by todo based on a TODO comment in ea2bf6e in #12759. cc @project-chip.

@todo
Copy link

todo bot commented Dec 8, 2021

Add a method to OTARequestorDriver used to report error condictions

// TODO: Add a method to OTARequestorDriver used to report error condictions
VerifyOrReturn(response.imageURI.HasValue(), ChipLogError(SoftwareUpdate, "Update is available but no image URI present"));
// Parse out the provider node ID and file designator from the image URI
NodeId nodeId = kUndefinedNodeId;
char fileDesignatorBuffer[kUriMaxLen] = { 0 };
MutableCharSpan fileDesignator(fileDesignatorBuffer, kUriMaxLen);
CHIP_ERROR err = requestorCore->mBdxDownloader->ParseBdxUri(response.imageURI.Value(), nodeId, fileDesignator);
VerifyOrReturn(err == CHIP_NO_ERROR,
ChipLogError(SoftwareUpdate, "Parse BDX image URI (%.*s) returned err=%" CHIP_ERROR_FORMAT,
static_cast<int>(response.imageURI.Value().size()), response.imageURI.Value().data(),


This comment was generated by todo based on a TODO comment in ea2bf6e in #12759. cc @project-chip.

@todo
Copy link

todo bot commented Dec 8, 2021

Add download protocol not supported

// TODO: Add download protocol not supported
// Issue #9524 should handle all response status appropriately
default:
break;
}
}
void OTARequestor::OnQueryImageFailure(void * context, EmberAfStatus status)
{
ChipLogDetail(SoftwareUpdate, "QueryImage failure response %" PRIu8, status);
}


This comment was generated by todo based on a TODO comment in ea2bf6e in #12759. cc @project-chip.

@todo
Copy link

todo bot commented Dec 8, 2021

this should be OTADownloader

BDXDownloader * mBdxDownloader = nullptr; // TODO: this should be OTADownloader
BDXMessenger mBdxMessenger; // TODO: ideally this is held by the application
Server * mServer = nullptr;
};
} // namespace chip


This comment was generated by todo based on a TODO comment in ea2bf6e in #12759. cc @project-chip.

@todo
Copy link

todo bot commented Dec 8, 2021

ideally this is held by the application

BDXMessenger mBdxMessenger; // TODO: ideally this is held by the application
Server * mServer = nullptr;
};
} // namespace chip


This comment was generated by todo based on a TODO comment in ea2bf6e in #12759. cc @project-chip.

@restyled-io restyled-io bot closed this Dec 8, 2021
@restyled-io restyled-io bot deleted the restyled/ota_requestor_csm branch December 8, 2021 23:51
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.

2 participants