node-poweredup/test.html
2019-02-09 11:15:33 -08:00

47 lines
1.1 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>node-poweredup Web Bluetooth Test</title>
<script src="./dist/browser/poweredup.js"></script>
<link rel="stylesheet" type="text/css" href="./test.css" />
<script>
const poweredUP = new PoweredUP.PoweredUP();
console.log("Looking for Hubs...");
poweredUP.on("discover", async (hub) => { // Wait to discover hubs
await hub.connect(); // Connect to hub
console.log(`Connected to ${hub.name}!`);
hub.on("disconnect", () => {
console.log("Hub disconnected");
})
});
const scan = async function () {
poweredUP.scan(); // Start scanning for hubs
}
</script>
</head>
<body>
<div><h1>Web Bluetooth node-poweredup Test Suite</h1></div>
<div>
<a class="button" href="#" onclick="scan();">Add new Hub</a>
</div>
<div>
<table id="log">
<thead class="headings"><td>Hub</td><td>Event</td><td>Port/Button</td><td>Values</td></thead>
<tr><td>NK_WeDo2_1</td><td>Attach</td><td>A</td><td>Train Motor</td></tr>
<tr><td>NK_WeDo2_1</td><td>Button</td><td>GREEN</td><td>Down</td></tr>
<tr><td>NK_WeDo2_1</td><td>Button</td><td>GREEN</td><td>Up</td></tr>
</table>
</div>
</body>
</html>