package info.izumin.android.bletia;

import android.bluetooth.BluetoothGattCharacteristic;

import org.jdeferred.Deferred;

import java.util.UUID;

/**
 * Created by izumin on 9/7/15.
 */
public class BleEvent {
    enum Type {
        WRITING_CHARACTERISTIC,
        READING_CHARACTERISTIC
    }

    private final UUID mUuid;
    private final Deferred mDeferred;
    private BluetoothGattCharacteristic mCharacteristic;

    public BleEvent(UUID uuid, Deferred deferred) {
        mUuid = uuid;
        mDeferred = deferred;
    }

    public UUID getUuid() {
        return mUuid;
    }

    public <D, F, P> Deferred<D, F, P> getDeferred() {
        return mDeferred;
    }

    public BluetoothGattCharacteristic getCharacteristic() {
        return mCharacteristic;
    }

    public void setCharacteristic(BluetoothGattCharacteristic characteristic) {
        mCharacteristic = characteristic;
    }
}

@@ -83,16 +83,69 @@
 eristic;
+%0Aimport android.os.Bundle;%0Aimport android.os.Message;
 %0A%0Aimport
@@ -286,19 +286,17 @@
     WRIT
-ING
+E
 _CHARACT
@@ -302,16 +302,19 @@
 TERISTIC
+(1)
 ,%0A      
@@ -323,11 +323,8 @@
 READ
-ING
 _CHA
@@ -334,22 +334,304 @@
 TERISTIC
+(2),
 %0A    
-%7D
+    WRITE_DESCRIPTOR(3),%0A        READ_DESCRIPTOR(4);%0A%0A        private final int mWhat;%0A%0A        Type(int what) %7B%0A            mWhat = what;%0A        %7D%0A%0A        public int getWhat() %7B%0A            return mWhat;%0A        %7D%0A    %7D%0A%0A    public static final String KEY_UUID = %22event uuid%22;
 %0A%0A    pr
@@ -1233,11 +1233,283 @@
 c;%0A    %7D
+%0A%0A    public Message obtainMessage() %7B%0A        Message message = Message.obtain();%0A        message.what = mType.getWhat();%0A        Bundle bundle = new Bundle();%0A        bundle.putSerializable(KEY_UUID, mUuid);%0A        message.setData(bundle);%0A        return message;%0A    %7D
 %0A%7D%0A

Add BleEvent#obtainMessage()