def __init__(self, application, ieee, nwk): self._application = application self._ieee = ieee self._initialize_task = None self.nwk = NWK(nwk) self.zdo = zdo.ZDO(self) self.endpoints: dict[int, zdo.ZDO | zigpy.endpoint.Endpoint] = { 0: self.zdo } self.lqi = None self.rssi = None self.last_seen = None self._initialize_task: Optional[asyncio.Task] = None self._group_scan_task: Optional[asyncio.Task] = None self._listeners = {} self._manufacturer = None self._model = None self.node_desc = None self.neighbors = zigpy.neighbor.Neighbors(self) self._pending = zigpy.util.Requests() self._relays = None self._skip_configuration = False # Retained for backwards compatibility, will be removed in a future release self.status = Status.NEW
def test_bind_req(): ''' zigpy_cc.zigbee.application DEBUG request ( 0xbd8b, 0, <ZDOCmd.Bind_req: 0x0021>, 0, 0, 1, b"\x01<x'\xfe\xffW\x0b\x00\x01\x08\x00\x03\x0c%\xed\x18\x00K\x12\x00\x01", True, False) zigpy_cc.api DEBUG waiting for 1 bindReq zigpy_cc.api DEBUG --> SREQ ZDO bindReq tsn: 1 { 'dstaddr': 0xbd8b, 'srcaddr': 00:0b:57:ff:fe:27:78:3c, 'srcendpoint': 1, 'clusterid': 8, 'dstaddrmode': 3, 'dstaddress': 00:12:4b:00:18:ed:25:0c, 'dstendpoint': 1} zigpy_cc.uart DEBUG Send: b"\xfe\x17%!\x8b\xbd<x'\xfe\xffW\x0b\x00\x01\x08\x00\x03\x0c%\xed\x18\x00K\x12\x00\x01\x95" ''' data = b"\x02<x'\xfe\xffW\x0b\x00\x01\x08\x00\x03\x0c%\xed\x18\x00K\x12\x00\x01" obj = ZpiObject.from_cluster( NWK(0x6292), 0, 0x0021, 0, 0, 2, data, 123 ) assert ( "SREQ ZDO bindReq tsn: 2 {" "'dstaddr': 0x6292, " "'srcaddr': 00:0b:57:ff:fe:27:78:3c, " "'srcendpoint': 1, " "'clusterid': 8, " "'dstaddrmode': 3, " "'dstaddress': 00:12:4b:00:18:ed:25:0c, " "'dstendpoint': 1}" == str(obj) ) assert ( bytes( [254, 23, 37, 33, 146, 98, 60, 120, 39, 254, 255, 87, 11, 0, 1, 8, 0, 3, 12, 37, 237, 24, 0, 75, 18, 0, 1, 83]) == obj.to_unpi_frame().to_buffer() )
def test_bind_req_serialize(): payload = {"dstaddr": NWK(25234), "srcaddr": EUI64(reversed(b'\x00\x0b\x57\xff\xfe\x27\x78\x3c')), "srcendpoint": 1, "clusterid": 8, "dstaddrmode": 3, "dstaddress": EUI64(reversed(b'\x00\x12\x4b\x00\x18\xed\x25\x0c')), "dstendpoint": 1} obj = ZpiObject.from_command(t.Subsystem.ZDO, 'bindReq', payload) assert ( "SREQ ZDO bindReq tsn: None {" "'dstaddr': 0x6292, " "'srcaddr': 00:0b:57:ff:fe:27:78:3c, " "'srcendpoint': 1, " "'clusterid': 8, " "'dstaddrmode': 3, " "'dstaddress': 00:12:4b:00:18:ed:25:0c, " "'dstendpoint': 1}" == str(obj) ) assert ( bytes( [254, 23, 37, 33, 146, 98, 60, 120, 39, 254, 255, 87, 11, 0, 1, 8, 0, 3, 12, 37, 237, 24, 0, 75, 18, 0, 1, 83]) == obj.to_unpi_frame().to_buffer() )
def test_list_nighbor_lqi(): value = [ { "extPanId": EUI64.convert("d8:dd:dd:dd:d0:dd:ed:dd"), "extAddr": EUI64.convert("00:15:8d:00:04:21:dc:b3"), "nwkAddr": NWK(0xE961), "deviceType": 1, "rxOnWhenIdle": 2, "relationship": 2, "permitJoin": 2, "depth": 255, "lqi": 69, } ] data_out = Buffalo(b"") data_out.write_parameter(t.ParameterType.LIST_NEIGHBOR_LQI, value, {}) assert ( b"\xdd\xed\xdd\xd0\xdd\xdd\xdd\xd8\xb3\xdc!\x04\x00\x8d\x15\x00a\xe9)\x02\xffE" == data_out.buffer ) data_in = Buffalo(data_out.buffer) options = BuffaloOptions() options.length = len(value) act = data_in.read_parameter("test", t.ParameterType.LIST_NEIGHBOR_LQI, options) assert value == act
def test_from_cluster_id(): profile = 0 obj = ZpiObject.from_cluster(NWK(53322), profile, ZDOCmd.Node_Desc_req, 0, 0, 0, b"\x03\x4a\xd0", 32) assert ( "SREQ ZDO nodeDescReq tsn: 0 {'dstaddr': 0xd04a, 'nwkaddrofinterest': 0xd04a}" == str(obj))
def test_from_cluster_id_ZCL(): profile = 260 obj = ZpiObject.from_cluster(NWK(53322), profile, 0, 1, 1, 1, b"\x00\x0b\x00\x04\x00\x05\x00", 123) assert ( "SREQ AF dataRequest tsn: 1 {'dstaddr': 53322, 'destendpoint': 1, " "'srcendpoint': 1, 'clusterid': 0, 'transid': 123, 'options': 0, 'radius': 30, " "'len': 7, 'data': b'\\x00\\x0b\\x00\\x04\\x00\\x05\\x00'}" == str(obj) )
def deserialize(cls, data: bytes): """Deserialize data.""" mode, data = AddrMode.deserialize(data) if mode in (AddrMode.NWK, AddrMode.Group, AddrMode.Broadcast): # a value of 2 indicates 2-byte (16-bit) address mode, # using only the 2 LSB’s of the DstAddr field to form # a 2-byte short address. addr64, data = basic.uint64_t.deserialize(data) addr = NWK(addr64 & 0xFFFF) elif mode == AddrMode.IEEE: addr, data = EUI64.deserialize(data) else: raise ValueError(f"Unknown address mode: {mode}") return cls(mode=mode, address=addr), data
def __init__(self, application, ieee, nwk): self._application = application self._ieee = ieee self._init_handle = None self.nwk = NWK(nwk) self.zdo = zdo.ZDO(self) self.endpoints = {0: self.zdo} self.lqi = None self.rssi = None self.last_seen = None self.status = Status.NEW self.initializing = False self._manufacturer = None self._model = None self.node_desc = zdo.types.NodeDescriptor() self._node_handle = None
def __init__(self, application, ieee, nwk): self._application = application self._ieee = ieee self._init_handle = None self.nwk = NWK(nwk) self.zdo = zdo.ZDO(self) self.endpoints = {0: self.zdo} self.lqi = None self.rssi = None self.last_seen = None self.status = Status.NEW self.initializing = False self._listeners = {} self._manufacturer = None self._model = None self.node_desc = zdo.types.NodeDescriptor() self._node_handle = None self._pending = zigpy.util.Requests() self._relays = None self._skip_configuration = False
def __init__(self, application, ieee, nwk): self._application: ControllerApplication = application self._ieee: EUI64 = ieee self.nwk: NWK = NWK(nwk) self.zdo: zdo.ZDO = zdo.ZDO(self) self.endpoints: dict[int, zdo.ZDO | zigpy.endpoint.Endpoint] = {0: self.zdo} self.lqi: int | None = None self.rssi: int | None = None self._last_seen: datetime | None = None self._initialize_task: asyncio.Task | None = None self._group_scan_task: asyncio.Task | None = None self._listeners = {} self._manufacturer: str | None = None self._model: str | None = None self.node_desc: zdo.types.NodeDescriptor | None = None self.neighbors: zigpy.neighbor.Neighbors = zigpy.neighbor.Neighbors(self) self._pending: zigpy.util.Requests = zigpy.util.Requests() self._relays: Relays | None = None self._skip_configuration: bool = False # Retained for backwards compatibility, will be removed in a future release self.status = Status.NEW
def __init__(self, application, ieee, nwk): self._application = application self._ieee = ieee self._init_handle = None self.nwk = NWK(nwk) self.zdo = zdo.ZDO(self) self.endpoints: Dict[int, Union[zdo.ZDO, zigpy.endpoint.Endpoint]] = { 0: self.zdo } self.lqi = None self.rssi = None self.last_seen = None self.status = Status.NEW self._group_scan_handle: Optional[asyncio.Task] = None self._listeners = {} self._manufacturer = None self._model = None self.node_desc = zdo.types.NodeDescriptor() self.neighbors = zigpy.neighbor.Neighbors(self) self._node_handle = None self._pending = zigpy.util.Requests() self._relays = None self._skip_configuration = False