List of usage examples for android.bluetooth BluetoothGattCharacteristic setValue
public boolean setValue(String value)
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 w ww . j a v a 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; } Log.d(TAG, Arrays.toString(value)); 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 ww . ja v a2 s . c om } 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.example.kevin.health.UartService.java
public void writeRXCharacteristic(byte[] value) { if (mBluetoothGatt != null) { BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); showMessage("mBluetoothGatt null" + mBluetoothGatt); if (RxService == null) { showMessage("Rx service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT); return; }//ww w . j ava2s .c om BluetoothGattCharacteristic RxChar = RxService.getCharacteristic(RX_CHAR_UUID); if (RxChar == null) { showMessage("Rx charateristic not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT); return; } RxChar.setValue(value); boolean status = mBluetoothGatt.writeCharacteristic(RxChar); Log.d(TAG, "write TXchar - status=" + status); } }
From source file:com.github.vgoliveira.panificadora.UartService.java
public void writeRXCharacteristic(byte[] value) { BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); if (RxService == null) { Log.d(TAG, "Rx service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return;//from ww w .j a v a 2 s.c o m } BluetoothGattCharacteristic RxChar = RxService.getCharacteristic(RX_CHAR_UUID); if (RxChar == null) { showMessage("Rx charateristic not found!"); Log.d(TAG, "Rx service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } boolean status_value_set = RxChar.setValue(value); boolean status_write = mBluetoothGatt.writeCharacteristic(RxChar); Log.d(TAG, "write RXchar set value - status=" + status_value_set); Log.d(TAG, "write RXchar - status=" + status_write); Log.d(TAG, "write RXchar - value[0/1]=" + value[0] + "/" + value[1]); }
From source file:com.nordicsemi.UART_UDP_PROXY.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. j a va 2 s. c om*/ } 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 RXchar - status=" + status); }
From source file:io.v.android.impl.google.discovery.plugins.ble.Driver.java
public void addService(final String uuid, Map<String, byte[]> characteristics) { BluetoothGattService service = new BluetoothGattService(UUID.fromString(uuid), BluetoothGattService.SERVICE_TYPE_PRIMARY); for (Map.Entry<String, byte[]> entry : characteristics.entrySet()) { BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic( UUID.fromString(entry.getKey()), BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ); characteristic.setValue(entry.getValue()); service.addCharacteristic(characteristic); }/*from w w w .j a v a2s .co m*/ synchronized (this) { if (mServices.put(uuid, service) != null) { throw new IllegalStateException("already being advertised: " + uuid); } if (mEnabled) { startAdvertising(service); } } }
From source file:com.example.bluetooth.RFduinoService.java
public boolean send(byte[] data) { if (mBluetoothGatt == null || mBluetoothGattService == null) { Log.w(TAG, "BluetoothGatt not initialized"); return false; }/*from w w w. java2s. c om*/ BluetoothGattCharacteristic characteristic = mBluetoothGattService.getCharacteristic(UUID_SEND); if (characteristic == null) { Log.w(TAG, "Send characteristic not found"); return false; } characteristic.setValue(data); characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE); return mBluetoothGatt.writeCharacteristic(characteristic); }
From source file:com.chenls.smartlock.UartService.java
/** * ???/*from w w w . j a v a2s . c o m*/ * * @param value */ public void writeRXCharacteristic(byte[] value) { BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); if (RxService == null) { showMessage("Rx service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } 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.cqupt.sensor_ble.activity.UartService.java
/** * ???// w ww . jav a 2s. co m * * @param value value */ public void writeRXCharacteristic(byte[] value) { BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID); if (RxService == null) { showMessage("Rx service not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; } BluetoothGattCharacteristic RxChar = RxService.getCharacteristic(RX_CHAR_UUID); if (RxChar == null) { showMessage("Rx characteristic 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.bluetooth.RFduinoService.java
public boolean disconnectRFduino() { if (mBluetoothGatt == null || mBluetoothGattService == null) { Log.w(TAG, "BluetoothGatt not initialized"); return false; }//from w ww . j av a 2s . c o m BluetoothGattCharacteristic characteristic = mBluetoothGattService.getCharacteristic(UUID_DISCONNECT); if (characteristic == null) { Log.w(TAG, "Disconnect characteristic not found"); return false; } characteristic.setValue(""); characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE); return mBluetoothGatt.writeCharacteristic(characteristic); }