Example usage for android.bluetooth BluetoothGattDescriptor PERMISSION_WRITE

List of usage examples for android.bluetooth BluetoothGattDescriptor PERMISSION_WRITE

Introduction

In this page you can find the example usage for android.bluetooth BluetoothGattDescriptor PERMISSION_WRITE.

Prototype

int PERMISSION_WRITE

To view the source code for android.bluetooth BluetoothGattDescriptor PERMISSION_WRITE.

Click Source Link

Document

Descriptor write permission

Usage

From source file:Main.java

public static JSONArray decodePermissions(BluetoothGattDescriptor descriptor) {

    // NOTE: props strings need to be consistent across iOS and Android
    JSONArray props = new JSONArray();
    int permissions = descriptor.getPermissions();

    if ((permissions & BluetoothGattDescriptor.PERMISSION_READ) != 0x0) {
        props.put("Read");
    }//from   w  ww  .  ja  v  a2  s . c  o m

    if ((permissions & BluetoothGattDescriptor.PERMISSION_WRITE) != 0x0) {
        props.put("Write");
    }

    if ((permissions & BluetoothGattDescriptor.PERMISSION_READ_ENCRYPTED) != 0x0) {
        props.put("ReadEncrypted");
    }

    if ((permissions & BluetoothGattDescriptor.PERMISSION_WRITE_ENCRYPTED) != 0x0) {
        props.put("WriteEncrypted");
    }

    if ((permissions & BluetoothGattDescriptor.PERMISSION_READ_ENCRYPTED_MITM) != 0x0) {
        props.put("ReadEncryptedMITM");
    }

    if ((permissions & BluetoothGattDescriptor.PERMISSION_WRITE_ENCRYPTED_MITM) != 0x0) {
        props.put("WriteEncryptedMITM");
    }

    if ((permissions & BluetoothGattDescriptor.PERMISSION_WRITE_SIGNED) != 0x0) {
        props.put("WriteSigned");
    }

    if ((permissions & BluetoothGattDescriptor.PERMISSION_WRITE_SIGNED_MITM) != 0x0) {
        props.put("WriteSignedMITM");
    }

    return props;
}

From source file:com.elitise.appv2.Peripheral.java

public static BluetoothGattDescriptor getClientCharacteristicConfigurationDescriptor() {
    return new BluetoothGattDescriptor(CLIENT_CHARACTERISTIC_CONFIGURATION_UUID,
            (BluetoothGattDescriptor.PERMISSION_WRITE | BluetoothGattDescriptor.PERMISSION_READ));
}

From source file:com.elitise.appv2.Peripheral.java

public static BluetoothGattDescriptor getClientCharacteristicExtendedDescriptor() {
    return new BluetoothGattDescriptor(CLIENT_CHARACTERISTIC_EXTENDED_UUID,
            (BluetoothGattDescriptor.PERMISSION_WRITE | BluetoothGattDescriptor.PERMISSION_READ));
}