import serial
import struct
from google.protobuf.message import DecodeError
from serial.tools import list_ports

from light_pb2 import GlobalBrightness, Theme, GlobalTheme, ThemeSettings
from usb_pb2 import PackageType
from vcp_driver import *

if __name__ == "__main__":
        ser = setup_connection()
        # Create a message
        request = GlobalBrightness()
        request.brightness = 100
        # Serialize the request to a bytearray
        request_data = request.SerializeToString()

        # Send the request
        send_package(PackageType.LIGHT_GLOBAL_BRIGHT, request_data, ser)


        request = GlobalTheme()
        request.theme = 1
        request_data = request.SerializeToString()
        send_package(PackageType.LIGHT_GLOBAL_THEME, request_data, ser)


        # request = ThemeSettings()
        # request.deviceId = 1
        # request.theme = 1
        # request.rgb = 0x00f000f0
        # request.brightness = 255
        # request.animation = 2
        # request_data = request.SerializeToString()
        # send_package(PackageType.LIGHT_SETTING_THEME, request_data, ser)
