LoginSignup
7
5

More than 3 years have passed since last update.

toio for Unity Editor Windows BLE対応

Last updated at Posted at 2020-11-15

初めに

Unityでtoioの開発できるってことで飛びつきました。
https://toio.io/blog/detail/20200930-1.html
しかし、よく内容を見ているとUnity Editor内で確認できるのは
シュミレーターでのtoioの動き確認のみ。

う~ん。やっぱUnity Editorでtoioコアキューブが動いてほしい
というわけでtoioの仕様についていろいろ調べ始めました。

toio™コア キューブ 技術仕様2.2.0
https://toio.github.io/toio-spec/docs/ble_communication_overview.html

BLEで接続してtoioコアキューブが動いているようなので
Unity EditorでBLE接続出来てしまえばいけちゃうのでは?
って事で調べ始めました。

Uunity EitorでBLEを接続する

UnityでBLE接続するぞってって事でAssetstoreに行って検索を!
自分で作るんじゃないんだ。。。
無ければ自分で作るんですけどね。。

ということで調べたら、あった!!神
Arduino Bluetooth Plugin $19
https://assetstore.unity.com/packages/tools/input-management/arduino-bluetooth-plugin-98960

で早速ポチって見ました。
image.png

Arduino Bluetooth Pluginを使ってBLE接続

image.png
Arduino Unity Plugin.pdfの説明の最後のほうに
Setup BLE in unity editor for Windows 10の説明があるので手順書通りインストールします。

※※現在は新しいアプリがあり、そちらを使うようです。※※
https://drive.google.com/drive/folders/1RIOVtYsLcoiU5626Ey1C-dMhFs2S42HG

image.png

BLEの通信するアプリ(BluetoothDesktopServer)を立ち上げて
image.png

アプリはBLEのサーバーと通信するものですが、コマンドでループバックで通信を行えるようにコマンドで実行しておきます。

CheckNetIsolation.exe LoopbackExempt -is -n=BluetoothDesktopServer_t05x7yb6e6yp0

Unityの方で[Arduino Bluetooth Plugin]をインポートして
サンプルシーンのscan_sceneを開きます。
image.png

そしてBluetoothHelper.BLE_AS_CLIENT = true;を追記します。

image.png

Unity EditorでPlayを押して、toioのBLEを探すので接続したら
ServiceとCharacteristicsを指定して値を渡すと
toioがtoio™コア キューブ 技術仕様通りに値を送ると
値通り動いてくれます。

image.png

※注意
Arduino Bluetooth PluginのwindowsのBLEの接続はまだ開発途中らしく、安定した接続はまだらしいです。

この記事は2020/10に環境を作りました。

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