List of usage examples for android.bluetooth BluetoothGattCharacteristic PROPERTY_WRITE
int PROPERTY_WRITE
To view the source code for android.bluetooth BluetoothGattCharacteristic PROPERTY_WRITE.
Click Source Link
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 . ja va2 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
void setItem(int pos) { boolean fHasRead; boolean fHasNotification; boolean fHasWrite; BluetoothGattDescriptor clientConfig; mChar = mCharList.get(pos);/*from w w w .j a va 2s. c o m*/ mProperty = mChar.getProperties(); fHasRead = (mProperty & BluetoothGattCharacteristic.PROPERTY_READ) > 0; fHasNotification = (mProperty & BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0; fHasWrite = (mProperty & BluetoothGattCharacteristic.PROPERTY_WRITE) > 0; // Activate input widgets according to char. property mBtnRead.setEnabled(fHasRead); mBtnWrite.setEnabled(fHasWrite); mData.setEnabled(fHasWrite); mBtnNotify.setEnabled(fHasNotification); if (fHasNotification) { mBtnNotify.setTextAppearance(mContext, R.style.checkboxStyle); mBtnNotify.setChecked(mGattService.isNotificationEnabled(mChar)); } else mBtnNotify.setTextAppearance(mContext, R.style.checkboxStyle_Disabled); if (fHasWrite) { mData.setHint(R.string.write_hint); } else { mData.setHint(""); } clientConfig = mChar.getDescriptor(GattInfo.CLIENT_CHARACTERISTIC_CONFIG); if (clientConfig != null) { int perm = clientConfig.getPermissions(); Log.d(TAG, "perm= " + perm); } setStatus(GattInfo.uuidToName(mChar.getUuid())); // Read the characteristic (if applicable) if (fHasRead) { mBtGatt.readCharacteristic(mChar); } // Make sure selection is highlighted mCharAdapter.setSelectedPosition(pos); mActivity.onSelectionUpdate(mChar); }
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;// w w w . jav a 2 s .com }
From source file:com.cypress.cysmart.GATTDBFragments.GattDetailsFragment.java
/** * Method to make the Buttons visible to the user */// www .jav a 2s. co 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.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. *///from w ww .j ava2s .c o m @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.megster.cordova.ble.central.Peripheral.java
private BluetoothGattCharacteristic findWritableCharacteristic(BluetoothGattService service, UUID characteristicUUID, int writeType) { BluetoothGattCharacteristic characteristic = null; // get write property int writeProperty = BluetoothGattCharacteristic.PROPERTY_WRITE; if (writeType == BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE) { writeProperty = BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE; }//from w w w . jav a 2 s . com List<BluetoothGattCharacteristic> characteristics = service.getCharacteristics(); for (BluetoothGattCharacteristic c : characteristics) { if ((c.getProperties() & writeProperty) != 0 && characteristicUUID.equals(c.getUuid())) { characteristic = c; 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.hxmmonitor.HxMBleService.java
/** * Writes READ, NOTIFY, WRITE properties to the Log. Use for debugging. * // w w w. ja va 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:org.bcsphere.bluetooth.tools.Tools.java
public static JSONArray decodeProperty(int property) { JSONArray properties = new JSONArray(); String strProperty = null;/*from w w w.j a v a 2 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:edu.umich.eecs.lab11.camera.CameraFragment.java
private void initServer() { BluetoothGattService service = new BluetoothGattService(DeviceProfile.SERVICE_UUID, BluetoothGattService.SERVICE_TYPE_PRIMARY); BluetoothGattCharacteristic offsetCharacteristic = new BluetoothGattCharacteristic( DeviceProfile.CHARACTERISTIC_UUID, //Read+write permissions BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_WRITE, BluetoothGattCharacteristic.PERMISSION_READ | BluetoothGattCharacteristic.PERMISSION_WRITE); service.addCharacteristic(offsetCharacteristic); mGattServer.addService(service);/*from www. java2s. c om*/ }