- From: Jeffrey Yasskin via GitHub <sysbot+gh@w3.org>
- Date: Fri, 12 Aug 2016 22:09:28 +0000
- To: public-web-bluetooth-log@w3.org
Yes, folks will need to write a custom `connect()` function that discovers the attributes they need on each connection. Something like: ```js let device; let characteristic; function reconnect() { if (device.gatt.connected) return Promise.resolve(); return device.gatt.connect() .then(server => server.getPrimaryService('battery_service')) .then(service => service.getCharacteristic('battery_level')) .then(char => { characteristic = char; }); } function doSomething() { let dp = Promise.resolve(); if (!device) { dp = navigator.bluetooth.requestDevice({ filters: [{ services: ['battery_service'] }] }) .then(d => device = d.gatt.connect()); } return dp.then(() => reconnect()) .then(_ => characteristic.readValue()); } ``` -- GitHub Notification of comment by jyasskin Please view or discuss this issue at https://github.com/WebBluetoothCG/web-bluetooth/pull/273#issuecomment-239571741 using your GitHub account
Received on Friday, 12 August 2016 22:09:35 UTC