aboutsummaryrefslogtreecommitdiff
path: root/Bluetooth.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Bluetooth.cpp')
-rw-r--r--Bluetooth.cpp36
1 files changed, 26 insertions, 10 deletions
diff --git a/Bluetooth.cpp b/Bluetooth.cpp
index ebdd527..a8b95a1 100644
--- a/Bluetooth.cpp
+++ b/Bluetooth.cpp
@@ -65,7 +65,7 @@ AttPdu::AttPdu(ByteBuffer &bytes) : bytes(bytes) {
}
AttPdu::AttPdu(ByteBuffer &bytes, AttPduType type) : bytes(bytes) {
- bytes.add8(type);
+ bytes.write8(type);
}
AttPduType AttPdu::getType() {
@@ -73,11 +73,17 @@ AttPduType AttPdu::getType() {
}
void AttPdu::makeReadByGroupType(ByteBuffer &bytes, uint16_t startHandle, uint16_t endHandle, uint16_t uuid) {
- bytes.setCursor(0);
- bytes.add8(AttPduType::READ_BY_GROUP_TYPE_REQ);
- bytes.add16le(startHandle);
- bytes.add16le(endHandle);
- bytes.add16le(uuid);
+ bytes.write8(AttPduType::READ_BY_GROUP_TYPE_REQ);
+ bytes.write16le(startHandle);
+ bytes.write16le(endHandle);
+ bytes.write16le(uuid);
+}
+
+void AttPdu::makeReadByType(ByteBuffer &bytes, uint16_t startHandle, uint16_t endHandle, uint16_t uuid) {
+ bytes.write8(AttPduType::READ_BY_TYPE_REQ);
+ bytes.write16le(startHandle);
+ bytes.write16le(endHandle);
+ bytes.write16le(uuid);
}
void AttPdu::checkType(ByteBuffer &bytes, AttPduType type) {
@@ -86,7 +92,7 @@ void AttPdu::checkType(ByteBuffer &bytes, AttPduType type) {
}
bytes.setCursor(0);
- AttPduType t = (AttPduType) bytes.get8();
+ AttPduType t = (AttPduType) bytes.read8();
if (t != type) {
throw BluetoothException("Unexpected type: " + to_string(t));
@@ -102,7 +108,7 @@ vector<AttributeData> AttPdu::parseReadByGroupType(ByteBuffer &bytes) {
throw BluetoothException("Bad READ_BY_GROUP_TYPE_RES packet, expected at least 4 octets, got " + to_string(bytes.getSize()));
}
- uint8_t length = bytes.get8();
+ uint8_t length = bytes.read8();
D << "length=" << (int) length;
size_t count = (bytes.getSize() - 2) / length;
@@ -124,8 +130,8 @@ vector<AttributeData> AttPdu::parseReadByGroupType(ByteBuffer &bytes) {
// -----------------------------------------------------------------------
AttributeData AttributeData::fromByteBuffer(ByteBuffer &bytes) {
- uint16_t handle = bytes.get16le();
- uint16_t groupEndHandle = bytes.get16le();
+ uint16_t handle = bytes.read16le();
+ uint16_t groupEndHandle = bytes.read16le();
return AttributeData(handle, groupEndHandle, bytes.view());
}
@@ -138,6 +144,16 @@ AttributeData::~AttributeData() {
}
// -----------------------------------------------------------------------
+// Device
+// -----------------------------------------------------------------------
+
+BluetoothDevice::BluetoothDevice() {
+}
+
+BluetoothDevice::~BluetoothDevice() {
+}
+
+// -----------------------------------------------------------------------
// Adapter
// -----------------------------------------------------------------------