From 8c8e5d7e6f72dacd0917fdf5a3fab3e5b19ce93c Mon Sep 17 00:00:00 2001 From: Guogang Li Date: Thu, 10 Nov 2022 11:35:12 -0800 Subject: [PATCH] Updated the read method for Bluetooth classic PiperOrigin-RevId: 487595432 --- .../windows/bluetooth_classic_socket.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/internal/platform/implementation/windows/bluetooth_classic_socket.cc b/internal/platform/implementation/windows/bluetooth_classic_socket.cc index 87f7fd5f..ea69b26e 100644 --- a/internal/platform/implementation/windows/bluetooth_classic_socket.cc +++ b/internal/platform/implementation/windows/bluetooth_classic_socket.cc @@ -150,9 +150,16 @@ ExceptionOr BluetoothSocket::BluetoothInputStream::Read( } Buffer buffer = Buffer(size); - winrt_stream_.ReadAsync(buffer, size, InputStreamOptions::Partial).get(); - DataReader dataReader = DataReader::FromBuffer(buffer); - ByteArray data((char*)buffer.data(), buffer.Length()); + + auto ibuffer = + winrt_stream_.ReadAsync(buffer, size, InputStreamOptions::None).get(); + + if (ibuffer.Length() != size) { + NEARBY_LOGS(WARNING) << __func__ << ": Got " << ibuffer.Length() + << " bytes of total " << size << " bytes."; + } + + ByteArray data((char*)ibuffer.data(), ibuffer.Length()); return ExceptionOr(data); } catch (std::exception exception) { NEARBY_LOGS(ERROR) << __func__ << ": Exception: " << exception.what();