Chrome Web Serial no compatible device found on MacOS - javascript

I am trying to connect to an ANT+ usb stick using Web Serial API in Google Chrome.
On linux (Ubuntu) it works out of the box, but on MacOS (v12.1) the device doesn’t show up into the search box. It does show up when using the web-serial-polyfill, but it is unfinished and missing features, and since the navigator.serial is present I wish to avoid using the polyfill.
var port = await navigator.serial.requestPort({ filters: [{ usbVendorId: 4047 }]});
Gets me ‘No compatible device found’. Requesting without params shows other devices, but not the ANT+ stick.
Any ideas why is that?

Related

access web serial api in android chrome browser

using web serial API in windows, mac os, and Linux chrome browser I can receive and send data. but in the android chrome browser, I am not able to send or receive data from a serial device.
so which API is used to read and write data to serial devices in the android chrome browser.
also, there is a polyfill serial API for android chrome but is showing an error shown in the image.
The team that built the implementation of the Web Serial API in Chromium also wrote a polyfill library which uses WebUSB to support platforms which don't provide built-in serial drivers: https://github.com/google/web-serial-polyfill
It looks like you are already trying to use this library. Can you file an issue on the library's GitHub project so the team can look at the error you're seeing?
Note, it seems like there are some Android devices which have USB serial drivers that end up blocking WebUSB from claiming interfaces even though the platform doesn't let apps actually use them. https://crbug.com/1099521 is tracking a workaround for that.

WebUSB `USBDevice.configurations` differs across platforms

I'm setting up a connection between a webpage and a thermal printer over WebUSB.
On my laptop (Mac, Chrome 91), the result is as expected: a device shows up, I can open it and select some configuration.
When trying to connect my phone (Android, Chrome 91) to the thermal printer however, the WebUSB object has no configurations available for me to select, and thus I cannot use the printer there.
How could it be that the same USBDevice has different configurations on MacOS and Android?
Code to reproduce:
const device = await navigator.usb.requestDevice({ filters: [{}] });
console.log(device.configurations);
This logs [USBConfiguration] on MacOS and [] on Android (when selecting thermal printer CITIZEN CT-E651).
I have searched throughout the issues of the WebUSB specification, but couldn't find an answer to this question not a solution there.
This is likely a bug in Chrome. Please file an issue report in the project issue tracker. To help collect more information please include any log output that is shown in chrome://device-log on the Android device after calling requestDevice().
To compare against the behavior on macOS please, on your macOS device, visit chrome://usb-internals, click the "Devices" tab, find your device and click the "Inspect" button and then click the "Get Configuration Descriptor" button and attach a screenshot of the resulting page to the issue you file.

Chrome WebUSB not recognizing devices (CAC cards, smart cards)

I have made a script to load all of the USB devices connected to Chrome using chrome.usb.getDevices. So far, it has listed a second-generation iPod touch as well as a mouse, keyboard, and two unknown items from Intel. However, it has not recognized any USB flash drives, and it does not recognize any Smart Cards that I have. I've also installed Chrome's Smart Card Connector app into Chrome, but I can still not get Chrome to recognize these Smart Cards. I can't continue to use Java nor ActiveX to for smartcard interactions in the browser. How can I get CAC/smartcard authentication through the browser without having to install a slew of other dependencies?
Edit: I also installed WinUSB as their drivers in place of their default HID drivers, but the results remained.
This Chrome USB Devices states that not all USB devices are supported and can be read:
Caveats
Not all devices can be accessed through the USB API. In general,
devices are not accessible because either the Operating System's
kernel or a native driver holds them off from user space code. Some
examples are devices with HID profiles on OSX systems, and USB pen
drives.
On most Linux systems, USB devices are mapped with read-only
permissions by default. To open a device through this API, your user
will need to have write access to it too. A simple solution is to set
a udev rule. Create a file /etc/udev/rules.d/50-yourdevicename.rules
with the following content:
SUBSYSTEM=="usb", ATTR{idVendor}=="[yourdevicevendor]", MODE="0664", GROUP="plugdev"

Chrome Extension w/ Serial and Page Action

Currently, I have created a Chrome App that gets data from a serial connection using the Chrome App Serial API. My goal is to inject this data into a web page. I know this is capable with Chrome Extensions, but the issue there is that Chrome Extensions aren't capable of accessing the serial data on it's own. I also would like to use an Extension instead of an App because the Chrome Apps aren't going to be supported starting this year.
The only option I could think of is to use a Chrome App to get the serial data, send the data to an Extension, and then inject the data into a web page. This is definitely not preferable though. Besides the Chrome Apps not being supported, except for Chrome OS, I wouldn't like to have to have a user download the extension and the app just to implement this.
My preferred method would to have an Extension access the serial devices. Is this possible and/or is it going to possible in the future? If not, why?
Thanks in advance!

How to initiate a new device pairing using the Chrome web bluetooth API?

Using navigator.bluetooth.requestDevice(), I can access bluetooth devices I've already set up a pair with using native OSX bluetooth pairing, but no previously-unpaired devices appear, even when their attributes match my generic query. Available devices show up in a Chrome modal requesting user consent to pair, but the only device that shows up is the one I've already paired with.
Am I misunderstanding the intended use case here, or is there another way to establish a connection with a nearby (previously unpaired) device from Chrome?
Docs: https://webbluetoothcg.github.io/web-bluetooth/
(See Example 2)
function bluetoothConnect() {
navigator.bluetooth.requestDevice({filters: [{services: ['generic_access']}]})
.then(device => {console.log(`Connected to: ${device.name}`)})
.catch(console.error);
}
First, Mac OS X is not yet fully implemented as we speak. Only discovery and GATT server connect/disconnect are working for now. See the Chrome Implementation status at https://github.com/WebBluetoothCG/web-bluetooth/blob/gh-pages/implementation-status.md. Check out Chrome OS, Linux and Android M (Android Lollipop workaround).
Regarding your specific issue, I believe that generic_access is not broadcasted by a nearby BLE device but is found because you've already paired (cached) this device. If your device is named "foo" for instance, you can go to https://googlechrome.github.io/samples/web-bluetooth/device-info.html and fill "foo" as the Device Name and hit "Get Bluetooth Device Info" button.
I would recommend you give a try to all Web Bluetooth samples at https://googlechrome.github.io/samples/web-bluetooth/index.html as well.
To complement the other answer, please be aware of the Chrome's chrome://bluetooth-internals tab/tool. This tool can not only list available devices and their services (which I don't think you can do with the Web Bluetooth API unless you requested the services in optionalServices or filters/services) and the characteristics of those services.
In the device list, there is a Forget button which becomes active once you connect to the devices GATT server using the Inspect button. This should allow you to full unpair and pair again in cases where you need to test the flow end to end.
Edit: Actually after doing some experimentation around this, the device still remains paired even after using the Forget button. Probably a bug in Chrome, however, the cache of the paired devices seems to be per-profile. This means the real answer is to:
Use the Incognito mode and in there the pairing flow will initiate from the get-go for each new Incognito session.

Categories

Resources