WebBluetoothCG / web-bluetooth

Bluetooth support for the Web.
http://www.w3.org/community/web-bluetooth/
Other
1.38k stars 187 forks source link

Is it possible to change Bluetooth device's name? #562

Closed nex314 closed 2 years ago

nex314 commented 2 years ago

As title, I want an unique to record which Bluetooth device was connected . Is it possible to change Bluetooth device's name?(I want to set a unique name) Have any API can do this? Or have any API can get connected Bluetooth device's MAC address?

thanks.

dlech commented 2 years ago

Getting the Bluetooth address is not possible for security/privacy reasons.

If the device supports writing the standard Device Name characteristic, then you can use that to change the name.

reillyeon commented 2 years ago

While the real Bluetooth address is not available for privacy reasons the Web Bluetooth API provides an id attribute which is an anonymized version of the address. In the default configuration Chromium-based browsers generate a new ID for every browsing session however if you enable about://flags/#enable-web-bluetooth-new-permissions-backend then the ID will be consistent between sessions. This new configuration is still being tested but should be shipped eventually.

As noted above, changing the device's advertised name is only possible if allowed by the device firmware.

nex314 commented 2 years ago

Thanks for yours kindly reply. Is it possible that the different computers generate a same ID when connect the same Bluetooth device?

reillyeon commented 2 years ago

No, different computers will always generate different IDs for the same device.