List of usage examples for android.bluetooth BluetoothGattCharacteristic getDescriptor
public BluetoothGattDescriptor getDescriptor(UUID uuid)
From source file:com.cardiograph.service.UartService.java
/** * Enable TXNotification//from w w w . j a v a 2s. com * * @return */ public void enableTXNotification() { if (mBluetoothGatt == null) { showMessage("mBluetoothGatt null" + mBluetoothGatt); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); if (RxService == null) { showMessage("Rx service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } BluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID); if (TxChar == null) { showMessage("Tx charateristic not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } mBluetoothGatt.setCharacteristicNotification(TxChar, true); BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD); descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); mBluetoothGatt.writeDescriptor(descriptor); }
From source file:com.pandadentist.service.UartService.java
/** * Enable TXNotification// w ww . j a v a 2 s. c o m * * @return */ public void enableTXNotification() { /* if (mBluetoothGatt == null) { showMessage("mBluetoothGatt null" + mBluetoothGatt); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } */ BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); if (RxService == null) { showMessage("Rx service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } BluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID); if (TxChar == null) { showMessage("Tx charateristic not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } mBluetoothGatt.setCharacteristicNotification(TxChar, true); BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD); descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); mBluetoothGatt.writeDescriptor(descriptor); }
From source file:com.github.vgoliveira.panificadora.UartService.java
/** * Enable TXNotification/*w w w . jav a 2s . c om*/ * * @return */ // No est sendo usadada na verso autal public void enableTXNotification() { /* if (mBluetoothGatt == null) { showMessage("mBluetoothGatt null" + mBluetoothGatt); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } */ BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); if (RxService == null) { showMessage("Rx service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } BluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID); if (TxChar == null) { showMessage("Tx charateristic not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } mBluetoothGatt.setCharacteristicNotification(TxChar, true); BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD); descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); mBluetoothGatt.writeDescriptor(descriptor); }
From source file:com.huiwu.bluetooth.BluetoothService.java
/** * Enable TXNotification/* w w w .j a va2 s .c om*/ * * @return */ public void enableTXNotification(boolean enable) { /* if (mBluetoothGatt == null) { showMessage("mBluetoothGatt null" + mBluetoothGatt); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } */ BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); if (RxService == null) { showMessage("Rx service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } BluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID); if (TxChar == null) { showMessage("Tx charateristic not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } mBluetoothGatt.setCharacteristicNotification(TxChar, true); BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD); if (enable) { descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); } else { descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE); } mBluetoothGatt.writeDescriptor(descriptor); }
From source file:com.example.UART.UartService.java
/** * Enable TXNotification/*from w ww . j a va2s .co m*/ * * @return */ @SuppressLint("NewApi") public void enableTXNotification() { if (mBluetoothGatt == null) { showMessage("mBluetoothGatt null" + mBluetoothGatt); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); if (RxService == null) { showMessage("Rx service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } BluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID); if (TxChar == null) { showMessage("Tx charateristic not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } mBluetoothGatt.setCharacteristicNotification(TxChar, true); BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD); descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); mBluetoothGatt.writeDescriptor(descriptor); }
From source file:com.ec.android.module.bluetooth40.BluetoothLeService.java
public void setCharacteristicNotification(BluetoothGattCharacteristic characteristic, boolean enabled) { if (mBluetoothAdapter == null || mBluetoothGatt == null) { Log.w(TAG, "BluetoothAdapter not initialized"); return;//w w w .j a v a 2 s . c o m } if (enabled == true) { mBluetoothGatt.setCharacteristicNotification(characteristic, true); BluetoothGattDescriptor descriptor = characteristic .getDescriptor(CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR_UUID); if (descriptor != null) { //?? descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); mBluetoothGatt.writeDescriptor(descriptor); } } else { mBluetoothGatt.setCharacteristicNotification(characteristic, false); BluetoothGattDescriptor descriptor = characteristic .getDescriptor(CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR_UUID); if (descriptor != null) { //?? descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE); mBluetoothGatt.writeDescriptor(descriptor); } } }
From source file:com.aprilbrother.blueduino.UartService.java
/** * Enable TXNotification//from w ww . j ava 2s.co m * * @return */ public void enableTXNotification() { /* * if (mBluetoothGatt == null) { showMessage("mBluetoothGatt null" + * mBluetoothGatt); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); * return; } */ BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); if (RxService == null) { showMessage("Rx service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } BluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID); if (TxChar == null) { showMessage("Tx charateristic not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } mBluetoothGatt.setCharacteristicNotification(TxChar, true); BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD); descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); mBluetoothGatt.writeDescriptor(descriptor); }
From source file:com.example.kevin.health.ble.UartService.java
/** * Enable TXNotification/*from w w w. java 2s .c om*/ * * @return */ public void enableHRNotification() { /* if (mBluetoothGatt == null) { showMessage("mBluetoothGatt null" + mBluetoothGatt); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT); return; } */ BluetoothGattService HRService = mBluetoothGatt.getService(HR_SERVICE_UUID); if (HRService == null) { showMessage("HR service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT); return; } BluetoothGattCharacteristic TxChar = HRService.getCharacteristic(HR_CHAR_UUID); if (TxChar == null) { showMessage("HR charateristic not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT); return; } mBluetoothGatt.setCharacteristicNotification(TxChar, true); BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD); descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); mBluetoothGatt.writeDescriptor(descriptor); }
From source file:com.example.kevin.health.ble.UartService.java
/** * Enable TXNotification//from w w w.ja v a 2 s . c o m * * @return */ public void enableTXNotification() { /* if (mBluetoothGatt == null) { showMessage("mBluetoothGatt null" + mBluetoothGatt); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT); return; } */ BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); if (RxService == null) { showMessage("Rx service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT); return; } BluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID); if (TxChar == null) { showMessage("Tx charateristic not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT); return; } mBluetoothGatt.setCharacteristicNotification(TxChar, true); BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD); descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); mBluetoothGatt.writeDescriptor(descriptor); }
From source file:com.sdingba.su.alphabet_demotest.view.lanya.UartService.java
/** * Enable TXNotification/*w w w .j av a 2s.c o m*/ * * @return */ public void enableTXNotification() { Log.d(TAG, "SDingBaLanYan : enableTXNotification "); if (mBluetoothGatt == null) { showMessage("mBluetoothGatt(is null) = null" + mBluetoothGatt); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); if (RxService == null) { showMessage("Rx service not found!---RX_SERVICE_UUID"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } BluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID); if (TxChar == null) { showMessage("==Tx== charateristic not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } mBluetoothGatt.setCharacteristicNotification(TxChar, true); BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD); descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); mBluetoothGatt.writeDescriptor(descriptor); }