Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: third_party/WebKit/LayoutTests/resources/bluetooth/heart-rate-iframe.html

Issue 2648583004: bluetooth: Stop firing value changed events after gatt disconnects (Closed)
Patch Set: Make iframe subscribe to notifications and add comments. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script>
3 let device;
4 window.onmessage = messageEvent => {
5 if (messageEvent.data === 'RequestAndConnect') {
6 navigator.bluetooth.requestDevice({
7 filters: [{services: ['heart_rate']}]
8 })
9 .then(device => device.gatt.connect())
10 .then(gattServer => {
11 device = gattServer.device;
12 parent.postMessage('Connected', '*');
13 }).catch(err => {
14 console.error(err);
15 parent.postMessage('FAIL: ' + err, '*');
16 });
17 } else if (messageEvent.data === 'StartNotifications') {
18 device.gatt.getPrimaryService('heart_rate')
19 .then(service => service.getCharacteristic('heart_rate_measurement'))
20 .then(char => char.startNotifications())
21 .then(char => {
22 char.addEventListener('characteristicvaluechanged', function() {});
23 parent.postMessage('NotificationsStarted', '*');
24 });
25 }
26 };
27 parent.postMessage("Ready", "*");
28 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698