# USB-to-RS-485 adapter compatible with EVBox ChargeStation Tool
# Written 2026 by Maarten Tromp <maarten@geekabit.nl>
# Website: https://www.geekabit.nl/projects/reversing-the-evbox-chargestation-tool/
# License: CC0 1.0 Universal (Public Domain Dedication)
# For more info see README


import usb_hid

REPORT_LEN = 64

hid = usb_hid.Device(
	report_descriptor = 
		b'\x06\x00\xff'	# USAGE_PAGE (Vendor Defined)
		b'\x09\x01'		# USAGE
		b'\xa1\x01'		# COLLECTION (Application)
		b'\x15\x00'		# LOGICAL_MINIMUM (0)
		b'\x26\xff\x00'	# LOGICAL_MAXIMUM (255)
		b'\x75\x08'		# REPORT_SIZE
		b'\x95\x40'		# 64 bytes input
		b'\x09\x01'		# USAGE
		b'\x81\x02'		# INPUT (Data,Var,Abs)
		b'\x95\x40'		# 64 bytes output
		b'\x09\x01'		# USAGE
		b'\x91\x02'		# OUTPUT (Data,Var,Abs)
		b'\xc0',		# END_COLLECTION
	usage_page = 0xff00,
	usage = 0x01,
	report_ids = (0,),	# no report ID
	in_report_lengths = (REPORT_LEN,),
	out_report_lengths = (REPORT_LEN,),
)

usb_hid.set_interface_name("EV-BOX USB-to-ChargeStation-LM")
usb_hid.enable((hid,))
