1 / 16

Bluetooth で Go!

Bluetooth で Go!. Bar Windows 8 in 名古屋 with 8.1 けきょ( Kouji Matsui @kekyo2 ). 自己紹介. けきょ @kekyo2 (あまり tweet してません) 会社やってます 「 Micoci 」と「まどべんよっかいち」 主に Windows 。 C#, C++/CLI, ATL, C++0x, x86/x64 アセンブラ , WDM, Azure, TFS, OpenCV , Geo, JNI, 鯖管理 , MCP 少々 , 自作 PC, 昔マイコン , 複式簿記経理

baxter
Download Presentation

Bluetooth で Go!

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. BluetoothでGo! Bar Windows 8 in 名古屋 with 8.1 けきょ(Kouji Matsui @kekyo2)

  2. 自己紹介 • けきょ @kekyo2 (あまりtweetしてません) • 会社やってます • 「Micoci」と「まどべんよっかいち」 • 主にWindows。C#, C++/CLI, ATL, C++0x, x86/x64アセンブラ, WDM, Azure, TFS, OpenCV, Geo, JNI, 鯖管理, MCP少々, 自作PC, 昔マイコン, 複式簿記経理 • アプリケーションフレームワーク設計・アーキテクトが仕事の主体。最近はWPFを使ったMVVMに足をツッコミ中

  3. Windows 8と言えば… • Bluetooth 4.0対応 • で、4.0で何が追加されたの?

  4. Bluetooth 4.0って? • 「Bluetooth 4.0 LE」ですよ • 「Low Energy」ですよ • 別名、「Bluetooth Smart」ですよ • 何か呼称がごちゃごちゃしてますが、3.0以前の規格とLEに互換性は無いです。(大人の事情で4.0としたのかも?) • 1.0~4.0全部ひっくるめて使えるのが、「Bluetooth Smart Ready」です(レシーバーしかない、多分)

  5. Bluetooth 4.0 LEって? • コンシューマーブランド「Bluetooth Smart」 • 「超」低消費電力デバイス向けの規格ボタン電池で半年~1年 • 3.0以前と互換性なし • プロファイルがいっぱい増えた • ライバルは、「Zigbee」「ANT+」「RFID」か?

  6. Windows 8との関係は? • Windows 8.0で「Bluetooth 4.0」対応表明 • しかし、一体何に対応したのか良く分からない(単に4.0プロトコルスタックを配布しただけ?) • APIについての情報が皆無 • そうこうしているうちに、Windows 8.1現わる!! • WinRTに名前空間が増えた!

  7. Bluetooth API GATT • Windows.Devices.Bluetooth • Windows.Devices.Bluetooth.GenericAttributeProfile これぞ LEデバイス!

  8. 公式サンプルコード • 「Bluetooth Generic Attribute Profile - Heart Rate Service」Demonstrates use of the Bluetooth Generic Attribute Profile (Gatt) Windows Runtime API to interact with a Bluetooth Gatt device which contains a Heart Rate Service.http://code.msdn.microsoft.com/windowsapps/Bluetooth-Generic-5a99ef95汚いサンプルコード…(T_T)

  9. 取りあえずやってみた • Bluetooth Smartデバイスが無ければ話にならない • 幸い?ロードバイク乗りなので… • Wahoo FITNESS BLUE HR (心拍計)http://www.wahoofitness.com/devices/wahoo-blue-hr-heart-rate-strap.html# • レシーバーは PLANEX BT-MICRO4

  10. Demo(サンプルコード)

  11. まあ… • サンプルコードを動かしただけでは面白くない • WinRTって、噂ではデスクトップからも呼び出せるらしいし • WPFから使えた方が、私的に面白いかも? • 本当にデスクトップアプリケーションから、デバイスにアクセス出来るか?

  12. APIはどう使うの? • デスクトップアプリケーションからWinRTを使うには、Bingって下さい例: http://www.codeproject.com/Articles/457335/How-to-call-WinRT-APIs-from-NET-desktop-apps • Windows 8.1の場合は、「TargetPlatformVersion」を「8.1」にすること(8.0では、新しいAPIは使えない) • Bluetooth APIはWindows.winmdに含まれているので、追加のアセンブリは不要

  13. APIはどう使うの? • デバイスセレクタの取得var selector =GattDeviceService.GetDeviceSelectorFromUuid(GattServiceUuids.HeartRate); • デバイスの列挙IEnumerable<DeviceInformation> dis = awaitDeviceInformation.FindAllAsync(selector); • デバイスの初期化varservice = await GattDeviceService.FromIdAsync(deviceInformation.Id); • 心拍情報のイベントをフックvar characteristics =service.GetCharacteristics(GattCharacteristicUuids.HeartRateMeasurement);characteristics[0].ValueChanged += (sender, e) => { … }; 心拍計

  14. イベントで心拍数が得られるんだ!(喜) • いやいや、得られるのは、ペイロードの「生」データ(バイト列)です解析はプロトコルに合わせて独自に行う必要があります(爆)orz • プロトコルの情報は、Bluetooth SIGで調べる必要がありますhttps://developer.bluetooth.org/gatt/Pages/GATT-Specification-Documents.aspx(ペイロードの説明は全部文書で、ボックス図がないです。辛い…) • とりあえず、心拍計については、サンプルコードのデコーダーが参考になるでしょう

  15. Demo(WPF版)

  16. それでは、引き続きお楽しみ下さい • ありがとうございました

More Related