Open1

yunipocket: Bluetooth LEサービスの設計

okuokuokuoku

色々試行錯誤したけど結局真面目に作るしかないという結論に至ったので。。

実装するサービス

可能な限り標準サービスを活用する。特にBatteryやDevice InformationサービスはPCや電話のUIに統合されているためユーザーベネフィットが大きい。

非標準サービス

... まだちゃんと設計を固めていないが、nordic UARTのような、バイト指向、双方向ストリームをサービスとして実装するつもり。

Web bluetoothでの利用を想定して自前のMTUディスカバリ等コントロール用に専用のCharacteristicsを用意する。

標準サービス

基本的にはApple device guideline https://developer.apple.com/accessories/Accessory-Design-Guidelines.pdf とHID over GATT https://www.bluetooth.com/ja-jp/specifications/specs/hid-over-gatt-profile-1-0/ に要求されているものを揃える。

サービス Apple HID
Battery 本体が提供 必須
Current Time 本体が提供 n/a
Device Information shall 必須
Scan Parameters n/a オプショナル

Appleは以下のように規定している。

41.12.3 Device Information Service

The accessory shall implement the Device Information Service. The service UUID for this service should not be advertised in the Advertising Data. The following characteristics should be supported:

  • Manufacturer Name String (26 characters maximum).
  • Model Number String (26 characters maximum).
  • Firmware Revision String
  • Software Revision String

また、全てのiOSデバイスはCurrent time serviceでデバイスに時刻を提供する。

41.12.4 Available Services

... The Current Time Service supports the current time and local time information characteristics. The service does not provide an "Adjust Reason" when the current time changes.

Scan ParametersはWindowsの対応bluetoothプロファイルの一覧に入っている https://learn.microsoft.com/en-us/windows-hardware/drivers/bluetooth/general-bluetooth-support-in-windows ものの、何につかっているのかは判然としなかった。WindowsはLE Swift Pairing https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/bluetooth-swift-pair (日本語では クイックペアリング だがMSのターミノロジー https://www.microsoft.com/en-us/language/Terminology に書かれていない) のような独自仕様もサポートしている。