package com.waytous.anticollision.serial

import android.hardware.usb.UsbManager
import com.hoho.android.usbserial.driver.UsbSerialDriver
import com.hoho.android.usbserial.driver.UsbSerialProber

fun UsbManager.refresh():List<SerialDeviceInfo>{
    val usbDefaultProbe = UsbSerialProber.getDefaultProber()
    val usbCustomProbe: UsbSerialProber = CustomProbe.getCustomProbe()
    val deviceInfos = mutableListOf<SerialDeviceInfo>()
    for (device in deviceList.values) {
        var driver: UsbSerialDriver? = usbDefaultProbe.probeDevice(device)
        if (driver == null) {
            driver = usbCustomProbe.probeDevice(device)
        }
//        if (driver != null) {
//            deviceInfos.add(SerialDeviceInfo(device.deviceId,device.po))
//            for (port in driver.ports.indices) listItems.add(ListItem(device, port, driver))
//        } else {
//            listItems.add(ListItem(device, 0, null))
//        }
    }

}