Chrome Version: 58.0.2991.0
What steps will reproduce the problem?
Execute code below:
navigator.bluetooth.requestDevice({filters: [{services: ['battery_service']}]})
.then(device => device.gatt.getPrimaryService('battery_service'))
.then(service => service.getCharacteristic('battery_level'))
.then(characteristic => characteristic.readValue())
.then(value => {
let batteryLevel = value.getUint8(0);
console.log('> Battery Level is ' + batteryLevel + '%');
})
.catch(error => {
console.log('Argh! ' + error);
});
}
What is the expected result?
An error message explains clearly what is happening...
I wish it would say something like "GATT Server is NOT connected. Please (re)connect first with `device.gatt.connect` to retrieve services".
What happens instead?
I get this error: "Argh! NetworkError: GATT Server is disconnected. Cannot retrieve services."
For info, I've seen real users having hard time figuring out what was wrong with their code when playing with Web Bluetooth. I believe this little tweak could improve their journey to solve this.
Comment 1 by scheib@chromium.org
, Jan 24 2017Status: Started (was: Untriaged)