- From: zhangzhoufei via GitHub <sysbot+gh@w3.org>
- Date: Tue, 08 Sep 2020 16:23:02 +0000
- To: public-web-bluetooth-log@w3.org
**The same problem as the originator:
error:**
DOMException: Origin is not allowed to access the service. Tip: Add the service UUID to 'optionalServices' in requestDevice() options.
It's been bothering me for a long time
Please help me.
--------------------------------------------
```
navigator.bluetooth.requestDevice({
filters: [
{ namePrefix: 'play' }
],
optionalServices: [ "162348d9-d5a8-4870-8086-8e152fd06a92"]
}).then(device => {
console.log('Got device:', device.name);
return device.gatt.connect();
})
.then(server => {
return server.getPrimaryService("162348d9-d5a8-4870-8086-8e152fd06a92");
})
.then(service => {
})
.then(characteristic => {
})
.then(value => {
value = value.buffer ? value : new DataView(value);
console.log('Battery percentage:', value.getUint8(0));
})
.catch(exception => {
console.log(exception);
});
```
--
GitHub Notification of comment by zhangzhoufei
Please view or discuss this issue at https://github.com/WebBluetoothCG/web-bluetooth/issues/513#issuecomment-688990121 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Tuesday, 8 September 2020 16:23:04 UTC