mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Updated the read method for Bluetooth classic
PiperOrigin-RevId: 487595432
This commit is contained in:
committed by
Copybara-Service
parent
dba1deab3c
commit
8c8e5d7e6f
@@ -150,9 +150,16 @@ ExceptionOr<ByteArray> 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();
|
||||
|
||||
Reference in New Issue
Block a user