Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom USB devices probe list is an extension to the (library) default one #484

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 39 additions & 7 deletions app/src/main/java/com/ds/avare/connections/USBConnectionIn.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.ds.avare.utils.Logger;
import com.hoho.android.usbserial.driver.UsbSerialDriver;
import com.hoho.android.usbserial.driver.UsbSerialPort;
import com.hoho.android.usbserial.driver.CdcAcmSerialDriver;
import com.hoho.android.usbserial.driver.ProbeTable;
import com.hoho.android.usbserial.driver.UsbSerialProber;

import java.util.ArrayList;
Expand All @@ -33,6 +35,28 @@
* @author zkhan
*
*/

/**
* add devices here, that are not known to DefaultProber
*
* if the App should auto start for these devices, also
* add IDs to app/src/main/res/xml/device_filter.xml
*/
class CustomProber {

static UsbSerialProber getCustomProber() {
ProbeTable customTable = new ProbeTable();
customTable.addProduct(0x239A, 0x8029, CdcAcmSerialDriver.class); // SoftRF Badge
customTable.addProduct(0x2341, 0x804d, CdcAcmSerialDriver.class); // SoftRF Academy
customTable.addProduct(0x1d50, 0x6089, CdcAcmSerialDriver.class); // SoftRF ES
customTable.addProduct(0x2e8a, 0xf00a, CdcAcmSerialDriver.class); // SoftRF Lego
customTable.addProduct(0x15ba, 0x0044, CdcAcmSerialDriver.class); // SoftRF Balkan
customTable.addProduct(0x303a, 0x8133, CdcAcmSerialDriver.class); // SoftRF Prime Mk3
return new UsbSerialProber(customTable);
}

}

public class USBConnectionIn extends Connection {

private static USBConnectionIn mConnection;
Expand Down Expand Up @@ -126,13 +150,16 @@ public boolean connect(String params, boolean secure) {
mParams = params;
List<UsbSerialDriver> availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(mUsbManager);
if (availableDrivers.isEmpty()) {
Logger.Logit("No USB serial device available");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
availableDrivers = CustomProber.getCustomProber().findAllDrivers(mUsbManager);
if (availableDrivers.isEmpty()) {
Logger.Logit("No USB serial device available");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return false;
}
return false;
}
mDriver = availableDrivers.get(0);
if(mDriver == null) {
Expand Down Expand Up @@ -185,7 +212,12 @@ else if (tokens[2].equals("o")) {
}
int stop = Integer.parseInt(tokens[3]);
mPort.setParameters(rate, data, stop, parity);
}
if (mDriver instanceof CdcAcmSerialDriver) {
if(!(mPort.getDTR())) {
mPort.setDTR(true);
}
}
}
catch (Exception e) {
setState(Connection.DISCONNECTED);
Logger.Logit("Failed!");
Expand Down
42 changes: 15 additions & 27 deletions app/src/main/res/xml/device_filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,20 @@
<usb-device vendor-id="6790" product-id="29987" /> <!-- 0x7523: CH340 -->

<!-- CDC driver -->
<usb-device vendor-id="9025" /> <!-- 0x2341 / ......: Arduino -->
<usb-device vendor-id="5824" product-id="1155" /> <!-- 0x16C0 / 0x0483: Teensyduino -->
<usb-device vendor-id="1003" product-id="8260" /> <!-- 0x03EB / 0x2044: Atmel Lufa -->
<usb-device vendor-id="7855" product-id="4" /> <!-- 0x1eaf / 0x0004: Leaflabs Maple -->
<usb-device vendor-id="3368" product-id="516" /> <!-- 0x0d28 / 0x0204: ARM mbed -->
<usb-device vendor-id="1155" product-id="22336" /><!-- 0x0483 / 0x5740: ST CDC -->
<usb-device vendor-id="11914" product-id="5" /> <!-- 0x2E8A / 0x0005: Raspberry Pi Pico Micropython -->
<usb-device vendor-id="11914" product-id="10" /> <!-- 0x2E8A / 0x000A: Raspberry Pi Pico SDK -->
<usb-device vendor-id="6790" product-id="21972" /><!-- 0x1A86 / 0x55D4: Qinheng CH9102F -->

<!-- 0x0483 / 0x5740: SoftRF Dongle -->
<usb-device vendor-id="1155" product-id="22336" class="2" />

<!-- 0x239A / 0x8029: SoftRF Badge -->
<usb-device vendor-id="9114" product-id="32809" class="2" />

<!-- 0x2341 / 0x804D: SoftRF Academy -->
<usb-device vendor-id="9025" product-id="32845" class="2" />

<!-- 0x1D50 / 0x6089: SoftRF ES -->
<usb-device vendor-id="7504" product-id="24713" class="2" />

<!-- 0x2E8A / 0x000A: SoftRF Lego -->
<usb-device vendor-id="11914" product-id="10" class="2" />

<!-- 0x2E8A / 0xF00A: SoftRF Lego -->
<usb-device vendor-id="11914" product-id="61450" class="2" />
<usb-device vendor-id="9025" /> <!-- 0x2341 / ......: Arduino -->
<usb-device vendor-id="5824" product-id="1155" /> <!-- 0x16C0 / 0x0483: Teensyduino -->
<usb-device vendor-id="1003" product-id="8260" /> <!-- 0x03EB / 0x2044: Atmel Lufa -->
<usb-device vendor-id="7855" product-id="4" /> <!-- 0x1eaf / 0x0004: Leaflabs Maple -->
<usb-device vendor-id="3368" product-id="516" /> <!-- 0x0d28 / 0x0204: ARM mbed -->
<usb-device vendor-id="1155" product-id="22336" /> <!-- 0x0483 / 0x5740: ST CDC -->
<usb-device vendor-id="11914" product-id="5" /> <!-- 0x2E8A / 0x0005: Raspberry Pi Pico Micropython -->
<usb-device vendor-id="11914" product-id="10" /> <!-- 0x2E8A / 0x000A: Raspberry Pi Pico SDK -->
<usb-device vendor-id="6790" product-id="21972" /> <!-- 0x1A86 / 0x55D4: Qinheng CH9102F -->

<usb-device vendor-id="9114" product-id="32809" /> <!-- 0x239A / 0x8029: SoftRF Badge -->
<usb-device vendor-id="7504" product-id="24713" /> <!-- 0x1D50 / 0x6089: SoftRF ES -->
<usb-device vendor-id="11914" product-id="61450" /><!-- 0x2E8A / 0xF00A: SoftRF Lego -->
<usb-device vendor-id="5562" product-id="68" /> <!-- 0x15ba / 0x0044: SoftRF Balkan -->
<usb-device vendor-id="12346" product-id="33075" /><!-- 0x303a / 0x8133: SoftRF Prime Mk3 -->

</resources>