summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2013-12-05 21:08:48 +0100
committerJavier S. Pedro <maemo@javispedro.com>2013-12-05 21:08:48 +0100
commite3ef07dd34b1d8d39d32fa1e43351b7d54c61336 (patch)
tree9249e42422a4a01c05da77c015a5866c8f94a4f6
parent5d8428e4f9801fa02df50091954f9d87ccb8a207 (diff)
downloadlibgato-e3ef07dd34b1d8d39d32fa1e43351b7d54c61336.tar.gz
libgato-e3ef07dd34b1d8d39d32fa1e43351b7d54c61336.zip
Rename GatoAtt to GatoAttClient and add WriteType support
-rw-r--r--gatoattclient.cpp (renamed from gatoatt.cpp)83
-rw-r--r--gatoattclient.h (renamed from gatoatt.h)13
-rw-r--r--gatoperipheral.cpp49
-rw-r--r--gatoperipheral.h8
-rw-r--r--gatoperipheral_p.h12
-rw-r--r--libgato.pro9
6 files changed, 100 insertions, 74 deletions
diff --git a/gatoatt.cpp b/gatoattclient.cpp
index 8015757..4310cd1 100644
--- a/gatoatt.cpp
+++ b/gatoattclient.cpp
@@ -20,7 +20,7 @@
#include <QtCore/QDebug>
-#include "gatoatt.h"
+#include "gatoattclient.h"
#include "helpers.h"
#define PROTOCOL_DEBUG 0
@@ -72,7 +72,7 @@ static QByteArray remove_method_signature(const char *sig)
return QByteArray(sig + 1, bracketPosition - 1 - sig);
}
-GatoAtt::GatoAtt(QObject *parent) :
+GatoAttClient::GatoAttClient(QObject *parent) :
QObject(parent), socket(new GatoSocket(this)), mtu(ATT_DEFAULT_LE_MTU), next_id(1)
{
connect(socket, SIGNAL(connected()), SLOT(handleSocketConnected()));
@@ -80,26 +80,26 @@ GatoAtt::GatoAtt(QObject *parent) :
connect(socket, SIGNAL(readyRead()), SLOT(handleSocketReadyRead()));
}
-GatoAtt::~GatoAtt()
+GatoAttClient::~GatoAttClient()
{
}
-GatoSocket::State GatoAtt::state() const
+GatoSocket::State GatoAttClient::state() const
{
return socket->state();
}
-bool GatoAtt::connectTo(const GatoAddress &addr)
+bool GatoAttClient::connectTo(const GatoAddress &addr)
{
return socket->connectTo(addr, ATT_CID);
}
-void GatoAtt::close()
+void GatoAttClient::close()
{
socket->close();
}
-uint GatoAtt::request(int opcode, const QByteArray &data, QObject *receiver, const char *member)
+uint GatoAttClient::request(int opcode, const QByteArray &data, QObject *receiver, const char *member)
{
Request req;
req.id = next_id++;
@@ -119,7 +119,7 @@ uint GatoAtt::request(int opcode, const QByteArray &data, QObject *receiver, con
return req.id;
}
-void GatoAtt::cancelRequest(uint id)
+void GatoAttClient::cancelRequest(uint id)
{
QQueue<Request>::iterator it = pending_requests.begin();
while (it != pending_requests.end()) {
@@ -131,13 +131,13 @@ void GatoAtt::cancelRequest(uint id)
}
}
-uint GatoAtt::requestExchangeMTU(quint8 client_mtu, QObject *receiver, const char *member)
+uint GatoAttClient::requestExchangeMTU(quint8 client_mtu, QObject *receiver, const char *member)
{
QByteArray data(1, client_mtu);
return request(AttOpExchangeMTURequest, data, receiver, member);
}
-uint GatoAtt::requestFindInformation(GatoHandle start, GatoHandle end, QObject *receiver, const char *member)
+uint GatoAttClient::requestFindInformation(GatoHandle start, GatoHandle end, QObject *receiver, const char *member)
{
QByteArray data;
QDataStream s(&data, QIODevice::WriteOnly);
@@ -147,7 +147,7 @@ uint GatoAtt::requestFindInformation(GatoHandle start, GatoHandle end, QObject *
return request(AttOpFindInformationRequest, data, receiver, member);
}
-uint GatoAtt::requestFindByTypeValue(GatoHandle start, GatoHandle end, const GatoUUID &uuid, const QByteArray &value, QObject *receiver, const char *member)
+uint GatoAttClient::requestFindByTypeValue(GatoHandle start, GatoHandle end, const GatoUUID &uuid, const QByteArray &value, QObject *receiver, const char *member)
{
QByteArray data;
QDataStream s(&data, QIODevice::WriteOnly);
@@ -168,7 +168,7 @@ uint GatoAtt::requestFindByTypeValue(GatoHandle start, GatoHandle end, const Gat
return request(AttOpFindByTypeValueRequest, data, receiver, member);
}
-uint GatoAtt::requestReadByType(GatoHandle start, GatoHandle end, const GatoUUID &uuid, QObject *receiver, const char *member)
+uint GatoAttClient::requestReadByType(GatoHandle start, GatoHandle end, const GatoUUID &uuid, QObject *receiver, const char *member)
{
QByteArray data;
QDataStream s(&data, QIODevice::WriteOnly);
@@ -179,7 +179,7 @@ uint GatoAtt::requestReadByType(GatoHandle start, GatoHandle end, const GatoUUID
return request(AttOpReadByTypeRequest, data, receiver, member);
}
-uint GatoAtt::requestRead(GatoHandle handle, QObject *receiver, const char *member)
+uint GatoAttClient::requestRead(GatoHandle handle, QObject *receiver, const char *member)
{
QByteArray data;
QDataStream s(&data, QIODevice::WriteOnly);
@@ -189,7 +189,7 @@ uint GatoAtt::requestRead(GatoHandle handle, QObject *receiver, const char *memb
return request(AttOpReadRequest, data, receiver, member);
}
-uint GatoAtt::requestReadByGroupType(GatoHandle start, GatoHandle end, const GatoUUID &uuid, QObject *receiver, const char *member)
+uint GatoAttClient::requestReadByGroupType(GatoHandle start, GatoHandle end, const GatoUUID &uuid, QObject *receiver, const char *member)
{
QByteArray data;
QDataStream s(&data, QIODevice::WriteOnly);
@@ -200,7 +200,7 @@ uint GatoAtt::requestReadByGroupType(GatoHandle start, GatoHandle end, const Gat
return request(AttOpReadByGroupTypeRequest, data, receiver, member);
}
-uint GatoAtt::requestWrite(GatoHandle handle, const QByteArray &value, QObject *receiver, const char *member)
+uint GatoAttClient::requestWrite(GatoHandle handle, const QByteArray &value, QObject *receiver, const char *member)
{
QByteArray data;
QDataStream s(&data, QIODevice::WriteOnly);
@@ -211,7 +211,7 @@ uint GatoAtt::requestWrite(GatoHandle handle, const QByteArray &value, QObject *
return request(AttOpWriteRequest, data, receiver, member);
}
-void GatoAtt::command(int opcode, const QByteArray &data)
+void GatoAttClient::command(int opcode, const QByteArray &data)
{
QByteArray packet = data;
packet.prepend(static_cast<char>(opcode));
@@ -223,7 +223,18 @@ void GatoAtt::command(int opcode, const QByteArray &data)
#endif
}
-void GatoAtt::sendARequest()
+void GatoAttClient::commandWrite(GatoHandle handle, const QByteArray &value)
+{
+ QByteArray data;
+ QDataStream s(&data, QIODevice::WriteOnly);
+ s.setByteOrder(QDataStream::LittleEndian);
+ s << handle;
+ s.writeRawData(value.constData(), value.length());
+
+ command(AttOpWriteCommand, data);
+}
+
+void GatoAttClient::sendARequest()
{
if (pending_requests.isEmpty()) {
return;
@@ -237,7 +248,7 @@ void GatoAtt::sendARequest()
#endif
}
-bool GatoAtt::handleEvent(const QByteArray &event)
+bool GatoAttClient::handleEvent(const QByteArray &event)
{
const char *data = event.constData();
quint8 opcode = event[0];
@@ -261,7 +272,7 @@ bool GatoAtt::handleEvent(const QByteArray &event)
}
}
-bool GatoAtt::handleResponse(const Request &req, const QByteArray &response)
+bool GatoAttClient::handleResponse(const Request &req, const QByteArray &response)
{
// If we know the request, we can provide a decoded answer
switch (req.opcode) {
@@ -289,14 +300,14 @@ bool GatoAtt::handleResponse(const Request &req, const QByteArray &response)
if (req.receiver) {
QMetaObject::invokeMethod(req.receiver, req.member.constData(),
Q_ARG(uint, req.id),
- Q_ARG(QList<GatoAtt::InformationData>, parseInformationData(response.mid(1))));
+ Q_ARG(QList<GatoAttClient::InformationData>, parseInformationData(response.mid(1))));
}
return true;
} else if (response[0] == AttOpErrorResponse && response[1] == AttOpFindInformationRequest) {
if (req.receiver) {
QMetaObject::invokeMethod(req.receiver, req.member.constData(),
Q_ARG(uint, req.id),
- Q_ARG(QList<GatoAtt::InformationData>, QList<InformationData>()));
+ Q_ARG(QList<GatoAttClient::InformationData>, QList<InformationData>()));
}
return true;
} else {
@@ -308,14 +319,14 @@ bool GatoAtt::handleResponse(const Request &req, const QByteArray &response)
if (req.receiver) {
QMetaObject::invokeMethod(req.receiver, req.member.constData(),
Q_ARG(uint, req.id),
- Q_ARG(QList<GatoAtt::HandleInformation>, parseHandleInformation(response.mid(1))));
+ Q_ARG(QList<GatoAttClient::HandleInformation>, parseHandleInformation(response.mid(1))));
}
return true;
} else if (response[0] == AttOpErrorResponse && response[1] == AttOpFindByTypeValueRequest) {
if (req.receiver) {
QMetaObject::invokeMethod(req.receiver, req.member.constData(),
Q_ARG(uint, req.id),
- Q_ARG(QList<GatoAtt::HandleInformation>, QList<HandleInformation>()));
+ Q_ARG(QList<GatoAttClient::HandleInformation>, QList<HandleInformation>()));
}
return true;
} else {
@@ -327,14 +338,14 @@ bool GatoAtt::handleResponse(const Request &req, const QByteArray &response)
if (req.receiver) {
QMetaObject::invokeMethod(req.receiver, req.member.constData(),
Q_ARG(uint, req.id),
- Q_ARG(QList<GatoAtt::AttributeData>, parseAttributeData(response.mid(1))));
+ Q_ARG(QList<GatoAttClient::AttributeData>, parseAttributeData(response.mid(1))));
}
return true;
} else if (response[0] == AttOpErrorResponse && response[1] == AttOpReadByTypeRequest) {
if (req.receiver) {
QMetaObject::invokeMethod(req.receiver, req.member.constData(),
Q_ARG(uint, req.id),
- Q_ARG(QList<GatoAtt::AttributeData>, QList<AttributeData>()));
+ Q_ARG(QList<GatoAttClient::AttributeData>, QList<AttributeData>()));
}
return true;
} else {
@@ -365,14 +376,14 @@ bool GatoAtt::handleResponse(const Request &req, const QByteArray &response)
if (req.receiver) {
QMetaObject::invokeMethod(req.receiver, req.member.constData(),
Q_ARG(uint, req.id),
- Q_ARG(QList<GatoAtt::AttributeGroupData>, parseAttributeGroupData(response.mid(1))));
+ Q_ARG(QList<GatoAttClient::AttributeGroupData>, parseAttributeGroupData(response.mid(1))));
}
return true;
} else if (response[0] == AttOpErrorResponse && response[1] == AttOpReadByGroupTypeRequest) {
if (req.receiver) {
QMetaObject::invokeMethod(req.receiver, req.member.constData(),
Q_ARG(uint, req.id),
- Q_ARG(QList<GatoAtt::AttributeGroupData>, QList<AttributeGroupData>()));
+ Q_ARG(QList<GatoAttClient::AttributeGroupData>, QList<AttributeGroupData>()));
}
return true;
} else {
@@ -407,7 +418,7 @@ bool GatoAtt::handleResponse(const Request &req, const QByteArray &response)
}
}
-void GatoAtt::writeUuid16or128(QDataStream &s, const GatoUUID &uuid)
+void GatoAttClient::writeUuid16or128(QDataStream &s, const GatoUUID &uuid)
{
s.setByteOrder(QDataStream::LittleEndian);
@@ -420,7 +431,7 @@ void GatoAtt::writeUuid16or128(QDataStream &s, const GatoUUID &uuid)
}
}
-QList<GatoAtt::InformationData> GatoAtt::parseInformationData(const QByteArray &data)
+QList<GatoAttClient::InformationData> GatoAttClient::parseInformationData(const QByteArray &data)
{
const int format = data[0];
QList<InformationData> list;
@@ -463,7 +474,7 @@ QList<GatoAtt::InformationData> GatoAtt::parseInformationData(const QByteArray &
return list;
}
-QList<GatoAtt::HandleInformation> GatoAtt::parseHandleInformation(const QByteArray &data)
+QList<GatoAttClient::HandleInformation> GatoAttClient::parseHandleInformation(const QByteArray &data)
{
const int item_len = 2;
const int items = data.size() / item_len;
@@ -484,7 +495,7 @@ QList<GatoAtt::HandleInformation> GatoAtt::parseHandleInformation(const QByteArr
return list;
}
-QList<GatoAtt::AttributeData> GatoAtt::parseAttributeData(const QByteArray &data)
+QList<GatoAttClient::AttributeData> GatoAttClient::parseAttributeData(const QByteArray &data)
{
const int item_len = data[0];
const int items = (data.size() - 1) / item_len;
@@ -505,7 +516,7 @@ QList<GatoAtt::AttributeData> GatoAtt::parseAttributeData(const QByteArray &data
return list;
}
-QList<GatoAtt::AttributeGroupData> GatoAtt::parseAttributeGroupData(const QByteArray &data)
+QList<GatoAttClient::AttributeGroupData> GatoAttClient::parseAttributeGroupData(const QByteArray &data)
{
const int item_len = data[0];
const int items = (data.size() - 1) / item_len;
@@ -527,18 +538,18 @@ QList<GatoAtt::AttributeGroupData> GatoAtt::parseAttributeGroupData(const QByteA
return list;
}
-void GatoAtt::handleSocketConnected()
+void GatoAttClient::handleSocketConnected()
{
requestExchangeMTU(ATT_DEFAULT_LE_MTU, this, SLOT(handleServerMTU(quint8)));
emit connected();
}
-void GatoAtt::handleSocketDisconnected()
+void GatoAttClient::handleSocketDisconnected()
{
emit disconnected();
}
-void GatoAtt::handleSocketReadyRead()
+void GatoAttClient::handleSocketReadyRead()
{
QByteArray pkt = socket->receive();
if (!pkt.isEmpty()) {
@@ -567,7 +578,7 @@ void GatoAtt::handleSocketReadyRead()
}
}
-void GatoAtt::handleServerMTU(uint req, quint8 server_mtu)
+void GatoAttClient::handleServerMTU(uint req, quint8 server_mtu)
{
Q_UNUSED(req);
if (server_mtu != 0) {
diff --git a/gatoatt.h b/gatoattclient.h
index 27cea3e..e373a27 100644
--- a/gatoatt.h
+++ b/gatoattclient.h
@@ -1,18 +1,18 @@
-#ifndef GATOATTSOCKET_H
-#define GATOATTSOCKET_H
+#ifndef GATOATTCLIENT_H
+#define GATOATTCLIENT_H
#include <QtCore/QObject>
#include <QtCore/QQueue>
#include "gatosocket.h"
#include "gatouuid.h"
-class GatoAtt : public QObject
+class GatoAttClient : public QObject
{
Q_OBJECT
public:
- explicit GatoAtt(QObject *parent = 0);
- ~GatoAtt();
+ explicit GatoAttClient(QObject *parent = 0);
+ ~GatoAttClient();
GatoSocket::State state() const;
@@ -52,6 +52,7 @@ public:
void cancelRequest(uint id);
void command(int opcode, const QByteArray &data);
+ void commandWrite(GatoHandle handle, const QByteArray &value);
signals:
void connected();
@@ -94,4 +95,4 @@ private:
QQueue<Request> pending_requests;
};
-#endif // GATOATTSOCKET_H
+#endif // GATOATTCLIENT_H
diff --git a/gatoperipheral.cpp b/gatoperipheral.cpp
index faec8cd..50e1bd3 100644
--- a/gatoperipheral.cpp
+++ b/gatoperipheral.cpp
@@ -49,7 +49,7 @@ GatoPeripheral::GatoPeripheral(const GatoAddress &addr, QObject *parent) :
{
Q_D(GatoPeripheral);
d->addr = addr;
- d->att = new GatoAtt(this);
+ d->att = new GatoAttClient(this);
connect(d->att, SIGNAL(connected()), d, SLOT(handleAttConnected()));
connect(d->att, SIGNAL(disconnected()), d, SLOT(handleAttDisconnected()));
@@ -162,7 +162,7 @@ void GatoPeripheral::discoverServices()
if (!d->complete_services && state() == StateConnected) {
d->clearServices();
d->att->requestReadByGroupType(0x0001, 0xFFFF, GatoUUID::GattPrimaryService,
- d, SLOT(handlePrimary(QList<GatoAtt::AttributeGroupData>)));
+ d, SLOT(handlePrimary(QList<GatoAttClient::AttributeGroupData>)));
} else {
qWarning() << "Not connected";
}
@@ -176,7 +176,7 @@ void GatoPeripheral::discoverServices(const QList<GatoUUID> &serviceUUIDs)
foreach (const GatoUUID& uuid, serviceUUIDs) {
QByteArray value = gatouuid_to_bytearray(uuid, true, false);
uint req = d->att->requestFindByTypeValue(0x0001, 0xFFFF, GatoUUID::GattPrimaryService, value,
- d, SLOT(handlePrimaryForService(uint,QList<GatoAtt::HandleInformation>)));
+ d, SLOT(handlePrimaryForService(uint,QList<GatoAttClient::HandleInformation>)));
d->pending_primary_reqs.insert(req, uuid);
}
} else {
@@ -209,7 +209,7 @@ void GatoPeripheral::discoverCharacteristics(const GatoService &service)
d->clearServiceCharacteristics(&our_service);
uint req = d->att->requestReadByType(start, end, GatoUUID::GattCharacteristic,
- d, SLOT(handleCharacteristic(QList<GatoAtt::AttributeData>)));
+ d, SLOT(handleCharacteristic(QList<GatoAttClient::AttributeData>)));
d->pending_characteristic_reqs.insert(req, start);
} else {
qWarning() << "Not connected";
@@ -244,7 +244,7 @@ void GatoPeripheral::discoverDescriptors(const GatoCharacteristic &characteristi
d->clearCharacteristicDescriptors(&our_char);
our_service.addCharacteristic(our_char); // Update service with empty descriptors list
uint req = d->att->requestFindInformation(our_char.startHandle() + 1, our_char.endHandle(),
- d, SLOT(handleDescriptors(uint,QList<GatoAtt::InformationData>)));
+ d, SLOT(handleDescriptors(uint,QList<GatoAttClient::InformationData>)));
d->pending_descriptor_reqs.insert(req, char_handle);
} else {
qWarning() << "Not connected";
@@ -302,7 +302,7 @@ void GatoPeripheral::readValue(const GatoDescriptor &descriptor)
}
}
-void GatoPeripheral::writeValue(const GatoCharacteristic &characteristic, const QByteArray &data)
+void GatoPeripheral::writeValue(const GatoCharacteristic &characteristic, const QByteArray &data, WriteType type)
{
Q_D(GatoPeripheral);
@@ -318,8 +318,17 @@ void GatoPeripheral::writeValue(const GatoCharacteristic &characteristic, const
Q_ASSERT(our_service.containsCharacteristic(char_handle));
if (state() == StateConnected) {
- d->att->requestWrite(characteristic.valueHandle(), data,
- d, SLOT(handleCharacteristicRead(uint,QByteArray)));
+ switch (type) {
+ case WriteWithResponse:
+ d->att->requestWrite(characteristic.valueHandle(), data,
+ d, SLOT(handleCharacteristicWrite(uint,bool)));
+ break;
+ case WriteWithoutResponse:
+ d->att->commandWrite(characteristic.valueHandle(), data);
+ break;
+ }
+
+
} else {
qWarning() << "Not connected";
}
@@ -563,7 +572,7 @@ void GatoPeripheralPrivate::handleAttAttributeUpdated(GatoHandle handle, const Q
}
}
-void GatoPeripheralPrivate::handlePrimary(uint req, const QList<GatoAtt::AttributeGroupData> &list)
+void GatoPeripheralPrivate::handlePrimary(uint req, const QList<GatoAttClient::AttributeGroupData> &list)
{
Q_Q(GatoPeripheral);
Q_UNUSED(req);
@@ -574,7 +583,7 @@ void GatoPeripheralPrivate::handlePrimary(uint req, const QList<GatoAtt::Attribu
} else {
GatoHandle last_handle = 0;
- foreach (const GatoAtt::AttributeGroupData &data, list) {
+ foreach (const GatoAttClient::AttributeGroupData &data, list) {
GatoUUID uuid = bytearray_to_gatouuid(data.value);
GatoService service;
@@ -590,11 +599,11 @@ void GatoPeripheralPrivate::handlePrimary(uint req, const QList<GatoAtt::Attribu
// Fetch following attributes
att->requestReadByGroupType(last_handle + 1, 0xFFFF, GatoUUID::GattPrimaryService,
- this, SLOT(handlePrimary(uint,QList<GatoAtt::AttributeGroupData>)));
+ this, SLOT(handlePrimary(uint,QList<GatoAttClient::AttributeGroupData>)));
}
}
-void GatoPeripheralPrivate::handlePrimaryForService(uint req, const QList<GatoAtt::HandleInformation> &list)
+void GatoPeripheralPrivate::handlePrimaryForService(uint req, const QList<GatoAttClient::HandleInformation> &list)
{
Q_Q(GatoPeripheral);
@@ -612,7 +621,7 @@ void GatoPeripheralPrivate::handlePrimaryForService(uint req, const QList<GatoAt
} else {
GatoHandle last_handle = 0;
- foreach (const GatoAtt::HandleInformation &data, list) {
+ foreach (const GatoAttClient::HandleInformation &data, list) {
GatoService service;
service.setUuid(uuid);
@@ -628,12 +637,12 @@ void GatoPeripheralPrivate::handlePrimaryForService(uint req, const QList<GatoAt
// Fetch following attributes
QByteArray value = gatouuid_to_bytearray(uuid, true, false);
uint req = att->requestFindByTypeValue(last_handle + 1, 0xFFFF, GatoUUID::GattPrimaryService, value,
- this, SLOT(handlePrimaryForService(uint,QList<GatoAtt::HandleInformation>)));
+ this, SLOT(handlePrimaryForService(uint,QList<GatoAttClient::HandleInformation>)));
pending_primary_reqs.insert(req, uuid);
}
}
-void GatoPeripheralPrivate::handleCharacteristic(uint req, const QList<GatoAtt::AttributeData> &list)
+void GatoPeripheralPrivate::handleCharacteristic(uint req, const QList<GatoAttClient::AttributeData> &list)
{
Q_Q(GatoPeripheral);
@@ -664,7 +673,7 @@ void GatoPeripheralPrivate::handleCharacteristic(uint req, const QList<GatoAtt::
}
for (int i = 0; i < list.size(); i++) {
- const GatoAtt::AttributeData &data = list.at(i);
+ const GatoAttClient::AttributeData &data = list.at(i);
GatoCharacteristic characteristic = parseCharacteristicValue(data.value);
characteristic.setStartHandle(data.handle);
@@ -689,12 +698,12 @@ void GatoPeripheralPrivate::handleCharacteristic(uint req, const QList<GatoAtt::
// Fetch following attributes
uint req = att->requestReadByType(last_handle + 1, service.endHandle(), GatoUUID::GattCharacteristic,
- this, SLOT(handleCharacteristic(uint,QList<GatoAtt::AttributeData>)));
+ this, SLOT(handleCharacteristic(uint,QList<GatoAttClient::AttributeData>)));
pending_characteristic_reqs.insert(req, service.startHandle());
}
}
-void GatoPeripheralPrivate::handleDescriptors(uint req, const QList<GatoAtt::InformationData> &list)
+void GatoPeripheralPrivate::handleDescriptors(uint req, const QList<GatoAttClient::InformationData> &list)
{
Q_Q(GatoPeripheral);
@@ -723,7 +732,7 @@ void GatoPeripheralPrivate::handleDescriptors(uint req, const QList<GatoAtt::Inf
} else {
GatoHandle last_handle = 0;
- foreach (const GatoAtt::InformationData &data, list) {
+ foreach (const GatoAttClient::InformationData &data, list) {
// Skip the value attribute itself.
if (data.handle == characteristic.valueHandle()) continue;
@@ -751,7 +760,7 @@ void GatoPeripheralPrivate::handleDescriptors(uint req, const QList<GatoAtt::Inf
// Fetch following attributes
uint req = att->requestFindInformation(last_handle + 1, characteristic.endHandle(),
- this, SLOT(handleDescriptors(uint,QList<GatoAtt::InformationData>)));
+ this, SLOT(handleDescriptors(uint,QList<GatoAttClient::InformationData>)));
pending_descriptor_reqs.insert(req, char_handle);
}
diff --git a/gatoperipheral.h b/gatoperipheral.h
index 6ad6782..d16ac9c 100644
--- a/gatoperipheral.h
+++ b/gatoperipheral.h
@@ -16,6 +16,7 @@ class LIBGATO_EXPORT GatoPeripheral : public QObject
Q_OBJECT
Q_DECLARE_PRIVATE(GatoPeripheral)
Q_ENUMS(State)
+ Q_ENUMS(WriteType)
Q_PROPERTY(GatoAddress address READ address)
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
@@ -29,6 +30,11 @@ public:
StateConnected
};
+ enum WriteType {
+ WriteWithResponse = 0,
+ WriteWithoutResponse
+ };
+
State state() const;
GatoAddress address() const;
QString name() const;
@@ -46,7 +52,7 @@ public slots:
void discoverDescriptors(const GatoCharacteristic &characteristic);
void readValue(const GatoCharacteristic &characteristic);
void readValue(const GatoDescriptor &descriptor);
- void writeValue(const GatoCharacteristic &characteristic, const QByteArray &data);
+ void writeValue(const GatoCharacteristic &characteristic, const QByteArray &data, WriteType type = WriteWithResponse);
void writeValue(const GatoDescriptor &descriptor, const QByteArray &data);
void setNotification(const GatoCharacteristic &characteristic, bool enabled);
diff --git a/gatoperipheral_p.h b/gatoperipheral_p.h
index 895270e..1d88ee4 100644
--- a/gatoperipheral_p.h
+++ b/gatoperipheral_p.h
@@ -5,7 +5,7 @@
#include "gatoservice.h"
#include "gatocharacteristic.h"
#include "gatodescriptor.h"
-#include "gatoatt.h"
+#include "gatoattclient.h"
class GatoPeripheralPrivate : public QObject
{
@@ -31,7 +31,7 @@ public:
QMap<GatoHandle, GatoHandle> value_to_characteristic;
QMap<GatoHandle, GatoHandle> descriptor_to_characteristic;
- GatoAtt *att;
+ GatoAttClient *att;
QMap<uint, GatoUUID> pending_primary_reqs;
QMap<uint, GatoHandle> pending_characteristic_reqs;
QMap<uint, GatoHandle> pending_characteristic_read_reqs;
@@ -58,10 +58,10 @@ public slots:
void handleAttConnected();
void handleAttDisconnected();
void handleAttAttributeUpdated(GatoHandle handle, const QByteArray &value, bool confirmed);
- void handlePrimary(uint req, const QList<GatoAtt::AttributeGroupData>& list);
- void handlePrimaryForService(uint req, const QList<GatoAtt::HandleInformation>& list);
- void handleCharacteristic(uint req, const QList<GatoAtt::AttributeData> &list);
- void handleDescriptors(uint req, const QList<GatoAtt::InformationData> &list);
+ void handlePrimary(uint req, const QList<GatoAttClient::AttributeGroupData>& list);
+ void handlePrimaryForService(uint req, const QList<GatoAttClient::HandleInformation>& list);
+ void handleCharacteristic(uint req, const QList<GatoAttClient::AttributeData> &list);
+ void handleDescriptors(uint req, const QList<GatoAttClient::InformationData> &list);
void handleCharacteristicRead(uint req, const QByteArray &value);
void handleDescriptorRead(uint req, const QByteArray &value);
void handleCharacteristicWrite(uint req, bool ok);
diff --git a/libgato.pro b/libgato.pro
index 2c90ac3..d0ac273 100644
--- a/libgato.pro
+++ b/libgato.pro
@@ -14,26 +14,25 @@ SOURCES += \
gatoperipheral.cpp \
gatoaddress.cpp \
gatosocket.cpp \
- gatoatt.cpp \
helpers.cpp \
gatoservice.cpp \
gatocharacteristic.cpp \
- gatodescriptor.cpp
+ gatodescriptor.cpp \
+ gatoattclient.cpp
-HEADERS += libgato_global.h \
+HEADERS += libgato_global.h gato.h \
gatocentralmanager.h \
gatouuid.h \
gatoperipheral.h \
gatoaddress.h \
gatosocket.h \
- gatoatt.h \
helpers.h \
gatoperipheral_p.h \
gatocentralmanager_p.h \
gatoservice.h \
gatocharacteristic.h \
gatodescriptor.h \
- gato.h
+ gatoattclient.h
target.path = /usr/lib
INSTALLS += target