LoginSignup
7
7

More than 5 years have passed since last update.

OMRON HVC-CにLinuxから接続する方法

Last updated at Posted at 2015-08-09

Bluezの使い方は私のエントリを参考に。
Bluez-5.29を使用。

UUIDやhandleの検索はHVC-CのAndroidサンプルソースとコマンド仕様書を参考にする。
SDKダウンロード
gatttoolを起動。tは三つ。

$ ./attrib/gatttool -b XX:XX:XX:XX:XX:XX -t random -I
[XX:XX:XX:XX:XX:XX][LE]>

connectする。

[XX:XX:XX:XX:XX:XX][LE]> connect
Attempting to connect to [XX:XX:XX:XX:XX:XX]
Connection successful

handleを探す。

[XX:XX:XX:XX:XX:XX][LE]> primary
attr handle: 0x0001, end grp handle: 0x0007 uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x0008, end grp handle: 0x000b uuid: 00001801-0000-1000-8000-00805f9b34fb
attr handle: 0x000c, end grp handle: 0xffff uuid: 35100001-d13a-4f39-8ab3-bf64d4fbb4b4

0x000cを使う。

[XX:XX:XX:XX:XX:XX][LE]> char-desc 0x000c
handle: 0x000c, uuid: 00002800-0000-1000-8000-00805f9b34fb
handle: 0x000d, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x000e, uuid: 35100003-d13a-4f39-8ab3-bf64d4fbb4b4
handle: 0x000f, uuid: 00002902-0000-1000-8000-00805f9b34fb
handle: 0x0010, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x0011, uuid: 35100002-d13a-4f39-8ab3-bf64d4fbb4b4
handle: 0x0012, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x0013, uuid: 35100004-d13a-4f39-8ab3-bf64d4fbb4b4

サンプルソースからHVC-Cから受信するには
00002902-0000-1000-8000-00805f9b34fb
のhandle 0x000fに0100を書き込めば良いことがわかる。
送信するには
35100002-d13a-4f39-8ab3-bf64d4fbb4b4
のhandle 0x0011を使用する。

[XX:XX:XX:XX:XX:XX][LE]> char-write-req 0x000f 0100
Characteristic value was written successfully

コマンド仕様書の4-1付近を読み込むと、送受信ヘッダには0xFEが付くことがわかる。4-3-1に書いてあるバージョン情報を取得するコマンドを叩いてみる。
同期コードにFE, コマンドNo.00, データ長0000を並べる。
送信にはhandle 0x0011を使用する。

[XX:XX:XX:XX:XX:XX][LE]> char-write-req 0x0011 FE000000
Characteristic value was written successfully
Notification handle = 0x000e value: fe 00 13 00 00 00 48 56 43 2d 43 31 42 20 20 20 20 20 01 01
Notification handle = 0x000e value: 00 96 09 00 00

それっぽい値が取れた。
受信時のデータ
同期コード:fe
レスポンスコード:00
データ長(4バイト):13 00 00 00
レスポンスコードに00(正常)データ長に0x13が帰ってきていて、返却バイト数も19bytesなので正常であることがわかる。
型式文字12文字:
48 56 43 2d 43 31 42 20 20 20 20 20 = "HVC-C1B "
メジャーバージョン:01 = 1
マイナーバージョン:01 = 1
リリースバージョン:00 = 0
リビジョン番号:96 09 00 00 = 0x00000996

これであとはどんなコマンドでもいけそう。

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