-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix wildcard reads + chunking #12140
Conversation
PR #12140: Size comparison from b83502b to 554cc03 Increases (31 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
Full report (38 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
|
Unfortunately, there are a bunch more bugs on the server side that the tests I've added to Python are un-earthing. So, will need to fix these before this PR is in a shape to merge. |
fast track: change up for a while, created by a domain owner. Most changes are python-related which is not affecting main functionality. |
Using the Matter REPL, this PR fixes a number of critical bugs in both the server-side logic as well as the Python APIs to validate all permutations of wildcard reads as well as basic chunking. On the server side, it fixes: - The AttributeExpandPathIterator was incorrectly using emberAfClusterIndex to iterate over clusters on an endpoint, but that isn't its API contract. That function returns something else completely. Fixed that implementation as well as created a new, better named function called emberAfClusterIndexInMatchingEndpoints that actually better describes what it does. - In ReadSingleClusterData, we were chaining a number of MessageDef builder calls one after another and checking the error at the end (by calling GetError()). However, this resulted in the original error encountered in the first call in that chain being lost and replaced with something else by the time it got to the end. This was especially problematic during chunking since the errors CHIP_ERROR_BUFFER_TOO_SMALL and CHIP_ERROR_NO_MEMORY are what the higher level calls in Engine::BuildSingleReportDataAttributeReportIBs expect to correclty handle chunking. Since the error got lost and converted, it resulted in the Engine treating it like a critical failure and stopping the generation of reports entirely. On the client side in Python: - Reading Clusters.OnOff.Attributes.SampleMfgSpecificAttribute0x00000x1049 broke because in the Python code, we were generating attribute IDs that were 16-bit values instead of 32-bits. This was a combination of not generating them correclty, as well as the C++ bindings expecting a c_uint16 instead of c_uint32 - Fixed up ChipDeviceController.ReadAttribute to actually work correctly with wildcards instead of just erroring out due to parsing issues. Validation: - Tested all wildcard read variations using the Python ReadAttribute API in the REPL and ensured it completed successfully. - Added all variations as tests to the mobile device test suite.
554cc03
to
259cb84
Compare
259cb84
to
ebd102f
Compare
PR #12140: Size comparison from 659190d to ebd102f Increases (3 builds for qpg, telink)
Full report (4 builds for qpg, telink)
|
PR #12140: Size comparison from 659190d to b2690ef Increases (29 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
Full report (38 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
|
PR #12140: Size comparison from 659190d to 0711b2c Increases (22 builds for efr32, esp32, k32w, linux, mbed, p6, qpg, telink)
Full report (28 builds for efr32, esp32, k32w, linux, mbed, p6, qpg, telink)
|
PR #12140: Size comparison from 67c8f1d to de666a7 Increases (29 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
Full report (38 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
|
PR #12140: Size comparison from ab5734c to c0475e0 Increases (29 builds for efr32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
Full report (36 builds for efr32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
|
PR #12140: Size comparison from ab5734c to f403549 Increases (31 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
Full report (38 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
|
Using the Matter REPL as a validation tool, this PR fixes a number of critical bugs in both the server-side logic as well as the Python APIs to validate all permutations of wildcard reads as well as basic chunking.
On the server side, it fixes:
The
AttributeExpandPathIterator
was incorrectly usingemberAfClusterIndex
to iterate over clusters on an endpoint, but that isn't its API contract. That function returns something else completely. Fixed that implementation as well as created a new, better named function calledemberAfClusterIndexInMatchingEndpoints
that actually better describes what it does.In
ReadSingleClusterData
, we were chaining a number of MessageDef builder calls one after another and checking the error at the end (by callingGetError()
). However, this resulted in the original error encountered in the first call in that chain being lost and replaced with something else by the time it got to the end. This was especially problematic during chunking since the errorsCHIP_ERROR_BUFFER_TOO_SMALL
andCHIP_ERROR_NO_MEMORY
are what the higher level calls inEngine::BuildSingleReportDataAttributeReportIBs
expect to correctly handle chunking. Since the error got lost and converted, it resulted in the Engine treating it like a critical failure and stopping the generation of reports entirely.Many places where we were assuming we could close out DataIB after encountering a TLV full error when writing data, which was incorrectly and resulted in the subscription failing. Instead, doing the correct reservation of space for these end-of-container tags was done in the fix to prevent encountering any subsequent errors on closure.
On the client side in Python:
Reading
Clusters.OnOff.Attributes.SampleMfgSpecificAttribute0x00000x1049
broke because in the Python code, we were generating attribute IDs that were 16-bit values instead of 32-bits. This was a combination of not generating them correctly, as well as the C++ bindings expecting a c_uint16 instead of c_uint32Fixed up
ChipDeviceController.ReadAttribute
to actually work correctly with wildcards instead of just erroring out due to parsing issues.Made the data returned by ReadAttribute actually return the value as strongly typed values, making it easier to read.
Validation:
Tested all wildcard read variations using the Python ReadAttribute API in the REPL and ensured it completed successfully, including reading every single attribute on the device! and validating that each and every attribute was of the right type.
Created a definitive, robust chunking validation unit test that artificially limits the size of a packet buffer and sweeps through a range of packet buffer sizes to empirically fit in N to N+1 attributes in a report, exposing all corner cases. This was used to not only ensure the above bugs were caught by the test, but to also validate the fixes.
Added all variations as tests to the mobile device test suite.