Skip to content

Commit e0ef62d

Browse files
authored
Merge pull request #315 from mkinney/master
detect devices only using vendor id
2 parents 48e7f8c + 02e8467 commit e0ef62d

File tree

2 files changed

+6
-42
lines changed

2 files changed

+6
-42
lines changed

meshtastic/supported_device.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ def __init__(self, name, version=None, for_firmware=None, device_class="esp32",
7272
rak4631_5005 = SupportedDevice(name="RAK 4631 5005", version="", for_firmware="rak4631_5005",
7373
device_class="nrf52",
7474
baseport_on_linux="ttyACM", baseport_on_mac="cu.usbmodem",
75-
usb_vendor_id_in_hex="239a", usb_product_id_in_hex="8029")
75+
usb_vendor_id_in_hex="239a", usb_product_id_in_hex="0029")
7676
rak4631_5005_epaper = SupportedDevice(name="RAK 4631 5005 14000 epaper", version="", for_firmware="rak4631_5005_epaper",
7777
device_class="nrf52",
7878
baseport_on_linux="ttyACM", baseport_on_mac="cu.usbmodem",
79-
usb_vendor_id_in_hex="239a", usb_product_id_in_hex="8029")
79+
usb_vendor_id_in_hex="239a", usb_product_id_in_hex="0029")
8080
# Note: The 19003 reports same product id as 5005 in boot mode
8181
rak4631_19003 = SupportedDevice(name="RAK 4631 19003", version="", for_firmware="rak4631_19003",
8282
device_class="nrf52",

meshtastic/util.py

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def camel_to_snake(a_string):
266266

267267

268268
def detect_supported_devices():
269-
"""detect supported devices"""
269+
"""detect supported devices based on vendor id"""
270270
system = platform.system()
271271
#print(f'system:{system}')
272272

@@ -285,19 +285,8 @@ def detect_supported_devices():
285285
if re.search(search, lsusb_output, re.MULTILINE):
286286
#print(f'Found vendor id that matches')
287287
devices = get_devices_with_vendor_id(vid)
288-
# check device id
289288
for device in devices:
290-
#print(f'device:{device} device.usb_product_id_in_hex:{device.usb_product_id_in_hex}')
291-
if device.usb_product_id_in_hex:
292-
search = f' {vid}:{device.usb_product_id_in_hex} '
293-
#print(f'search:"{search}"')
294-
if re.search(search, lsusb_output, re.MULTILINE):
295-
# concatenate the devices with vendor id to possibles
296-
possible_devices.add(device)
297-
else:
298-
# if there is a supported device witout a product id, then it
299-
# might be a match... so, concatenate
300-
possible_devices.add(device)
289+
possible_devices.add(device)
301290

302291
elif system == "Windows":
303292
# if windows, run Get-PnpDevice
@@ -313,22 +302,8 @@ def detect_supported_devices():
313302
if re.search(search, sp_output, re.MULTILINE):
314303
#print(f'Found vendor id that matches')
315304
devices = get_devices_with_vendor_id(vid)
316-
# check device id
317305
for device in devices:
318-
#print(f'device:{device} device.usb_product_id_in_hex:{device.usb_product_id_in_hex}')
319-
if device.usb_product_id_in_hex:
320-
search = f'DeviceID.*{vid.upper()}&PID_{device.usb_product_id_in_hex.upper()}'
321-
#print(f'search:"{search}"')
322-
if re.search(search, sp_output, re.MULTILINE):
323-
# concatenate the devices with vendor id to possibles
324-
possible_devices.add(device)
325-
# do a check to see if there is a Windows driver issue
326-
if detect_windows_needs_driver(device, False):
327-
print("WARNING: Need to install driver.")
328-
else:
329-
# if there is a supported device witout a product id, then it
330-
# might be a match... so, concatenate
331-
possible_devices.add(device)
306+
possible_devices.add(device)
332307

333308
elif system == "Darwin":
334309
# run: system_profiler SPUSBDataType
@@ -343,19 +318,8 @@ def detect_supported_devices():
343318
if re.search(search, sp_output, re.MULTILINE):
344319
#print(f'Found vendor id that matches')
345320
devices = get_devices_with_vendor_id(vid)
346-
# check device id
347321
for device in devices:
348-
#print(f'device:{device} device.usb_product_id_in_hex:{device.usb_product_id_in_hex}')
349-
if device.usb_product_id_in_hex:
350-
search = f'Product ID: 0x{device.usb_product_id_in_hex}'
351-
#print(f'search:"{search}"')
352-
if re.search(search, sp_output, re.MULTILINE):
353-
# concatenate the devices with vendor id to possibles
354-
possible_devices.add(device)
355-
else:
356-
# if there is a supported device witout a product id, then it
357-
# might be a match... so, concatenate
358-
possible_devices.add(device)
322+
possible_devices.add(device)
359323
return possible_devices
360324

361325

0 commit comments

Comments
 (0)