Forget already paired device - web-bluetooth - javascript

I am working on web-bluetooth to connect a Web-App with BLE device. I have the connections now, I am looking how can I unpair a device.
I have looked into the official web-bluetooth documents
https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-getdevices haven't find much about it.
Can anybody suggest something on this?
Thanks

What a coincidence! I am currently working on adding a new forget() method on BluetoothDevice so that web developers can revoke permission access to a paired BluetoothDevice.
// Request a Bluetooth device.
const device = await navigator.bluetooth.requestDevice({ acceptAllDevices: true });
// Then later... revoke permission to the Bluetooth device.
await device.forget();
Spec PR: https://github.com/WebBluetoothCG/web-bluetooth/pull/574
Chromium CL: https://bugs.chromium.org/p/chromium/issues/detail?id=1302328
Note that this experimental functionality is currently available in Chrome 101 and requires users to enable the chrome://flags/#enable-web-bluetooth-new-permissions-backend flag.
You can try my sample at https://bluetoothdevice-forget.glitch.me/

Related

Can a DigitalPersona USB fingerprint scanner be used directly in the browser using only JavaScript?

I can access a DigitalPersona 4500 with the following code :
navigator.usb.requestDevice({ filters: [{ vendorId: 0x05ba }] })
.then(device => {
console.log(device.productName); // "VM56:3 U.are.U® 4500 Fingerprint Reader"
console.log(device.manufacturerName); // "VM56:4 DigitalPersona, Inc."
// ...
})
.catch(error => { console.error(error); });
Now, is it possible to open the device and start scanning?
(Disclaimer: I do not have access to the DP SDK because the devices I have access to were bought before I was hired, from some third party vendor and, after contacting them, they did not provide me with any support. The devices work just fine, so there are no plans to throw them away and replace them.)
Related questions
Finger print scanner with webusb
With WebUSB, without clear documentation for the "DigitalPersona 4500" device and what USB commands this device supports, it's really hard but still possible with lucky guessing. I strongly recommend getting the device.
Check out https://web.dev/devices-introduction/ for tips on how do this.
TLDR;
Watch Exploring WebUSB and its exciting potential from Suz Hinton.
You can also reverse-engineer this device by capturing raw USB
traffic and inspecting USB descriptors with external tools like
Wireshark and built-in browser tools such as the internal page
about://usb-internals in Chromium-based browsers.

Outlook getAccessTokenAsync errorcode:13003 on desktop

I am trying to create an Outlook Add-in, but have a problem.
The Office library returned an error when I called Office.context.auth.getAccessTokenAsync running on Outlook for the desktop.
But when I run this program on the web version (Office365) it is working without problems.
How to get AccessToken on Outlook for the desktop?
Office.initialize = function () {};
function testfunction(event) {
Office.context.auth.getAccessTokenAsync(function (result) {
if (result.status === "succeeded") {
//...
}
})
}
Error:
code:13003
message:The identity type of the user is not supported
Using Outlook 2016 (15.0.9126.2152) on Windows 10 Pro.
From the documentation:
13001
The user is not signed into Office. Your code should recall the getAccessTokenAsync method and pass the option forceAddAccount: true in the options parameter. But don't do this more than once. The user may have decided not to sign-in.
This error is never seen in Office Online. If the user's cookie expires, Office Online returns error 13006.
With Outlook, in particular, you will see this using an Outlook.com account (MSA isn't currently supported). You may also get a 13001 if you're using an on-prem Exchange Server without "modern auth" enabled. If this is the case, you will need to enable modern auth to resolve the error.
Please note that your desktop Outlook 2016(15.0.9126.2152) is the MSI (non-subscription) version. getAccessTokenAsync is not supported on that version.

How to pair a new Bluetooth device from a Chrome App on ChromeOS?

I'm writing a Chrome App using the chrome.bluetooth Javascript API and PNACL. I can turn on Bluetooth discovery, find devices, connect, and communicate successfully. But I cannot figure out how to pair a new device programmatically from my app.
There are Windows and Mac system APIs for this; is there an equivalent on ChromeOS?
Use the chrome.bluetooth API to connect to a Bluetooth device which works only on OS X, Windows and Chrome OS. All functions report failures via chrome.runtime.lastError.
You may make your chrome app connect to any device that supports RFCOMM or L2CAP services and that includes the majority of classic Bluetooth devices on the market.
As detailed in Chrome - Bluetooth, there are three things you need to make a connection to a device:
A socket to make the connection with, created using bluetoothSocket.create
the address of the device you wish to connect to
the UUID of the service itself.
Sample code implementation:
var uuid = '1105';
var onConnectedCallback = function() {
if (chrome.runtime.lastError) {
console.log("Connection failed: " + chrome.runtime.lastError.message);
} else {
// Profile implementation here.
}
};
chrome.bluetoothSocket.create(function(createInfo) {
chrome.bluetoothSocket.connect(createInfo.socketId,
device.address, uuid, onConnectedCallback);
});
Please note too that before making the connection, you should verify that the adapter is aware of the device by using bluetooth.getDevice or the device discovery APIs.
More information and sample code implementations can be found in the documentation.

Using Notification API for Electron App

How to implement Notification API on Electron App?
I tried checking Notification.permission and it returns granted
But when I try to run:
new Notification("FOO", {body:"FOOOOOOOOOOOOOOOOOOOOOOOOO"});
nothing happens. Is it even supported?
A good approach is use node-notifier for notifications, because the package have cross-platform notification support
Note: Since this is an HTML5 API it is only available in the renderer process.
Example :
let myNotification = new Notification('Title', {
body: 'Lorem Ipsum Dolor Sit Amet'
})
myNotification.onclick = () => {
console.log('Notification clicked')
}
Windows
On Windows 10, notifications "just work".
On Windows 8.1 and Windows 8, a shortcut to your app, with a Application User Model ID, must be installed to the Start screen. Note, however, that it does not need to be pinned to the Start screen.
On Windows 7, notifications are not supported. You can however send "balloon notifications" using the Tray API.
Furthermore, the maximum length for the notification body is 250 characters, with the Windows team recommending that notifications should be kept to 200 characters.
More information : https://github.com/electron/electron/blob/master/docs/tutorial/desktop-environment-integration.md#notifications-windows-linux-os-x
The HTML5 Notification API is only available in the renderer process.
You must require the Electron Notification API if you want to use notifications from the main process. The API is different from the standard/HTML5 version.
const {Notification} = require('electron');
new Notification({
title: 'Headline',
body: 'Here write your message'
}).show();
The notification API doesn't work on Windows, because there is no notification API that works on all versions of Windows (really Win10 is the first version where desktops have a documented API for it, Win8.x had it but it was WinRT-only)
Posting an updated answer that Electron has a section in their tutorial for their Notifications and about how to handle Windows
Windows
On Windows 10, a shortcut to your app with an Application User Model ID must be installed to the Start Menu. This can be overkill during development, so adding node_modules\electron\dist\electron.exe to your Start Menu also does the trick. Navigate to the file in Explorer, right-click and 'Pin to Start Menu'. You will then need to add the line app.setAppUserModelId(process.execPath) to your main process to see notifications.
On Windows 8.1 and Windows 8, a shortcut to your app with an Application User Model ID must be installed to the Start screen. Note, however, that it does not need to be pinned to the Start screen.
On Windows 7, notifications work via a custom implementation which visually resembles the native one on newer systems.
Electron attempts to automate the work around the Application User Model ID. When Electron is used together with the installation and update framework Squirrel, shortcuts will automatically be set correctly. Furthermore, Electron will detect that Squirrel was used and will automatically call app.setAppUserModelId() with the correct value. During development, you may have to call app.setAppUserModelId() yourself.
Furthermore, in Windows 8, the maximum length for the notification body is 250 characters, with the Windows team recommending that notifications should be kept to 200 characters. That said, that limitation has been removed in Windows 10, with the Windows team asking developers to be reasonable. Attempting to send gigantic amounts of text to the API (thousands of characters) might result in instability.
for window 7, you might try this: https://github.com/blainesch/electron-notifications - it generates 'desktop' notifications as separate electron windows. It looks pretty slick; I'm about to implement it now. I believe you'll need to use something like https://github.com/electron/electron/blob/master/docs/api/ipc-main.md to communicate between your app and the main electron process which would be responsible for displaying and managing the notifications, unless your main electron process is already responsible for the notification logic.
use
const notification = new window.Notification(
'LO SIENTO OCURRIO EL ERROR:',
{
body: error,
}
);
notification.onclick = () => console.log('Clicked');
notification.onclose = () => console.log('Closed');

RTCIceCandidate instance cannot be created in browsers on moblie devices

I'm recently trying some awesome features of HTML5 and WebRTC, and am building a site to allow multiple people video chat.
Everything works just fine on my PC and the Media Capture of HTML5 works like a charm. But when I set up a video source on my PC, and try to connect to it via my android/iphone/ipad, it just did not work. I checked the logs, it suggests that the creation of RTCIceCandidate failed for some unknown reason:
// To be processed as either Client or Server
case "CANDIDATE":
trace("************important*********", "we get in");
var candidate = new RTCIceCandidate({candidate: msg.candidate});
trace("************important*********", JSON.stringify(candidate));
break;
turns out the second log never shows up.
Anyone has any idea? Is is because such features are not available on mobile devices for now? Or should I do something specially for mobile devices?
oh and this is the callback of IceCandidatem which is never called:
// This function sends candidates to the remote peer, via the node server
var onIceCandidate = function(event) {
if (event.candidate) {
trace("openChannel","Sending ICE candidate to remote peer : " + event.candidate.candidate);
var msgCANDIDATE = {};
msgCANDIDATE.msg_type = 'CANDIDATE';
msgCANDIDATE.candidate = event.candidate.candidate;
msgCANDIDATE.peer = server;
msgCANDIDATE.me = weAreActingAs;
//trace("openChannel","candidate peer : " + JSON.stringify(event));
socket.send(JSON.stringify(msgCANDIDATE));
} else {
trace("onIceCandidate","End of candidates");
}
}
The server is in nodejs.
Thanks so much guys! Need your hands!
You should be able to test device support here: http://www.simpl.info/getusermedia/
I'm no expert on webrtc but according to the following site there should be supported for IOS and Android: http://updates.html5rocks.com/2012/12/WebRTC-hits-Firefox-Android-and-iOS but you'll need to use the ericsson browser
In one of the comments it does say that ericsson browser uses the depreciated ROAP signaling and can't be used in peer communication with (for example) Chrome. One comment states that blackbarry native browser now supports getUserMedia so maybe Android and iOS will follow. No native support at the moment though. And ericsson browser implementation seems to be based on depreciated standards.

Categories