Upgrade to Pro — share decks privately, control downloads, hide ads and more …

こわくないBLE / BLE is afraid

Masayuki Izumi
September 20, 2015

こわくないBLE / BLE is afraid

第48回 情報科学若手の会 LT資料
Bletia: https://github.com/izumin5210/Bletia

Masayuki Izumi

September 20, 2015
Tweet

More Decks by Masayuki Izumi

Other Decks in Technology

Transcript

  1. こわくない BLE (Bluetooth Low Energy) Masayuki IZUMI - @izumin5210 第

    48 回情報科学若手の会 https://www.flickr.com/photos/36571434@N03/8524872002
  2.  > Masayuki IZUMI a.k.a. @izumin5210 > Rekimoto Lab. at

    the University of Tokyo > Wantedly, Inc. > Rubyist / Androider / {Java,Type}Scripter
  3. BLE

  4. Bluetooth® Smart is the intelligent, power-friendly version of Bluetooth wireless

    technology. While the power-efficiency of Bluetooth Smart makes it perfect for devices needing to run off a tiny battery for long periods, the magic of Bluetooth Smart is its ability to work with an application on the smartphone or tablet you already own. Bluetooth Smart makes it easy for developers and OEMs to create solutions that will work with the billions of Bluetooth enabled products already in the market today. - Bluetooth Technology Website
  5. BLE とは  Bluetooth 3.0 の次世代規格  省電力  後方互換性なし

    ※ 周波数帯は共通  GATT というプロファイルを利用
  6. Write charcteristic | BLE on Android Central wants data Peripheral

    has data write value BluetoothGatt#writeCharacteristic()
  7. Write charcteristic | BLE on Android Central wants data Peripheral

    has data write value BluetoothGatt#writeCharacteristic() (async)
  8. Write charcteristic | BLE on Android Central wants data Peripheral

    has data write value BluetoothGatt#writeCharacteristic() BluetoothGattCallback#onCharacteristicWrite() (async)
  9. Handle callback public void onCharacteristicWrite ( BluetoothGatt gatt, BluetoothGattCharacteristic characteristic,

    int status) { if (status == BluetoothGatt.GATT_SUCCESS) { // check characteristic instance, handling... } else { // error handling... } }
  10. Handle callback public void onCharacteristicWrite ( BluetoothGatt gatt, BluetoothGattCharacteristic characteristic,

    int status) { if (status == BluetoothGatt.GATT_SUCCESS) { // check characteristic instance, handling... } else { // error handling... } }
  11. When is the callback registered ? class final BluetoothDevice {

    public BluetoothGatt connectGatt ( Context context, boolean autoConnect, BluetoothGattCallback callback ) { // ... } }
  12. When is the callback registered ? class final BluetoothDevice {

    public BluetoothGatt connectGatt ( Context context, boolean autoConnect, BluetoothGattCallback callback ) { // ... } } We can register only 1 instance...