zgp: add the Green Power types, frame, and crypto parsing core#1847
zgp: add the Green Power types, frame, and crypto parsing core#1847nmingam wants to merge 4 commits into
Conversation
Carve out the radio-agnostic Green Power parsing layer as a standalone, self-contained unit: - types.py: GPD command IDs, GP endpoint/cluster/group constants, the default GP link key, and fixes to SecurityLevel and the ProxyCommissioningModeExitMode bitmap - frame.py: GP Commissioning (0xE0) and Channel Request (0xE3) payload parsing and serialization - crypto.py: AES-128-CCM* nonce construction, key (de)encryption, and payload (de)encryption per ZGP spec A.1.5.4 / A.3.7.1.2.3 - greenpower.py: correct the GP Commissioning Notification, Response, and Proxy Commissioning Mode ZCL schemas against the spec figures The manager, device, and proxy layers that build on this core are left out and will follow in separate PRs. Co-authored-by: puddly <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1847 +/- ##
========================================
Coverage 99.47% 99.48%
========================================
Files 57 59 +2
Lines 12026 12214 +188
========================================
+ Hits 11963 12151 +188
Misses 63 63 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
puddly
left a comment
There was a problem hiding this comment.
Thanks! This looks good, just a few comments.
| assert "0x" in repr(d).lower() | ||
|
|
||
|
|
||
| def test_no_security(): |
There was a problem hiding this comment.
I think you can remove any unit tests that assert that value of an enum. They're not really useful tests.
There was a problem hiding this comment.
Dropped the bare assert Enum.Member == 0bNN tests — agreed they weren't pulling weight. Kept the handful that check actual behavior: the protocol constants (endpoint/cluster/group IDs, the default link key), DeviceID uint32 coercion + hex repr, and the bitmap OR-composition test.
Replace the manual bit masks and offset parsing in frame.py with IntStruct options bytes and a Struct payload with requires-gated fields, per review. GPChannelRequestPayload now exposes the raw channel nibbles; consumers apply the +11 offset.
Standalone Green Power parsing core, split out of #1814 so it can land on its own — following @puddly's suggestion to get the types/command parsing in first and shrink the larger PR.
Contents
zgp/types.py: GPD command IDs, GP endpoint/cluster/group constants, the default GP link key, and fixes toSecurityLeveland theProxyCommissioningModeExitModebitmapzgp/frame.py: GP Commissioning (0xE0) and Channel Request (0xE3) payload parsing and serializationzgp/crypto.py: AES-128-CCM* nonce construction, key and payload (de)encryption per ZGP spec A.1.5.4 / A.3.7.1.2.3zcl/clusters/greenpower.py: GP Commissioning Notification / Response / Proxy Commissioning Mode ZCL schema fixestests/zgp/:test_types,test_frame,test_crypto— 100% line coverage of the four modules aboveThe manager, device, and proxy layers that build on this core are intentionally left out and will follow in separate PRs.
Credits