-
Notifications
You must be signed in to change notification settings - Fork 2k
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
BDX transfer support for Python tests #34821
base: master
Are you sure you want to change the base?
Conversation
…e transfer delegate.
Also add the transfer obtained context to the C++ methods relating to expecting transfers.
…a BDX transfer. Also run the python BDX initialisation.
Also ignore the BDX transfer server implementation that only handles diagnostic logs.
…ata. * Call Responder::PrepareForTransfer from BdxTransfer. * Correctly schedule satisfying the future on the event loop. * Use the real property to determine if a PyChipError was a success.
Also don't ignore all messages after the init.
…he way one would expect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to Cecille: made it down to bdx.cpp, but haven't reviewed that yet.
* remove a check that was inadvertently kept. * print a log message when something that shouldn't happen inevitably does. * use user_params to get the end user support log test parameter.
|
||
|
||
class BdxTransfer: | ||
def __init__(self, bdx_transfer: c_void_p, init_message: InitMessage, data=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a type annotation for data? Is it expecting bytes? or string? or something else entirely
eventLoop = asyncio.get_running_loop() | ||
future = eventLoop.create_future() | ||
|
||
if self._data != None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if self._data != None: | |
if self._data is not None: |
I think Or not self._data if data can't be a thing that evaluates to false. Not sure on the data type or whether an empty data is viable.
OnTransferCompletedCallback gOnTransferCompletedCallback = nullptr; | ||
|
||
// The information for a single transfer. | ||
struct TransferData |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of this struct is a bit odd because it's not the data for transfer, its the information about the transfer. Can this be TranferInfo or some other such thing
if (gOnTransferObtainedCallback && transferData) | ||
{ | ||
gOnTransferObtainedCallback(transferData->OnTransferObtainedContext, ToPyChipError(result), nullptr, | ||
static_cast<bdx::TransferControlFlags>(0), 0, 0, 0, nullptr, 0, nullptr, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are the args here?
// The information for a single transfer. | ||
struct TransferData | ||
{ | ||
bdx::BdxTransfer * Transfer = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I've tracked down all the pieces, and it seems correct, but would you mind adding some documentation here about what owns which pieces of this transfer and what the expected lifefimes are? The callbacks are python, it looks like the TransferData is owned by the TransferMap (owned by ...? But referenced by the delegate?) Transfers are owned by the transfer server? Does the transfer server also own the data or is that owned externally? Does that change for receive/send?
Add support for BDX transfers to the Python tests.
This allows Python tests to wait for BDX transfers, inspect the init message's details, accept or reject the transfer, and send or receive data. This assists with writing tests for the OTA requestor and diagnostic logs clusters that involve BDX transfers. The code takes some inspiration from the existing BDX transfer server code in src/protocols/bdx, and I think it's worth following up at some point to expand the capabilities of that code to reduce the amount of code specific to the Python controller code introduced in this change.
Included is a test that uses the diagnostic logs cluster on the all clusters app to initiate and complete a BDX transfer.