Merge "Fix data corruption when writing to Bluetooth socket"