Example usage for android.bluetooth BluetoothGattCharacteristic PROPERTY_SIGNED_WRITE

List of usage examples for android.bluetooth BluetoothGattCharacteristic PROPERTY_SIGNED_WRITE

Introduction

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

Prototype

int PROPERTY_SIGNED_WRITE

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

Click Source Link

Document

Characteristic property: Characteristic supports write with signature

Usage

From source file:Main.java

public static JSONArray decodeProperties(BluetoothGattCharacteristic characteristic) {

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

    if ((properties & BluetoothGattCharacteristic.PROPERTY_BROADCAST) != 0x0) {
        props.put("Broadcast");
    }/*from  ww  w  .  j  ava  2  s  .c o  m*/

    if ((properties & BluetoothGattCharacteristic.PROPERTY_READ) != 0x0) {
        props.put("Read");
    }

    if ((properties & BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) != 0x0) {
        props.put("WriteWithoutResponse");
    }

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

    if ((properties & BluetoothGattCharacteristic.PROPERTY_NOTIFY) != 0x0) {
        props.put("Notify");
    }

    if ((properties & BluetoothGattCharacteristic.PROPERTY_INDICATE) != 0x0) {
        props.put("Indicate");
    }

    if ((properties & BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE) != 0x0) {
        // Android calls this "write with signature", using iOS name for now
        props.put("AuthenticateSignedWrites");
    }

    if ((properties & BluetoothGattCharacteristic.PROPERTY_EXTENDED_PROPS) != 0x0) {
        props.put("ExtendedProperties");
    }

    //      iOS only?
    //
    //            if ((p & CBCharacteristicPropertyNotifyEncryptionRequired) != 0x0) {  // 0x100
    //                [props addObject:@"NotifyEncryptionRequired"];
    //            }
    //
    //            if ((p & CBCharacteristicPropertyIndicateEncryptionRequired) != 0x0) { // 0x200
    //                [props addObject:@"IndicateEncryptionRequired"];
    //            }

    return props;
}

From source file:ti.android.ble.devicemonitor.ServiceView.java

private String getPropertyDescription(int prop) {
    String str = new String();

    if ((prop & BluetoothGattCharacteristic.PROPERTY_READ) > 0)
        str += "R";

    if ((prop & BluetoothGattCharacteristic.PROPERTY_WRITE) > 0)
        str += "W";

    if ((prop & BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0)
        str += "N";

    if ((prop & BluetoothGattCharacteristic.PROPERTY_INDICATE) > 0)
        str += "I";

    if ((prop & BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) > 0)
        str += "*";

    if ((prop & BluetoothGattCharacteristic.PROPERTY_BROADCAST) > 0)
        str += "B";

    if ((prop & BluetoothGattCharacteristic.PROPERTY_EXTENDED_PROPS) > 0)
        str += "E";

    if ((prop & BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE) > 0)
        str += "S";

    return str;/*from   www . j a  v a2  s.com*/
}

From source file:org.bcsphere.bluetooth.tools.Tools.java

public static JSONArray decodeProperty(int property) {
    JSONArray properties = new JSONArray();
    String strProperty = null;/*  w  ww.  j  a  v a2 s.  com*/
    if ((strProperty = lookup(property, BluetoothGattCharacteristic.PROPERTY_BROADCAST)) != null) {
        properties.put(strProperty);
    }
    if ((strProperty = lookup(property, BluetoothGattCharacteristic.PROPERTY_READ)) != null) {
        properties.put(strProperty);
    }
    if ((strProperty = lookup(property, BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE)) != null) {
        properties.put(strProperty);
    }
    if ((strProperty = lookup(property, BluetoothGattCharacteristic.PROPERTY_WRITE)) != null) {
        properties.put(strProperty);
    }
    if ((strProperty = lookup(property, BluetoothGattCharacteristic.PROPERTY_NOTIFY)) != null) {
        properties.put(strProperty);
    }
    if ((strProperty = lookup(property, BluetoothGattCharacteristic.PROPERTY_INDICATE)) != null) {
        properties.put(strProperty);
    }
    if ((strProperty = lookup(property, BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE)) != null) {
        properties.put(strProperty);
    }
    if ((strProperty = lookup(property, BluetoothGattCharacteristic.PROPERTY_EXTENDED_PROPS)) != null) {
        properties.put(strProperty);
    }
    return properties;
}