HBaseマイグレーション
- Migrating an Apache HBase Table Between Different Clusters | Pivotal P.O.V.
- Apache HBase ™ Reference Guide - Apache HBase Operational Management
- Apache HBase ™ Reference Guide - HBase Backup
- Apache HBase ™ Reference Guide - CopyTable
- Apache HBase ™ Reference Guide - Cluster Replication
FRP: Functional reactive programming
BLEでペリフェラルを操作する
とりあえずAndroid DeveloperにあるBLEのサンプル(BluetoothLeGatt | Android Developers)をいじって、ペリフェラルのスキャン => 接続 => Characteristic の取得 => HRPで心拍数を取得する処理の流れはひととおりわかった(気がする)。
HRPは心拍数が変わったら通知するだけの単純なプロファイルらしく、あんまり応用がない。
というわけで Characteristic で read/writeしたいのだが、下記のサイトが参考になった。
BLEの拡張プロファイルについては下記が参考になりそう。
【BLEを使う】GATT(Generic Attribute Profile)概要 - 叶鋼は午前1時に計算をする
Android と BLESerial をつなげた例。サンプルコードあり。
浅草ギ研 ArduinoとAndroid端末をBLEでつないでみる
任意のcharacteristicのnotificationをenable/disableする疑似コード
BluetoothGattCharacteristic characteristic; // 任意のcharacteristic boolean enable; int charaProp = characteristic.getProperties(); if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) { // このcharacteristicは read に対応している enable = false; mBluetoothGatt.setCharacteristicNotification(characteristic, enabled); mBluetoothGatt.readCharacteristic(characteristic); // このcharacteristicに対してreadのリクエストを送る // 非同期に BluetoothGattCallback#onCharacteristicRead(BluetoothGatt, BluetoothGattCharacteristic, int) がコールバックされる } if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { // このcharacteristicは notification に対応している enable = true; mBluetoothGatt.setCharacteristicNotification(characteristic, enabled); BluetoothGattDescriptor descriptor = characteristic.getDescriptor( UUID.fromString("00002902-0000-1000-8000-00805f9b34fb")); descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); // characteristicの設定を行うときに指定するUUIDは "00002902-0000-1000-8000-00805f9b34fb" の固定値 // 対向の BLE peripheral の notification 機能を有効化するため、この characteristic の descriptor に対して BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE を設定する mBluetoothGatt.writeDescriptor(descriptor); // 設定した descriptor を書き込む // 非同期に BluetoothGattCallback#onCharacteristicChanged(BluetoothGatt, BluetoothGattCharacteristic) がコールバックされる }
使っているAPI:
- boolean BluetoothGatt#setCharacteristicNotification(BluetoothGattCharacteristic characteristic, boolean enable)
- BluetoothGattDescriptor BluetoothGattCharacteristic#getDescriptor(UUID uuid)
- characteristicの設定を行うときに指定するUUIDは "00002902-0000-1000-8000-00805f9b34fb" の固定値
- BluetoothGattDescriptor#setValue(byte[] bytes)
- BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE を設定
- BluetoothGatt#writeDescriptor(BluetoothGattDescriptor descriptor)
BLE peripheral へバイト列を書き込む模擬コード
byte[] bytes = { … }; // 書き込むバイト列 BluetoothGattService myService = mBluetoothGatt.getService(UUID.fromString("<Service UUID>")); BluetoothGattCharacteristic characteristic = myService.getCharacteristic(UUID.fromString("<Characteristic UUID>")); characteristic.setValue(bytes); mBluetoothGatt.writeCharacteristic(characteristic);
使っているAPI:
- BluetoothGattService BluetoothGatt#getService(UUID uuid)
- 引数は対向 BLE peripheral の Service UUID
- BluetoothGattCharacteristic BluetoothGattService#getCharacteristic(UUID uuid)
- 引数は対向 BLE peripheral の Service の Characteristic UUID
- BluetoothGattCharacteristic#setValue(byte[] bytes);
- 引数は書き込むバイト列
- boolean BluetoothGatt#writeCharacteristic(BluetoothGattCharacteristic characteristic)
- 引数は対向 BLE peripheral へ送信する Characteristic
BLEで何かつくる
BLEを使って何かつくれないか考えてみる。
ただBLEといっても漠然としすぎてるので、アイデア出しの下地として以下の構成を考えてみた。
- 各機器の構成
Raspberry Pi ではなく Arduino とBLE通信させる構成だとこんな感じ。
ちなみに、よくあるBeaconの構成はこんな感じで、スマホのアプリになにかアクションを起こさせるトリガとしてBLE(アドバタイズメント・チャネル)を使っている。
Beacon はアドバタイズメント・チャネルでID情報(UUID:会社ID, major:店舗)を一定時間ごとに送信する。スマホはID情報を受信すると、アプリを起動してアクションを起こす。
このアクションは、例えばWebサーバからメッセージを取得すること (いわゆるプッシュ通知) や、アプリ内ダイアログやビルトイン機能を表示することなど。
Beacon 自体は単にID情報をブロードキャストするだけなので、ボタン電池で数年稼動させることができる。