Exemplo n.º 1
0
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)))
Exemplo n.º 2
0
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),
    ]
Exemplo n.º 3
0
def multizone_effect_parameters_for(typ):
    if typ is enums.MultiZoneEffectType.MOVE:
        yield ("parameter1", T.Reserved(32))
        yield ("speed_direction", T.Uint32.enum(enums.Direction).default(enums.Direction.RIGHT))
        for i in range(6):
            yield ("parameter{0}".format(i + 2), T.Reserved(32))
    else:
        for i in range(8):
            yield ("parameter{0}".format(i), T.Reserved(32))
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
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)))
Exemplo n.º 6
0
class FrameHeader(dictobj.PacketSpec):
    fields = [
        ("size", T.Uint16.default(lambda pkt: int(pkt.size_bits(pkt) / 8))),
        ("protocol", T.Uint16.S(12).default(1024)),
        ("addressable",
         T.Bool.default(lambda pkt: False
                        if getattr(pkt, "target", None) is None else True)),
        ("tagged",
         T.Bool.default(lambda pkt: True
                        if getattr(pkt, "target", None) is None else False)),
        ("reserved1", T.Reserved(2, left=True)), ("source", T.Uint32)
    ]
Exemplo n.º 7
0
class FrameHeader(dictobj.PacketSpec):
    fields = [
        ("size", T.Uint16.default(lambda pkt: int(pkt.size_bits(pkt) / 8))),
        ("protocol", T.Uint16.S(12).default(1024)),
        ("addressable", T.Bool.default(lambda pkt: True)),
        (
            "tagged",
            T.Bool.default(lambda pkt: pkt.actual("target") in
                           (None, b"\x00" * 8, emptybt)),
        ),
        ("reserved1", T.Reserved(2, left=True)),
        ("source", T.Uint32),
    ]
Exemplo n.º 8
0
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)))
Exemplo n.º 9
0
class LightMessages(Messages):
    GetColor = msg(101)

    SetColor = msg(102, ("reserved6", T.Reserved(8)), *fields.hsbk,
                   ("duration", fields.duration_type))

    SetWaveform = msg(
        103, ("reserved6", T.Reserved(8)), ("transient", T.BoolInt.default(0)),
        *fields.hsbk, ("period", fields.waveform_period),
        ("cycles", T.Float.default(1)),
        ("skew_ratio", fields.waveform_skew_ratio),
        ("waveform", T.Uint8.enum(enums.Waveform).default(enums.Waveform.SAW)))

    LightState = msg(107, *fields.hsbk, ("reserved6", T.Reserved(16)),
                     ("power", T.Uint16), ("label", T.String(32 * 8)),
                     ("reserved7", T.Reserved(64)))

    GetLightPower = msg(116)

    SetLightPower = msg(117, ("level", T.Uint16),
                        ("duration", fields.duration_type))

    StateLightPower = msg(118, ("level", T.Uint16))

    SetWaveformOptional = msg(
        119, ("reserved6", T.Reserved(8)), ("transient", T.BoolInt.default(0)),
        *fields.hsbk_with_optional, ("period", fields.waveform_period),
        ("cycles", T.Float.default(1)),
        ("skew_ratio", fields.waveform_skew_ratio),
        ("waveform", T.Uint8.enum(enums.Waveform).default(enums.Waveform.SAW)),
        ("set_hue",
         T.BoolInt.default(lambda pkt: 0 if empty(pkt, "hue") else 1)),
        ("set_saturation",
         T.BoolInt.default(lambda pkt: 0 if empty(pkt, "saturation") else 1)),
        ("set_brightness",
         T.BoolInt.default(lambda pkt: 0 if empty(pkt, "brightness") else 1)),
        ("set_kelvin",
         T.BoolInt.default(lambda pkt: 0 if empty(pkt, "kelvin") else 1)))

    GetInfrared = msg(120)

    StateInfrared = msg(121, ("brightness", T.Uint16))

    SetInfrared = msg(122, ("brightness", T.Uint16))
Exemplo n.º 10
0
class ProtocolHeader(dictobj.PacketSpec):
    fields = [
        ("reserved4", T.Reserved(64)),
        ("pkt_type", T.Uint16.default(lambda pkt: pkt.Payload.message_type)),
        ("reserved5", T.Reserved(16)),
    ]
Exemplo n.º 11
0
 class Messages(Messages):
     SetExample = msg(9001, ("one", T.Reserved(6)), ("two", T.String(10)))
Exemplo n.º 12
0
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)
Exemplo n.º 13
0
def tile_effect_parameters_for(typ):
    for i in range(8):
        yield ("parameter{0}".format(i), T.Reserved(32))
Exemplo n.º 14
0
hsbk = [
      ("hue", scaled_hue)
    , ("saturation", scaled_to_65535)
    , ("brightness", scaled_to_65535)
    , ("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)
Exemplo n.º 15
0
                      ("saturation", scaled_to_65535.optional()),
                      ("brightness", scaled_to_65535.optional()),
                      ("kelvin", T.Uint16.optional()))

hsbk = (("hue", scaled_hue), ("saturation", scaled_to_65535),
        ("brightness", scaled_to_65535), ("kelvin", T.Uint16.default(3500)))


class Color(dictobj.PacketSpec):
    fields = hsbk


Color.Meta.cache = LRU(8000)

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), ("firmware_build",
                                  T.Uint64), ("reserved8", T.Reserved(64)),
                     ("firmware_version",
                      T.Uint32.version_number()), ("reserved9",
                                                   T.Reserved(32)))


class Tile(dictobj.PacketSpec):
    fields = tile_state_device