Commit graph

11 commits

Author SHA1 Message Date
Michael Keller
b579342639 Cleanup: Remove 'context' Reference from Logging Defines.
Remove the reference to `context` from the defines used for logging, as
this is not used.

Signed-off-by: Michael Keller <mikeller@042.ch>
2024-05-16 16:39:48 +02:00
Christof Arnosti
87e12029f9 android/usb: remove "autoselect driver" option for unknown VID/PIDs
Signed-off-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
ec3a968df9 android/usb: pass in the UsbDevice when downloading
This finally allows us to download from not just the first device, but specifically
the device that the user picks.

Passing the object through a void pointer is not nice - but since this traverses
C code other solutions (like passing an index into the list) seemed even worse.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
c19e3bd5ba android/usb: remove alternative way of scanning for devices
We now always create a list of usb devices that doesn't list a driver
for known devices, and adds multiple entries with each of the drivers
for devices that are unknown to us.

This removes some debugging output in the ..._open() function as well.

This could be combined with Christof's earlier commit.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
c81854ca21 android/usb: add helper to recognize chipsets known to us
This will allow us to know when we can guess the driver.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
c2077992ff android/usb: guess the actual manufacturer and product
For a small number of dive computers we can actually figure out the
real information which we can then later show to the user.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Christof Arnosti
ce7d4d1ca6 usb-serial-for-android: More fields in device descriptor
As discussed in issue #2657, there are now more fields about the usb
device information in android_usb_serial_device_descriptor.

Additionally, the user-facing string now makes more sense:
"vendor [<bus# as integer>:<dev# as integer>]"
Where vendor is as reported by android, but shortened to 16 characters.

Examples:
FTDI [1:2]
Silicon Labs [1:4]

Signed-off-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Christof Arnosti
344f7861b4 usb-serial-for-android: Use correct format spezifier for size_t
Signed-off-by: Christof Arnosti <charno@charno.ch>
2020-03-16 07:58:20 -07:00
Christof Arnosti
a34a81d120 android usb serial: Prepare device / driver select
This commit contains the serial_android_usb part of the changes proposed
in issue #2657.

What's implemented:
- A data structure that contains all the data that can be used to
  describe an usb device (including user-facing string).
- A function to get a list of all attached usb devices (optionally with
  selectable driver class).
- Changes in the serial_android_usb_open-function and in the Java part
  to use the information about the usb device and optionally selected
  driver when connecting.

This commit keeps compatibility with the current UI-Code in the case
that only one USB-Device is connected. If two devices are connected,
only the first one is tried.

There are still some small things to do:
- Change the user-facing string to something more descriptive.
- Parts which aren't uesd anymore when the UI-Part is implemented are
  simply marked as obsolete (to keep compatibility for now).

But generally it seems to work.

[Dirk Hohndel: some white space / coding style adjustments]

Signed-off-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Christof Arnosti
b15b9c6cd0 usb-serial-for-android: Implement timeout-handling
Since the Android USB stack and subsequently the usb-serial-for-android
driver have problems with read-timeouts, the read-timeout is now
implemented in AndroidSerial.java. Also, DC_STATUS_TIMEOUT is returned
if there are less bytes returned than expected.

Different chipsets seem to behave differently with
usb-serial-for-android. On CP210x the read blocks until there is some
data here, but on FTDI the chip seems to return whatever is currently in
the buffer (so 0 bytes if the buffer is empty). This different behaviour
should be mitigated by the changes by this commit.

Signed-off-by: Christof Arnosti <charno@charno.ch>
2020-03-08 11:22:55 -07:00
Christof Arnosti
6e38f85ba7 usb-serial-for-android: Implementation
Implement the libdivecomputer API in Java and create C/JNI translation
layer.

[Dirk Hohndel: whitespace harmonization - yes, some of this is Java,
               this still makes it much easier to read for me;
               also changed the FTDI conditional compilation to make
               sure we can still use that for mobile-on-desktop if
               necessary]

Signed-off-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-07 12:34:43 -08:00