Hi!
I'm fiddling around with the PCA10040 and the experimental_ble_app_blinky from the SDK found in examples/ble_peripheral/experimental_ble_app_blinky. I've had great success connecting through the nRF Blinky android app. The LED blink on the board when I click the app, and the app blink when i touch the button on the board. Awesome!
Now I'm trying to connect to the board using the web bluetooth api. dev.opera.com/.../
I'm still using experimental_ble_app_blinky, using the precompiled hex file from the SDK. And this little part of html/js. It is based on the article linked previous, and it is simplified to show the problem.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>web API test</title>
</head>
<body>
<button id="the-button">Connect</button>
<script>
const button = document.querySelector('#the-button');
button.addEventListener('click', function() {
navigator.bluetooth.requestDevice({
filters: [{
services: ['00001523-1212-efde-1523-785feabcd123']
}]
})
.then(device => {
console.log('Got device:', device.name);
console.log('id:', device.id);
return device.gatt.connect(); // Chromium 49 and below use `connectGATT()` but from Chromium 50 it will use gatt.connect();
})
.then(server => {
console.log('Getting primary service');
return server.getPrimaryService('00001523-1212-efde-1523-785feabcd123');
})
.then(service => {
console.log('Getting LED char');
return service.getCharacteristic('00001525-1212-efde-1523-785feabcd123');
})
.catch(exception => {
console.log(exception);
});
})
</script>
</body>
</html>
When I click the button, the output to the console looks like this:
Got device: Nordic_Blinky
id: 7lkNjG247R5lsY9Yp/yflw==
Getting primary service
The LED indicating advertising turns off and the LED indicating connection turns on. The board stays in this mode untill i close the web page.
My guess is that it is the call «server.getPrimaryService('00001523-1212-efde-1523-785feabcd123');» that fails, but I'm not sure why.
Anyone have an idea why this fails, or have a working example?