I am trying to communicate with a Samsung J7 over Web using WebUSB API. I am currently using this basic code:
<body>
<button onclick="myFunction()">Click me</button>
<script>
function myFunction() {
console.log('Clicked');
var device;
navigator.usb.requestDevice({ filters: [{ vendorId: 0x04e8 }] })
.then(selectedDevice => {
device = selectedDevice;
console.log('Deive Selected: ');
console.log(device.productName);
console.log(device.manufacturerName);
return device.open(); // Begin a session.
})
.catch(error => { console.log(error); });
}
</script>
</body>
The device.open()
call is returning
DOMException: The device was disconnected
I tested the code on Windows and Ubuntu machines with Chrome. Both gave the same result. Any help with the cause of the problem?