Skip to content

Commit 9edaffe

Browse files
authored
Test for browser Web Bluetooth support
1 parent 721455f commit 9edaffe

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

BLESense-test-dashboard/index.html

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@
7575
<body>
7676

7777
<div class="container">
78+
<div class="label">&nbsp;&nbsp;IMPORTANT - first upload <a href="https://create.arduino.cc/editor/dpajak/e4128780-d76d-438f-97a4-541740cb0473/preview">sketch</a> to Arduino Nano 33 BLE Sense board<br></div>
7879
<div class="status widget">
79-
<button id="bigButton" onclick="connect()"></button>
80-
<div class="label">Arduino Nano 33 BLE Sense: </div>
81-
<div class="label" id="bluetooth">Click to connect</div>
80+
<button id="bigButton"></button>
81+
<div class="label" id="bluetooth">Click button to connect to the board</div>
8282
</div>
8383

8484
<div class="square widget" id="3d">
@@ -157,6 +157,8 @@
157157
enable the highlighted flag, and restart Chrome for now.
158158
*/
159159

160+
161+
160162
var maxRecords = 64;
161163

162164
var BLEsense =
@@ -241,6 +243,16 @@
241243
const bigButton = document.getElementById('bigButton');
242244
const BLEstatus = document.getElementById('bluetooth');
243245

246+
if ("bluetooth" in navigator) {
247+
bigButton.addEventListener('click', function(event) {
248+
connect();
249+
});
250+
// else the browser doesn't support bluetooth
251+
} else {
252+
msg("browser not supported"); bigButton.style.backgroundColor = "red";
253+
alert("Error: This browser doesn't support Web Bluetooth. Try using Chrome.");
254+
}
255+
244256
function msg(m){
245257
BLEstatus.innerHTML = m;
246258
}

0 commit comments

Comments
 (0)