gniezen / webusb-uploader

Upload diabetes data using just the power of the web
BSD 2-Clause "Simplified" License
6 stars 4 forks source link

DOMException: The requested interface implements a protected class #1

Open Chakib-Temal opened 4 years ago

Chakib-Temal commented 4 years ago

hi

i used your code to connect my reader Freestyle libre & collect data in the server python : i removed this line httpd.socket = ssl.wrap_socket (httpd.socket, certfile='./newkey.crt', keyfile='./newkey.key', server_side=True)

because it's cause an exception : Traceback (most recent call last): File "simple-http-server.py", line 9, in <module> httpd.socket = ssl.wrap_socket (httpd.socket, certfile='./newkey.crt', keyfile='./newkey.key', server_side=True) File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 949, in wrap_socket ciphers=ciphers) File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 560, in __init__ self._context.load_cert_chain(certfile, keyfile) IOError: [Errno 2] No such file or directory but i think it's not a problem to do it , it just a certificat

i can contact my server, when i click in connect button , the reader appears in the list of devices

when i choose it , i have this exception :

webusb.js:70 An attempt to claim a USB device interface has been blocked because it implements a protected interface class. DOMException: The requested interface implements a protected class.

i run it in a OS X (mac os)

si any idea ? it's a cross platform library ? thank you

tomaks-moon commented 4 years ago

Hello,

Did you find any solution?

gniezen commented 4 years ago

Sorry, I somehow missed this when it was first asked. FreeStyle Libre is an HID-class device, which cannot be claimed by WebUSB. If you want to connect to it from the browser, you'll have to use WebHID. Lots of details about WebHID is available here: https://github.com/robatwilliams/awesome-webhid

If you want to connect to a FreeStyle Libre using Node.js instead, there's a working driver implemented here: https://github.com/tidepool-org/uploader/blob/master/lib/drivers/abbott/abbottFreeStyleLibre.js

tomaks-moon commented 4 years ago

According to webhid explainer on example section. It is possible to send report directly (to my freestyle libre for example). but I am confronted to an error

Uncaught Error: The error you provided does not contain a stack trace.

the following is my code to get fsl serial number

`const cmd = new Uint8Array([ 4, 3, 115, 110, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ]);

function handleInputReport(e) { console.log(e.device.productName + ": got input report " + e.reportId); console.log(new Uint8Array(e.data.buffer)); }

navigator.hid .requestDevice({ filters: [{ vendorId: 0x1a61 }] }) .then((devices) => { if (devices.length === 0) return; devices[0].open().then(() => { devices[0].addEventListener("inputreport", handleInputReport); devices[0].sendReport(0x01, cmd).then(() => { console.log("sent", cmd); }); }); });`

gniezen commented 4 years ago

I haven't used WebHID myself so I can't be of much help unfortunately. Keep in mind that you may need to initialise comms with the Libre before you request the serial number, see https://github.com/tidepool-org/uploader/blob/master/lib/drivers/abbott/freeStyleLibreProtocol.js#L723-L734

Somebody reverse-engineered the protocol and made it available here: https://protocols.glucometers.tech/abbott/freestyle-libre.html