ユーザ用ツール

サイト用ツール


kb:mbed-ble

差分

この文書の現在のバージョンと選択したバージョンの差分を表示します。

この比較画面にリンクする

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
kb:mbed-ble [2014/07/08 08:26]
t-matsuoka [7/7メモ]
kb:mbed-ble [2014/07/17 21:57] (現在)
t-matsuoka [注意事項]
ライン 2: ライン 2:
 {{projects:​20140618e.jpg?​400}} {{projects:​20140618e.jpg?​400}}
  
 +ひょんなことから、発売前にmbed HRM1017を先行利用する機会に。
 +mbedほぼ初めて。(mbed LPC1114でLチカしたくらい。)
 +Bluetooth初めて。もちろん、Bluetooth LEも初めてからの挑戦です~。
 +(MLN松岡)
  
-===== 小ネタ =====+[[kb:​mbed-ble:​memo|日々のメモ]]
  
-==== ペアリンきるようにすには? ====+===== 注意事項 ===== 
 +  *Nordic mkit向けのプロラムを流用するとは、クロックの設定を変更す必要があります。[[https://​mbed.org/​teams/​Switch-Science/​wiki/​mbed-HRM1017をはじめよう#​low-frequency-clock|参照]] 
 +  *Nordic mkit用ライブラリは大きく2種類あります。 
 +    *{BLE_API_Native} 
 +    *{BLE_API+nRF51822} <- こちらが最新 
 +  *mbed HRM1017用ライブラリ修正されたものはこちらで。 
 +    *{BLE_API_Native}->​{BLE_API_Native_IRC} 
 +    *{BLE_API+nRF51822}->​なし(左記ライブラリがそのままmbed HRM1017で動くようなる予定) 
 +  *{BLE_API_Native}と{BLE_API+nRF51822}API非互換のため、ライブラリを切り替えた場合はプログラムの修正が必要です。
  
-AdvertiseDiscoverableを有効にします。 +===== BLE_Health_Thermometer_IRC ===== 
-<code cpp> +  *{BLE_API_Native_IRC}を使った、Health Thermometerプログラムです。
-advData.addFlags((GapAdvertisingData::​Flags)(GapAdvertisingData::​LE_GENERAL_DISCOVERABLE | GapAdvertisingData::​BREDR_NOT_SUPPORTED));​ +
-</​code>​+
  
 ==== デバイス名を設定するには? ==== ==== デバイス名を設定するには? ====
ライン 32: ライン 42:
 {{kb:​20140624a.png?​200}} {{kb:​20140624a.png?​200}}
  
 +==== Windowsとペアリングできるようにするには? ====
  
-===== Windows関連 ​=====+AdvertiseのDiscoverableを有効にします。 
 +<code cpp> 
 +advData.addFlags((GapAdvertisingData::​Flags)(GapAdvertisingData::​LE_GENERAL_DISCOVERABLE | GapAdvertisingData::​BREDR_NOT_SUPPORTED));​ 
 +</​code>​ 
 + 
 +===== Windowsアプリ ​===== 
 +  *Windowsは8以降でBluetooth LEに対応しています。 
 +  *Windows 8以降で、Bluetooth LE用のNative APIがあります。 
 +  *Windows 8.1以降で、Bluetooth LE用のWinRT APIがあります。 
 +  *[[https://​github.com/​matsujirushi/​mjwinble|mjwinble]]では、開発利便性と知識継続の観点から、WindowsデスクトップアプリからWinRT APIを呼び出す方法を選択しています。
  
 ==== Windows8と接続するには? ==== ==== Windows8と接続するには? ====
ライン 52: ライン 72:
 3.Bluetooth SMART Devicesに表示されているデバイスを選択します。\\ 3.Bluetooth SMART Devicesに表示されているデバイスを選択します。\\
  
-===== メモ ===== 
- 
-==== 6/14メモ ==== 
-  *下調べ。 
-  *開発チームはココ。[[https://​mbed.org/​teams/​Bluetooth-Low-Energy/​wiki/​Homepage|mbed BLE API homepage]] 
-  *使っているハードウェアは、nRF51822 Evaluation Kit。 
-  *GAPとGATTに対応。 
-  *GATTのサンプルコードは、[[http://​mbed.org/​teams/​Bluetooth-Low-Energy/​code/​BLE_HeartRate/​|BLE_HeartRate]]。 
-  *BLEDevice,​GattService,​GattCharacteristicクラス。 
-  *静的変数を用意しておき、Characteristicクラスに紐づけておくことで、BLEのCharacteristicと同期される模様。 
- 
-==== 6/15メモ ==== 
-  *ハードウェアが手元に届いた。[[https://​www.facebook.com/​photo.php?​fbid=512309988896759|mbed HRM1017]] 
-  *mbedオンラインコンパイラのPlatformは、Nordic nRF51822を選択する。 
-  *内蔵オシレーター32KHzなので注意。(nRF51822-mKITは、外部32KHz。) 
-  *コンパイル結果のHEXファイルをmbedドライブへコピーすれば書き込める。ブラウザから直書きはダメ。一旦、ローカル保存を経由する。 
-  *SurfacePro2のペアリングには何も表示されない。 
-  *[[http://​apps.microsoft.com/​windows/​app/​eg-bluetooth-smart-gatt-profile/​87207696-068a-410c-bfdd-a96f44d43b3f|EG Bluetooth Smart Device GATT Profile Checker]]でも認識されない。 
- 
-==== 6/16メモ ==== 
-  *mbed HRM1017(BLE_Health_Thermometer_IRC) + iPhone(Nordic Toolbox)は、認識できた。 
-  *mbed HRM1017(BLE_Health_Thermometer_IRC) + Nexus7(Nordic Toolbox)は、認識できず。というか、手元のNexus7はBLE未対応みたい。 
-  *BLE喋れるデバイスが、SurfacePro2とTOSHIBA DynabookTabしかない。両方、Win8.1。 
-  *なんとかしてWin8.1でBLE喋らせるしか道が無さそう。 
-  *Win8.1から、WinストアアプリでBLEできる模様。 
-  *BluetoothSIG提供の、ApplicationAcceleratorが使えそう。 
-  *GATT違いでダメでした。BLE_Health_Thermometer_IRCは「UUID_HEALTH_THERMOMETER_SERVICE ​    = 0x1809,​」で、ApplicationAcceleratorは「HeartRateMeasurement 0x2A37」。 
-  *明日、ApplicationAcceleratorのコードを書き換えてみることにしよう。 
- 
-==== 6/​17メモ(Win8.1StoreApp) ==== 
-  *GattServiceUuids.HeartRate = "​{0000180d-0000-1000-8000-00805f9b34fb}"​ 
-  *Uuidを"​180d-0000-0000-..."​に変更。→Guidで例外。 
-  *GattDeviceService.GetDeviceSelectorFromUuid()をGattDeviceService.GetDeviceSelectorFromShortId(0x180d)に変更。→Not found 
-  *恐ろしい[[http://​sviluppomobile.blogspot.jp/​2014/​02/​ble-for-windows-81-part-i.html|記述]]を発見。「Windows 8.1 supports only GATT client mode.」 
- 
-==== 6/17メモ ==== 
-  *mbed HRM1017(BLE_Health_Thermometer_IRC改) + SurfacePro2(BluetoothSmartDeviceGATTProfileChecker)で、接続に成功。 
- 
-==== 6/18メモ ==== 
-  *SHORTENED_LOCAL_NAMEのpayloadが正しいか不安だったので、Bluetooth specificationを確認したところ、長さ情報が無かった。したがって、終端の'​\0'​が必要と思われる。strlen()に+1が必要。 
-  *文字コードがUTF-8だということが分かったので、日本語が表示できるか試してみた。(必要なのか?疑問ではあるが。) 
- 
-==== 6/20メモ ==== 
-  *ペアリング後のデバイス名を指定する方法を模索。 
-  *Bluetooth LE的には、Generic Access Service)(0x1800)のDevice Name Characteristic(0x2A00)を表示している。 
-  *mbed HRM1017のconstに、Generic Access Serviceが定義されていない。orz 
-  *無理にSerivceを登録したものの、思うように動かず。(名前変わらず。Advertisingまでおかしくなった。Winアプリによって、Generic Access Serviceが表示されたりされなかったり。) 
-  *Generic Access Serviceを登録しなくても、Winアプリに表示されていた。値はnRF5x。 
-  *nRFのライブラリ内で設定しているのか??? 
-  *行き止まり。Generic Access ServiceはSoftDeviceで提供されているため、変更不可らしい。({{https://​devzone.nordicsemi.com/​question/​4630/​custom-gap-service-with-user-descriptions-uuid-0x2901/​|元ネタ}}) 
-  *Device Information ServiceのManufacturer Nameでもダメ。ダメになると、何故かAdvertisingの名前もダメになる。 
- 
-==== 6/24メモ ==== 
-  *mbedコンパイラでの検索操作が間違ってた。orz 
-  *CFG_GAP_LOCAL_NAMEに"​nRF5x"​が定義されていた。 
-  *深堀りすると、nRF51822n::​init()->​btle_init()->​btle_gap_init()->​sd_ble_gap_device_name_set()で設定していることが分かった。 
-  *こちらに類似情報あり。[[http://​electronics.stackexchange.com/​questions/​96048/​how-to-discover-a-custom-bluetooth-le-device|How to discover a custom Bluetooth LE device]] 
-  *偶然、[[http://​bril-tech.blogspot.jp/​2014/​05/​bluetoothsmartmbed-1.html|mbed+HRM1017]]の情報を発見。「なお mbed版 nRF51822ではライブラリ側に"​Generic Access"​と"​Generic Attribute"​が組み込まれているため」という記述がある。<​-0x1800,​0x1801 
- 
-==== 7/5メモ ==== 
-  *6/​18メモの「Bluetooth specificationを確認したところ、長さ情報が無かった。」は間違いっぽい。掘り下げ中。vol3,​PartB,​3 Data Representationあたり。 
-  *data element = header field + data field 
-  *header field = type descripter + size descripter 
-  *type descripterは5bits 
-  *size descripterは3bits 
-  *The size index is contained in the least significant (loworder) 3 bits of the first byte of the data element header. 
-  *というわけで、6/​18メモの「Bluetooth specificationを確認したところ、長さ情報が無かった。」は間違い。 
- 
-  *以前によくわからなかったUUID。ここに載っていた。vol3,​Part F,3,3.2 Basic Concepts。 
- 
-==== 7/7メモ ==== 
-  *WindowsのBluetoothLEアクセス方法を再考。 
-  *Bluetooth LEの対応は、Windows8以降。 
-  *Windows8以降は、APIがある。SetupDiGetClassDevs,​SetupDiEnumDeviceInterfaces,​SetupDiGetDeviceInterfaceDetailでサービスを探して、CreateFileでオープン。BluetoothGATTGetServicesやBleGetGattCharacteristicでアクセス。 
-  *Windows8.1は、WinRTにクラスが追加されている。Windows.Devices.Bluetooth.GenericAttributeProfile名前空間。 
-  *DesktopAppでも、(csprojを編集して)TargetPlatformVersionを8.1にして、Windowsコア参照すれば、WinRTのクラスが使える。 
  
-==== 7/8メモ ==== 
-  *WinRTクラスを確認。いろいろ難あり。 
-  *1.deviceだけの一覧を取得できない。(deviceとserviceの直積が得られる。) 
-  *2.serviceからcharacteristicの一覧を取得できない。(Windows Phoneだけは可能?) 
-  *特に、2.ができないのは開発時にツラい。 
kb/mbed-ble.1404775604.txt.gz · 最終更新: 2014/07/08 08:26 by t-matsuoka