131
//
成功か失敗かを判断する
if(status == BluetoothGatt.GATT_SUCCESS) {
mUiCallback.uiSuccessfulWrite( mBluetoothGatt, mBluetoothDevice,
mBluetoothSelectedService,
descriptor.getCharacteristic(),
description);
}
else {
mUiCallback.uiFailedWrite( mBluetoothGatt, mBluetoothDevice,
mBluetoothSelectedService,
descriptor.getCharacteristic(),
description + " STATUS = " + status);
}
};
...
}
この
onDescriptorWrite()
は、通知が正しくオンにされた場合にはApplication
Acceleratorの
uiSuccessfulWrite()
メソッドを呼 び 出すことになる。
すべてのセンサー特性について通知をオンにするには、センサーそのものをオンにした
のと同 様に、ステートマシンを使ってシーケンシャルに 1つ1つ処理すればよい。通知につ
いて気を付けてほしいのは、Android 4.4(KitKat)で は 、 同 時 に 4つの特性しか通知をオ
ン に できな い ことだ 。こ れ は 現 在 の Android BLEライブラリの実装上の制限だが、おそら
く将来のバージョンでは改善されることだろう。
この章のコードの大部分は断片として提示したが、完全なソースコードはこの本の
GitHubリ ポ ジ ト リ( https:// ...