Example usage for android.bluetooth BluetoothGattCharacteristic PERMISSION_READ_ENCRYPTED

List of usage examples for android.bluetooth BluetoothGattCharacteristic PERMISSION_READ_ENCRYPTED

Introduction

In this page you can find the example usage for android.bluetooth BluetoothGattCharacteristic PERMISSION_READ_ENCRYPTED.

Prototype

int PERMISSION_READ_ENCRYPTED

To view the source code for android.bluetooth BluetoothGattCharacteristic PERMISSION_READ_ENCRYPTED.

Click Source Link

Document

Characteristic permission: Allow encrypted read operations

Usage

From source file:Main.java

public static JSONArray decodePermissions(BluetoothGattCharacteristic characteristic) {

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

    if ((permissions & BluetoothGattCharacteristic.PERMISSION_READ) != 0x0) {
        props.put("Read");
    }//from  ww w . j  a  v  a 2 s  .c om

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

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

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

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

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

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

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

    return props;
}