private void writePacket(final BluetoothGatt gatt,final BluetoothGattCharacteristic characteristic,final byte[] buffer,final int size){
  byte[] locBuffer=buffer;
  if (size <= 0)   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);
}

private void writePacket ( final BluetoothGatt gatt , final BluetoothGattCharacteristic characteristic , final byte [ ] buffer , final int size ) { byte [ ] locBuffer = buffer ; if ( size <= 0 ) 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 20 bytes . this method is asynchronous and returns immediately after adding the data to tx queue .
