class TileMessages(Messages): GetDeviceChain = msg(701) StateDeviceChain = msg( 702, ("start_index", T.Uint8), ("tile_devices", T.Bytes(440 * 16).many(lambda pkt: fields.Tile)), ("total_count", T.Uint8)) SetUserPosition = msg(703, ("tile_index", T.Uint8), ("reserved6", T.Reserved(16)), ("user_x", T.Float), ("user_y", T.Float)) GetState64 = msg(707, ("tile_index", T.Uint8), ("length", T.Uint8), *fields.tile_buffer_rect, multi=MultiOptions( lambda req: TileMessages.State64, lambda req, res: MultiOptions.Max(req.length))) State64 = msg(711, ("tile_index", T.Uint8), *fields.tile_buffer_rect, ("colors", T.Bytes(64 * 64).many(lambda pkt: fields.Color))) SetState64 = msg( 715, ("tile_index", T.Uint8), ("length", T.Uint8), *fields.tile_buffer_rect, ("duration", fields.duration_type), ("colors", T.Bytes(64 * 64).many(lambda pkt: fields.Color)))
class TileMessages(Messages): GetDeviceChain = msg(701) StateDeviceChain = msg( 702, ("start_index", T.Uint8), ("tile_devices", T.Bytes(440).multiple(16, kls=fields.Tile)), ("tile_devices_count", T.Uint8)) SetUserPosition = msg(703, ("tile_index", T.Uint8), ("reserved6", T.Reserved(16)), ("user_x", T.Float), ("user_y", T.Float)) Get64 = msg(707, ("tile_index", T.Uint8), ("length", T.Uint8), *fields.tile_buffer_rect, multi=MultiOptions( lambda req: TileMessages.State64, lambda req, res: MultiOptions.Max(req.length))) State64 = msg(711, ("tile_index", T.Uint8), *fields.tile_buffer_rect, ("colors", T.Bytes(64).multiple(64, kls=fields.Color))) Set64 = msg(715, ("tile_index", T.Uint8), ("length", T.Uint8), *fields.tile_buffer_rect, ("duration", fields.duration_type), ("colors", T.Bytes(64).multiple(64, kls=fields.Color))) GetTileEffect = msg(718, ("reserved6", T.Reserved(8)), ("reserved7", T.Reserved(8))) SetTileEffect = msg(719, ("reserved8", T.Reserved(8)), ("reserved9", T.Reserved(8)), *fields.tile_effect_settings) StateTileEffect = msg(720, ("reserved8", T.Reserved(8)), *fields.tile_effect_settings)
class MultiZoneMessages(Messages): SetColorZones = msg( 501, ("start_index", T.Uint8), ("end_index", T.Uint8), *fields.hsbk, ("duration", fields.duration_type), ("apply", T.Uint8.enum(enums.MultiZoneApplicationRequest).default( enums.MultiZoneApplicationRequest.APPLY)), multi=MultiOptions( lambda req: [MultiZoneMessages.StateZone, MultiZoneMessages.StateMultiZone], lambda req, res: color_zones_response_count(req, res))) GetColorZones = msg( 502, ("start_index", T.Uint8), ("end_index", T.Uint8), multi=MultiOptions( lambda req: [MultiZoneMessages.StateZone, MultiZoneMessages.StateMultiZone], lambda req, res: color_zones_response_count(req, res))) StateZone = msg(503, ("zones_count", T.Uint8), ("zone_index", T.Uint8), *fields.hsbk) StateMultiZone = msg(506, ("zones_count", T.Uint8), ("zone_index", T.Uint8), ("colors", T.Bytes(64).multiple(8, kls=fields.Color))) GetMultiZoneEffect = msg(507) SetMultiZoneEffect = msg(508, *fields.multi_zone_effect_settings) StateMultiZoneEffect = SetMultiZoneEffect.using(509) SetExtendedColorZones = msg( 510, ("duration", fields.duration_type), ("apply", T.Uint8.enum( enums.MultiZoneExtendedApplicationRequest).default( enums.MultiZoneExtendedApplicationRequest.APPLY)), ("zone_index", T.Uint16), ("colors_count", T.Uint8), ("colors", T.Bytes(64).multiple(82, kls=fields.Color))) GetExtendedColorZones = msg(511) StateExtendedColorZones = msg( 512, ("zones_count", T.Uint16), ("zone_index", T.Uint16), ("colors_count", T.Uint8), ("colors", T.Bytes(64).multiple(82, kls=fields.Color)))
class FrameAddress(dictobj.PacketSpec): fields = [ ("target", T.Bytes(64).transform(look_at_target, look_at_target)), ("reserved2", T.Reserved(48)), ("res_required", T.Bool.default(True)), ("ack_required", T.Bool.default(True)), ("reserved3", T.Reserved(6)), ("sequence", T.Uint8), ]
class MultiZoneMessages(Messages): SetColorZones = msg( 501, ("start_index", T.Uint8), ("end_index", T.Uint8), *fields.hsbk, ("duration", fields.duration_type), ("apply", T.Uint8.enum(enums.MultiZoneApplicationRequest).default( enums.MultiZoneApplicationRequest.APPLY))) GetColorZones = msg( 502, ("start_index", T.Uint8), ("end_index", T.Uint8), multi=MultiOptions( lambda req: [MultiZoneMessages.StateZone, MultiZoneMessages.StateMultiZone], lambda req, res: min( (req.end_index // 8) + 1, res.zones_count // 8))) StateZone = msg(503, ("zones_count", T.Uint8), ("zone_index", T.Uint8), *fields.hsbk) StateMultiZone = msg( 506, ("zones_count", T.Uint8), ("zone_index", T.Uint8), ("colors", T.Bytes(64 * 8).many(lambda pkt: fields.Color)))
class DeviceMessages(Messages): GetHostInfo = msg(12) StateHostInfo = msg(13, ("signal", T.Float), ("tx", T.Uint32), ("rx", T.Uint32), ("reserved6", T.Reserved(16))) GetHostFirmware = msg(14) StateHostFirmware = msg(15, ("build", T.Uint64), ("reserved6", T.Reserved(64)), ("version", T.Uint32.version_number())) GetWifiInfo = msg(16) StateWifiInfo = msg(17, ("signal", T.Float), ("tx", T.Uint32), ("rx", T.Uint32), ("reserved6", T.Reserved(16))) GetWifiFirmware = msg(18) StateWifiFirmware = msg(19, ("build", T.Uint64), ("reserved6", T.Reserved(64)), ("version", T.Uint32.version_number())) GetPower = msg(20) SetPower = msg(21, ("level", T.Uint16)) StatePower = msg(22, ("level", T.Uint16)) GetLabel = msg(23) SetLabel = msg(24, ("label", T.String(32 * 8))) StateLabel = SetLabel.using(25) GetVersion = msg(32) StateVersion = msg(33, ("vendor", T.Uint32), ("product", T.Uint32), ("version", T.Uint32)) GetInfo = msg(34) StateInfo = msg(35, ("time", T.Uint64), ("uptime", fields.nano_to_seconds), ("downtime", fields.nano_to_seconds)) GetLocation = msg(48) SetLocation = msg(49, ("location", T.Bytes(16 * 8)), ("label", T.String(32 * 8)), ("updated_at", T.Uint64)) StateLocation = SetLocation.using(50) GetGroup = msg(51) SetGroup = msg(52, ("group", T.Bytes(16 * 8)), ("label", T.String(32 * 8)), ("updated_at", T.Uint64)) StateGroup = SetGroup.using(53) EchoRequest = msg(58, ("echoing", T.Bytes(64 * 8))) EchoResponse = EchoRequest.using(59)
, ("kelvin", T.Uint16.default(3500)) ] class Color(dictobj.PacketSpec): fields = hsbk Color.Meta.cache = LRU(8000) multi_zone_effect_settings = [ ("instanceid", T.Uint32.default(lambda pkt: random.randrange(1, 1<<32))) , ("type", T.Uint8.enum(enums.MultiZoneEffectType, allow_unknown=True).default(enums.MultiZoneEffectType.MOVE)) , ("reserved6", T.Reserved(16)) , ("speed", duration_type.default(5)) , ("duration", extended_duration_type) , ("reserved7", T.Reserved(32)) , ("reserved8", T.Reserved(32)) , ("parameters", T.Bytes(32 * 8).dynamic(lambda pkt: multizone_effect_parameters_for(pkt.type))) ] tile_state_device = [ ("accel_meas_x", T.Int16) , ("accel_meas_y", T.Int16) , ("accel_meas_z", T.Int16) , ("reserved6", T.Reserved(16)) , ("user_x", T.Float) , ("user_y", T.Float) , ("width", T.Uint8) , ("height", T.Uint8) , ("reserved7", T.Reserved(8)) , ("device_version_vendor", T.Uint32) , ("device_version_product", T.Uint32) , ("device_version_version", T.Uint32)