private void writePacket ( final BluetoothGatt gatt , final BluetoothGattCharacteristic characteristic , final byte [ ] buffer , final int size ) { byte [ ] locBuffer = buffer ; if ( size <= 0 ) // This should never happen return ; if ( buffer . length != size ) { locBuffer = new byte [ size ] ; System . arraycopy ( buffer , 0 , locBuffer , 0 , size ) ; } characteristic . setWriteType ( BluetoothGattCharacteristic . WRITE_TYPE_NO_RESPONSE ) ; characteristic . setValue ( locBuffer ) ; gatt . writeCharacteristic ( characteristic ) ; }
Writes the buffer to the characteristic . The maximum size of the buffer is dependent on MTU . This method is ASYNCHRONOUS and returns immediately after adding the data to TX queue .