I'm trying to use a card reader (https://www.ewent-online.com/tcpdf/pdf/ew/p/EW1052/) to read a Health Card.
This is the code (copy-pasted from the official doc: https://developers.google.com/web/updates/2016/03/access-usb-devices-on-the-web):
var device;
navigator['usb'].requestDevice({ filters: [] })
.then(selectedDevice => {
device = selectedDevice;
return device.open(); // Begin a session.
})
.then(() => device.selectConfiguration(1)) // Select configuration #1 forhe device.
.then(() => device.claimInterface(0)) // Request exclusive control over interface #2.
.then(() => device.controlTransferOut({
requestType: 'class',
recipient: 'interface',
request: 0x22,
value: 0x01,
index: 0x00}
)) // Ready to receive data
.then(() => device.transferIn(5, 64)) // Waiting for 64 bytes of data from endpoint #5.
.then(result => {
let decoder = new window['TextDecoder']();
console.log('Received: ' + decoder.decode(result.data));
})
.catch(error => {
console.log(error);
});
The error is here:
device.claimInterface(0)
For some reason i can't access at the class. I can't figure out hot to make it work, i have read alla stackoverflow related thread without found a solution.
Thanks in advance!