Cannot open the device if it is a composite device (with two interfaces) using webUSB APIs - webusb

I am using Chrome browser v72.0.3626.109(Official Build)(32-bit) on Windows 10.
Trying to claim a USB interface of a vendor specific composite USB device with 1 interface that is vendor specific and the other DFU runtime interface that loads a winusb driver.
I have ensured, that the vendor specific driver is not loaded, yet
opening the device via webUSB API device.open() fails with code:18 (SecurityError: Access denied.)
document.addEventListener('DOMContentLoaded', event => {
let button = document.getElementById('connect')
button.addEventListener('click', async() => {
let device
const VENDOR_ID = 0x04xx
const PRODUCT_ID = 0x6xxx
try {
device = await navigator.usb.requestDevice({
filters: [{
vendorId: VENDOR_ID,
productId: PRODUCT_ID
}]
})
await device.open(); //Begin a session
await device.selectConfiguration(1);
await device.claimInterface(0);
await device.releaseInterface(0);
await device.close();
} catch (error) {
console.log(error)
}
await device.close()
})
})
Other scenarios that I have tried...
My USB device comes up with only 1 interface (vendor specific bulk interface) and no drivers loaded. The device does not get listed in the device selection menu opened by requestDevice.
My USB device comes up with only 1 interface (DFU runtime interface) with winusb driver loaded. The device gets listed, opened and claim inteface can work using webUSB API.
Is there a restriction to list and open a vendor specific USB device using webUSB APIs? Anything that I am missing?

The vendor specific interface can be opened with WebUSB but the WinUSB driver needs to be loaded against it. This is a requirement from the Windows API that the browser uses to open the device.

Related

Button is not showing in Google Nest devices but showing properly in Mobile Assistant

I am using google actions for one of our clients. We are using Button to navigate the user to a specific URL but Button is not showing in the Nest devices, but it is showing fine in Mobile Assistant devices.
Anyway, where we can enable the same?
Also if there is no option, what is the way to identify if the user logged in the device has button functionality enabled?
Buttons that link to a webpage are not available on smart displays. In the platform different devices have certain limitations. As such, the device running the action sends capabilities that define what is possible. You will need to check for the WEB_LINK capability.
In the Node.js library this would be done as such:
app.handle('handle-name', conv => {
const supportsWebLink = conv.device.capabilities.includes('WEB_LINK')
if (!supportsWebLink) {
// Behavior for Nest Hub and other devices
}
})
I see you have the dialogflow-es tag rather than actions-builder, so to do it in Dialogflow:
app.intent('intent-name', conv => {
const supportsWebLink = conv.device.capabilities.includes('WEB_LINK')
if (!supportsWebLink) {
// Behavior for Nest Hub and other devices
}
})

Is reading a NFC chip as a web app possible

I'd like to use Vaadin to create a web app in Java that reads a NFC chip to identify the user and then proceeds with other options, is that possible?
My reason why I don't want to do that in an android app is to decentralize myself to perform the same work for multiple versions and/or different systems
The Web NFC API is what you're looking for: https://web.dev/nfc
Web NFC is available only on Chrome for Android for now. It is limited to NDEF because the security properties of reading and writing NDEF data are more easily quantifiable. Low-level I/O operations (e.g. ISO-DEP, NFC-A/B, NFC-F), Peer-to-Peer communication mode and Host-based Card Emulation (HCE) are not supported.
Here's a sample for you to play with: https://googlechrome.github.io/samples/web-nfc/
const ndef = new NDEFReader();
await ndef.scan();
ndef.addEventListener("reading", ({ message, serialNumber }) => {
console.log(`> Serial Number: ${serialNumber}`);
console.log(`> Records: (${message.records.length})`);
});

Can't check output devices like speaker in Mozilla browser through WebRTC API

I want to check the output devices like speakers etc through WebRTC API. I've implemented the below code in Angular 5 and Node.
The WebRTC link is:
https://www.webrtc-experiment.com/DetectRTC/
// for node.js users
var DetectRTC = require('detectrtc');
// non-nodejs users can skip above line
// below code will work for all users
console.log(DetectRTC.browser);
DetectRTC.load(function() {
console.log(DetectRTC);
});
In Angular 5, the output devices e.g. Speaker status can be detected however, in Mozilla it says NOPE in "System has Speakers?" (see screen shot). In Node, everything is showing false / NOPE in mozilla / chrome browsers.
How can I detect the output devices e.g. Speaker in Mozilla for Angular? How can I detect all the status in Node?
Please note, the following code in JS also shows me the same output:
navigator.mediaDevices.enumerateDevices().then((devices) => {
console.log(devices);
devices = devices.filter((d) => d.kind === 'audioinput');
console.log(devices);
});
The setSinkId API which is behind this functionality is not implemented in Firefox. bugzilla has the details.

Web Bluetooth API get list of all available device nearby

I am looking for an API call that could be used to retrieve all the Bluetooth devices near me. These samples Web Bluetooth talk about getting different characteristics from a single Bluetooth device, however I couldn't find any example which retrieves all the Bluetooth devices(like available bluetooth devices list on windows native Bluetooth app). Is it even supported?
(Well, this question sent me down a rabbit hole...)
It's a couple years later and we're starting to signs of life from api.Bluetooth.getDevices. I eventually got an experimental demo working in Chrome.
You'll probably need to enable Chrome's "Web Bluetooth experiment". (Firefox has an equivalent but I didn't try it.)
Go to chrome://flags/ then search for bluetooth and enable the API.
Click the buttons on the demo page: Web Bluetooth / Get Devices Sample
Demo code from the same page:
function onGetBluetoothDevicesButtonClick() {
log('Getting existing permitted Bluetooth devices...');
navigator.bluetooth.getDevices()
.then(devices => {
log('> Got ' + devices.length + ' Bluetooth devices.');
for (const device of devices) {
log(' > ' + device.name + ' (' + device.id + ')');
}
})
.catch(error => {
log('Argh! ' + error);
});
}
function onRequestBluetoothDeviceButtonClick() {
log('Requesting any Bluetooth device...');
navigator.bluetooth.requestDevice({
// filters: [...] <- Prefer filters to save energy & show relevant devices.
acceptAllDevices: true
})
.then(device => {
log('> Requested ' + device.name + ' (' + device.id + ')');
})
.catch(error => {
log('Argh! ' + error);
});
}
Good luck!
I personally haven't experimented with Web Bluetooth API a lot, but I think you're looking for Device Discovery and Request Bluetooth Devices:
This version of the Web Bluetooth API specification allows websites,
running in the Central role, to connect to remote GATT Servers over a
BLE connection. It supports communication among devices that implement
Bluetooth 4.0 or later.
When a website requests access to nearby devices using
navigator.bluetooth.requestDevice, Google Chrome will prompt user with
a device chooser where they can pick one device or simply cancel the
request.
The navigator.bluetooth.requestDevice function takes a mandatory
Object that defines filters. These filters are used to return only
devices that match some advertised Bluetooth GATT services and/or the
device name.
Also, here's the list of GATT
Services.
A Web Bluetooth Scanning specification draft exists, but implementation isn't started anywhere as of 2018.

write peripheral.name Xcode

I have an app that connects to a bluetooth LE peripheral. Is it possible to change the peripheral's name from the app. In other words I want to rewrite the peripherals localized name from the central device. I can get the name through the advertised data and only connect to the peripheral if it have a certain name. but I would like the user to be able to change the peripheral's name so only they can connect to that specific peripheral from the app.
I'm not sure if my peripheral allows it or not. How would I check and How would I write the new name??
I have used the following code to get the service device information and then to get the manufacturers name
if([service.UUID isEqual:[CBUUID UUIDWithString:#"180A"]]) {
for (CBCharacteristic *characteristic in service.characteristics) {
NSLog(#"discovered characteristic %#", characteristic.UUID);
if([characteristic.UUID isEqual:[CBUUID UUIDWithString:#"2A29"]]) {
NSLog(#"Found Notified Characteristic %#", characteristic);
self.mycharacteristic2 = characteristic;
[self.testPeripheral setNotifyValue:YES forCharacteristic:characteristic];
[self.testPeripheral readValueForCharacteristic:mycharacteristic2];
NSLog(#"value:%#",mycharacteristic2.value);
}
} NSLog(#"services%#",service);}
however if I substitute 2A00 (which is supposed to be the UUID for the device Name) I get nothing.
I have also tried to use 1800 for generic access and 1801 for generic information but I don't get any response for the device name 2A00.
I do get a log that 1801 is Device information but no information for 2A00 which is supposed to be Device Name. Does anyone know how to access the Device Name characteristic UUID?
You need to check the properties property of the characteristic. You'd be looking for CBCharacteristicPropertyWrite.
Also, are you absolutely sure the peripheral supports 2A00? Try using the app LightBlue to browse all the available services and chacteristics.

Resources