Skip to content

Commit fbcb89d

Browse files
authored
0.4.0 Release.
0.4.0 Release.
2 parents 6e09580 + ceae733 commit fbcb89d

File tree

4 files changed

+71
-20
lines changed

4 files changed

+71
-20
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Setup module for zigbpy-xbee"""
1+
"""Setup module for zigpy-xbee"""
22

33
from setuptools import find_packages, setup
44

tests/test_application.py

Lines changed: 65 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import pytest
55

66
from zigpy.exceptions import DeliveryError
7-
from zigpy.types import EUI64, uint16_t
8-
from zigpy.zdo.types import LogicalType
7+
from zigpy import types as t
8+
from zigpy.zdo.types import LogicalType, ZDOCmd
99

1010
from zigpy_xbee.api import ModemStatus, XBee
1111
from zigpy_xbee.zigbee import application
@@ -143,7 +143,7 @@ def test_rx_failed_deserialize(app, caplog):
143143
app._handle_reply = mock.MagicMock()
144144
app.handle_message = mock.MagicMock()
145145
nwk = 0x1234
146-
ieee, _ = EUI64.deserialize(b'\x01\x02\x03\x04\x05\x06\x07\x08')
146+
ieee, _ = t.EUI64.deserialize(b'\x01\x02\x03\x04\x05\x06\x07\x08')
147147
device = app.add_device(ieee, nwk)
148148
device.status = DeviceStatus.ENDPOINTS_INIT
149149
app.get_device = mock.MagicMock(return_value=device)
@@ -168,10 +168,10 @@ def test_rx_failed_deserialize(app, caplog):
168168

169169
@pytest.fixture
170170
def device(app):
171-
def _device(new=False, zdo_init=False, nwk=uint16_t(0x1234)):
171+
def _device(new=False, zdo_init=False, nwk=t.uint16_t(0x1234)):
172172
from zigpy.device import Device, Status as DeviceStatus
173173

174-
ieee, _ = EUI64.deserialize(b'\x08\x07\x06\x05\x04\x03\x02\x01')
174+
ieee, _ = t.EUI64.deserialize(b'\x08\x07\x06\x05\x04\x03\x02\x01')
175175
dev = Device(app, ieee, nwk)
176176
if new:
177177
dev.status = DeviceStatus.NEW
@@ -368,43 +368,43 @@ async def test_startup_ai(app):
368368
auto_form = True
369369
await _test_startup(app, 0x00, auto_form)
370370
assert app._nwk == 0x0000
371-
assert app._ieee == EUI64(range(1, 9))
371+
assert app._ieee == t.EUI64(range(1, 9))
372372
assert app.form_network.call_count == 0
373373

374374
auto_form = False
375375
await _test_startup(app, 0x00, auto_form)
376376
assert app._nwk == 0x0000
377-
assert app._ieee == EUI64(range(1, 9))
377+
assert app._ieee == t.EUI64(range(1, 9))
378378
assert app.form_network.call_count == 0
379379

380380
auto_form = True
381381
await _test_startup(app, 0x06, auto_form)
382382
assert app._nwk == 0xfffe
383-
assert app._ieee == EUI64(range(1, 9))
383+
assert app._ieee == t.EUI64(range(1, 9))
384384
assert app.form_network.call_count == 1
385385

386386
auto_form = False
387387
await _test_startup(app, 0x06, auto_form)
388388
assert app._nwk == 0xfffe
389-
assert app._ieee == EUI64(range(1, 9))
389+
assert app._ieee == t.EUI64(range(1, 9))
390390
assert app.form_network.call_count == 0
391391

392392
auto_form = True
393393
await _test_startup(app, 0x00, auto_form, zs=1)
394394
assert app._nwk == 0x0000
395-
assert app._ieee == EUI64(range(1, 9))
395+
assert app._ieee == t.EUI64(range(1, 9))
396396
assert app.form_network.call_count == 1
397397

398398
auto_form = False
399399
await _test_startup(app, 0x06, auto_form, legacy_module=True)
400400
assert app._nwk == 0xfffe
401-
assert app._ieee == EUI64(range(1, 9))
401+
assert app._ieee == t.EUI64(range(1, 9))
402402
assert app.form_network.call_count == 0
403403

404404
auto_form = True
405405
await _test_startup(app, 0x00, auto_form, zs=1, legacy_module=True)
406406
assert app._nwk == 0x0000
407-
assert app._ieee == EUI64(range(1, 9))
407+
assert app._ieee == t.EUI64(range(1, 9))
408408
assert app.form_network.call_count == 1
409409

410410

@@ -413,7 +413,7 @@ async def test_startup_no_api_mode(app):
413413
auto_form = True
414414
await _test_startup(app, 0x00, auto_form, api_mode=False)
415415
assert app._nwk == 0x0000
416-
assert app._ieee == EUI64(range(1, 9))
416+
assert app._ieee == t.EUI64(range(1, 9))
417417
assert app.form_network.call_count == 0
418418
assert app._api.init_api_mode.call_count == 1
419419
assert app._api._at_command.call_count >= 16
@@ -446,7 +446,7 @@ async def _test_request(app, do_reply=True, expect_reply=True,
446446
logical_type=None, **kwargs):
447447
seq = 123
448448
nwk = 0x2345
449-
ieee = EUI64(b'\x01\x02\x03\x04\x05\x06\x07\x08')
449+
ieee = t.EUI64(b'\x01\x02\x03\x04\x05\x06\x07\x08')
450450
dev = app.add_device(ieee, nwk)
451451
dev.node_desc = mock.MagicMock()
452452
dev.node_desc.logical_type = logical_type
@@ -591,3 +591,54 @@ def test_remote_at_cmd(app, device):
591591
assert app._api._remote_at_command.call_args[0][2] == 0x22
592592
assert app._api._remote_at_command.call_args[0][3] == s.cmd
593593
assert app._api._remote_at_command.call_args[0][4] == s.data
594+
595+
596+
@pytest.fixture
597+
def ieee():
598+
return t.EUI64.deserialize(b'\x00\x01\x02\x03\x04\x05\x06\x07')[0]
599+
600+
601+
@pytest.fixture
602+
def nwk():
603+
return t.uint16_t(0x0100)
604+
605+
606+
def test_rx_device_annce(app, ieee, nwk):
607+
dst_ep = 0
608+
cluster_id = ZDOCmd.Device_annce
609+
device = mock.MagicMock()
610+
device.status = device.Status.NEW
611+
app.get_device = mock.MagicMock(return_value=device)
612+
app.deserialize = mock.MagicMock(return_value=(mock.sentinel.tsn,
613+
mock.sentinel.cmd_id,
614+
False,
615+
mock.sentinel.args, ))
616+
app.handle_join = mock.MagicMock()
617+
app._handle_reply = mock.MagicMock()
618+
app.handle_message = mock.MagicMock()
619+
620+
data = t.uint8_t(0xaa).serialize()
621+
data += nwk.serialize()
622+
data += ieee.serialize()
623+
data += t.uint8_t(0x8e).serialize()
624+
625+
app.handle_rx(
626+
ieee,
627+
nwk,
628+
mock.sentinel.src_ep,
629+
dst_ep,
630+
cluster_id,
631+
mock.sentinel.profile_id,
632+
mock.sentinel.rx_opt,
633+
data,
634+
)
635+
636+
assert app.deserialize.call_count == 1
637+
assert app.deserialize.call_args[0][2] == cluster_id
638+
assert app.deserialize.call_args[0][3] == data
639+
assert app._handle_reply.call_count == 0
640+
assert app.handle_message.call_count == 1
641+
assert app.handle_join.call_count == 1
642+
assert app.handle_join.call_args[0][0] == nwk
643+
assert app.handle_join.call_args[0][1] == ieee
644+
assert app.handle_join.call_args[0][2] == 0

zigpy_xbee/__init__.py

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

zigpy_xbee/zigbee/application.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ def handle_rx(self, src_ieee, src_nwk, src_ep, dst_ep, cluster_id, profile_id, r
210210
ember_ieee = zigpy.types.EUI64(src_ieee)
211211
if dst_ep == 0 and cluster_id == 0x13:
212212
# ZDO Device announce request
213-
nwk, data = zigpy.types.uint16_t.deserialize(data[1:])
214-
ieee, data = zigpy.types.EUI64.deserialize(data)
213+
nwk, rest = zigpy.types.NWK.deserialize(data[1:])
214+
ieee, rest = zigpy.types.EUI64.deserialize(rest)
215215
LOGGER.info("New device joined: NWK 0x%04x, IEEE %s", nwk, ieee)
216216
if ember_ieee != ieee:
217217
LOGGER.warning(
@@ -312,11 +312,11 @@ def __init__(self, *args, **kwargs):
312312
0x00ff, 0x2c00, 0x00ff, 0x00)
313313

314314
replacement = {
315+
'manufacturer': 'Digi',
316+
'model': 'XBee',
315317
'endpoints': {
316318
XBEE_ENDPOINT_ID: {
317319
'device_type': 0x0050,
318-
'manufacturer': 'Digi',
319-
'model': 'XBee',
320320
'profile_id': 0xc105,
321321
'input_clusters': [XBeeGroup, XBeeGroupResponse],
322322
'output_clusters': [],

0 commit comments

Comments
 (0)