0
0

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.

PaperangをBLEで動かしたい - #1 UUIDを調べる

Posted at

はじめに

PaperangをBLE接続できたので、BLE経由で動かせないかと思い調査開始。
iOSはBluetooth シリアルは対応していないらしいのでBLEで動いているのでは?というのがそもそもの始まり。
iOSがBLEで動かしていると仮定すれば、AndroidでもBLEで動くんじゃね?と。
あと、FlutterでBLEを使ってみたいのもあったので。

とはいってもBLEに関してはあまり詳しくないので調べながらになります。
もし、間違いがあれば指摘していただけると助かります。

最終目的はAndroidでBLEでPaperangを操作することと、これができたら別のデバイスも調べたい。

今回はどんなUUIDがあるのかを調べます。
各UUIDの詳細は次回書きます。

もしかすると、これに追記するだけになるいかもしれないけど。

BLEのUUID

BLEのUUIDは、定義済UUIDとオリジナルUUIDの2種類があります。
定義済みUUIDは14Byteが共通で、2byteが目的に応じた定義(XXXXの部分)になります

0000XXXX-0000-1000-8000-00805f9b34fb

UUIDを調査

PaperangにかかわらずBLEで接続して、Service、characteristic、descrioptorの情報をログに出すプログラムを作る。
機能的には、スキャンした結果から選んだデバイスに接続して詳細を出力する感じ。

    var device = _selectItem.device!;
    await device.connect(autoConnect: false, timeout: const Duration(seconds: 60));
    List<BluetoothService> services = await device.discoverServices();
    for (var service in services) {
      print(service.uuid.toString() + " : isPrimary " + service.isPrimary.toString() + " : device id " + service.deviceId.id);
      for (var characteristic in service.characteristics) {
        print("characteristic uuid             : " + characteristic.uuid.toString());
        print("     read                       : " + characteristic.properties.read.toString());
        print("     write                      : " + characteristic.properties.write.toString());
        print("     writeWithoutResponse       : " + characteristic.properties.writeWithoutResponse.toString());
        print("     notify                     : " + characteristic.properties.notify.toString());
        print("     broadcast                  : " + characteristic.properties.broadcast.toString());
        print("     indicate                   : " + characteristic.properties.indicate.toString());
        print("     indicateEncryptionRequired : " + characteristic.properties.indicateEncryptionRequired.toString());
        for(var descrioptor in characteristic.descriptors){
          print("     descrioptor uuid           : " + descrioptor.uuid.toString());
        }
      }
    }

    device.disconnect();

で、16-bit UUID Numbers Document(PDF)と比較してみた結果がコレ。

0000ff00-0000-1000-8000-00805f9b34fb : カスタムサービス?

カスタムっぽいのでなんだかわからない

UUID 16bit 定義済 備考
characteristic 0000ff02-0000-1000-8000-00805f9b34fb 0xff02 0xffから始まるのはカスタムらしい?
characteristic 0000ff01-0000-1000-8000-00805f9b34fb 0xff01 0xffから始まるのはカスタムらしい?
  descrioptor 00002902-0000-1000-8000-00805f9b34fb 0x2902 GATT Descriptor - Client Characteristic Configuration
characteristic 0000ff03-0000-1000-8000-00805f9b34fb 0xff03 0xffから始まるのはカスタムらしい?
  descrioptor 00002905-0000-1000-8000-00805f9b34fb 0x2905 GATT Descriptor - Characteristic Aggregate Format
  descrioptor 00002902-0000-1000-8000-00805f9b34fb 0x2902 GATT Descriptor - Client Characteristic Configuration

0000180a-0000-1000-8000-00805f9b34fb : GATT Service - Device Information

デバイスの情報が取れるっぽい?

UUID 16bit 定義済 備考
characteristic 00002a29-0000-1000-8000-00805f9b34fb 0x2a29 GATT Characteristic and Object Type
characteristic 00002a24-0000-1000-8000-00805f9b34fb 0x2a24 GATT Characteristic and Object Type
characteristic 00002a27-0000-1000-8000-00805f9b34fb 0x2a27 GATT Characteristic and Object Type
characteristic 00002a26-0000-1000-8000-00805f9b34fb 0x2a26 GATT Characteristic and Object Type

49535343-fe7d-4ae5-8fa9-9fafd205e455 : オリジナル

よくわからん

UUID 16bit 定義済 備考
characteristic 49535343-8841-43f4-a8d4-ecbe34729bb3 0x5343 ×
characteristic 49535343-1e4d-4bd9-ba61-23c647249616 0x5343 ×
  descrioptor 00002902-0000-1000-8000-00805f9b34fb 0x2902 GATT Descriptor - Client Characteristic Configuration
characteristic 49535343-aca3-481c-91ec-d85e28a60318 0x5343 ×
  descrioptor 00002902-0000-1000-8000-00805f9b34fb 0x2902 GATT Descriptor - Client Characteristic Configuration

0000fee7-0000-1000-8000-00805f9b34fb : 16-bit UUID for Members - Tencent Holdings Limited.

なんか、テンセントとかAppleとか紐づくんだが・・・
ここ使えば動いたりするんだろうか?

UUID 16bit 定義済 備考
characteristic 0000fec7-0000-1000-8000-00805f9b34fb 0xfec7 16-bit UUID for Members - Apple, Inc.
characteristic 0000fec8-0000-1000-8000-00805f9b34fb 0xfec8 16-bit UUID for Members - Apple, Inc.
  descrioptor 00002902-0000-1000-8000-00805f9b34fb 0x2902 GATT Descriptor - Client Characteristic Configuration
characteristic 0000fec9-0000-1000-8000-00805f9b34fb 0xfec9 16-bit UUID for Members - Apple, Inc.

0000ff80-0000-1000-8000-00805f9b34fb : カスタムサービス?

カスタムっぽいのでなんだかわからない

UUID 16bit 定義済 備考
characteristic 0000ff82-0000-1000-8000-00805f9b34fb 0xff82 0xffから始まるのはカスタムらしい?
characteristic 0000ff81-0000-1000-8000-00805f9b34fb 0xff81 0xffから始まるのはカスタムらしい?
  descrioptor 00002902-0000-1000-8000-00805f9b34fb 0x2902 GATT Descriptor - Client Characteristic Configuration

16bit UUIDが一致しないものもあって分かってないのと、本当にあっているかが少し不安・・・
(全部のドキュメントを読んだわけでもないし・・・)
16bitのUUIDが0xfee7のサービスが怪しいかなぁと思ってますが、果たしてどうなるか・・・

参考サイト

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?