Skip to content

Commit 0fcd626

Browse files
authored
Merge pull request #135 from puddly/rc
0.10.1 Release
2 parents a78951d + cb47bde commit 0fcd626

File tree

3 files changed

+62
-22
lines changed

3 files changed

+62
-22
lines changed

zigpy_zigate/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
MAJOR_VERSION = 0
22
MINOR_VERSION = 10
3-
PATCH_VERSION = '0'
3+
PATCH_VERSION = '1'
44
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
55
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)

zigpy_zigate/types.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,52 @@ class Status(uint8_t, enum.Enum):
207207
# No free BTR entries left.
208208
NoFreeBTREntries = 0x8B
209209

210+
# A transmit request failed since the ASDU is too large and fragmentation is not
211+
# supported.
212+
AsduTooLong = 0xA0
213+
# A received fragmented frame could not be defragmented at the current time.
214+
DefragDeferred = 0xA1
215+
# A received fragmented frame could not be defragmented since the device does not
216+
# support fragmentation.
217+
DefragUnsupported = 0xA2
218+
# A parameter value was out of range.
219+
IllegalRequest = 0xA3
220+
# An APSME-UNBIND.request failed due to the requested binding link not existing in
221+
# the binding table.
222+
InvalidBinding = 0xA4
223+
# An APSME-REMOVE-GROUP.request has been issued with a group identifier that does
224+
# not appear in the group table.
225+
InvalidGroup = 0xA5
226+
# A parameter value was invalid or out of range.
227+
InvalidParameter = 0xA6
228+
# An APSDE-DATA.request requesting acknowledged transmission failed due to no
229+
# acknowledgement being received.
230+
NoAck = 0xA7
231+
# An APSDE-DATA.request with a destination addressing mode set to 0x00 failed due to
232+
# there being no devices bound to this device.
233+
NoBoundDevice = 0xA8
234+
# An APSDE-DATA.request with a destination addressing mode set to 0x03 failed due to
235+
# no corresponding short address found in the address map table.
236+
NoShortAddress = 0xA9
237+
# An APSDE-DATA.request with a destination addressing mode set to 0x00 failed due to
238+
# a binding table not being supported on the device.
239+
NotSupported = 0xAA
240+
# An ASDU was received that was secured using a link key.
241+
SecuredLinkKey = 0xAB
242+
# An ASDU was received that was secured using a network key.
243+
SecuredNwkKey = 0xAC
244+
# An APSDE-DATA.request requesting security has resulted in an error during the
245+
# corresponding security processing.
246+
SecurityFail = 0xAD
247+
# An APSME-BIND.request or APSME.ADDGROUP.request issued when the binding or group
248+
# tables, respectively, were full.
249+
TableFull = 0xAE
250+
# An ASDU was received without any security.
251+
Unsecured = 0xAF
252+
# An APSME-GET.request or APSMESET. request has been issued with an unknown
253+
# attribute identifier.
254+
UnsupportedAttribute = 0xB0
255+
210256
@classmethod
211257
def _missing_(cls, value):
212258
if not isinstance(value, int):

zigpy_zigate/zigbee/application.py

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import asyncio
24
import logging
35
from typing import Any, Dict, Optional
@@ -32,20 +34,21 @@ def __init__(self, config: Dict[str, Any]):
3234
self._pending = {}
3335
self._pending_join = []
3436

35-
self.version = ''
37+
self.version: str = ""
3638

3739
async def connect(self):
3840
api = await ZiGate.new(self._config[CONF_DEVICE], self)
3941
await api.set_raw_mode()
4042
await api.set_time()
4143
version, lqi = await api.version()
4244

43-
hex_version = f"{version[1]:x}"
44-
self.version = f"{hex_version[0]}.{hex_version[1:]}"
4545
self._api = api
4646

47+
major, minor = version.to_bytes(2, "big")
48+
self.version = f"{major:x}.{minor:x}"
49+
4750
if self.version < '3.21':
48-
LOGGER.warning('Old ZiGate firmware detected, you should upgrade to 3.21 or newer')
51+
LOGGER.error('Old ZiGate firmware detected, you should upgrade to 3.21 or newer')
4952

5053
async def disconnect(self):
5154
# TODO: how do you stop the network? Is it possible?
@@ -235,20 +238,6 @@ def _handle_frame_failure(self, message_tag, status):
235238
async def send_packet(self, packet):
236239
LOGGER.debug("Sending packet %r", packet)
237240

238-
if packet.dst.addr_mode == zigpy.types.AddrMode.IEEE:
239-
LOGGER.warning("IEEE addressing is not supported, falling back to NWK")
240-
241-
try:
242-
device = self.get_device_with_address(packet.dst)
243-
except (KeyError, ValueError):
244-
raise ValueError(f"Cannot find device with IEEE {packet.dst.address}")
245-
246-
packet = packet.replace(
247-
dst=zigpy.types.AddrModeAddress(
248-
addr_mode=zigpy.types.AddrMode.NWK, address=device.nwk
249-
)
250-
)
251-
252241
ack = (zigpy.types.TransmitOptions.ACK in packet.tx_options)
253242

254243
try:
@@ -265,11 +254,16 @@ async def send_packet(self, packet):
265254
except NoResponseError:
266255
raise zigpy.exceptions.DeliveryError("ZiGate did not respond to command")
267256

257+
self._pending[tsn] = asyncio.get_running_loop().create_future()
258+
268259
if status != t.Status.Success:
269260
self._pending.pop(tsn)
270-
raise zigpy.exceptions.DeliveryError(f"Failed to deliver packet: {status}", status=status)
271261

272-
self._pending[tsn] = asyncio.get_running_loop().create_future()
262+
# Firmwares 3.1d and below fail to send packets on every request
263+
if status == t.Status.InvalidParameter and self.version <= "3.1d":
264+
pass
265+
else:
266+
raise zigpy.exceptions.DeliveryError(f"Failed to send packet: {status}", status=status)
273267

274268
# disabled because of https://github.com/fairecasoimeme/ZiGate/issues/324
275269
# try:
@@ -300,7 +294,7 @@ def __init__(self, application, ieee, nwk):
300294
model = 'PiZiGate'
301295
elif c.is_zigate_din(port):
302296
model = 'ZiGate USB-DIN'
303-
self._model = '{} {}'.format(model, application.version)
297+
self._model = f'{model} {application.version}'
304298

305299
@property
306300
def manufacturer(self):

0 commit comments

Comments
 (0)