Skip to content
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 XNCP parsing for hacked LIDL gateway #657

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

puddly
Copy link
Contributor

@puddly puddly commented Dec 5, 2024

Fixes the issue reported in #656

Copy link

codecov bot commented Dec 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.20%. Comparing base (5dd3447) to head (504fe2d).
Report is 1 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #657   +/-   ##
=======================================
  Coverage   99.20%   99.20%           
=======================================
  Files          51       51           
  Lines        3647     3649    +2     
=======================================
+ Hits         3618     3620    +2     
  Misses         29       29           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@puddly puddly merged commit a81bbd4 into zigpy:dev Dec 5, 2024
14 checks passed
@asiersan
Copy link

asiersan commented Dec 5, 2024

Upgrading the EZSP Version to 6.7.8.0 with this tutorial procedure:

https://zigbee.blakadder.com/Lidl_TYGWZ-01.html

solves the problem

@zeyus
Copy link

zeyus commented Dec 6, 2024

Upgrading the EZSP Version to 6.7.8.0 with this tutorial procedure:

https://zigbee.blakadder.com/Lidl_TYGWZ-01.html

solves the problem

Oh interesting. I thought I had already upgraded the firmware, but I guess either I had not, or it was a previous version. I'm not sure where to check the current version on the device, but I'll try out the upgrade procedure anyway :) thanks!

@zeyus
Copy link

zeyus commented Dec 6, 2024

Upgrading the EZSP Version to 6.7.8.0 with this tutorial procedure:

https://zigbee.blakadder.com/Lidl_TYGWZ-01.html

solves the problem

@asiersan It turns out:

  1. I had upgraded the firmware before, but it wasn't that (latest?) version (see the logs below, EZSP protocol is now version 8 instead of 7)
  2. The upgraded firmware may still throw an exception without this PR, because at some point it sent an invalid reply (although, maybe these ones EmberStatus.INVALID_CALL and EzspStatus.ERROR_INVALID_ID were already handled correctly) because I can see the gateway gives a different reply now to 0x000000 -> 0x018001G0x00p0x00 instead of the previous 0x000103

Regardless, I appreciate the effort @puddly, and hopefully it prevents someone else suddenly losing all their zigbee devices.

, model=None, manufacturer=None, version='6.7.8.0 build 373'))
2024-12-06 10:04:17.222 DEBUG (MainThread) [zigpy.serial] Opening a serial connection to 'socket://192.168.2.207:8888' (baudrate=115200, xonxoff=True, rtscts=False)
2024-12-06 10:04:17.233 DEBUG (MainThread) [zigpy.serial] Connection made: <bellows.ash.AshProtocol object at 0x7f4a2e9e3df0>
2024-12-06 10:04:18.235 DEBUG (MainThread) [bellows.ezsp] Resetting EZSP
2024-12-06 10:04:18.235 DEBUG (MainThread) [bellows.uart] Resetting ASH
2024-12-06 10:04:18.235 DEBUG (MainThread) [bellows.ash] Sending frame CANCEL + RstFrame() + FLAG
2024-12-06 10:04:18.235 DEBUG (MainThread) [bellows.ash] Sending data  1ac038bc7e
2024-12-06 10:04:19.314 DEBUG (MainThread) [bellows.ash] Received data 1ac1020b0a527e
2024-12-06 10:04:19.315 DEBUG (MainThread) [bellows.ash] Received cancel byte, clearing buffer
2024-12-06 10:04:19.315 DEBUG (MainThread) [bellows.ash] Received frame RStackFrame(version=2, reset_code=<NcpResetCode.RESET_SOFTWARE: 11>)
2024-12-06 10:04:19.315 DEBUG (MainThread) [bellows.ezsp] Switching to EZSP protocol version 4
2024-12-06 10:04:19.315 DEBUG (MainThread) [bellows.ezsp.protocol] Sending command  version: () {'desiredProtocolVersion': 4}
2024-12-06 10:04:19.315 DEBUG (MainThread) [bellows.ash] Sending frame DataFrame(frm_num=0, re_tx=False, ack_num=0, ezsp_frame=b'\x00\x00\x00\x04') + FLAG
2024-12-06 10:04:19.315 DEBUG (MainThread) [bellows.ash] Sending data  004221a850ed2c7e
2024-12-06 10:04:19.320 DEBUG (MainThread) [bellows.ash] Received data 0142a1a85c2895d5
2024-12-06 10:04:19.321 DEBUG (MainThread) [bellows.ash] Received data 2e8b7e
2024-12-06 10:04:19.321 DEBUG (MainThread) [bellows.ash] Received frame DataFrame(frm_num=0, re_tx=0, ack_num=1, ezsp_frame=b'\x00\x80\x00\x08\x02\x80g')
2024-12-06 10:04:19.321 DEBUG (MainThread) [bellows.ash] Sending frame AckFrame(res=0, ncp_ready=0, ack_num=1) + FLAG
2024-12-06 10:04:19.321 DEBUG (MainThread) [bellows.ash] Sending data  8160597e
2024-12-06 10:04:19.322 DEBUG (MainThread) [bellows.ezsp.protocol] Received command version: {'protocolVersion': 8, 'stackType': 2, 'stackVersion': 26496}
2024-12-06 10:04:19.322 DEBUG (MainThread) [bellows.ash] Changing ACK timeout from 1.60 to 1.40
2024-12-06 10:04:19.322 DEBUG (MainThread) [bellows.ezsp] Switching to EZSP protocol version 8
2024-12-06 10:04:19.322 DEBUG (MainThread) [bellows.ezsp.protocol] Sending command  version: () {'desiredProtocolVersion': 8}
2024-12-06 10:04:19.322 DEBUG (MainThread) [bellows.ash] Sending frame DataFrame(frm_num=1, re_tx=False, ack_num=1, ezsp_frame=b'\x00\x00\x01\x00\x00\x08') + FLAG
2024-12-06 10:04:19.323 DEBUG (MainThread) [bellows.ash] Sending data  7d314221a9542a1d8cdf7e
2024-12-06 10:04:19.328 DEBUG (MainThread) [bellows.ash] Received data 1242a1a9542a1db0
2024-12-06 10:04:19.329 DEBUG (MainThread) [bellows.ash] Received data d9f389507e
2024-12-06 10:04:19.329 DEBUG (MainThread) [bellows.ash] Received frame DataFrame(frm_num=1, re_tx=0, ack_num=2, ezsp_frame=b'\x00\x80\x01\x00\x00\x08\x02\x80g')
2024-12-06 10:04:19.329 DEBUG (MainThread) [bellows.ash] Sending frame AckFrame(res=0, ncp_ready=0, ack_num=2) + FLAG
2024-12-06 10:04:19.329 DEBUG (MainThread) [bellows.ash] Sending data  82503a7e
2024-12-06 10:04:19.329 DEBUG (MainThread) [bellows.ezsp.protocol] Received command version: {'protocolVersion': 8, 'stackType': 2, 'stackVersion': 26496}
2024-12-06 10:04:19.329 DEBUG (MainThread) [bellows.ash] Changing ACK timeout from 1.40 to 1.23
2024-12-06 10:04:19.329 DEBUG (MainThread) [bellows.ezsp] EZSP Stack Type: 2, Stack Version: 6780, Protocol version: 8
2024-12-06 10:04:19.329 DEBUG (MainThread) [bellows.ezsp] Sending XNCP frame: XncpCommand(command_id=<XncpCommandId.GET_SUPPORTED_FEATURES_REQ: 0>, status=<EmberStatus.SUCCESS: 0>, payload=GetSupportedFeaturesReq())
2024-12-06 10:04:19.330 DEBUG (MainThread) [bellows.ezsp.protocol] Sending command  customFrame: (b'\x00\x00\x00',) {}
2024-12-06 10:04:19.330 DEBUG (MainThread) [bellows.ash] Sending frame DataFrame(frm_num=2, re_tx=False, ack_num=2, ezsp_frame=b'\x01\x00\x01G\x00\x03\x00\x00\x00') + FLAG
2024-12-06 10:04:19.330 DEBUG (MainThread) [bellows.ash] Sending data  224321a97d332a16b25994e79e7e
2024-12-06 10:04:19.335 DEBUG (MainThread) [bellows.ash] Received data 2343a1a97d332a65
2024-12-06 10:04:19.377 DEBUG (MainThread) [bellows.ash] Received data b27d33e77e
2024-12-06 10:04:19.377 DEBUG (MainThread) [bellows.ash] Received frame DataFrame(frm_num=2, re_tx=0, ack_num=3, ezsp_frame=b'\x01\x80\x01G\x00p\x00')
2024-12-06 10:04:19.377 DEBUG (MainThread) [bellows.ash] Sending frame AckFrame(res=0, ncp_ready=0, ack_num=3) + FLAG
2024-12-06 10:04:19.377 DEBUG (MainThread) [bellows.ash] Sending data  83401b7e
2024-12-06 10:04:19.378 DEBUG (MainThread) [bellows.ezsp.protocol] Received command customFrame: {'status': <EmberStatus.INVALID_CALL: 112>, 'reply': b''}
2024-12-06 10:04:19.378 DEBUG (MainThread) [bellows.ash] Changing ACK timeout from 1.23 to 1.10
2024-12-06 10:04:19.378 DEBUG (MainThread) [bellows.ezsp] XNCP features: 0
2024-12-06 10:04:19.378 DEBUG (MainThread) [bellows.ezsp.protocol] Sending command  getValue: () {'valueId': <EzspValueId.VALUE_FORCE_TX_AFTER_FAILED_CCA_ATTEMPTS: 58>}
2024-12-06 10:04:19.378 DEBUG (MainThread) [bellows.ash] Sending frame DataFrame(frm_num=3, re_tx=False, ack_num=3, ezsp_frame=b'\x02\x00\x01\xaa\x00:') + FLAG
2024-12-06 10:04:19.378 DEBUG (MainThread) [bellows.ash] Sending data  334021a9fe2a2f65c67e
2024-12-06 10:04:19.383 DEBUG (MainThread) [bellows.ash] Received data 3440a1a9fe2a22b2
2024-12-06 10:04:19.384 DEBUG (MainThread) [bellows.ash] Received data 7d38fe7e
2024-12-06 10:04:19.384 DEBUG (MainThread) [bellows.ash] Received frame DataFrame(frm_num=3, re_tx=0, ack_num=4, ezsp_frame=b'\x02\x80\x01\xaa\x007\x00')
2024-12-06 10:04:19.385 DEBUG (MainThread) [bellows.ash] Sending frame AckFrame(res=0, ncp_ready=0, ack_num=4) + FLAG
2024-12-06 10:04:19.385 DEBUG (MainThread) [bellows.ash] Sending data  8430fc7e
2024-12-06 10:04:19.385 DEBUG (MainThread) [bellows.ezsp.protocol] Received command getValue: {'status': <EzspStatus.ERROR_INVALID_ID: 55>, 'value': b''}
2024-12-06 10:04:19.385 DEBUG (MainThread) [bellows.ash] Changing ACK timeout from 1.10 to 0.97
2024-12-06 10:04:19.385 DEBUG (MainThread) [bellows.ezsp] Setting value VALUE_FORCE_TX_AFTER_FAILED_CCA_ATTEMPTS = 1 (old value None)
2024-12-06 10:04:19.385 DEBUG (MainThread) [bellows.ezsp.protocol] Sending command  setValue: () {'valueId': <EzspValueId.VALUE_FORCE_TX_AFTER_FAILED_CCA_ATTEMPTS: 58>, 'value': b'\x01'}
2024-12-06 10:04:19.385 DEBUG (MainThread) [bellows.ash] Sending frame DataFrame(frm_num=4, re_tx=False, ack_num=4, ezsp_frame=b'\x03\x00\x01\xab\x00:\x01\x01') + FLAG
2024-12-06 10:04:19.385 DEBUG (MainThread) [bellows.ash] Sending data  444121a9ff2a2fb3582a047e
2024-12-06 10:04:19.390 DEBUG (MainThread) [bellows.ash] Received data 4541a1a9ff2a1587
2024-12-06 10:04:19.391 DEBUG (MainThread) [bellows.ash] Received data db7e
2024-12-06 10:04:19.392 DEBUG (MainThread) [bellows.ash] Received frame DataFrame(frm_num=4, re_tx=0, ack_num=5, ezsp_frame=b'\x03\x80\x01\xab\x00\x00')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants