From ffa313e80a27005405334db6491075442f6e1abd Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Thu, 20 Dec 2018 08:35:51 +0100 Subject: Mac: o Using more natural byte ordering in the code. No external effect. o Using global ==, != and < operators instead of in-class operators for better compatibility with STL. ByteBuffer: o Renaming setPosition() to setCursor(). --- ble/LinuxBluetooth.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'ble/LinuxBluetooth.cpp') diff --git a/ble/LinuxBluetooth.cpp b/ble/LinuxBluetooth.cpp index 9e7193f..3c4925c 100644 --- a/ble/LinuxBluetooth.cpp +++ b/ble/LinuxBluetooth.cpp @@ -307,7 +307,7 @@ void LinuxBluetoothGatt::writeHandle(uint16_t handle, const ByteBuffer &bytes) { writeAndRead(buffer, buffer); auto cursor = buffer.getPosition(); - buffer.setPosition(0); + buffer.setCursor(0); AttPdu::parseWrite(buffer); @@ -319,7 +319,7 @@ void LinuxBluetoothGatt::writeHandle(uint16_t handle, const ByteBuffer &bytes) { } } -ByteBuffer LinuxBluetoothGatt::readValue(const BluetoothGattCharacteristicPtr &c, ByteBuffer &response) { +ByteBuffer LinuxBluetoothGatt::readValue(const BluetoothGattCharacteristicPtr &c, ByteBuffer& response) { uint8_t b[mtu]; ByteBuffer buffer{b, mtu}; @@ -328,7 +328,7 @@ ByteBuffer LinuxBluetoothGatt::readValue(const BluetoothGattCharacteristicPtr &c writeAndRead(buffer, response); auto cursor = response.getPosition(); - response.setPosition(0); + response.setCursor(0); AttPdu::parseRead(response); @@ -428,7 +428,7 @@ void LinuxBluetoothGatt::discoverServices() { } while (startHandle != 0xffff); } -void LinuxBluetoothGatt::writeAndRead(const ByteBuffer &buffer, ByteBuffer &response) { +void LinuxBluetoothGatt::writeAndRead(const ByteBuffer &buffer, ByteBuffer& response) { // LOG_DEBUG("pdu size=" << out.getCursor()); auto to_be_written = buffer.getPosition(); @@ -447,8 +447,9 @@ void LinuxBluetoothGatt::writeAndRead(const ByteBuffer &buffer, ByteBuffer &resp throw BluetoothException(&device, "read(): " + errnoAsString()); } - response.setPosition(static_cast(r)); + response.setCursor(static_cast(r)); LOG_DEBUG("read: " << r << " bytes: " << response.viewBeginningToCursor().toString()); + response.setCursor(static_cast(r)); } void LinuxBluetoothGatt::writeL2cap(ByteBuffer &buffer) { @@ -459,7 +460,7 @@ void LinuxBluetoothGatt::writeL2cap(ByteBuffer &buffer) { throw BluetoothException(&device, "Expected to write " + to_string(to_be_written) + " but wrote only " + to_string(written)); } - buffer.setPosition(0); + buffer.setCursor(0); } AttVariant LinuxBluetoothGatt::processAvailableMessages(ByteBuffer &buffer) { -- cgit v1.2.3