Ejemplo n.º 1
0
def test_handle_announce(zdo_f):
    dev = zdo_f._device
    zdo_f.listener_event = mock.MagicMock()
    dev._application.devices.pop(dev.ieee)
    aps = t.EmberApsFrame()
    zdo_f.handle_message(False, aps, 111, 0x0013, [0, dev.ieee, dev.nwk])
    assert zdo_f.listener_event.call_count == 1
Ejemplo n.º 2
0
async def _update_nwk_id(ezsp, nwk_update_id):
    """Update NWK id by sending a ZDO broadcast."""

    aps_frame = t.EmberApsFrame(
        profileId=0x0000,
        clusterId=zigpy.zdo.types.ZDOCmd.Mgmt_NWK_Update_req,
        sourceEndpoint=0x00,
        destinationEndpoint=0x00,
        options=t.EmberApsOption.APS_OPTION_NONE,
        groupId=0x0000,
        sequence=0xDE,
    )
    nwk_update_id = t.uint8_t(nwk_update_id).serialize()
    payload = b"\xDE" + zigpy.types.Channels.ALL_CHANNELS.serialize() + b"\xFF"
    payload += nwk_update_id + b"\x00\x00"

    status, _ = await ezsp.sendBroadcast(
        zigpy.types.BroadcastAddress.ALL_DEVICES,
        aps_frame,
        0x00,
        0x01,
        payload,
    )
    assert status == t.EmberStatus.SUCCESS
    await asyncio.sleep(1)
Ejemplo n.º 3
0
def aps():
    f = t.EmberApsFrame()
    f.profileId = 99
    f.sourceEndpoint = 8
    f.destinationEndpoint = 8
    f.sequence = 100
    return f
Ejemplo n.º 4
0
def test_handle_message_output(ep):
    c = ep.add_output_cluster(0)
    c.handle_message = mock.MagicMock()
    f = t.EmberApsFrame()
    f.clusterId = 0
    ep.handle_message(False, f, 0, 1, [])
    c.handle_message.assert_called_once_with(False, f, 0, 1, [])
Ejemplo n.º 5
0
def test_handle_request(ep):
    c = ep.add_cluster(0)
    c.handle_request = mock.MagicMock()
    f = t.EmberApsFrame()
    f.clusterId = 0
    ep.handle_request(f, 0, 1, [])
    c.handle_request.assert_called_once_with(f, 0, 1, [])
Ejemplo n.º 6
0
    async def broadcast(self, profile, cluster, src_ep, dst_ep, grpid, radius,
                        sequence, data,
                        broadcast_address=BroadcastAddress.RX_ON_WHEN_IDLE):
        if not self.is_controller_running:
            raise ControllerError("ApplicationController is not running")

        aps_frame = t.EmberApsFrame()
        aps_frame.profileId = t.uint16_t(profile)
        aps_frame.clusterId = t.uint16_t(cluster)
        aps_frame.sourceEndpoint = t.uint8_t(src_ep)
        aps_frame.destinationEndpoint = t.uint8_t(dst_ep)
        aps_frame.options = t.EmberApsOption(
            t.EmberApsOption.APS_OPTION_NONE
        )
        aps_frame.groupId = t.uint16_t(grpid)
        aps_frame.sequence = t.uint8_t(sequence)

        with self._pending.new(sequence) as req:
            async with self._in_flight_msg:
                res = await self._ezsp.sendBroadcast(broadcast_address,
                                                     aps_frame, radius,
                                                     sequence, data)
                if res[0] != t.EmberStatus.SUCCESS:
                    hdr, hdr_args = self._dst_pp(broadcast_address, aps_frame)
                    msg = hdr + "Broadcast failure: %s"
                    msg_args = (hdr_args + (res[0], ))
                    raise DeliveryError(msg % msg_args)

                # Wait for messageSentHandler message
                res = await asyncio.wait_for(req.send,
                                             timeout=APS_ACK_TIMEOUT)
        return res
Ejemplo n.º 7
0
    async def request(self, nwk, profile, cluster, src_ep, dst_ep, sequence, data, expect_reply=True,
                      timeout=APS_REPLY_TIMEOUT):
        if not self.is_controller_running:
            raise ControllerError("ApplicationController is not running")

        aps_frame = t.EmberApsFrame()
        aps_frame.profileId = t.uint16_t(profile)
        aps_frame.clusterId = t.uint16_t(cluster)
        aps_frame.sourceEndpoint = t.uint8_t(src_ep)
        aps_frame.destinationEndpoint = t.uint8_t(dst_ep)
        aps_frame.options = t.EmberApsOption(
            t.EmberApsOption.APS_OPTION_RETRY |
            t.EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY
        )
        aps_frame.groupId = t.uint16_t(0)
        aps_frame.sequence = t.uint8_t(sequence)

        with self._pending.new(sequence, expect_reply) as req:
            async with self._in_flight_msg:
                res = await self._ezsp.sendUnicast(self.direct, nwk, aps_frame,
                                                   sequence, data)
                if res[0] != t.EmberStatus.SUCCESS:
                    hdr, hdr_args = self._dst_pp(nwk, aps_frame)
                    msg = hdr + "message send failure: %s"
                    msg_args = (hdr_args + (res[0], ))
                    raise DeliveryError(msg % msg_args)

                res = await asyncio.wait_for(req.send, timeout=APS_ACK_TIMEOUT)

            if expect_reply:
                res = await asyncio.wait_for(req.reply, timeout)
        return res
Ejemplo n.º 8
0
def test_deserialize():
    frame = t.EmberApsFrame()
    frame.clusterId = 2
    tsn, command_id, is_reply, args = zdo.deserialize(frame, b'\x01\x02\x03xx')
    assert tsn == 1
    assert is_reply is False
    assert args == [0x0302]
Ejemplo n.º 9
0
    async def request(
        self,
        device,
        profile,
        cluster,
        src_ep,
        dst_ep,
        sequence,
        data,
        expect_reply=True,
        use_ieee=False,
    ):
        """Submit and send data out as an unicast transmission.

        :param device: destination device
        :param profile: Zigbee Profile ID to use for outgoing message
        :param cluster: cluster id where the message is being sent
        :param src_ep: source endpoint id
        :param dst_ep: destination endpoint id
        :param sequence: transaction sequence number of the message
        :param data: Zigbee message payload
        :param expect_reply: True if this is essentially a request
        :param use_ieee: use EUI64 for destination addressing
        :returns: return a tuple of a status and an error_message. Original requestor
                  has more context to provide a more meaningful error message
        """
        if not self.is_controller_running:
            raise ControllerError("ApplicationController is not running")

        aps_frame = t.EmberApsFrame()
        aps_frame.profileId = t.uint16_t(profile)
        aps_frame.clusterId = t.uint16_t(cluster)
        aps_frame.sourceEndpoint = t.uint8_t(src_ep)
        aps_frame.destinationEndpoint = t.uint8_t(dst_ep)
        aps_frame.options = t.EmberApsOption(
            t.EmberApsOption.APS_OPTION_RETRY
            | t.EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY)
        aps_frame.groupId = t.uint16_t(0)
        aps_frame.sequence = t.uint8_t(sequence)
        message_tag = self.get_sequence()

        if use_ieee:
            LOGGER.warning(("EUI64 addressing is not currently supported, "
                            "reverting to NWK"))
        if expect_reply and device.node_desc.is_end_device in (True, None):
            LOGGER.debug("Extending timeout for %s/0x%04x", device.ieee,
                         device.nwk)
            await self._ezsp.setExtendedTimeout(device.ieee, True)
        with self._pending.new(message_tag) as req:
            async with self._in_flight_msg:
                res = await self._ezsp.sendUnicast(self.direct, device.nwk,
                                                   aps_frame, message_tag,
                                                   data)
                if res[0] != t.EmberStatus.SUCCESS:
                    return res[0], "EZSP sendUnicast failure: %s" % (res[0], )

                res = await asyncio.wait_for(req.result, APS_ACK_TIMEOUT)
        return res
Ejemplo n.º 10
0
    async def broadcast(
        self,
        profile,
        cluster,
        src_ep,
        dst_ep,
        grpid,
        radius,
        sequence,
        data,
        broadcast_address=BroadcastAddress.RX_ON_WHEN_IDLE,
    ):
        """Submit and send data out as an unicast transmission.

        :param profile: Zigbee Profile ID to use for outgoing message
        :param cluster: cluster id where the message is being sent
        :param src_ep: source endpoint id
        :param dst_ep: destination endpoint id
        :param: grpid: group id to address the broadcast to
        :param radius: max radius of the broadcast
        :param sequence: transaction sequence number of the message
        :param data: zigbee message payload
        :param timeout: how long to wait for transmission ACK
        :param broadcast_address: broadcast address.
        :returns: return a tuple of a status and an error_message. Original requestor
                  has more context to provide a more meaningful error message
        """
        if not self.is_controller_running:
            raise ControllerError("ApplicationController is not running")

        aps_frame = t.EmberApsFrame()
        aps_frame.profileId = t.uint16_t(profile)
        aps_frame.clusterId = t.uint16_t(cluster)
        aps_frame.sourceEndpoint = t.uint8_t(src_ep)
        aps_frame.destinationEndpoint = t.uint8_t(dst_ep)
        aps_frame.options = t.EmberApsOption.APS_OPTION_NONE
        aps_frame.groupId = t.uint16_t(grpid)
        aps_frame.sequence = t.uint8_t(sequence)
        message_tag = self.get_sequence()

        with self._pending.new(message_tag) as req:
            async with self._in_flight_msg:
                async with self._req_lock:
                    res = await self._ezsp.sendBroadcast(
                        broadcast_address, aps_frame, radius, message_tag,
                        data)
                if res[0] != t.EmberStatus.SUCCESS:
                    return res[0], "broadcast send failure"

                # Wait for messageSentHandler message
                res = await asyncio.wait_for(req.result,
                                             timeout=APS_ACK_TIMEOUT)
        return res
Ejemplo n.º 11
0
    async def mrequest(
        self,
        group_id,
        profile,
        cluster,
        src_ep,
        sequence,
        data,
        *,
        hops=EZSP_DEFAULT_RADIUS,
        non_member_radius=EZSP_MULTICAST_NON_MEMBER_RADIUS
    ):
        """Submit and send data out as a multicast transmission.

        :param group_id: destination multicast address
        :param profile: Zigbee Profile ID to use for outgoing message
        :param cluster: cluster id where the message is being sent
        :param src_ep: source endpoint id
        :param sequence: transaction sequence number of the message
        :param data: Zigbee message payload
        :param hops: the message will be delivered to all nodes within this number of
                     hops of the sender. A value of zero is converted to MAX_HOPS
        :param non_member_radius: the number of hops that the message will be forwarded
                                  by devices that are not members of the group. A value
                                  of 7 or greater is treated as infinite
        :returns: return a tuple of a status and an error_message. Original requestor
                  has more context to provide a more meaningful error message
        """
        if not self.is_controller_running:
            raise ControllerError("ApplicationController is not running")

        aps_frame = t.EmberApsFrame()
        aps_frame.profileId = t.uint16_t(profile)
        aps_frame.clusterId = t.uint16_t(cluster)
        aps_frame.sourceEndpoint = t.uint8_t(src_ep)
        aps_frame.destinationEndpoint = t.uint8_t(src_ep)
        aps_frame.options = t.EmberApsOption(
            t.EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY
        )
        aps_frame.groupId = t.uint16_t(group_id)
        aps_frame.sequence = t.uint8_t(sequence)
        message_tag = self.get_sequence()

        with self._pending.new(message_tag) as req:
            async with self._in_flight_msg:
                res = await self._ezsp.sendMulticast(
                    aps_frame, hops, non_member_radius, message_tag, data
                )
                if res[0] != t.EmberStatus.SUCCESS:
                    return res[0], "EZSP sendMulticast failure: %s" % (res[0],)

                res = await asyncio.wait_for(req.result, APS_ACK_TIMEOUT)
        return res
Ejemplo n.º 12
0
 def get_aps(self, profile, cluster, endpoint):
     f = t.EmberApsFrame()
     f.profileId = t.uint16_t(profile)
     f.clusterId = t.uint16_t(cluster)
     f.sourceEndpoint = t.uint8_t(endpoint)
     f.destinationEndpoint = t.uint8_t(endpoint)
     f.options = t.EmberApsOption(
         t.EmberApsOption.APS_OPTION_RETRY
         | t.EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY)
     f.groupId = t.uint16_t(0)
     f.sequence = t.uint8_t(self._application.get_sequence())
     return f
Ejemplo n.º 13
0
    async def request(self,
                      nwk,
                      profile,
                      cluster,
                      src_ep,
                      dst_ep,
                      sequence,
                      data,
                      expect_reply=True,
                      timeout=10):
        assert sequence not in self._pending
        send_fut = asyncio.Future()
        reply_fut = None
        if expect_reply:
            reply_fut = asyncio.Future()
        self._pending[sequence] = (send_fut, reply_fut)

        aps_frame = t.EmberApsFrame()
        aps_frame.profileId = t.uint16_t(profile)
        aps_frame.clusterId = t.uint16_t(cluster)
        aps_frame.sourceEndpoint = t.uint8_t(src_ep)
        aps_frame.destinationEndpoint = t.uint8_t(dst_ep)
        aps_frame.options = t.EmberApsOption(
            t.EmberApsOption.APS_OPTION_RETRY
            | t.EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY)
        aps_frame.groupId = t.uint16_t(0)
        aps_frame.sequence = t.uint8_t(sequence)

        v = await self._ezsp.sendUnicast(self.direct, nwk, aps_frame, sequence,
                                         data)
        if v[0] != t.EmberStatus.SUCCESS:
            self._pending.pop(sequence)
            send_fut.cancel()
            if expect_reply:
                reply_fut.cancel()
            raise DeliveryError("Message send failure %s" % (v[0], ))

        # Wait for messageSentHandler message
        v = await send_fut
        if expect_reply:
            # Wait for reply
            try:
                v = await asyncio.wait_for(reply_fut, timeout)
            except:  # noqa: E722
                # If we timeout (or fail for any reason), clear the future
                self._pending.pop(sequence)
                raise
        return v
Ejemplo n.º 14
0
    async def request(self,
                      nwk,
                      profile,
                      cluster,
                      src_ep,
                      dst_ep,
                      sequence,
                      data,
                      expect_reply=True,
                      timeout=10):
        assert sequence not in self._pending
        send_fut = asyncio.Future()
        reply_fut = None
        if expect_reply:
            reply_fut = asyncio.Future()
        self._pending[sequence] = (send_fut, reply_fut)

        aps_frame = t.EmberApsFrame()
        aps_frame.profileId = t.uint16_t(profile)
        aps_frame.clusterId = t.uint16_t(cluster)
        aps_frame.sourceEndpoint = t.uint8_t(src_ep)
        aps_frame.destinationEndpoint = t.uint8_t(dst_ep)
        aps_frame.options = t.EmberApsOption(
            t.EmberApsOption.APS_OPTION_RETRY
            | t.EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY)
        aps_frame.groupId = t.uint16_t(0)
        aps_frame.sequence = t.uint8_t(sequence)

        v = await self._ezsp.sendUnicast(self.direct, nwk, aps_frame, sequence,
                                         data)
        if v[0] != t.EmberStatus.SUCCESS:
            self._pending.pop(sequence)
            send_fut.cancel()
            if expect_reply:
                reply_fut.cancel()
            raise DeliveryError("Message send failure _send_unicast_fail %s" %
                                (v[0], ))
        try:
            v = await send_fut
        except DeliveryError as e:
            LOGGER.debug("DeliveryError: %s", e)
            raise
        except Exception as e:
            LOGGER.debug("other Exception: %s", e)
        if expect_reply:
            v = await asyncio.wait_for(reply_fut, timeout)
        return v
Ejemplo n.º 15
0
 async def send_zdo_broadcast(self, command, grpid, radius, args):
     """ create aps_frame for zdo broadcast"""
     aps_frame = t.EmberApsFrame()
     aps_frame.profileId = t.uint16_t(0x0000)  # 0 for zdo
     aps_frame.clusterId = t.uint16_t(command)
     aps_frame.sourceEndpoint = t.uint8_t(0)  # endpoint 0x00 for zdo
     aps_frame.destinationEndpoint = t.uint8_t(0)  # endpoint 0x00 for zdo
     aps_frame.options = t.EmberApsOption(t.EmberApsOption.APS_OPTION_NONE)
     aps_frame.groupId = t.uint16_t(grpid)
     aps_frame.sequence = t.uint8_t(self.get_sequence())
     radius = t.uint8_t(radius)
     data = aps_frame.sequence.to_bytes(1, 'little')
     schema = zigpy.zdo.types.CLUSTERS[command][2]
     data += t.serialize(args, schema)
     LOGGER.debug("zdo-broadcast: %s - %s", aps_frame, data)
     await self._ezsp.sendBroadcast(0xfffd, aps_frame, radius, len(data),
                                    data)
Ejemplo n.º 16
0
    async def request(
        self,
        device,
        profile,
        cluster,
        src_ep,
        dst_ep,
        sequence,
        data,
        expect_reply=True,
        use_ieee=False,
    ):
        """Submit and send data out as an unicast transmission.

        :param device: destination device
        :param profile: Zigbee Profile ID to use for outgoing message
        :param cluster: cluster id where the message is being sent
        :param src_ep: source endpoint id
        :param dst_ep: destination endpoint id
        :param sequence: transaction sequence number of the message
        :param data: Zigbee message payload
        :param expect_reply: True if this is essentially a request
        :param use_ieee: use EUI64 for destination addressing
        :returns: return a tuple of a status and an error_message. Original requestor
                  has more context to provide a more meaningful error message
        """
        if not self.is_controller_running:
            raise ControllerError("ApplicationController is not running")

        aps_frame = t.EmberApsFrame()
        aps_frame.profileId = t.uint16_t(profile)
        aps_frame.clusterId = t.uint16_t(cluster)
        aps_frame.sourceEndpoint = t.uint8_t(src_ep)
        aps_frame.destinationEndpoint = t.uint8_t(dst_ep)
        aps_frame.options = self._tx_options
        aps_frame.groupId = t.uint16_t(0)
        aps_frame.sequence = t.uint8_t(sequence)
        message_tag = self.get_sequence()

        if use_ieee:
            LOGGER.warning(("EUI64 addressing is not currently supported, "
                            "reverting to NWK"))
        with self._pending.new(message_tag) as req:
            async with self._in_flight_msg:
                delays = [0.5, 1.0, 1.5]
                while True:
                    async with self._req_lock:
                        if expect_reply and device.node_desc.is_end_device in (
                                True,
                                None,
                        ):
                            LOGGER.debug(
                                "Extending timeout for %s/0x%04x",
                                device.ieee,
                                device.nwk,
                            )
                            await self._ezsp.setExtendedTimeout(
                                device.ieee, True)
                        if self.use_source_routing and self._ezsp.ezsp_version < 8:
                            (res, ) = await self._ezsp.set_source_route(device)
                            if res == t.EmberStatus.SUCCESS:
                                aps_frame.options ^= (
                                    t.EmberApsOption.
                                    APS_OPTION_ENABLE_ROUTE_DISCOVERY)
                                LOGGER.debug(
                                    "Set source route for %s to %s: %s",
                                    device.nwk,
                                    device.relays,
                                    res,
                                )
                            else:
                                LOGGER.debug(
                                    "using route discovery for %s device",
                                    device.nwk,
                                )

                        status, _ = await self._ezsp.sendUnicast(
                            self.direct, device.nwk, aps_frame, message_tag,
                            data)
                    if not (status == t.EmberStatus.MAX_MESSAGE_LIMIT_REACHED
                            and delays):
                        # retry only on MAX_MESSAGE_LIMIT_REACHED if tries are left
                        break

                    delay = delays.pop(0)
                    LOGGER.debug("retrying request %s tag in %ss", message_tag,
                                 delay)
                    await asyncio.sleep(delay)

                if status != t.EmberStatus.SUCCESS:
                    return status, f"EZSP sendUnicast failure: {str(status)}"

                res = await asyncio.wait_for(req.result, APS_ACK_TIMEOUT)
        return res
Ejemplo n.º 17
0
def test_handle_request_unknown(ep):
    f = t.EmberApsFrame()
    f.clusterId = 99
    ep.handle_request(f, 0, 0, [])
Ejemplo n.º 18
0
def test_handle_request_unknown(ep):
    f = t.EmberApsFrame()
    f.clusterId = 99
    ep.handle_message(False, f, 0, 0, [])
Ejemplo n.º 19
0
def test_handle_permit_join(zdo_f):
    aps = t.EmberApsFrame()
    zdo_f.listener_event = mock.MagicMock()
    zdo_f.handle_message(False, aps, 111, 0x0036, [100, 1])
    assert zdo_f.listener_event.call_count == 1
Ejemplo n.º 20
0
def aps():
    f = t.EmberApsFrame()
    f.sequence = 100
    return f
Ejemplo n.º 21
0
def aps():
    return t.EmberApsFrame()
Ejemplo n.º 22
0
def test_handle_addr(zdo_f):
    aps = t.EmberApsFrame()
    nwk = zdo_f._device.application.nwk
    zdo_f.reply = mock.MagicMock()
    zdo_f.handle_message(False, aps, 234, 0x0001, [nwk])
    assert zdo_f.reply.call_count == 1
Ejemplo n.º 23
0
    async def request(self, nwk, profile, cluster, src_ep, dst_ep, sequence,
            data, expect_reply=True, timeout=15):
#        LOGGER.debug("pending message queue length: %s", len(self._pending))
        assert sequence not in self._pending
        send_fut = asyncio.Future()
        reply_fut = None
        if expect_reply:
            reply_fut = asyncio.Future()
        self._pending[sequence] = (send_fut, reply_fut)

        aps_frame = t.EmberApsFrame()
        aps_frame.profileId = t.uint16_t(profile)
        aps_frame.clusterId = t.uint16_t(cluster)
        aps_frame.sourceEndpoint = t.uint8_t(src_ep)
        aps_frame.destinationEndpoint = t.uint8_t(dst_ep)
        aps_frame.options = t.EmberApsOption(
            t.EmberApsOption.APS_OPTION_RETRY |
            t.EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY
        )
        aps_frame.groupId = t.uint16_t(0)
        aps_frame.sequence = t.uint8_t(sequence)
        LOGGER.debug(
            "sendUnicast to NWKID:0x%04x DST_EP:%s PROFIL_ID:%s CLUSTER:0x%04x TSN:%s, Timeout:%s",
            nwk, dst_ep, profile,  cluster, sequence, timeout,
            )
        try:
            v = await asyncio.wait_for(self._ezsp.sendUnicast(self.direct,
                nwk, aps_frame, sequence, data), timeout)
        except asyncio.TimeoutError:
            LOGGER.debug(
                "sendunicast uart timeout NWKID:0x%04x DST_EP:%s PROFIL_ID:%s CLUSTER:0x%04x TSN:%s, Timeout:%s",
                nwk, dst_ep, profile,  cluster, sequence, timeout,
            )
            self._pending.pop(sequence)
            send_fut.cancel()
            if expect_reply:
                reply_fut.cancel()
            raise DeliveryError("Message send failure uart timeout")
        if v[0] != t.EmberStatus.SUCCESS:
            self._pending.pop(sequence)
            send_fut.cancel()
            if expect_reply:
                reply_fut.cancel()
            LOGGER.debug("sendunicast send failure NWKID:0x%04x DST_EP:%s PROFIL_ID:%s CLUSTER:0x%04x TSN:%s, Timeout:%s",
                    nwk, dst_ep, profile,  cluster, sequence, timeout,
            )
            raise DeliveryError("Message send failure _send_unicast_fail")
        try:
            v = await asyncio.wait_for(send_fut, timeout)
        except DeliveryError as e:
            LOGGER.debug("0x%04x:%s:0x%04x sendunicast send_ACK failure - Error:%s", nwk, dst_ep, cluster, e)
            raise
        except asyncio.TimeoutError:
            LOGGER.debug("sendunicast message send_ACK timeout NWKID:0x%04x DST_EP:%s PROFIL_ID:%s CLUSTER:0x%04x TSN:%s, Timeout:%s",
                    nwk, dst_ep, profile,  cluster, sequence, timeout,
            )
            
            self._pending.pop(sequence)
            if expect_reply:
                reply_fut.cancel()
            raise DeliveryError("ACK_TIMEOUT")
 #       if v != t.EmberStatus.SUCCESS:
 #           self._pending.pop(sequence)
 #           if expect_reply:
 #               reply_fut.cancel()
 #           LOGGER.debug("sendunicast send_ACK failure 0x%04x:%s:0x%04x = %s", nwk, dst_ep, cluster, v)
 #           raise DeliveryError("sendunicast send_ACK failure")
        if expect_reply:
            try:
                v = await asyncio.wait_for(reply_fut, timeout)
            except asyncio.TimeoutError:
                LOGGER.debug(
                        "[0x%04x:%s:0x%04x] sendunicast reply(TSN:%s) timeout failure",
                        nwk, dst_ep, cluster, sequence)
                self._pending.pop(sequence)
                raise DeliveryError("sendunicast reply timeout error")
            return v
Ejemplo n.º 24
0
def test_handle_unsupported(zdo_f):
    aps = t.EmberApsFrame()
    zdo_f.handle_message(False, aps, 321, 0xffff, [])
Ejemplo n.º 25
0
def test_handle_announce(zdo_f):
    dev = zdo_f._device
    dev._application.devices.pop(dev._ieee)
    aps = t.EmberApsFrame()
    zdo_f.handle_request(aps, 111, 0x0013, [0, dev._ieee, dev._nwk])
    assert dev._application.add_device.call_count == 1
Ejemplo n.º 26
0
def test_handle_addr(zdo_f):
    aps = t.EmberApsFrame()
    nwk = zdo_f._device._application._nwk
    zdo_f.reply = mock.MagicMock()
    zdo_f.handle_request(aps, 234, 0x0001, [nwk])
    assert zdo_f.reply.call_count == 1
Ejemplo n.º 27
0
def _handle_match_desc(zdo_f, profile):
    zdo_f.reply = mock.MagicMock()
    aps = t.EmberApsFrame()
    zdo_f.handle_request(aps, 123, 0x0006, [None, profile, [], []])
    assert zdo_f.reply.call_count == 1
Ejemplo n.º 28
0
def test_deserialize_unknown():
    frame = t.EmberApsFrame()
    frame.clusterId = 0x0100
    tsn, command_id, is_reply, args = zdo.deserialize(frame, b'\x01')
    assert tsn == 1
    assert is_reply is False
Ejemplo n.º 29
0
def test_handle_announce(zdo_f):
    dev = zdo_f._device
    dev._application.devices.pop(dev.ieee)
    aps = t.EmberApsFrame()
    zdo_f.handle_message(False, aps, 111, 0x0013, [0, dev.ieee, dev.nwk])