async def mrequest( self, group_id, profile, cluster, src_ep, sequence, data, *, hops=0, non_member_radius=3 ): """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 """ req_id = self.get_sequence() LOGGER.debug( "Sending Zigbee multicast with tsn %s under %s request id, data: %s", sequence, req_id, binascii.hexlify(data), ) dst_addr_ep = t.DeconzAddressEndpoint() dst_addr_ep.address_mode = t.ADDRESS_MODE.GROUP dst_addr_ep.address = group_id with self._pending.new(req_id) as req: try: await self._api.aps_data_request( req_id, dst_addr_ep, profile, cluster, min(1, src_ep), data ) except zigpy_cc.exception.CommandError as ex: return ex.status, "Couldn't enqueue send data request: {}".format(ex) r = await asyncio.wait_for(req.result, SEND_CONFIRM_TIMEOUT) if r: LOGGER.warning("Error while sending %s req id frame: 0x%02x", req_id, r) return r, "message send failure" return Status.SUCCESS, "message send success"
def test_api_frame(api): addr = t.DeconzAddressEndpoint() addr.address_mode = t.ADDRESS_MODE.NWK addr.address = t.uint8_t(0) addr.endpoint = t.uint8_t(0) for cmd, schema in zigpy_cc.api.TX_COMMANDS.items(): if schema: args = [ addr if isinstance(a(), t.DeconzAddressEndpoint) else a() for a in schema ] api._api_frame(cmd, *args) else: api._api_frame(cmd)
async def broadcast( self, profile, cluster, src_ep, dst_ep, grpid, radius, sequence, data, broadcast_address=zigpy.types.BroadcastAddress.RX_ON_WHEN_IDLE, ): req_id = self.get_sequence() LOGGER.debug( "Sending Zigbee broadcast with tsn %s under %s request id, data: %s", sequence, req_id, binascii.hexlify(data), ) dst_addr_ep = t.DeconzAddressEndpoint() dst_addr_ep.address_mode = t.uint8_t(t.ADDRESS_MODE.GROUP.value) dst_addr_ep.address = t.uint16_t(broadcast_address) with self._pending.new(req_id) as req: try: await self._api.aps_data_request( req_id, dst_addr_ep, profile, cluster, min(1, src_ep), data ) except zigpy_cc.exception.CommandError as ex: return ( ex.status, "Couldn't enqueue send data request for broadcast: {}".format(ex), ) r = await asyncio.wait_for(req.result, SEND_CONFIRM_TIMEOUT) if r: LOGGER.warning( "Error while sending %s req id broadcast: 0x%02x", req_id, r ) return r, "broadcast send failure" return r, "broadcast send success"