List of usage examples for android.bluetooth BluetoothGattCharacteristic PROPERTY_NOTIFY
int PROPERTY_NOTIFY
To view the source code for android.bluetooth BluetoothGattCharacteristic PROPERTY_NOTIFY.
Click Source Link
From source file:com.cypress.cysmart.GATTDBFragments.GattDetailsFragment.java
/** * Method to make the Buttons visible to the user *//* ww w. j av a2 s . c om*/ private void UIbuttonvisibility() { // Getting the properties of each characteristics boolean read = false, write = false, notify = false, indicate = false; if (getGattCharacteristicsPropertices(mReadCharacteristic.getProperties(), BluetoothGattCharacteristic.PROPERTY_READ)) { // Read property available read = true; mBtnread.setVisibility(View.VISIBLE); } if (getGattCharacteristicsPropertices(mReadCharacteristic.getProperties(), BluetoothGattCharacteristic.PROPERTY_WRITE) | getGattCharacteristicsPropertices(mReadCharacteristic.getProperties(), BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE)) { // Write property available write = true; mBtnwrite.setVisibility(View.VISIBLE); } if (getGattCharacteristicsPropertices(mReadCharacteristic.getProperties(), BluetoothGattCharacteristic.PROPERTY_NOTIFY)) { // Notify property available notify = true; mBtnnotify.setVisibility(View.VISIBLE); BluetoothGattDescriptor descriptor = mReadCharacteristic .getDescriptor(UUIDDatabase.UUID_CLIENT_CHARACTERISTIC_CONFIG); if (descriptor != null) { BluetoothLeService.readDescriptor(descriptor); } } if (getGattCharacteristicsPropertices(mReadCharacteristic.getProperties(), BluetoothGattCharacteristic.PROPERTY_INDICATE)) { // Indicate property available indicate = true; mBtnIndicate.setVisibility(View.VISIBLE); BluetoothGattDescriptor descriptor = mReadCharacteristic .getDescriptor(UUIDDatabase.UUID_CLIENT_CHARACTERISTIC_CONFIG); if (descriptor != null) { BluetoothLeService.readDescriptor(descriptor); } } }
From source file:net.kenevans.android.hxmmonitor.HxMBleService.java
/** * Writes READ, NOTIFY, WRITE properties to the Log. Use for debugging. * // w w w . j a v a 2 s .c o m * @param charBat * @param charHr * @param charCustom */ public void checkPermissions(BluetoothGattCharacteristic charBat, BluetoothGattCharacteristic charHr, BluetoothGattCharacteristic charCustom) { // DEBUG // Check permissions if ((charBat.getProperties() & BluetoothGattCharacteristic.PROPERTY_READ) == 0) { Log.d(TAG, "incrementSessionState: charBat: Not Readable"); } else { Log.d(TAG, "incrementSessionState: charBat: Readable"); } if ((charBat.getProperties() & BluetoothGattCharacteristic.PROPERTY_NOTIFY) == 0) { Log.d(TAG, "incrementSessionState: charBat: Not Notifiable"); } else { Log.d(TAG, "incrementSessionState: charBat: Notifiable"); } if ((charBat.getProperties() & BluetoothGattCharacteristic.PROPERTY_WRITE) == 0) { Log.d(TAG, "incrementSessionState: charBat: Not Writeable"); } else { Log.d(TAG, "incrementSessionState: charBat: Writeable"); } if ((charHr.getProperties() & BluetoothGattCharacteristic.PROPERTY_READ) == 0) { Log.d(TAG, "incrementSessionState: charHr: Not Readable"); } else { Log.d(TAG, "incrementSessionState: charHr: Readable"); } if ((charHr.getProperties() & BluetoothGattCharacteristic.PROPERTY_NOTIFY) == 0) { Log.d(TAG, "incrementSessionState: charHr: Not Notifiable"); } else { Log.d(TAG, "incrementSessionState: charHr: Notifiable"); } if ((charHr.getProperties() & BluetoothGattCharacteristic.PROPERTY_WRITE) == 0) { Log.d(TAG, "incrementSessionState: charHr: Not Writeable"); } else { Log.d(TAG, "incrementSessionState: charHr: Writeable"); } if ((charCustom.getProperties() & BluetoothGattCharacteristic.PROPERTY_READ) == 0) { Log.d(TAG, "incrementSessionState: charCustom: Not Readable"); } else { Log.d(TAG, "incrementSessionState: charCustom: Readable"); } if ((charCustom.getProperties() & BluetoothGattCharacteristic.PROPERTY_NOTIFY) == 0) { Log.d(TAG, "incrementSessionState: charCustom: Not Notifiable"); } else { Log.d(TAG, "incrementSessionState: charCustom: Notifiable"); } if ((charCustom.getProperties() & BluetoothGattCharacteristic.PROPERTY_WRITE) == 0) { Log.d(TAG, "incrementSessionState: charCustom: Not Writeable"); } else { Log.d(TAG, "incrementSessionState: charCustom: Writeable"); } }
From source file:com.cypress.cysmart.GATTDBFragments.GattDetailsFragment.java
/** * Preparing Broadcast receiver to broadcast notify characteristics * * @param gattCharacteristic//www . ja v a 2s .c o m */ 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.GATTDBFragments.GattDetailsFragment.java
/** * Stopping Broadcast receiver to broadcast notify characteristics * * @param gattCharacteristic//from ww w .j av 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:org.bcsphere.bluetooth.tools.Tools.java
public static JSONArray decodeProperty(int property) { JSONArray properties = new JSONArray(); String strProperty = null;//from w w w .ja v a2 s. c o m 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; }
From source file:com.nbplus.iotapp.bluetooth.BluetoothLeService.java
/** * Enables or disables notification on a give characteristic. * * @param enabled If true, enable notification. False otherwise. *///from ww w .ja va 2 s.com public boolean setCharacteristicNotification(String address, String serviceUuid, String characteristicUuid, boolean enabled) { Log.d(TAG, "writeRemoteCharacteristic add = " + address + ", svc = " + serviceUuid + ", char = " + characteristicUuid); if (StringUtils.isEmptyString(address) || StringUtils.isEmptyString(serviceUuid) || StringUtils.isEmptyString(characteristicUuid)) { Log.w(TAG, "Unknown parameter"); return false; } BluetoothGatt bluetoothGatt = mConnectedBluetoothGattMap.get(address); if (mBluetoothAdapter == null || bluetoothGatt == null) { Log.w(TAG, "BluetoothAdapter not initialized"); return false; } BluetoothGattService service = bluetoothGatt.getService(UUID.fromString(serviceUuid)); if (service == null) { Log.w(TAG, "Service not found."); return false; } BluetoothGattCharacteristic characteristic = service.getCharacteristic(UUID.fromString(characteristicUuid)); if (characteristic == null) { Log.w(TAG, "characteristic not found."); return false; } bluetoothGatt.setCharacteristicNotification(characteristic, enabled); final int charaProp = characteristic.getProperties(); if ((charaProp & BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { BluetoothGattDescriptor descriptor = characteristic .getDescriptor(UUID.fromString(GattAttributes.CLIENT_CHARACTERISTIC_CONFIG)); if (descriptor != null) { Log.d(TAG, ">>>> ENABLE_NOTIFICATION_VALUE : " + characteristic.getUuid().toString()); descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); bluetoothGatt.writeDescriptor(descriptor); return true; } else { return false; } } else if ((charaProp & BluetoothGattCharacteristic.PROPERTY_INDICATE) > 0) { BluetoothGattDescriptor descriptor = characteristic .getDescriptor(UUID.fromString(GattAttributes.CLIENT_CHARACTERISTIC_CONFIG)); if (descriptor != null) { Log.d(TAG, ">>>> ENABLE_INDICATION_VALUE : " + characteristic.getUuid().toString()); descriptor.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE); bluetoothGatt.writeDescriptor(descriptor); return true; } else { return false; } } else { return false; } }
From source file:com.cypress.cysmart.BLEServiceFragments.SensorHubService.java
/** * Stopping Broadcast receiver to broadcast notify characteristics * * @param gattCharacteristic/*from w w w . j a v a 2s. c o m*/ */ private static void stopBroadcastDataNotify(BluetoothGattCharacteristic gattCharacteristic) { final int charaProp = gattCharacteristic.getProperties(); if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { if (gattCharacteristic != null) { BluetoothLeService.setCharacteristicNotification(gattCharacteristic, false); } } }
From source file:com.cypress.cysmart.BLEServiceFragments.SensorHubService.java
/** * Preparing Broadcast receiver to broadcast notify characteristics * * @param gattCharacteristic/*from w w w .jav a 2 s . c o m*/ */ void prepareBroadcastDataNotify(BluetoothGattCharacteristic gattCharacteristic) { final int charaProp = gattCharacteristic.getProperties(); if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { BluetoothLeService.setCharacteristicNotification(gattCharacteristic, true); } }