Ejemplo n.º 1
0
 def _ezsp_frame(self, name, *args):
     c = self.COMMANDS[name]
     data = t.serialize(args, c[1])
     return bytes([
         self._seq & 0xff,
         0,  # Frame control. TODO.
         c[0],  # Frame ID
     ]) + data
Ejemplo n.º 2
0
    def _ezsp_frame(self, name, *args):
        c = self.COMMANDS[name]
        data = t.serialize(args, c[1])
        frame = [self._seq & 0xFF, 0, c[0]]  # Frame control. TODO.  # Frame ID
        if self.ezsp_version >= 5:
            frame.insert(1, 0xFF)  # Legacy Frame ID
            frame.insert(1, 0x00)  # Ext frame control. TODO.

        return bytes(frame) + data
Ejemplo n.º 3
0
    def request(self, general, command_id, schema, *args):
        aps = self._endpoint.get_aps(self.cluster_id)
        if general:
            frame_control = 0x00
        else:
            frame_control = 0x01
        data = bytes([frame_control, aps.sequence, command_id])
        data += t.serialize(args, schema)

        return self._endpoint._device.request(aps, data)
Ejemplo n.º 4
0
    def reply(self, command_id, schema, *args):
        if len(schema) != len(args):
            self.error("Schema and args lengths do not match in reply")
            error = asyncio.Future()
            error.set_exception(ValueError("Wrong number of parameters for reply, expected %d argument(s)" % len(schema)))
            return error

        aps = self._endpoint.get_aps(self.cluster_id)
        frame_control = 0b1001  # Cluster reply command
        data = bytes([frame_control, aps.sequence, command_id])
        data += t.serialize(args, schema)

        return self._endpoint.device.reply(aps, data)
Ejemplo n.º 5
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.º 6
0
    def request(self, general, command_id, schema, *args):
        if len(schema) != len(args):
            self.error("Schema and args lengths do not match")
            error = asyncio.Future()
            error.set_exception(
                ValueError(
                    "Missing parameters for request, expected %d argument(s)" %
                    len(schema)))
            return error

        aps = self._endpoint.get_aps(self.cluster_id)
        if general:
            frame_control = 0x00
        else:
            frame_control = 0x01
        data = bytes([frame_control, aps.sequence, command_id])
        data += t.serialize(args, schema)

        return self._endpoint.device.request(aps, data)
Ejemplo n.º 7
0
 def _serialize(self, command, *args):
     aps = self._device.get_aps(profile=0, cluster=command, endpoint=0)
     data = aps.sequence.to_bytes(1, 'little')
     schema = types.CLUSTERS[command][2]
     data += t.serialize(args, schema)
     return aps, data