Fix gpepIncomingMessageHandler schema for EZSP v13+ - #746
Open
bedge117 wants to merge 1 commit into
Open
Conversation
The inherited schema predates the EmberZNet 7.x wire format, so every incoming Green Power frame failed to parse and was dropped before reaching the application. Redefine the handler for EZSP v13 with the layout 7.x NCPs emit: applicationId, 8-byte GPD id union, and endpoint, followed by the security, frame counter, command, MIC, proxy table index, and payload fields. Verified against frames captured from an EmberZNet 7.5.1 NCP receiving an EnOcean PTM 215Z switch; one such frame is added as a regression test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix gpepIncomingMessageHandler schema for EZSP v13+
Problem
Every incoming Green Power frame on an EmberZNet 7.x NCP fails to parse and is dropped before it reaches the application:
This is the long-standing symptom behind the Friends-of-Hue / PTM 215Z reports (e.g. zigpy/zha-device-handlers#2477) and blocks any Green Power work on top of bellows.
Cause
gpepIncomingMessageHandleris only defined in the v4 schema (and redefined in v17). Everything from v5 through v16 inherits the v4 layout, which predates the EmberZNet 7.x wire format. In 7.x theEmberGpAddressmember is serialized asapplicationId, an 8-byte GPD id union, thenendpoint; the v4 schema expects a different, longer layout and runs out of bytes.Fix
Redefine the handler for EZSP v13 (inherited by v14 and v16) with the 7.x layout:
status, gpdLink, sequenceNumber, applicationId, gpdIdUnion[8], endpoint, gpdfSecurityLevel, gpdfSecurityKeyType, autoCommissioning, bidirectionalInfo, gpdSecurityFrameCounter, gpdCommandId, mic, proxyTableIndex, gpdCommandPayloadThis matches the field order the zigbee-herdsman ember adapter uses for the same callback.
Verification
Captured live from a Home Assistant SkyConnect running EmberZNet 7.5.1 (EZSP v13) receiving an EnOcean PTM 215Z (Philips Hue Tap). With this change the frames parse correctly: source ID
0x0043EA9E, security level 2 (full frame counter + MIC), a frame counter that increments per press, and distinct GPD command IDs per button (0x10–0x12,0x22). One captured operational frame is added totests/test_ezsp_v13.pyas a regression test. Full test suite passes.Notes
EmberGpAddressstruct type, whose Python field order (gpdIeeeAddress, sourceId, applicationId, endpoint) does not match this wire layout either, so it likely needs the same treatment. Left out of this PR to keep the change minimal and limited to what was verified on hardware.packet_receivedas a GP Notification on endpoint 242 / cluster 0x0021) is a separate change that depends on zigpy's in-progress Green Power runtime (zgp: add the Green Power manager, device, and proxy runtime zigpy#1848).