2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Ubuntu20.04 で Web Bluetooth

Posted at

最近はデスクトップPC でも BLE を使う環境が揃ってきている。
今回は、Ubuntu20.04 で Web Bluetooth を使えるようにするお話。

環境

  • Ubuntu 20.04 AMD64
  • blueZ 5.53
  • chrome バージョン: 86.0.4240.111(Official Build) (64 ビット)
  • chromium バージョン: 86.0.4240.111(Official Build)snap (64 ビット)

対応状況

「Implementation Status」
https://github.com/WebBluetoothCG/web-bluetooth/blob/master/implementation-status.md

によると、

「Linux is partially implemented and not supported. The chrome://flags/#enable-experimental-web-platform-features flag must be enabled.」

とあります。
また、

「Linux: Requires Kernel 3.19+ and BlueZ 5.41+ installed. Read How to get Chrome Web Bluetooth working on Linux.
Note that Bluetooth daemon needs to run with experimental interfaces if BlueZ version is lower than 5.43: sudo /usr/sbin/bluetoothd -E」

ともありました。以前、Ubuntu16.04 で試したときはBlueZのバージョンが低くてうまくいきませんでした。さて、今回はうまくいくかな・・・

さて、
https://developer.mozilla.org/en-US/docs/Web/API/Web_Bluetooth_API
によると、firefox は未対応ということです。

設定作業

状況確認

本来は、ペアリングしようとすると以下のようなダイアログが出ます。

image.png

このサイトは Windows10 や Android 上の Google Chrome で出ることを確認できていますが、Linux 上の Google Chrome では出てきませんでした。

blueZ

まず、bluez を確認してみます。


$ sudo apt install bluez
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
bluez はすでに最新バージョン (5.53-0ubuntu3) です。
以下のパッケージが自動でインストールされましたが、もう必要とされていません:
  libfprint-2-tod1 libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib
  python2 python2-minimal python2.7 python2.7-minimal
これを削除するには 'sudo apt autoremove' を利用してください。
アップグレード: 0 個、新規インストール: 0 個、削除: 0 個、保留: 11 個。


既に入っていました。バージョンも 5.53 なので問題無さそうです。

Google Chrome

次に、

chrome://flags
を開き、
#enable-experimental-web-platform-features
をEnabledにします。

image.png

以下のURLだと直接アクセスできて便利でした。

chrome://flags/#enable-experimental-web-platform-features

Google Chrome だとそれだけで Web Bluetooth が使えるようになりました。

Chromium browser

Chromium でも試してみました。
chrome://flags/#enable-experimental-web-platform-features
にアクセスして上記と同じように Enable にします。ブラウザ再起動後、試してみるとこちらもOKになりました。

image.png

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?