Example usage for android.bluetooth BluetoothGattCharacteristic getProperties

List of usage examples for android.bluetooth BluetoothGattCharacteristic getProperties

Introduction

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

Prototype

public int getProperties() 

Source Link

Document

Returns the properties of this characteristic.

Usage

From source file:com.cypress.cysmart.GATTDBFragments.GattDescriptorDetails.java

/**
 * Preparing Broadcast receiver to broadcast indicate characteristics
 *
 * @param gattCharacteristic/*from   w w w  .  ja v  a  2 s.c  o  m*/
 */
void prepareBroadcastDataIndicate(BluetoothGattCharacteristic gattCharacteristic) {
    Logger.i("Indicate called");
    final BluetoothGattCharacteristic characteristic = gattCharacteristic;
    final int charaProp = characteristic.getProperties();

    if ((charaProp | BluetoothGattCharacteristic.PROPERTY_INDICATE) > 0) {
        BluetoothLeService.setCharacteristicIndication(gattCharacteristic, true);

    }
}

From source file:com.cypress.cysmart.GATTDBFragments.GattDescriptorDetails.java

/**
 * Stopping Broadcast receiver to broadcast notify characteristics
 *
 * @param gattCharacteristic//from   w  w w . j  a  v a  2  s .c o  m
 */
void stopBroadcastDataNotify(BluetoothGattCharacteristic gattCharacteristic) {
    Logger.i("Notify stopped");
    final BluetoothGattCharacteristic characteristic = gattCharacteristic;
    final int charaProp = characteristic.getProperties();

    if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
        if (gattCharacteristic != null) {
            BluetoothLeService.setCharacteristicNotification(gattCharacteristic, false);
        }

    }

}

From source file:com.cypress.cysmart.GATTDBFragments.GattDescriptorDetails.java

/**
 * Stopping Broadcast receiver to broadcast indicate characteristics
 *
 * @param gattCharacteristic//from   ww  w . ja va  2s .  c  o  m
 */
void stopBroadcastDataIndicate(BluetoothGattCharacteristic gattCharacteristic) {
    Logger.i("Indicate stopped");
    final BluetoothGattCharacteristic characteristic = gattCharacteristic;
    final int charaProp = characteristic.getProperties();

    if ((charaProp | BluetoothGattCharacteristic.PROPERTY_INDICATE) > 0) {
        if (gattCharacteristic != null) {
            Logger.d("Stopped notification");
            BluetoothLeService.setCharacteristicIndication(gattCharacteristic, false);
        }

    }
}

From source file:com.cypress.cysmart.BLEServiceFragments.FindMeService.java

/**
 * Prepare Broadcast receiver to broadcast read characteristics Transmission
 * power/*  w w  w. jav  a 2  s . co m*/
 *
 * @param gattCharacteristic
 */
void prepareBroadcastDataReadtp(BluetoothGattCharacteristic gattCharacteristic) {
    final BluetoothGattCharacteristic characteristic = gattCharacteristic;
    final int charaProp = characteristic.getProperties();
    if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
        mReadCharacteristic_tp = characteristic;
        BluetoothLeService.readCharacteristic(characteristic);
    }
}

From source file:com.cypress.cysmart.BLEServiceFragments.CSCService.java

/**
 * Preparing Broadcast receiver to broadcast notify characteristics
 *
 * @param gattCharacteristic//w  w w . j ava  2s  . co m
 */
void prepareBroadcastDataNotify(BluetoothGattCharacteristic gattCharacteristic) {
    final int charaProp = gattCharacteristic.getProperties();

    if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
        mNotifyCharacteristic = gattCharacteristic;
        BluetoothLeService.setCharacteristicNotification(gattCharacteristic, true);
    }

}

From source file:com.cypress.cysmart.BLEServiceFragments.CSCService.java

/**
 * Stopping Broadcast receiver to broadcast notify characteristics
 *
 * @param gattCharacteristic/*from   w w  w  . jav a  2  s  .  c o m*/
 */
void stopBroadcastDataNotify(BluetoothGattCharacteristic gattCharacteristic) {
    final int charaProp = gattCharacteristic.getProperties();

    if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
        if (mNotifyCharacteristic != null) {
            Logger.d("Stopped notification");
            BluetoothLeService.setCharacteristicNotification(mNotifyCharacteristic, false);
            mNotifyCharacteristic = null;
        }

    }

}

From source file:com.cypress.cysmart.BLEServiceFragments.DeviceInformationService.java

/**
 * Prepare Broadcast receiver to broadcast read characteristics
 *
 * @param gattCharacteristic/*from w  w w.  j  a  v a2 s. co m*/
 */

void prepareBroadcastDataRead(BluetoothGattCharacteristic gattCharacteristic) {
    final BluetoothGattCharacteristic characteristic = gattCharacteristic;
    final int charaProp = characteristic.getProperties();
    if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
        mReadCharacteristic = characteristic;
        BluetoothLeService.readCharacteristic(characteristic);
    }
}

From source file:com.cypress.cysmart.BLEServiceFragments.RSCService.java

/**
 * Stopping Broadcast receiver to broadcast notify characteristics
 *
 * @param gattCharacteristic/*from   w  ww  . ja va  2 s .co m*/
 */
void stopBroadcastDataNotify(BluetoothGattCharacteristic gattCharacteristic) {
    final int charaProp = gattCharacteristic.getProperties();

    if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
        if (mNotifyCharacteristic != null) {
            Logger.d("Stopped notification");
            BluetoothLeService.setCharacteristicNotification(mNotifyCharacteristic, false);
            mNotifyCharacteristic = null;
        }

    }
}

From source file:kr.ac.kaist.resl.sensorservice.BluetoothService.java

private boolean readCharacteristic(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
    if (null == characteristic)
        return false;

    final int charaProp = characteristic.getProperties();

    if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
        // If there is an active notification on a characteristic,
        // clear it first so it doesn't update the data field on the user interface.
        if (mNotifyCharacteristic != null) {
            bleService.setCharacteristicNotification(gatt, mNotifyCharacteristic, false);
            mNotifyCharacteristic = null;
        }/*from  ww  w  . j  a v  a2 s.c om*/

        //JS: if no data is displayed, immediately read data from the connected sensor.
        gatt.readCharacteristic(characteristic);
    }

    if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
        mNotifyCharacteristic = characteristic;
        bleService.setCharacteristicNotification(gatt, characteristic, true);
    }

    return true;
}

From source file:com.megster.cordova.ble.central.Peripheral.java

private BluetoothGattCharacteristic findReadableCharacteristic(BluetoothGattService service,
        UUID characteristicUUID) {
    BluetoothGattCharacteristic characteristic = null;

    int read = BluetoothGattCharacteristic.PROPERTY_READ;

    List<BluetoothGattCharacteristic> characteristics = service.getCharacteristics();
    for (BluetoothGattCharacteristic c : characteristics) {
        if ((c.getProperties() & read) != 0 && characteristicUUID.equals(c.getUuid())) {
            characteristic = c;/*from  w  ww. j ava  2 s .co  m*/
            break;
        }
    }

    // As a last resort, try and find ANY characteristic with this UUID, even if it doesn't have the correct properties
    if (characteristic == null) {
        characteristic = service.getCharacteristic(characteristicUUID);
    }

    return characteristic;
}