List of usage examples for android.bluetooth BluetoothGattCharacteristic getProperties
public int getProperties()
From source file:Main.java
public static boolean hasProperty(BluetoothGattCharacteristic characteristic, int property) { return (characteristic.getProperties() & property) != 0; }
From source file:Main.java
public static String getReadableCharacteristicProperties(BluetoothGattCharacteristic c) { List<String> qualities = new ArrayList<String>(); StringBuilder s = new StringBuilder(); int cProps = c.getProperties(); for (Object[] property : properties) { if ((cProps & ((Integer) property[0])) != 0) { s.append((String) property[1]); s.append('\n'); }/* w w w.j av a 2 s.com*/ } int cPerms = c.getPermissions(); for (Object[] permission : permissions) { if ((cProps & ((Integer) permission[0])) != 0) { s.append((String) permission[1]); s.append('\n'); } } return s.toString(); }
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 www .j a v a2 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:com.cypress.cysmart.BLEServiceFragments.CapsenseService.java
/** * Stopping Broadcast receiver to broadcast notify characteristics * * @param gattCharacteristic// www. j av a 2 s. c o m */ private static void stopBroadcastDataNotify(BluetoothGattCharacteristic gattCharacteristic) { final BluetoothGattCharacteristic characteristic = gattCharacteristic; final int charaProp = characteristic.getProperties(); if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { if (characteristic != null) { Logger.d("Stopped notification"); BluetoothLeService.setCharacteristicNotification(characteristic, false); } } }
From source file:com.cypress.cysmart.BLEServiceFragments.GlucoseService.java
/** * Preparing Broadcast receiver to broadcast notify characteristics * * @param gattCharacteristic/*from w w w. j a v a 2s .com*/ */ void prepareBroadcastDataNotify(BluetoothGattCharacteristic gattCharacteristic) { final BluetoothGattCharacteristic characteristic = gattCharacteristic; final int charaProp = characteristic.getProperties(); if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { mNotifyCharacteristic = characteristic; BluetoothLeService.setCharacteristicNotification(characteristic, true); } }
From source file:com.cypress.cysmart.BLEServiceFragments.GlucoseService.java
/** * Stopping Broadcast receiver to broadcast notify characteristics * * @param gattCharacteristic/* www . ja v a2 s. co m*/ */ void stopBroadcastDataNotify(BluetoothGattCharacteristic gattCharacteristic) { final BluetoothGattCharacteristic characteristic = gattCharacteristic; final int charaProp = characteristic.getProperties(); if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { if (mNotifyCharacteristic != null) { BluetoothLeService.setCharacteristicNotification(mNotifyCharacteristic, false); } } }
From source file:com.cypress.cysmart.BLEServiceFragments.BatteryInformationService.java
/** * Preparing Broadcast receiver to broadcast read characteristics * * @param gattCharacteristic//from www . jav a 2s.co m */ void prepareBroadcastDataRead(BluetoothGattCharacteristic gattCharacteristic) { final int charaProp = gattCharacteristic.getProperties(); if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) { mReadCharacteristic = gattCharacteristic; BluetoothLeService.readCharacteristic(gattCharacteristic); } }
From source file:com.cypress.cysmart.BLEServiceFragments.BloodPressureService.java
/** * Preparing Broadcast receiver to broadcast indicate characteristics * * @param gattCharacteristic//from w w w . j a va 2 s. c om */ void prepareBroadcastDataIndicate(BluetoothGattCharacteristic gattCharacteristic) { final int charaProp = gattCharacteristic.getProperties(); if ((charaProp | BluetoothGattCharacteristic.PROPERTY_INDICATE) > 0) { if (mIndicateCharacteristic != null) { mIndicateCharacteristic = gattCharacteristic; BluetoothLeService.setCharacteristicIndication(mIndicateCharacteristic, true); } } }
From source file:com.cypress.cysmart.BLEServiceFragments.BloodPressureService.java
/** * Stopping Broadcast receiver to broadcast indicate characteristics * * @param gattCharacteristic//from ww w.j a v a 2s . co m */ void stopBroadcastDataIndicate(BluetoothGattCharacteristic gattCharacteristic) { final int charaProp = gattCharacteristic.getProperties(); if ((charaProp | BluetoothGattCharacteristic.PROPERTY_INDICATE) > 0) { if (mIndicateCharacteristic != null) { Logger.d("Stopped notification"); BluetoothLeService.setCharacteristicIndication(mIndicateCharacteristic, false); mIndicateCharacteristic = null; } } }
From source file:com.cypress.cysmart.BLEServiceFragments.BatteryInformationService.java
/** * Preparing Broadcast receiver to broadcast notify characteristics * * @param gattCharacteristic/* www . ja va 2 s . c o m*/ */ void prepareBroadcastDataNotify(BluetoothGattCharacteristic gattCharacteristic) { Logger.i("Notify called"); final int charaProp = gattCharacteristic.getProperties(); if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { BluetoothLeService.setCharacteristicNotification(gattCharacteristic, true); } }