INKBIRD IBS-TH2 Plus について Bluetooth の GATT と BLE advertisements から参照すればよいことが分かったので、今を時めく Web Bluetooth API を使って、Web Browser 単体でこれを取れないかと思い、Microsoft Copilot 先生に聞いた結果が以下。
で、これ成功はして、開いているページが知覚の Bluetooth デバイスのスキャンを求めているが許可するかどうか聞いてくるので、許可すると、BLE Advertising がずらずらと表示された。

ところが、navigator.bluetooth.requestLEScan() の説明が MDN にもない。
「navigator.bluetooth.requestLEScan()」でググってみると以下のページを見つけた。
曰く、以下に情報があるとの事。
とりあえず、
ID: xxxxxxxxxxxxxxxxxxxxxx== を base64 decode しても
Copilot 曰く、個人追跡に使えるため、Web Bluetooth API では
同じデバイスでもセッション毎にIDが変わってしまうらしい。
- Microsoft Copilot / 2026-05-08: Web BluetoothでBLE広告取得
- chrome://flags/#enable-experimental-web-platform-features
Experimental Web Platform features Enables experimental Web Platform features that are in development. – Mac, Windows, Linux, ChromeOS, Android #enable-experimental-web-platform-featuresを
- 停止中 → 有効
const scan = await navigator.bluetooth.requestLEScan({
keepRepeatedDevices: true,
acceptAllAdvertisements: true
});
navigator.bluetooth.addEventListener('advertisementreceived', event => {
console.log("Device:", event.device.name || "(no name)");
console.log("ID:", event.device.id);
console.log("RSSI:", event.rssi);
for (const [companyId, dataView] of event.manufacturerData) {
console.log(`Manufacturer 0x${companyId.toString(16)}:`,
[...new Uint8Array(dataView.buffer)]);
}
});
みたいにしてみろとの事。で、これ成功はして、開いているページが知覚の Bluetooth デバイスのスキャンを求めているが許可するかどうか聞いてくるので、許可すると、BLE Advertising がずらずらと表示された。

ところが、navigator.bluetooth.requestLEScan() の説明が MDN にもない。
「navigator.bluetooth.requestLEScan()」でググってみると以下のページを見つけた。
- Qiita / @youtoy / 2021-05-16: Updated: 2021-05-17: SwitchBot温湿度計のデータを Web Bluetooth API で取得する:【未完】準備や試行錯誤のメモ
曰く、以下に情報があるとの事。
- Web Bluetooth API / Web Bluetooth Scanning
- GitHub / WebBluetoothCG / web-bluetooth / implementation-status.md # Scanning API
とりあえず、
const scan = await navigator.bluetooth.requestLEScan({
keepRepeatedDevices: true,
filters: [{name: ["sps"]}]
});
navigator.bluetooth.addEventListener('advertisementreceived', event => {
console.log("Device:", event.device.name || "(no name)");
console.log("ID:", event.device.id);
console.log("RSSI:", event.rssi);
for (const [companyId, dataView] of event.manufacturerData) {
console.log(`Manufacturer 0x${companyId.toString(16)}:`,
[...new Uint8Array(dataView.buffer)]);
}
for (const [uuid, dataView] of event.serviceData) {
console.log(`Service 0x${uuid.toString(16)}:`,
[...new Uint8Array(dataView.buffer)]);
}
});
みたいにすることでDevice: sps ID: xxxxxxxxxxxxxxxxxxxxxx== RSSI: -69 Manufacturer 0xbad: (7) [160, 15, 0, 142, 46, 42, 8]0: 1601: 152: 03: 1424: 465: 426: 8length: 7[[Prototype]]: Array(0)が得られたんだけど、
ID: xxxxxxxxxxxxxxxxxxxxxx== を base64 decode しても
$ bluetoothctl scan on [NEW] Device xx:xx:xx:xx:xx:xx sps [CHG] Device xx:xx:xx:xx:xx:xx RSSI: -48 [CHG] Device xx:xx:xx:xx:xx:xx ManufacturerData Key: 0x0bbd [CHG] Device xx:xx:xx:xx:xx:xx ManufacturerData Value: a1 0f 00 1e 2d 2a 08 ....-*.で得られる MAC アドレスと一致しない。
Copilot 曰く、個人追跡に使えるため、Web Bluetooth API では
- MAC アドレスの露出
- デバイスの永続的識別子の露出
同じデバイスでもセッション毎にIDが変わってしまうらしい。
と言うことで
const scan = await navigator.bluetooth.requestLEScan({
keepRepeatedDevices: true,
filters: [{name: ["sps"]}]
});
navigator.bluetooth.addEventListener('advertisementreceived', event => {
console.log("Device:", event.device.name || "(no name)");
console.log("ID:", event.device.id);
console.log("RSSI:", event.rssi);
for (const [key, value] of event.manufacturerData) {
console.log(`Temperature : ${(key<<16>>16) / 100} ℃`);
console.log(`Humidity : ${value.getInt16(0, true) / 100} %`);
console.log(`Battery : ${value.getInt8(5)} %`);
}
});
とすればDevice: sps ID: xxxxxxxxxxxxxxxxxxxxxx== RSSI: -68 Temperature : 29.78 ℃ Humidity : 39.56 % Battery : 42 %が得られた。
タグ

コメントをかく