Reputation: 39
I'm trying to make communication between my Android phone and Windows PC via WebUSB. My PC can see my phone withput any troubles, but my phone can't.
Code I'm using, actually it's part of a function that I'm calling:
navigator.usb
.requestDevice({ filters: [{vendorId: 8921}]})
.then(device => {
console.log('Found a device:', device);
return device.open();
})
.catch(error => {
console.error(`Error: ${error}`);
})
I don't know why. But somewhere I've read about some problems with WinUSB, but I don't know.
Thanks.
Upvotes: 0
Views: 258
Reputation: 6093
USB has dedicated host and peripheral roles, so your PC as the host will see the phone as the peripheral. WebUSB only supports running on the device acting as the host so unless your PC can switch modes (this is something your phone does, but most PCs can't) then you will only see your phone from your PC but not the other way around.
This means you can't use WebUSB to connect a website on your PC to a website on your phone.
Upvotes: 1