zigpy / bellows

A Python 3 project to implement EZSP for EmberZNet devices
GNU General Public License v3.0
179 stars 87 forks source link

Reduce command duplication #635

Closed puddly closed 1 month ago

puddly commented 1 month ago

This PR finishes the "derives from the previous version" format that we've been using for EZSP v8-v14.

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.15%. Comparing base (91b8f37) to head (18d1d52).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## dev #635 +/- ## ======================================= Coverage 99.15% 99.15% ======================================= Files 50 50 Lines 3412 3447 +35 ======================================= + Hits 3383 3418 +35 Misses 29 29 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

puddly commented 1 month ago

I believe that https://github.com/zigpy/bellows/pull/635/commits/18d1d524830c536666e22a2a403a56718a91e003 is going to be a safe change: I've not seen a single SDK version where the sent command parameter is actually 16 bits. The SDK uses 16-bit integer constants but the command is always serialized and deserialized to/from an 8-bit integer. I think the fact that EZSP is lenient with command payload lengths and that we use little endian encoding has sort of "hidden" this problem:

In [1]: (0x0012).to_bytes(2, 'little')
Out[1]: b'\x12\x00'

In [2]: (0x0012).to_bytes(1, 'little')
Out[2]: b'\x12'