HTML5の新しいAPIの中でも特に先進的なAPIがWeb Bluetoothです。Google Chrome60以降、Androidのブラウザでも56以降でしかサポートされていないAPIになります。しかしWebブラウザがBluetooth通信をサポートする各種デバイスと通信できることで様々な使い道が考えられます。 今回はそんなWeb Bluetoothの簡単な使い方を紹介します。 コードについて Web Bluetoothを扱う場合にはPromise処理が連続して行われます。例えば今回はバッテリーレベルを取得します。 まずWeb Bluetoothをサポートしているかどうかは navigator.bluetooth の有無で判定します。 This file contains bidirectional Unicode text that may be interpreted or com
![WebブラウザからBluetooth接続できるWeb Bluetoothを試す](https://cdn-ak-scissors.b.st-hatena.com/image/square/8855f190cc412ba814be2cd558ab3851afe2fb8b/height=288;version=1;width=512/https%3A%2F%2Fblog.htmlhifive.com%2Fwp-content%2Fuploads%2F2017%2F10%2Fwebbluetooth-2.png)