Android - Bluetooth Writing Event

63 views Asked by At

I'v made a Ble(Bluetooth 4.0 LE) App.

This App send byte data to BT device.

I had test when I made this function, but as soon as send(write) device was disconnected.

why disconnect?

Especially, LG SMART Phone.

Plz Help me..

//////////////

public static void Send_Data(byte[] data) {

    if (mByteCharacteristic != null ) {

        mByteCharacteristic.setValue(data);
        mByteCharacteristic setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE);

        if (bluetoothGatt != null) {
            bluetoothGatt.writeCharacteristic(mByteCharacteristic);
        }

    }

}

///////////////

1

There are 1 answers

0
Doug Koellmer On

Make sure that:

mByteCharacteristic.getProperties() & BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) != 0x0

Otherwise try omitting the setWriteType() call. By default the characteristic should be using the correct write type.