List of usage examples for android.bluetooth BluetoothGattService getCharacteristic
public BluetoothGattCharacteristic getCharacteristic(UUID uuid)
From source file:com.example.kevin.health.ble.UartService.java
/** * Enable TXNotification//from w ww . j a v a 2 s.c om * * @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.vehicle.uart.UartService.java
public void writeRXCharacteristic(byte[] value) { BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); showMessage("mBluetoothGatt null" + mBluetoothGatt); if (RxService == null) { showMessage("Rx service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return;/*from w w w. j a v a 2 s .co m*/ } BluetoothGattCharacteristic RxChar = RxService.getCharacteristic(RX_CHAR_UUID); if (RxChar == null) { showMessage("Rx charateristic not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } RxChar.setValue(value); boolean status = mBluetoothGatt.writeCharacteristic(RxChar); EVLog.e("write TXchar - status=" + status); }
From source file:com.zpci.firstsignhairclipdemo.UartService.java
public void writeRXCharacteristic(byte[] value) { BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); showMessage("mBluetoothGatt null" + mBluetoothGatt); if (RxService == null) { showMessage("Rx service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return;//from w w w . j a va 2s. c o m } BluetoothGattCharacteristic RxChar = RxService.getCharacteristic(RX_CHAR_UUID); if (RxChar == null) { showMessage("Rx charateristic not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } RxChar.setValue(value); boolean status = mBluetoothGatt.writeCharacteristic(RxChar); Log.d(TAG, "write TXchar - status=" + status + " value[0:1] = " + value[0] + " " + value[1]); }
From source file:com.example.seokchan.swinedroid.UartService.java
public void writeRXCharacteristic(byte[] value) { BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); showMessage("mBluetoothGatt null" + mBluetoothGatt); if (RxService == null) { showMessage("Rx service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return;/*from w w w. j a va 2s .c o m*/ } BluetoothGattCharacteristic RxChar = RxService.getCharacteristic(RX_CHAR_UUID); if (RxChar == null) { showMessage("Rx charateristic not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } RxChar.setValue(value); boolean status = mBluetoothGatt.writeCharacteristic(RxChar); Log.d(TAG, "write TXchar - status=" + status); }
From source file:com.example.alan.bikelog.UartService.java
public void writeRXCharacteristic(byte[] value) { BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); showMessage("mBluetoothGatt null" + mBluetoothGatt); if (RxService == null) { showMessage("Rx service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return;/* w ww . jav a2 s. c o m*/ } BluetoothGattCharacteristic RxChar = RxService.getCharacteristic(RX_CHAR_UUID); if (RxChar == null) { showMessage("Rx charateristic not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } RxChar.setValue(value); boolean status = mBluetoothGatt.writeCharacteristic(RxChar); Log.d(TAG, "write TXchar - status=" + status); }
From source file:com.example.firstsigns.UartService.java
public Boolean writeRXCharacteristic(byte[] value) { BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); showMessage("mBluetoothGatt null" + mBluetoothGatt); if (RxService == null) { showMessage("Rx service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return false; }/* w w w .j ava 2s . co m*/ BluetoothGattCharacteristic RxChar = RxService.getCharacteristic(RX_CHAR_UUID); if (RxChar == null) { showMessage("Rx charateristic not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return false; } RxChar.setValue(value); boolean status = mBluetoothGatt.writeCharacteristic(RxChar); Log.d(TAG, "write TXchar - status=" + status + " value[0:1] = " + value[0] + " " + value[1]); return true; }
From source file:com.cardiograph.service.UartService.java
public void writeRXCharacteristic(byte[] value) { BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); // showMessage("mBluetoothGatt null"+ mBluetoothGatt); if (RxService == null) { showMessage("Rx service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return;/*from www . j a v a 2 s. co m*/ } BluetoothGattCharacteristic RxChar = RxService.getCharacteristic(RX_CHAR_UUID); if (RxChar == null) { showMessage("Rx charateristic not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } RxChar.setValue(value); boolean status = mBluetoothGatt.writeCharacteristic(RxChar); // Log.d(TAG, "write TXchar - status=" + status); }
From source file:com.huiwu.temperaturecontrol.bluetooth.BluetoothService.java
public void writeRXCharacteristic(byte[] value) { BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); showMessage("mBluetoothGatt null" + mBluetoothGatt); if (RxService == null) { showMessage("Rx service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return;//from w w w . j a v a2 s. c o m } BluetoothGattCharacteristic RxChar = RxService.getCharacteristic(RX_CHAR_UUID); if (RxChar == null) { showMessage("Rx charateristic not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } TestLog.d(TAG, Arrays.toString(value)); RxChar.setValue(value); boolean status = mBluetoothGatt.writeCharacteristic(RxChar); TestLog.d(TAG, "write TXchar - status=" + status); }
From source file:com.google.android.apps.forscience.ble.BleFlow.java
public BluetoothGattCharacteristic getCharacteristic(UUID serviceId, UUID charractId) { BluetoothGattService service = client.getService(address, serviceId); if (service == null) { return null; }/* w w w .j av a 2 s . com*/ return service.getCharacteristic(charractId); }
From source file:com.huiwu.bluetooth.BluetoothService.java
public void writeRXCharacteristic(byte[] value) { BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); showMessage("mBluetoothGatt null" + mBluetoothGatt); if (RxService == null) { showMessage("Rx service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return;//from ww w.j av a2 s. co m } BluetoothGattCharacteristic RxChar = RxService.getCharacteristic(RX_CHAR_UUID); if (RxChar == null) { showMessage("Rx charateristic not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } Log.d(TAG, Arrays.toString(value)); RxChar.setValue(value); boolean status = mBluetoothGatt.writeCharacteristic(RxChar); Log.d(TAG, "write TXchar - status=" + status); }