Java Code Examples for android.bluetooth.BluetoothGattCharacteristic#PROPERTY_NOTIFY
The following examples show how to use
android.bluetooth.BluetoothGattCharacteristic#PROPERTY_NOTIFY .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeviceControlActivity.java From connectivity-samples with Apache License 2.0 | 6 votes |
@Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { if (mGattCharacteristics != null) { final BluetoothGattCharacteristic characteristic = mGattCharacteristics.get(groupPosition).get(childPosition); 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) { mBluetoothLeService.setCharacteristicNotification( mNotifyCharacteristic, false); mNotifyCharacteristic = null; } mBluetoothLeService.readCharacteristic(characteristic); } if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { mNotifyCharacteristic = characteristic; mBluetoothLeService.setCharacteristicNotification( characteristic, true); } return true; } return false; }
Example 2
Source File: GattServer.java From blefun-androidthings with Apache License 2.0 | 6 votes |
private BluetoothGattService createAwesomenessService() { BluetoothGattService service = new BluetoothGattService(SERVICE_UUID, BluetoothGattService.SERVICE_TYPE_PRIMARY); // Counter characteristic (read-only, supports notifications) BluetoothGattCharacteristic counter = new BluetoothGattCharacteristic(CHARACTERISTIC_COUNTER_UUID, BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_NOTIFY, BluetoothGattCharacteristic.PERMISSION_READ); BluetoothGattDescriptor counterConfig = new BluetoothGattDescriptor(DESCRIPTOR_CONFIG, BluetoothGattDescriptor.PERMISSION_READ | BluetoothGattDescriptor.PERMISSION_WRITE); counter.addDescriptor(counterConfig); BluetoothGattDescriptor counterDescription = new BluetoothGattDescriptor(DESCRIPTOR_USER_DESC, BluetoothGattDescriptor.PERMISSION_READ); counter.addDescriptor(counterDescription); // Interactor characteristic BluetoothGattCharacteristic interactor = new BluetoothGattCharacteristic(CHARACTERISTIC_INTERACTOR_UUID, BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE, BluetoothGattCharacteristic.PERMISSION_WRITE); BluetoothGattDescriptor interactorDescription = new BluetoothGattDescriptor(DESCRIPTOR_USER_DESC, BluetoothGattDescriptor.PERMISSION_READ); interactor.addDescriptor(interactorDescription); service.addCharacteristic(counter); service.addCharacteristic(interactor); return service; }
Example 3
Source File: CharacteristicDetailActivity.java From AndroidBleManager with Apache License 2.0 | 6 votes |
private String getPropertyString(int property){ StringBuilder sb = new StringBuilder(); // 可读 if ((property & BluetoothGattCharacteristic.PROPERTY_READ) > 0) { sb.append("Read "); } // 可写,注:要 & 其可写的两个属性 if ((property & BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) > 0 || (property & BluetoothGattCharacteristic.PROPERTY_WRITE) > 0) { sb.append("Write "); } // 可通知,可指示 if ((property & BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0 || (property & BluetoothGattCharacteristic.PROPERTY_INDICATE) > 0) { sb.append("Notity Indicate "); } // 广播 if ((property & BluetoothGattCharacteristic.PROPERTY_BROADCAST) > 0){ sb.append("Broadcast "); } sb.deleteCharAt(sb.length() - 1); return sb.toString(); }
Example 4
Source File: P_Task_ToggleNotify.java From AsteroidOSSync with GNU General Public License v3.0 | 6 votes |
static byte[] getWriteValue(BluetoothGattCharacteristic char_native, boolean enable) { final int type; if( (char_native.getProperties() & BluetoothGattCharacteristic.PROPERTY_NOTIFY) != 0x0 ) { type = Type_NOTIFY; } else if( (char_native.getProperties() & BluetoothGattCharacteristic.PROPERTY_INDICATE) != 0x0 ) { type = Type_INDICATE; } else { type = Type_NOTIFY; } final byte[] enableValue = type == Type_NOTIFY ? BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE : BluetoothGattDescriptor.ENABLE_INDICATION_VALUE; final byte[] disableValue = BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE; return enable ? enableValue : disableValue; }
Example 5
Source File: BlePeripheral.java From Bluefruit_LE_Connect_Android_V2 with MIT License | 6 votes |
public void characteristicEnableNotify(@NonNull final BluetoothGattCharacteristic characteristic, NotifyHandler notifyHandler, CompletionHandler completionHandler) { final String identifier = getCharacteristicIdentifier(characteristic); BleCommand command = new BleCommand(BleCommand.BLECOMMANDTYPE_SETNOTIFY, kDebugCommands ? identifier : null, completionHandler) { @Override public void execute() { BluetoothGattDescriptor descriptor = characteristic.getDescriptor(kClientCharacteristicConfigUUID); if (mBluetoothGatt != null && descriptor != null && (characteristic.getProperties() & BluetoothGattCharacteristic.PROPERTY_NOTIFY) != 0) { mNotifyHandlers.put(identifier, notifyHandler); mBluetoothGatt.setCharacteristicNotification(characteristic, true); descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); mBluetoothGatt.writeDescriptor(descriptor); //characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT); } else { Log.w(TAG, "enable notify: client config descriptor not found for characteristic: " + characteristic.getUuid().toString()); finishExecutingCommand(BluetoothGatt.GATT_FAILURE); } } }; mCommmandQueue.add(command); }
Example 6
Source File: BleManager.java From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License | 5 votes |
private boolean internalSetBatteryNotifications(final boolean enable) { final BluetoothGatt gatt = bluetoothGatt; if (gatt == null) { return false; } final BluetoothGattService batteryService = gatt.getService(BATTERY_SERVICE); if (batteryService == null) return false; final BluetoothGattCharacteristic batteryLevelCharacteristic = batteryService.getCharacteristic(BATTERY_LEVEL_CHARACTERISTIC); if (batteryLevelCharacteristic == null) return false; // Check characteristic property final int properties = batteryLevelCharacteristic.getProperties(); if ((properties & BluetoothGattCharacteristic.PROPERTY_NOTIFY) == 0) return false; gatt.setCharacteristicNotification(batteryLevelCharacteristic, enable); final BluetoothGattDescriptor descriptor = batteryLevelCharacteristic.getDescriptor(CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR_UUID); if (descriptor != null) { if (enable) { descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); } else { descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE); } return internalWriteDescriptorWorkaround(descriptor); } return false; }
Example 7
Source File: ChangeCharActivity.java From bleTester with Apache License 2.0 | 5 votes |
@SuppressLint("NewApi") @Override public void onServiceConnected(ComponentName arg0, IBinder service) { // TODO Auto-generated method stub bleService = ((BleService.LocalBinder) service).getService(); gattChar = bleService.mBluetoothGatt.getService(serUuid) .getCharacteristic(charUuid); bleService.mBluetoothGatt.readCharacteristic(gattChar); if (gattChar.getDescriptors().size() != 0) { BluetoothGattDescriptor des = gattChar.getDescriptors().get(0); des.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); bleService.mBluetoothGatt.writeDescriptor(des); } int prop = gattChar.getProperties(); if ((prop & BluetoothGattCharacteristic.PROPERTY_WRITE) > 0) { bleService.mBluetoothGatt.setCharacteristicNotification( gattChar, false); } if ((prop & BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) > 0) { bleService.mBluetoothGatt.setCharacteristicNotification( gattChar, false); } if ((prop & BluetoothGattCharacteristic.PROPERTY_READ) > 0) { bleService.mBluetoothGatt.setCharacteristicNotification( gattChar, false); } if ((prop & BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { bleService.mBluetoothGatt.setCharacteristicNotification( gattChar, true); } }
Example 8
Source File: DeviceControlActivity.java From IoT-Firstep with GNU General Public License v3.0 | 5 votes |
/** * 获取BLE的特征值 * @param gattServices */ private void getCharacteristic(List<BluetoothGattService> gattServices) { if (gattServices == null) return; String uuid = null; // Loops through available GATT Services. for (BluetoothGattService gattService : gattServices) { uuid = gattService.getUuid().toString(); //找uuid为0xffe0的服务 if (uuid.equals(C.SERVICE_UUID)) { List<BluetoothGattCharacteristic> gattCharacteristics = gattService.getCharacteristics(); //找uuid为0xffe1的特征值 for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) { uuid = gattCharacteristic.getUuid().toString(); if(uuid.equals(C.CHAR_UUID)){ mCharacteristic = gattCharacteristic; final int charaProp = gattCharacteristic.getProperties(); //开启该特征值的数据的监听 if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { mBluetoothLeService.setCharacteristicNotification( mCharacteristic, true); } System.out.println("uuid----->" + uuid); } } } } //如果没找到指定的特征值,直接返回 if (mCharacteristic == null) { Toast.makeText(DeviceControlActivity.this, "未找到指定特征值", Toast.LENGTH_LONG).show(); finish(); } }
Example 9
Source File: BleConnector.java From FastBle with Apache License 2.0 | 5 votes |
/** * indicate */ public void enableCharacteristicIndicate(BleIndicateCallback bleIndicateCallback, String uuid_indicate, boolean useCharacteristicDescriptor) { if (mCharacteristic != null && (mCharacteristic.getProperties() | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { handleCharacteristicIndicateCallback(bleIndicateCallback, uuid_indicate); setCharacteristicIndication(mBluetoothGatt, mCharacteristic, useCharacteristicDescriptor, true, bleIndicateCallback); } else { if (bleIndicateCallback != null) bleIndicateCallback.onIndicateFailure(new OtherException("this characteristic not support indicate!")); } }
Example 10
Source File: DeviceControlActivity.java From IoT-Firstep with GNU General Public License v3.0 | 5 votes |
/** * 获取BLE的特征值 * @param gattServices */ private void getCharacteristic(List<BluetoothGattService> gattServices) { if (gattServices == null) return; String uuid = null; // Loops through available GATT Services. for (BluetoothGattService gattService : gattServices) { uuid = gattService.getUuid().toString(); //找uuid为0xffe0的服务 if (uuid.equals(C.SERVICE_UUID)) { List<BluetoothGattCharacteristic> gattCharacteristics = gattService.getCharacteristics(); //找uuid为0xffe1的特征值 for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) { uuid = gattCharacteristic.getUuid().toString(); if(uuid.equals(C.CHAR_UUID)){ mCharacteristic = gattCharacteristic; final int charaProp = gattCharacteristic.getProperties(); //开启该特征值的数据的监听 if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { mBluetoothLeService.setCharacteristicNotification( mCharacteristic, true); } System.out.println("uuid----->" + uuid); } } } } //如果没找到指定的特征值,直接返回 if (mCharacteristic == null) { Toast.makeText(DeviceControlActivity.this, "未找到指定特征值", Toast.LENGTH_LONG).show(); finish(); } }
Example 11
Source File: TourTheStairs.java From jessica with MIT License | 5 votes |
public void setAllNotification( Boolean enable ) { for( ArrayList<BluetoothGattCharacteristic> myList : mGattCharacteristics ) for( BluetoothGattCharacteristic characteristic : myList) { int charaProp = characteristic.getProperties(); if ((charaProp & BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { mBluetoothLeService.setCharacteristicNotification(characteristic, enable); sleep(50); } } }
Example 12
Source File: CharacteristicDetailsActivity.java From BLEService with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static String getCharacteristicPropertiesString(int props) { String propertiesString = String.format("0x%04X [", props); if((props & BluetoothGattCharacteristic.PROPERTY_READ) != 0) propertiesString += "read "; if((props & BluetoothGattCharacteristic.PROPERTY_WRITE) != 0) propertiesString += "write "; if((props & BluetoothGattCharacteristic.PROPERTY_NOTIFY) != 0) propertiesString += "notify "; if((props & BluetoothGattCharacteristic.PROPERTY_INDICATE) != 0) propertiesString += "indicate "; if((props & BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) != 0) propertiesString += "write_no_response "; propertiesString += "]"; return propertiesString; }
Example 13
Source File: GattServerTests.java From bitgatt with Mozilla Public License 2.0 | 5 votes |
@BeforeClass public static void before() { Timber.plant(new Timber.DebugTree()); mockContext = InstrumentationRegistry.getInstrumentation().getContext(); main = new BluetoothGattService(UUID.fromString("adabfb00-6e7d-4601-bda2-bffaa68956ba"), BluetoothGattService.SERVICE_TYPE_PRIMARY); BluetoothGattCharacteristic txChar = new BluetoothGattCharacteristic(UUID.fromString("ADABFB01-6E7D-4601-BDA2-BFFAA68956BA"), BluetoothGattCharacteristic.PROPERTY_WRITE | BluetoothGattCharacteristic.PROPERTY_NOTIFY, BluetoothGattCharacteristic.PERMISSION_WRITE | BluetoothGattCharacteristic.PERMISSION_WRITE_ENCRYPTED); main.addCharacteristic(txChar); BluetoothGattCharacteristic rxChar = new BluetoothGattCharacteristic(UUID.fromString("ADABFB02-6E7D-4601-BDA2-BFFAA68956BA"), BluetoothGattCharacteristic.PROPERTY_INDICATE | BluetoothGattCharacteristic.PROPERTY_NOTIFY | BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ | BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED); main.addCharacteristic(rxChar); liveData = new BluetoothGattService(UUID.fromString("558dfa00-4fa8-4105-9f02-4eaa93e62980"), BluetoothGattService.SERVICE_TYPE_PRIMARY); BluetoothGattCharacteristic ldChar = new BluetoothGattCharacteristic(UUID.fromString("558DFA01-4FA8-4105-9F02-4EAA93E62980"), BluetoothGattCharacteristic.PROPERTY_INDICATE | BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ | BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED); liveData.addCharacteristic(ldChar); dncs = new BluetoothGattService(UUID.fromString("16bcfd00-253f-c348-e831-0db3e334d580"), BluetoothGattService.SERVICE_TYPE_PRIMARY); BluetoothGattCharacteristic notifChar = new BluetoothGattCharacteristic(UUID.fromString("16BCFD02-253F-C348-E831-0DB3E334D580"), BluetoothGattCharacteristic.PROPERTY_NOTIFY | BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED | BluetoothGattCharacteristic.PERMISSION_WRITE); dncs.addCharacteristic(notifChar); cpChar = new BluetoothGattCharacteristic(UUID.fromString("16BCFD01-253F-C348-E831-0DB3E334D580"), BluetoothGattCharacteristic.PROPERTY_WRITE | BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ | BluetoothGattCharacteristic.PERMISSION_WRITE); dncs.addCharacteristic(cpChar); BluetoothGattCharacteristic flsChar = new BluetoothGattCharacteristic(UUID.fromString("16BCFD04-253F-C348-E831-0DB3E334D580"), BluetoothGattCharacteristic.PROPERTY_WRITE | BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ | BluetoothGattCharacteristic.PERMISSION_WRITE); dncs.addCharacteristic(flsChar); }
Example 14
Source File: DeviceControlActivity.java From IoT-Firstep with GNU General Public License v3.0 | 5 votes |
/** * 获取BLE的特征值 * @param gattServices */ private void getCharacteristic(List<BluetoothGattService> gattServices) { if (gattServices == null) return; String uuid = null; // Loops through available GATT Services. for (BluetoothGattService gattService : gattServices) { uuid = gattService.getUuid().toString(); //找uuid为0000ffe0-0000-1000-8000-00805f9b34fb的服务 if (uuid.equals(C.SERVICE_UUID)) { List<BluetoothGattCharacteristic> gattCharacteristics = gattService.getCharacteristics(); //找uuid为0000ffe1-0000-1000-8000-00805f9b34fb的特征值 for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) { uuid = gattCharacteristic.getUuid().toString(); if(uuid.equals(C.CHAR_UUID)){ mCharacteristic = gattCharacteristic; final int charaProp = gattCharacteristic.getProperties(); //开启该特征值的数据的监听 if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { mBluetoothLeService.setCharacteristicNotification( mCharacteristic, true); } System.out.println("uuid----->" + uuid); } } } } //如果没找到指定的特征值,直接返回 if (mCharacteristic == null) { Toast.makeText(DeviceControlActivity.this, "未找到指定特征值", Toast.LENGTH_LONG).show(); finish(); } }
Example 15
Source File: Node.java From BlueSTSDK_Android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * send a request for enable/disable the notification update on a specific characteristics * @param characteristic characteristics to notify * @param enable true if you want enable the notification, false if you want disable it * @return true if the request is correctly send, false otherwise */ boolean changeNotificationStatus(BluetoothGattCharacteristic characteristic, boolean enable){ if(charCanBeNotify(characteristic) && mConnection!=null && isConnected()){ BluetoothGattDescriptor descriptor = characteristic.getDescriptor(NOTIFY_CHAR_DESC_UUID); if(descriptor==null) return false; WriteDescCommand command = null; final int properties = characteristic.getProperties(); if((properties & BluetoothGattCharacteristic.PROPERTY_NOTIFY) != 0) { command = new WriteDescCommand(descriptor, enable ? BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE : BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE); }else if((properties & BluetoothGattCharacteristic.PROPERTY_INDICATE) != 0) { command = new WriteDescCommand(descriptor, enable ? BluetoothGattDescriptor.ENABLE_INDICATION_VALUE : BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE); } if(command==null) return false; enqueueWriteDesc(command); return true; }else return false; }
Example 16
Source File: GattDatabase.java From SweetBlue with GNU General Public License v3.0 | 4 votes |
public final Properties notify_prop() { m_properties |= BluetoothGattCharacteristic.PROPERTY_NOTIFY; return this; }
Example 17
Source File: BleConnectWorker.java From Android-BluetoothKit with Apache License 2.0 | 4 votes |
private boolean isCharacteristicNotifyable(BluetoothGattCharacteristic characteristic) { return characteristic != null && (characteristic.getProperties() & BluetoothGattCharacteristic.PROPERTY_NOTIFY) != 0; }
Example 18
Source File: BLEUtils.java From android with MIT License | 4 votes |
/** * @return Returns <b>true</b> if property is supports notification */ public static boolean isCharacteristicNotifiable(BluetoothGattCharacteristic pChar) { return (pChar.getProperties() & BluetoothGattCharacteristic.PROPERTY_NOTIFY) != 0; }
Example 19
Source File: P_DeviceServiceManager.java From SweetBlue with GNU General Public License v3.0 | 4 votes |
static BleDevice.ReadWriteListener.Type modifyResultType(BleCharacteristicWrapper char_native, BleDevice.ReadWriteListener.Type type) { if( !char_native.isNull()) { if( type == Type.NOTIFICATION ) { if( (char_native.getCharacteristic().getProperties() & BluetoothGattCharacteristic.PROPERTY_NOTIFY) == 0x0 ) { if( (char_native.getCharacteristic().getProperties() & BluetoothGattCharacteristic.PROPERTY_INDICATE) != 0x0 ) { type = Type.INDICATION; } } } else if( type == Type.WRITE ) { if( (char_native.getCharacteristic().getProperties() & BluetoothGattCharacteristic.PROPERTY_WRITE) == 0x0 ) { if( (char_native.getCharacteristic().getProperties() & BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) != 0x0 ) { type = Type.WRITE_NO_RESPONSE; } else if( (char_native.getCharacteristic().getProperties() & BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE) != 0x0 ) { type = Type.WRITE_SIGNED; } } //--- RB > Check the write type on the characteristic, in case this char has multiple write types int writeType = char_native.getCharacteristic().getWriteType(); if (writeType == BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE) { type = Type.WRITE_NO_RESPONSE; } else if (writeType == BluetoothGattCharacteristic.WRITE_TYPE_SIGNED) { type = Type.WRITE_SIGNED; } } } return type; }
Example 20
Source File: CorePeripheral.java From RxCentralBle with Apache License 2.0 | 4 votes |
@Nullable private PeripheralError setCharacteristicNotification( BluetoothGatt bluetoothGatt, BluetoothGattCharacteristic characteristic, boolean enable) { BluetoothGattDescriptor cccd = characteristic.getDescriptor(CCCD_UUID); if (cccd == null) { return new PeripheralError(PeripheralError.Code.SET_CHARACTERISTIC_NOTIFICATION_CCCD_MISSING); } if (!bluetoothGatt.setCharacteristicNotification(characteristic, enable)) { return new PeripheralError(PeripheralError.Code.SET_CHARACTERISTIC_NOTIFICATION_FAILED); } int properties = characteristic.getProperties(); byte[] value; if (enable) { if ((properties & BluetoothGattCharacteristic.PROPERTY_NOTIFY) == BluetoothGattCharacteristic.PROPERTY_NOTIFY) { value = BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE; } else if ((properties & BluetoothGattCharacteristic.PROPERTY_INDICATE) == BluetoothGattCharacteristic.PROPERTY_INDICATE) { value = BluetoothGattDescriptor.ENABLE_INDICATION_VALUE; } else { return new PeripheralError(PeripheralError.Code.SET_CHARACTERISTIC_NOTIFICATION_MISSING_PROPERTY); } } else { value = BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE; } characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT); if (!cccd.setValue(value)) { return new PeripheralError(CHARACTERISTIC_SET_VALUE_FAILED); } if (!bluetoothGatt.writeDescriptor(cccd)) { return new PeripheralError(PeripheralError.Code.WRITE_DESCRIPTOR_FAILED, ERROR_STATUS_CALL_FAILED); } return null; }