3

I recently tried to use web API to get my USB device. However, there are a few problems.

First, the examples I found online are all about Arduino which I never try, so don't know whether it works on my computer or not. I tried to communicate with my smartphone SAMSUNG J7. I set VID and PID as the same as I found in device manager. Then, there was no device can be selected, it only shows "No compatible device was found."

found nothing picture

Then, I delete the filter part to blank in order to get all device. However, all I got is internal intel USB chip or something. I still cannot find my device.

no filter picture

The below is my javascript code

const filters = [{}];
  navigator.usb.requestDevice({
      filters: filters
    })
    .then(usbDevice => {
      console.log("Product name: " + usbDevice.productName);
      console.log(usbDevice.manufacturerName);
    })
    .catch(e => {
      console.log("There is no device. " + e);
    });

Can anyone tell me where am I wrong or is there any misunderstanding about Webusb

howcome333
  • 31
  • 1
  • 4

1 Answers1

2

You should be able to connect to your SAMSUNG J7 however if you are on Windows then you need to make sure that the system is loading the WinUSB.sys driver (this is what lets Chrome, as an application, access the device). Instructions for that are here: https://developer.android.com/studio/run/win-usb

If you are building your own device (and just testing with your phone) the Arduino-based examples are a good starting place for understanding what descriptors you device should implement in order to take advantage of WebUSB features and be compatible with multiple operating systems (mostly just Windows-related issues).

Reilly Grant
  • 5,590
  • 1
  • 13
  • 23
  • Sir, first, thanks a lot for your answer. It really helps a lot. While I follow the step given by android developer forum, another problem occurs. That is my computer kept telling me that Win10 has already chosen the best driver for my hardware. Therefore, I couldn't update the driver at all. Do you know any solution? Thanks again. – howcome333 Jun 15 '18 at 13:46
  • Which driver is Windows currently using and which driver are you trying to switch it to? – Reilly Grant Jun 19 '18 at 17:32
  • I am using win10 right now and the driver was the link given by the android develop forum --- Google USB Driver. – howcome333 Jun 22 '18 at 11:51