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.
Related
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
}
})
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})`);
});
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.
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.
I work on own specialized VoIP client for W10 mobile & desktop. Basic things work ok.
However I cannot get audio output to speakers on my old Lumia.
foreach (var item in (await DeviceInformation.FindAllAsync(DeviceClass.AudioRender)).Where(i => i.Name.Contains("Speakers")))
RendererId = item.Id;
There is "Speakers (WaveRT)" in device list so RendererId is valid.
Later application tries to open audio device (WSAPI) with found RendererId. But anyway phone plays to receiver only.
I modified Voip sample app in attempt to reproduce issue - yes, it happens with Voip sample app also.
My collegue confirms he has same problem on his phone.
Is it possible to play audio via speaker for voip app ?
Thank you!
On the Phone devices only, you can use the AudioRoutingManager to change the audio output.
// to get the audio manager
IsAudioRoutingSupported = ApiInformation.IsApiContractPresent(typeof(PhoneContract).FullName, 1);
if(IsAudioRoutingSupported)
{
// audio routing is supported, we register for the output change events
m_audioRoutingManager = AudioRoutingManager.GetDefault();
m_audioRoutingManager.AudioEndpointChanged += OnAudioEndpointChanged;
}
// to change to output
m_audioRoutingManager.SetAudioEndpoint(AudioRoutingEndpoint.Speakerphone);