1616from . import resources
1717from ._vendored import dfu_create , dfu_upload
1818from .ble .lwp3 .bytecodes import HubKind
19+ from .usb import LEGO_USB_VID , LegoUsbPid
1920
2021FIRMWARE_ADDRESS = 0x08008000
2122FIRMWARE_SIZE = 1 * 1024 * 1024 - 32 * 1024 # 1MiB - 32KiB
22- LEGO_VID = 0x0694
23- SPIKE_PRIME_PID = 0x0008
24- SPIKE_ESSENTIAL_PID = 0x000C
25- MINDSTORMS_INVENTOR_PID = 0x0011
2623
2724ALL_PIDS = {
28- MINDSTORMS_INVENTOR_PID : HubKind .TECHNIC_LARGE ,
29- SPIKE_ESSENTIAL_PID : HubKind .TECHNIC_SMALL ,
30- SPIKE_PRIME_PID : HubKind .TECHNIC_LARGE ,
25+ LegoUsbPid . SPIKE_PRIME_DFU : HubKind .TECHNIC_LARGE ,
26+ LegoUsbPid . SPIKE_ESSENTIAL_DFU : HubKind .TECHNIC_SMALL ,
27+ LegoUsbPid . ROBOT_INVENTOR_DFU : HubKind .TECHNIC_LARGE ,
3128}
32- ALL_DEVICES = [f"{ LEGO_VID :04x} :{ pid :04x} " for pid in ALL_PIDS .keys ()]
29+ ALL_DEVICES = [f"{ LEGO_USB_VID :04x} :{ pid :04x} " for pid in ALL_PIDS .keys ()]
3330
3431
3532def _get_dfu_util () -> ContextManager [os .PathLike ]:
@@ -165,7 +162,7 @@ def flash_dfu(firmware_bin: bytes, metadata: dict) -> None:
165162 try :
166163 # Determine correct product ID
167164
168- devices = dfu_upload .get_dfu_devices (idVendor = LEGO_VID )
165+ devices = dfu_upload .get_dfu_devices (idVendor = LEGO_USB_VID )
169166 if not devices :
170167 print (
171168 "No DFU devices found." ,
@@ -184,11 +181,11 @@ def flash_dfu(firmware_bin: bytes, metadata: dict) -> None:
184181 exit (1 )
185182
186183 # Create dfu file
187- device = "0x{0:04x}:0x{1:04x}" .format (LEGO_VID , product_id )
184+ device = "0x{0:04x}:0x{1:04x}" .format (LEGO_USB_VID , product_id )
188185 dfu_create .build (outfile , [[target ]], device )
189186
190187 # Init dfu tool
191- dfu_upload .__VID = LEGO_VID
188+ dfu_upload .__VID = LEGO_USB_VID
192189 dfu_upload .__PID = product_id
193190 dfu_upload .init ()
194191 elements = dfu_upload .read_dfu_file (outfile )
0 commit comments