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
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With