List of usage examples for android.bluetooth BluetoothGattCharacteristic PROPERTY_READ
int PROPERTY_READ
To view the source code for android.bluetooth BluetoothGattCharacteristic PROPERTY_READ.
Click Source Link
From source file:com.cypress.cysmart.BLEServiceFragments.HealthTemperatureService.java
/** * Preparing Broadcast receiver to broadcast read characteristics * * @param gattCharacteristic// w ww. j a va2 s .c o m */ void prepareBroadcastDataRead(BluetoothGattCharacteristic gattCharacteristic) { final int charaProp = gattCharacteristic.getProperties(); if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) { mReadCharacteristic = gattCharacteristic; BluetoothLeService.readCharacteristic(gattCharacteristic); } }
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;/*ww w . ja va 2 s . c om*/ }
From source file:com.cypress.cysmart.BLEServiceFragments.HeartRateService.java
/** * Preparing Broadcast receiver to broadcast read characteristics * * @param gattCharacteristic// w w w . java 2 s.c om */ void prepareBroadcastDataRead(BluetoothGattCharacteristic gattCharacteristic) { final int charaProp = gattCharacteristic.getProperties(); if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) { mReadCharacteristic = gattCharacteristic; BluetoothLeService.readCharacteristic(gattCharacteristic); } }
From source file:com.muggins.test.ble.DeviceControlActivity.java
private void displayGattServices(List<BluetoothGattService> gattServices) { if (gattServices == null) return;//from ww w . j a v a 2 s . co m String uuid = null; // String unknownServiceString = getResources().getString(R.string.unknown_service); // String unknownCharaString = getResources().getString(R.string.unknown_characteristic); ArrayList<HashMap<String, String>> gattServiceData = new ArrayList<HashMap<String, String>>(); ArrayList<ArrayList<HashMap<String, String>>> gattCharacteristicData = new ArrayList<ArrayList<HashMap<String, String>>>(); mGattCharacteristics = new ArrayList<ArrayList<BluetoothGattCharacteristic>>(); // Loops through available GATT Services. for (BluetoothGattService gattService : gattServices) { HashMap<String, String> currentServiceData = new HashMap<String, String>(); if (SampleGattAttributes.SERVICE_NUMBER.equals(gattService.getUuid().toString())) { uuid = gattService.getUuid().toString(); // currentServiceData.put(LIST_NAME, "?"); // currentServiceData.put(LIST_UUID, "??1234"); // gattServiceData.add(currentServiceData); ArrayList<HashMap<String, String>> gattCharacteristicGroupData = new ArrayList<HashMap<String, String>>(); List<BluetoothGattCharacteristic> gattCharacteristics = gattService.getCharacteristics(); ArrayList<BluetoothGattCharacteristic> charas = new ArrayList<BluetoothGattCharacteristic>(); // Loops through available Characteristics. for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) { charas.add(gattCharacteristic); HashMap<String, String> currentCharaData = new HashMap<String, String>(); if (SampleGattAttributes.HEART_RATE_MEASUREMENT .equals(gattCharacteristic.getUuid().toString())) { uuid = gattCharacteristic.getUuid().toString(); currentCharaData.put(LIST_NAME, "?"); currentCharaData.put(LIST_UUID, ""); gattCharacteristicGroupData.add(currentCharaData); final int charaProp = gattCharacteristic.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. Log.e("BluetoothLeService", "read"); if (mNotifyCharacteristic != null) { mBluetoothLeService.setCharacteristicNotification( // mNotifyCharacteristic, false); mNotifyCharacteristic, true); mNotifyCharacteristic = null; } mBluetoothLeService.readCharacteristic(gattCharacteristic); // Intent intent = new Intent(DeviceControlActivity.this, ShowWave.class); // startActivity(intent); } if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { Log.e("BluetoothLeService", "notify"); mNotifyCharacteristic = gattCharacteristic; mBluetoothLeService.setCharacteristicNotification(gattCharacteristic, true); } } } mGattCharacteristics.add(charas); gattCharacteristicData.add(gattCharacteristicGroupData); } } SimpleExpandableListAdapter gattServiceAdapter = new SimpleExpandableListAdapter(this, gattServiceData, android.R.layout.simple_expandable_list_item_2, new String[] { LIST_NAME, LIST_UUID }, new int[] { android.R.id.text1, android.R.id.text2 }, gattCharacteristicData, android.R.layout.simple_expandable_list_item_2, new String[] { LIST_NAME, LIST_UUID }, new int[] { android.R.id.text1, android.R.id.text2 }); mGattServicesList.setAdapter(gattServiceAdapter); }
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 www.j av a 2 s .c om*/ 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; }
From source file:net.kenevans.android.blecardiacmonitor.BCMBleService.java
/** * Writes READ, NOTIFY, WRITE properties to the Log. Use for debugging. * * @param charBat The BAT characteristic. * @param charHr The HR characteristic. * @param charCustom The custom characteristic. */// w ww . ja v a2 s .c om @SuppressWarnings("unused") 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 Writable"); } else { Log.d(TAG, "incrementSessionState: charBat: Writable"); } 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 Writable"); } else { Log.d(TAG, "incrementSessionState: charHr: Writable"); } 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 Writable"); } else { Log.d(TAG, "incrementSessionState: charCustom: Writable"); } }
From source file:com.cypress.cysmart.GATTDBFragments.GattDetailsFragment.java
/** * Method to make the Buttons visible to the user *///from ww w . j a v a2 s . c o m 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. * /*from w ww .j ava 2s .co 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 read characteristics * * @param gattCharacteristic/* w w w. jav a 2 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.DeviceInformationService.java
/** * Prepare Broadcast receiver to broadcast read characteristics * * @param gattCharacteristic// www. jav a 2 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); } }