Example usage for android.bluetooth BluetoothGattCharacteristic setValue

List of usage examples for android.bluetooth BluetoothGattCharacteristic setValue

Introduction

In this page you can find the example usage for android.bluetooth BluetoothGattCharacteristic setValue.

Prototype

public boolean setValue(String value) 

Source Link

Document

Set the locally stored value of this characteristic.

Usage

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;/* ww  w . j a va2 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 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   ww w. j a  va  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;
    }
    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  .ja v  a2s.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.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 w w  w  . j a v  a 2s.com
    }
    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;
    }/*from w ww  .j av  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 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.shenqu.jlplayer.nRFUARTv2.UartService.java

public boolean writeRXCharacteristic(byte[] value) {
    //Log.i(TAG, System.currentTimeMillis() + " write RXchar " + HexCodec.HexEncodeStr(value, false));
    BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID);
    if (RxService == null) {
        showMessage("Rx service not found!");
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return false;
    }/* w  w  w. jav  a 2  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 false;
    }
    RxChar.setValue(value);
    boolean status = mBluetoothGatt.writeCharacteristic(RxChar);
    //        if (!status)
    //            return status;
    //        BluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID);
    //        if (TxChar != null) {
    //            readCharacteristic(TxChar);
    //            Log.i(TAG, System.currentTimeMillis() + " write TXchar - status = " + status + " TxChar = " + TxChar.getStringValue(0));
    //        }
    return status;
}

From source file:net.jpuderer.android.bluedoor.DoorlockService.java

public void sendSerial(byte[] data) {
    if (mBluetoothAdapter == null || mBluetoothGatt == null) {
        Log.w(TAG, "BluetoothAdapter not initialized");
        return;//w w  w . j a  v  a2s.  c  om
    }
    if ((mGattBlunoService == null) || (mGattDeviceInfoService == null)) {
        Log.w(TAG, "Bluetooth service has not been discovered");
        return;
    }
    if (data.length > MAX_SERIAL_TX_SIZE) {
        Log.w(TAG, "Maximum data size exceeded.  Cannot send more than " + MAX_SERIAL_TX_SIZE + " bytes");
        return;
    }
    BluetoothGattCharacteristic characteristic = mGattBlunoService
            .getCharacteristic(SERIAL_PORT_CHARACTERISTIC_UUID);
    characteristic.setValue(data);
    mBluetoothGatt.writeCharacteristic(characteristic);
}

From source file:com.example.UART.UartService.java

@SuppressLint("NewApi")
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  w w  .  j av 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.aprilbrother.blueduino.UartService.java

public boolean writeRXCharacteristic(byte[] value) {
    BluetoothGattService RxService = null;
    if (mBluetoothGatt != null) {
        RxService = mBluetoothGatt.getService(RX_SERVICE_UUID);
    } else {//from w w  w .  j a v  a 2  s  . c om
        showMessage("mBluetoothGatt null" + mBluetoothGatt);
    }
    if (RxService == null) {
        showMessage("Rx service not found!");
        broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
        return false;
    }
    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);

    return status;
}

From source file:com.example.kevin.health.ble.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);
        return;// ww  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);
        return;
    }
    RxChar.setValue(value);
    boolean status = mBluetoothGatt.writeCharacteristic(RxChar);

    Log.d(TAG, "write TXchar - status=" + status);
}