Search in sources :

Example 1 with UsbSerialProber

use of com.eveningoutpost.dexdrip.ImportedLibraries.usbserial.driver.UsbSerialProber in project xDrip by NightscoutFoundation.

the class SyncingService method acquireSerialDevice.

private boolean acquireSerialDevice() {
    UsbDevice found_device = findDexcom();
    if (mUsbManager == null) {
        Log.w("CALIBRATION-CHECK-IN: ", "USB manager is null");
        return false;
    }
    if (dexcom == null) {
        Log.e(TAG, "dex device == null");
        return false;
    }
    if (mUsbManager.hasPermission(dexcom)) {
        // the system is allowing us to poke around this device
        // From the USB library...
        ProbeTable customTable = new ProbeTable();
        // ...Specify the Vendor ID and Product ID
        customTable.addProduct(0x22A3, 0x0047, CdcAcmSerialDriver.class);
        // Probe the device with the custom values
        UsbSerialProber prober = new UsbSerialProber(customTable);
        // let's go through the list
        List<UsbSerialDriver> drivers = prober.findAllDrivers(mUsbManager);
        // Invalid Return code
        Iterator<UsbSerialDriver> foo = drivers.iterator();
        while (foo.hasNext()) {
            // let's loop through
            // set fooDriver to the next available driver
            UsbSerialDriver driver = foo.next();
            if (driver != null) {
                UsbDeviceConnection connection = mUsbManager.openDevice(driver.getDevice());
                if (connection != null) {
                    mSerialDevice = driver;
                    mConnection = connection;
                    Log.i("CALIBRATION-CHECK-IN: ", "CONNECTEDDDD!!");
                    return true;
                }
            } else {
                Log.w("CALIBRATION-CHECK-IN: ", "Driver was no good");
            }
        }
        Log.w("CALIBRATION-CHECK-IN: ", "No usable drivers found");
    } else {
        Log.w("CALIBRATION-CHECK-IN: ", "You dont have permissions for that dexcom!!");
    }
    return false;
}
Also used : UsbSerialDriver(com.eveningoutpost.dexdrip.ImportedLibraries.usbserial.driver.UsbSerialDriver) UsbSerialProber(com.eveningoutpost.dexdrip.ImportedLibraries.usbserial.driver.UsbSerialProber) ProbeTable(com.eveningoutpost.dexdrip.ImportedLibraries.usbserial.driver.ProbeTable) UsbDeviceConnection(android.hardware.usb.UsbDeviceConnection) UsbDevice(android.hardware.usb.UsbDevice)

Example 2 with UsbSerialProber

use of com.eveningoutpost.dexdrip.ImportedLibraries.usbserial.driver.UsbSerialProber in project xDrip-plus by jamorham.

the class SyncingService method acquireSerialDevice.

private boolean acquireSerialDevice() {
    UsbDevice found_device = findDexcom();
    if (mUsbManager == null) {
        Log.w("CALIBRATION-CHECK-IN: ", "USB manager is null");
        return false;
    }
    if (dexcom == null) {
        Log.e(TAG, "dex device == null");
        return false;
    }
    if (mUsbManager.hasPermission(dexcom)) {
        // the system is allowing us to poke around this device
        // From the USB library...
        ProbeTable customTable = new ProbeTable();
        // ...Specify the Vendor ID and Product ID
        customTable.addProduct(0x22A3, 0x0047, CdcAcmSerialDriver.class);
        // Probe the device with the custom values
        UsbSerialProber prober = new UsbSerialProber(customTable);
        // let's go through the list
        List<UsbSerialDriver> drivers = prober.findAllDrivers(mUsbManager);
        // Invalid Return code
        Iterator<UsbSerialDriver> foo = drivers.iterator();
        while (foo.hasNext()) {
            // let's loop through
            // set fooDriver to the next available driver
            UsbSerialDriver driver = foo.next();
            if (driver != null) {
                UsbDeviceConnection connection = mUsbManager.openDevice(driver.getDevice());
                if (connection != null) {
                    mSerialDevice = driver;
                    mConnection = connection;
                    Log.i("CALIBRATION-CHECK-IN: ", "CONNECTEDDDD!!");
                    return true;
                }
            } else {
                Log.w("CALIBRATION-CHECK-IN: ", "Driver was no good");
            }
        }
        Log.w("CALIBRATION-CHECK-IN: ", "No usable drivers found");
    } else {
        Log.w("CALIBRATION-CHECK-IN: ", "You dont have permissions for that dexcom!!");
    }
    return false;
}
Also used : UsbSerialDriver(com.eveningoutpost.dexdrip.ImportedLibraries.usbserial.driver.UsbSerialDriver) UsbSerialProber(com.eveningoutpost.dexdrip.ImportedLibraries.usbserial.driver.UsbSerialProber) ProbeTable(com.eveningoutpost.dexdrip.ImportedLibraries.usbserial.driver.ProbeTable) UsbDeviceConnection(android.hardware.usb.UsbDeviceConnection) UsbDevice(android.hardware.usb.UsbDevice)

Aggregations

UsbDevice (android.hardware.usb.UsbDevice)2 UsbDeviceConnection (android.hardware.usb.UsbDeviceConnection)2 ProbeTable (com.eveningoutpost.dexdrip.ImportedLibraries.usbserial.driver.ProbeTable)2 UsbSerialDriver (com.eveningoutpost.dexdrip.ImportedLibraries.usbserial.driver.UsbSerialDriver)2 UsbSerialProber (com.eveningoutpost.dexdrip.ImportedLibraries.usbserial.driver.UsbSerialProber)2