Update WebBluetooth to use Promises

This commit is contained in:
Mátyás Mustoha 2016-09-15 10:44:17 +02:00 committed by Attila Dusnoki
parent fb52bb7c8d
commit e05a839d25
32 changed files with 684 additions and 458 deletions

View file

@ -52,19 +52,20 @@
function onButtonClick(testNumber) {
clear();
try {
log('Requesting Bluetooth Device...');
var device = window.navigator.bluetooth.requestDevice(testCases[testNumber]);
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice(testCases[testNumber])
.then(device => {
log('Found a device!');
log('> Name: ' + device.name);
log('> Id: ' + device.id);
log('> Appearance: ' + device.adData.appearance);
log('> Tx Power: ' + device.adData.txPower + ' dBm');
log('> RSSI: ' + device.adData.rssi + ' dBm');
} catch(err) {
})
.catch(err => {
log(err);
}
});
}
populate(testCases);