From e3ef07dd34b1d8d39d32fa1e43351b7d54c61336 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Thu, 5 Dec 2013 21:08:48 +0100 Subject: Rename GatoAtt to GatoAttClient and add WriteType support --- gatoatt.cpp | 578 ---------------------------------------------------- gatoatt.h | 97 --------- gatoattclient.cpp | 589 +++++++++++++++++++++++++++++++++++++++++++++++++++++ gatoattclient.h | 98 +++++++++ gatoperipheral.cpp | 49 +++-- gatoperipheral.h | 8 +- gatoperipheral_p.h | 12 +- libgato.pro | 9 +- 8 files changed, 733 insertions(+), 707 deletions(-) delete mode 100644 gatoatt.cpp delete mode 100644 gatoatt.h create mode 100644 gatoattclient.cpp create mode 100644 gatoattclient.h diff --git a/gatoatt.cpp b/gatoatt.cpp deleted file mode 100644 index 8015757..0000000 --- a/gatoatt.cpp +++ /dev/null @@ -1,578 +0,0 @@ -/* - * libgato - A GATT/ATT library for use with Bluez - * - * Copyright (C) 2013 Javier S. Pedro - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#include "gatoatt.h" -#include "helpers.h" - -#define PROTOCOL_DEBUG 0 - -#define ATT_CID 4 -#define ATT_PSM 31 - -#define ATT_DEFAULT_LE_MTU 23 - -enum AttOpcode { - AttOpNone = 0, - AttOpErrorResponse = 0x1, - AttOpExchangeMTURequest = 0x2, - AttOpExchangeMTUResponse = 0x3, - AttOpFindInformationRequest = 0x4, - AttOpFindInformationResponse = 0x5, - AttOpFindByTypeValueRequest = 0x6, - AttOpFindByTypeValueResponse = 0x7, - AttOpReadByTypeRequest = 0x8, - AttOpReadByTypeResponse = 0x9, - AttOpReadRequest = 0xA, - AttOpReadResponse = 0xB, - AttOpReadBlobRequest = 0xC, - AttOpReadBlobResponse = 0xD, - AttOpReadMultipleRequest = 0xE, - AttOpReadMultipleResponse = 0xF, - AttOpReadByGroupTypeRequest = 0x10, - AttOpReadByGroupTypeResponse = 0x11, - AttOpWriteRequest = 0x12, - AttOpWriteResponse = 0x13, - AttOpWriteCommand = 0x52, - AttOpPrepareWriteRequest = 0x16, - AttOpPrepareWriteResponse = 0x17, - AttOpExecuteWriteRequest = 0x18, - AttOpExecuteWriteResponse = 0x19, - AttOpHandleValueNotification = 0x1B, - AttOpHandleValueIndication = 0x1D, - AttOpHandleValueConfirmation = 0x1E, - AttOpSignedWriteCommand = 0xD2 -}; - -static QByteArray remove_method_signature(const char *sig) -{ - const char* bracketPosition = strchr(sig, '('); - if (!bracketPosition || !(sig[0] >= '0' && sig[0] <= '3')) { - qWarning("Invalid slot specification"); - return QByteArray(); - } - return QByteArray(sig + 1, bracketPosition - 1 - sig); -} - -GatoAtt::GatoAtt(QObject *parent) : - QObject(parent), socket(new GatoSocket(this)), mtu(ATT_DEFAULT_LE_MTU), next_id(1) -{ - connect(socket, SIGNAL(connected()), SLOT(handleSocketConnected())); - connect(socket, SIGNAL(disconnected()), SLOT(handleSocketDisconnected())); - connect(socket, SIGNAL(readyRead()), SLOT(handleSocketReadyRead())); -} - -GatoAtt::~GatoAtt() -{ -} - -GatoSocket::State GatoAtt::state() const -{ - return socket->state(); -} - -bool GatoAtt::connectTo(const GatoAddress &addr) -{ - return socket->connectTo(addr, ATT_CID); -} - -void GatoAtt::close() -{ - socket->close(); -} - -uint GatoAtt::request(int opcode, const QByteArray &data, QObject *receiver, const char *member) -{ - Request req; - req.id = next_id++; - req.opcode = opcode; - req.pkt = data; - req.pkt.prepend(static_cast(opcode)); - req.receiver = receiver; - req.member = remove_method_signature(member); - - pending_requests.enqueue(req); - - if (pending_requests.size() == 1) { - // So we can just send this request instead of waiting for others to complete - sendARequest(); - } - - return req.id; -} - -void GatoAtt::cancelRequest(uint id) -{ - QQueue::iterator it = pending_requests.begin(); - while (it != pending_requests.end()) { - if (it->id == id) { - it = pending_requests.erase(it); - } else { - ++it; - } - } -} - -uint GatoAtt::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) -{ - QByteArray data; - QDataStream s(&data, QIODevice::WriteOnly); - s.setByteOrder(QDataStream::LittleEndian); - s << start << end; - - return request(AttOpFindInformationRequest, data, receiver, member); -} - -uint GatoAtt::requestFindByTypeValue(GatoHandle start, GatoHandle end, const GatoUUID &uuid, const QByteArray &value, QObject *receiver, const char *member) -{ - QByteArray data; - QDataStream s(&data, QIODevice::WriteOnly); - s.setByteOrder(QDataStream::LittleEndian); - s << start << end; - - bool uuid16_ok; - quint16 uuid16 = uuid.toUInt16(&uuid16_ok); - if (uuid16_ok) { - s << uuid16; - } else { - qWarning() << "FindByTypeValue does not support UUIDs other than UUID16"; - return -1; - } - - s << value; - - return request(AttOpFindByTypeValueRequest, data, receiver, member); -} - -uint GatoAtt::requestReadByType(GatoHandle start, GatoHandle end, const GatoUUID &uuid, QObject *receiver, const char *member) -{ - QByteArray data; - QDataStream s(&data, QIODevice::WriteOnly); - s.setByteOrder(QDataStream::LittleEndian); - s << start << end; - writeUuid16or128(s, uuid); - - return request(AttOpReadByTypeRequest, data, receiver, member); -} - -uint GatoAtt::requestRead(GatoHandle handle, QObject *receiver, const char *member) -{ - QByteArray data; - QDataStream s(&data, QIODevice::WriteOnly); - s.setByteOrder(QDataStream::LittleEndian); - s << handle; - - return request(AttOpReadRequest, data, receiver, member); -} - -uint GatoAtt::requestReadByGroupType(GatoHandle start, GatoHandle end, const GatoUUID &uuid, QObject *receiver, const char *member) -{ - QByteArray data; - QDataStream s(&data, QIODevice::WriteOnly); - s.setByteOrder(QDataStream::LittleEndian); - s << start << end; - writeUuid16or128(s, uuid); - - return request(AttOpReadByGroupTypeRequest, data, receiver, member); -} - -uint GatoAtt::requestWrite(GatoHandle handle, const QByteArray &value, QObject *receiver, const char *member) -{ - QByteArray data; - QDataStream s(&data, QIODevice::WriteOnly); - s.setByteOrder(QDataStream::LittleEndian); - s << handle; - s.writeRawData(value.constData(), value.length()); - - return request(AttOpWriteRequest, data, receiver, member); -} - -void GatoAtt::command(int opcode, const QByteArray &data) -{ - QByteArray packet = data; - packet.prepend(static_cast(opcode)); - - socket->send(packet); - -#if PROTOCOL_DEBUG - qDebug() << "Wrote" << packet.size() << "bytes (command)" << packet.toHex(); -#endif -} - -void GatoAtt::sendARequest() -{ - if (pending_requests.isEmpty()) { - return; - } - - Request &req = pending_requests.head(); - socket->send(req.pkt); - -#if PROTOCOL_DEBUG - qDebug() << "Wrote" << req.pkt.size() << "bytes (request)" << req.pkt.toHex(); -#endif -} - -bool GatoAtt::handleEvent(const QByteArray &event) -{ - const char *data = event.constData(); - quint8 opcode = event[0]; - GatoHandle handle; - - switch (opcode) { - case AttOpHandleValueNotification: - handle = read_le(&data[1]); - emit attributeUpdated(handle, event.mid(3), false); - return true; - case AttOpHandleValueIndication: - handle = read_le(&data[1]); - - // Send the confirmation back - command(AttOpHandleValueConfirmation, QByteArray()); - - emit attributeUpdated(handle, event.mid(3), true); - return true; - default: - return false; - } -} - -bool GatoAtt::handleResponse(const Request &req, const QByteArray &response) -{ - // If we know the request, we can provide a decoded answer - switch (req.opcode) { - case AttOpExchangeMTURequest: - if (response[0] == AttOpExchangeMTUResponse) { - if (req.receiver) { - QMetaObject::invokeMethod(req.receiver, req.member.constData(), - Q_ARG(uint, req.id), - Q_ARG(quint8, response[1])); - } - return true; - } else if (response[0] == AttOpErrorResponse && response[1] == AttOpExchangeMTURequest) { - if (req.receiver) { - QMetaObject::invokeMethod(req.receiver, req.member.constData(), - Q_ARG(uint, req.id), - Q_ARG(quint8, response[1])); - } - return true; - } else { - return false; - } - break; - case AttOpFindInformationRequest: - if (response[0] == AttOpFindInformationResponse) { - if (req.receiver) { - QMetaObject::invokeMethod(req.receiver, req.member.constData(), - Q_ARG(uint, req.id), - Q_ARG(QList, 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, QList())); - } - return true; - } else { - return false; - } - break; - case AttOpFindByTypeValueRequest: - if (response[0] == AttOpFindByTypeValueResponse) { - if (req.receiver) { - QMetaObject::invokeMethod(req.receiver, req.member.constData(), - Q_ARG(uint, req.id), - Q_ARG(QList, 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, QList())); - } - return true; - } else { - return false; - } - break; - case AttOpReadByTypeRequest: - if (response[0] == AttOpReadByTypeResponse) { - if (req.receiver) { - QMetaObject::invokeMethod(req.receiver, req.member.constData(), - Q_ARG(uint, req.id), - Q_ARG(QList, 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, QList())); - } - return true; - } else { - return false; - } - break; - case AttOpReadRequest: - if (response[0] == AttOpReadResponse) { - if (req.receiver) { - QMetaObject::invokeMethod(req.receiver, req.member.constData(), - Q_ARG(uint, req.id), - Q_ARG(QByteArray, response.mid(1))); - } - return true; - } else if (response[0] == AttOpErrorResponse && response[1] == AttOpReadRequest) { - if (req.receiver) { - QMetaObject::invokeMethod(req.receiver, req.member.constData(), - Q_ARG(uint, req.id), - Q_ARG(QByteArray, QByteArray())); - } - return true; - } else { - return false; - } - break; - case AttOpReadByGroupTypeRequest: - if (response[0] == AttOpReadByGroupTypeResponse) { - if (req.receiver) { - QMetaObject::invokeMethod(req.receiver, req.member.constData(), - Q_ARG(uint, req.id), - Q_ARG(QList, 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, QList())); - } - return true; - } else { - return false; - } - break; - case AttOpWriteRequest: - if (response[0] == AttOpWriteResponse) { - if (req.receiver) { - QMetaObject::invokeMethod(req.receiver, req.member.constData(), - Q_ARG(uint, req.id), - Q_ARG(bool, true)); - } - return true; - } else if (response[0] == AttOpErrorResponse && response[1] == AttOpWriteRequest) { - if (req.receiver) { - QMetaObject::invokeMethod(req.receiver, req.member.constData(), - Q_ARG(uint, req.id), - Q_ARG(bool, false)); - } - return true; - } else { - return false; - } - break; - default: // Otherwise just send a QByteArray. - if (req.receiver) { - QMetaObject::invokeMethod(req.receiver, req.member.constData(), - Q_ARG(const QByteArray&, response)); - } - return true; - } -} - -void GatoAtt::writeUuid16or128(QDataStream &s, const GatoUUID &uuid) -{ - s.setByteOrder(QDataStream::LittleEndian); - - bool uuid16_ok; - quint16 uuid16 = uuid.toUInt16(&uuid16_ok); - if (uuid16_ok) { - s << uuid16; - } else { - s << uuid.toUInt128(); - } -} - -QList GatoAtt::parseInformationData(const QByteArray &data) -{ - const int format = data[0]; - QList list; - int item_len; - - switch (format) { - case 1: - item_len = 2 + 2; - break; - case 2: - item_len = 2 + 16; - break; - default: - qWarning() << "Unknown InformationData format!"; - return list; - } - - int items = (data.size() - 1) / item_len; - list.reserve(items); - - int pos = 1; - const char *s = data.constData(); - for (int i = 0; i < items; i++) { - InformationData d; - d.handle = read_le(&s[pos]); - switch (format) { - case 1: - d.uuid = GatoUUID(read_le(&s[pos + 2])); - break; - case 2: - d.uuid = GatoUUID(read_le(&s[pos + 2])); - break; - } - - list.append(d); - - pos += item_len; - } - - return list; -} - -QList GatoAtt::parseHandleInformation(const QByteArray &data) -{ - const int item_len = 2; - const int items = data.size() / item_len; - QList list; - list.reserve(items); - - int pos = 0; - const char *s = data.constData(); - for (int i = 0; i < items; i++) { - HandleInformation d; - d.start = read_le(&s[pos]); - d.end = read_le(&s[pos + 2]); - list.append(d); - - pos += item_len; - } - - return list; -} - -QList GatoAtt::parseAttributeData(const QByteArray &data) -{ - const int item_len = data[0]; - const int items = (data.size() - 1) / item_len; - QList list; - list.reserve(items); - - int pos = 1; - const char *s = data.constData(); - for (int i = 0; i < items; i++) { - AttributeData d; - d.handle = read_le(&s[pos]); - d.value = data.mid(pos + 2, item_len - 2); - list.append(d); - - pos += item_len; - } - - return list; -} - -QList GatoAtt::parseAttributeGroupData(const QByteArray &data) -{ - const int item_len = data[0]; - const int items = (data.size() - 1) / item_len; - QList list; - list.reserve(items); - - int pos = 1; - const char *s = data.constData(); - for (int i = 0; i < items; i++) { - AttributeGroupData d; - d.start = read_le(&s[pos]); - d.end = read_le(&s[pos + 2]); - d.value = data.mid(pos + 4, item_len - 4); - list.append(d); - - pos += item_len; - } - - return list; -} - -void GatoAtt::handleSocketConnected() -{ - requestExchangeMTU(ATT_DEFAULT_LE_MTU, this, SLOT(handleServerMTU(quint8))); - emit connected(); -} - -void GatoAtt::handleSocketDisconnected() -{ - emit disconnected(); -} - -void GatoAtt::handleSocketReadyRead() -{ - QByteArray pkt = socket->receive(); - if (!pkt.isEmpty()) { -#if PROTOCOL_DEBUG - qDebug() << "Received" << pkt.size() << "bytes" << pkt.toHex(); -#endif - - // Check if it is an event - if (handleEvent(pkt)) { - return; - } - - // Otherwise, if we have a request waiting, check if this answers it - if (!pending_requests.isEmpty()) { - if (handleResponse(pending_requests.head(), pkt)) { - pending_requests.dequeue(); - // Proceed to next request - if (!pending_requests.isEmpty()) { - sendARequest(); - } - return; - } - } - - qDebug() << "No idea what this packet is"; - } -} - -void GatoAtt::handleServerMTU(uint req, quint8 server_mtu) -{ - Q_UNUSED(req); - if (server_mtu != 0) { - mtu = server_mtu; - } -} - - diff --git a/gatoatt.h b/gatoatt.h deleted file mode 100644 index 27cea3e..0000000 --- a/gatoatt.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef GATOATTSOCKET_H -#define GATOATTSOCKET_H - -#include -#include -#include "gatosocket.h" -#include "gatouuid.h" - -class GatoAtt : public QObject -{ - Q_OBJECT - -public: - explicit GatoAtt(QObject *parent = 0); - ~GatoAtt(); - - GatoSocket::State state() const; - - bool connectTo(const GatoAddress& addr); - void close(); - - struct InformationData - { - GatoHandle handle; - GatoUUID uuid; - }; - struct HandleInformation - { - GatoHandle start; - GatoHandle end; - }; - struct AttributeData - { - GatoHandle handle; - QByteArray value; - }; - struct AttributeGroupData - { - GatoHandle start; - GatoHandle end; - QByteArray value; - }; - - uint request(int opcode, const QByteArray &data, QObject *receiver, const char *member); - uint requestExchangeMTU(quint8 client_mtu, QObject *receiver, const char *member); - uint requestFindInformation(GatoHandle start, GatoHandle end, QObject *receiver, const char *member); - uint requestFindByTypeValue(GatoHandle start, GatoHandle end, const GatoUUID &uuid, const QByteArray& value, QObject *receiver, const char *member); - uint requestReadByType(GatoHandle start, GatoHandle end, const GatoUUID &uuid, QObject *receiver, const char *member); - uint requestRead(GatoHandle handle, QObject *receiver, const char *member); - uint requestReadByGroupType(GatoHandle start, GatoHandle end, const GatoUUID &uuid, QObject *receiver, const char *member); - uint requestWrite(GatoHandle handle, const QByteArray &value, QObject *receiver, const char *member); - void cancelRequest(uint id); - - void command(int opcode, const QByteArray &data); - -signals: - void connected(); - void disconnected(); - - void attributeUpdated(GatoHandle handle, const QByteArray &value, bool confirmed); - -private: - struct Request - { - uint id; - quint8 opcode; - QByteArray pkt; - QObject *receiver; - QByteArray member; - }; - - void sendARequest(); - bool handleEvent(const QByteArray &event); - bool handleResponse(const Request& req, const QByteArray &response); - - void writeUuid16or128(QDataStream& s, const GatoUUID& uuid); - - QList parseInformationData(const QByteArray &data); - QList parseHandleInformation(const QByteArray &data); - QList parseAttributeData(const QByteArray &data); - QList parseAttributeGroupData(const QByteArray &data); - -private slots: - void handleSocketConnected(); - void handleSocketDisconnected(); - void handleSocketReadyRead(); - - void handleServerMTU(uint req, quint8 server_mtu); - -private: - GatoSocket *socket; - quint8 mtu; - uint next_id; - QQueue pending_requests; -}; - -#endif // GATOATTSOCKET_H diff --git a/gatoattclient.cpp b/gatoattclient.cpp new file mode 100644 index 0000000..4310cd1 --- /dev/null +++ b/gatoattclient.cpp @@ -0,0 +1,589 @@ +/* + * libgato - A GATT/ATT library for use with Bluez + * + * Copyright (C) 2013 Javier S. Pedro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "gatoattclient.h" +#include "helpers.h" + +#define PROTOCOL_DEBUG 0 + +#define ATT_CID 4 +#define ATT_PSM 31 + +#define ATT_DEFAULT_LE_MTU 23 + +enum AttOpcode { + AttOpNone = 0, + AttOpErrorResponse = 0x1, + AttOpExchangeMTURequest = 0x2, + AttOpExchangeMTUResponse = 0x3, + AttOpFindInformationRequest = 0x4, + AttOpFindInformationResponse = 0x5, + AttOpFindByTypeValueRequest = 0x6, + AttOpFindByTypeValueResponse = 0x7, + AttOpReadByTypeRequest = 0x8, + AttOpReadByTypeResponse = 0x9, + AttOpReadRequest = 0xA, + AttOpReadResponse = 0xB, + AttOpReadBlobRequest = 0xC, + AttOpReadBlobResponse = 0xD, + AttOpReadMultipleRequest = 0xE, + AttOpReadMultipleResponse = 0xF, + AttOpReadByGroupTypeRequest = 0x10, + AttOpReadByGroupTypeResponse = 0x11, + AttOpWriteRequest = 0x12, + AttOpWriteResponse = 0x13, + AttOpWriteCommand = 0x52, + AttOpPrepareWriteRequest = 0x16, + AttOpPrepareWriteResponse = 0x17, + AttOpExecuteWriteRequest = 0x18, + AttOpExecuteWriteResponse = 0x19, + AttOpHandleValueNotification = 0x1B, + AttOpHandleValueIndication = 0x1D, + AttOpHandleValueConfirmation = 0x1E, + AttOpSignedWriteCommand = 0xD2 +}; + +static QByteArray remove_method_signature(const char *sig) +{ + const char* bracketPosition = strchr(sig, '('); + if (!bracketPosition || !(sig[0] >= '0' && sig[0] <= '3')) { + qWarning("Invalid slot specification"); + return QByteArray(); + } + return QByteArray(sig + 1, bracketPosition - 1 - sig); +} + +GatoAttClient::GatoAttClient(QObject *parent) : + QObject(parent), socket(new GatoSocket(this)), mtu(ATT_DEFAULT_LE_MTU), next_id(1) +{ + connect(socket, SIGNAL(connected()), SLOT(handleSocketConnected())); + connect(socket, SIGNAL(disconnected()), SLOT(handleSocketDisconnected())); + connect(socket, SIGNAL(readyRead()), SLOT(handleSocketReadyRead())); +} + +GatoAttClient::~GatoAttClient() +{ +} + +GatoSocket::State GatoAttClient::state() const +{ + return socket->state(); +} + +bool GatoAttClient::connectTo(const GatoAddress &addr) +{ + return socket->connectTo(addr, ATT_CID); +} + +void GatoAttClient::close() +{ + socket->close(); +} + +uint GatoAttClient::request(int opcode, const QByteArray &data, QObject *receiver, const char *member) +{ + Request req; + req.id = next_id++; + req.opcode = opcode; + req.pkt = data; + req.pkt.prepend(static_cast(opcode)); + req.receiver = receiver; + req.member = remove_method_signature(member); + + pending_requests.enqueue(req); + + if (pending_requests.size() == 1) { + // So we can just send this request instead of waiting for others to complete + sendARequest(); + } + + return req.id; +} + +void GatoAttClient::cancelRequest(uint id) +{ + QQueue::iterator it = pending_requests.begin(); + while (it != pending_requests.end()) { + if (it->id == id) { + it = pending_requests.erase(it); + } else { + ++it; + } + } +} + +uint GatoAttClient::requestExchangeMTU(quint8 client_mtu, QObject *receiver, const char *member) +{ + QByteArray data(1, client_mtu); + return request(AttOpExchangeMTURequest, data, receiver, member); +} + +uint GatoAttClient::requestFindInformation(GatoHandle start, GatoHandle end, QObject *receiver, const char *member) +{ + QByteArray data; + QDataStream s(&data, QIODevice::WriteOnly); + s.setByteOrder(QDataStream::LittleEndian); + s << start << end; + + return request(AttOpFindInformationRequest, data, receiver, 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); + s.setByteOrder(QDataStream::LittleEndian); + s << start << end; + + bool uuid16_ok; + quint16 uuid16 = uuid.toUInt16(&uuid16_ok); + if (uuid16_ok) { + s << uuid16; + } else { + qWarning() << "FindByTypeValue does not support UUIDs other than UUID16"; + return -1; + } + + s << value; + + return request(AttOpFindByTypeValueRequest, data, receiver, member); +} + +uint GatoAttClient::requestReadByType(GatoHandle start, GatoHandle end, const GatoUUID &uuid, QObject *receiver, const char *member) +{ + QByteArray data; + QDataStream s(&data, QIODevice::WriteOnly); + s.setByteOrder(QDataStream::LittleEndian); + s << start << end; + writeUuid16or128(s, uuid); + + return request(AttOpReadByTypeRequest, data, receiver, member); +} + +uint GatoAttClient::requestRead(GatoHandle handle, QObject *receiver, const char *member) +{ + QByteArray data; + QDataStream s(&data, QIODevice::WriteOnly); + s.setByteOrder(QDataStream::LittleEndian); + s << handle; + + return request(AttOpReadRequest, data, receiver, member); +} + +uint GatoAttClient::requestReadByGroupType(GatoHandle start, GatoHandle end, const GatoUUID &uuid, QObject *receiver, const char *member) +{ + QByteArray data; + QDataStream s(&data, QIODevice::WriteOnly); + s.setByteOrder(QDataStream::LittleEndian); + s << start << end; + writeUuid16or128(s, uuid); + + return request(AttOpReadByGroupTypeRequest, data, receiver, member); +} + +uint GatoAttClient::requestWrite(GatoHandle handle, const QByteArray &value, QObject *receiver, const char *member) +{ + QByteArray data; + QDataStream s(&data, QIODevice::WriteOnly); + s.setByteOrder(QDataStream::LittleEndian); + s << handle; + s.writeRawData(value.constData(), value.length()); + + return request(AttOpWriteRequest, data, receiver, member); +} + +void GatoAttClient::command(int opcode, const QByteArray &data) +{ + QByteArray packet = data; + packet.prepend(static_cast(opcode)); + + socket->send(packet); + +#if PROTOCOL_DEBUG + qDebug() << "Wrote" << packet.size() << "bytes (command)" << packet.toHex(); +#endif +} + +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; + } + + Request &req = pending_requests.head(); + socket->send(req.pkt); + +#if PROTOCOL_DEBUG + qDebug() << "Wrote" << req.pkt.size() << "bytes (request)" << req.pkt.toHex(); +#endif +} + +bool GatoAttClient::handleEvent(const QByteArray &event) +{ + const char *data = event.constData(); + quint8 opcode = event[0]; + GatoHandle handle; + + switch (opcode) { + case AttOpHandleValueNotification: + handle = read_le(&data[1]); + emit attributeUpdated(handle, event.mid(3), false); + return true; + case AttOpHandleValueIndication: + handle = read_le(&data[1]); + + // Send the confirmation back + command(AttOpHandleValueConfirmation, QByteArray()); + + emit attributeUpdated(handle, event.mid(3), true); + return true; + default: + return false; + } +} + +bool GatoAttClient::handleResponse(const Request &req, const QByteArray &response) +{ + // If we know the request, we can provide a decoded answer + switch (req.opcode) { + case AttOpExchangeMTURequest: + if (response[0] == AttOpExchangeMTUResponse) { + if (req.receiver) { + QMetaObject::invokeMethod(req.receiver, req.member.constData(), + Q_ARG(uint, req.id), + Q_ARG(quint8, response[1])); + } + return true; + } else if (response[0] == AttOpErrorResponse && response[1] == AttOpExchangeMTURequest) { + if (req.receiver) { + QMetaObject::invokeMethod(req.receiver, req.member.constData(), + Q_ARG(uint, req.id), + Q_ARG(quint8, response[1])); + } + return true; + } else { + return false; + } + break; + case AttOpFindInformationRequest: + if (response[0] == AttOpFindInformationResponse) { + if (req.receiver) { + QMetaObject::invokeMethod(req.receiver, req.member.constData(), + Q_ARG(uint, req.id), + Q_ARG(QList, 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, QList())); + } + return true; + } else { + return false; + } + break; + case AttOpFindByTypeValueRequest: + if (response[0] == AttOpFindByTypeValueResponse) { + if (req.receiver) { + QMetaObject::invokeMethod(req.receiver, req.member.constData(), + Q_ARG(uint, req.id), + Q_ARG(QList, 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, QList())); + } + return true; + } else { + return false; + } + break; + case AttOpReadByTypeRequest: + if (response[0] == AttOpReadByTypeResponse) { + if (req.receiver) { + QMetaObject::invokeMethod(req.receiver, req.member.constData(), + Q_ARG(uint, req.id), + Q_ARG(QList, 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, QList())); + } + return true; + } else { + return false; + } + break; + case AttOpReadRequest: + if (response[0] == AttOpReadResponse) { + if (req.receiver) { + QMetaObject::invokeMethod(req.receiver, req.member.constData(), + Q_ARG(uint, req.id), + Q_ARG(QByteArray, response.mid(1))); + } + return true; + } else if (response[0] == AttOpErrorResponse && response[1] == AttOpReadRequest) { + if (req.receiver) { + QMetaObject::invokeMethod(req.receiver, req.member.constData(), + Q_ARG(uint, req.id), + Q_ARG(QByteArray, QByteArray())); + } + return true; + } else { + return false; + } + break; + case AttOpReadByGroupTypeRequest: + if (response[0] == AttOpReadByGroupTypeResponse) { + if (req.receiver) { + QMetaObject::invokeMethod(req.receiver, req.member.constData(), + Q_ARG(uint, req.id), + Q_ARG(QList, 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, QList())); + } + return true; + } else { + return false; + } + break; + case AttOpWriteRequest: + if (response[0] == AttOpWriteResponse) { + if (req.receiver) { + QMetaObject::invokeMethod(req.receiver, req.member.constData(), + Q_ARG(uint, req.id), + Q_ARG(bool, true)); + } + return true; + } else if (response[0] == AttOpErrorResponse && response[1] == AttOpWriteRequest) { + if (req.receiver) { + QMetaObject::invokeMethod(req.receiver, req.member.constData(), + Q_ARG(uint, req.id), + Q_ARG(bool, false)); + } + return true; + } else { + return false; + } + break; + default: // Otherwise just send a QByteArray. + if (req.receiver) { + QMetaObject::invokeMethod(req.receiver, req.member.constData(), + Q_ARG(const QByteArray&, response)); + } + return true; + } +} + +void GatoAttClient::writeUuid16or128(QDataStream &s, const GatoUUID &uuid) +{ + s.setByteOrder(QDataStream::LittleEndian); + + bool uuid16_ok; + quint16 uuid16 = uuid.toUInt16(&uuid16_ok); + if (uuid16_ok) { + s << uuid16; + } else { + s << uuid.toUInt128(); + } +} + +QList GatoAttClient::parseInformationData(const QByteArray &data) +{ + const int format = data[0]; + QList list; + int item_len; + + switch (format) { + case 1: + item_len = 2 + 2; + break; + case 2: + item_len = 2 + 16; + break; + default: + qWarning() << "Unknown InformationData format!"; + return list; + } + + int items = (data.size() - 1) / item_len; + list.reserve(items); + + int pos = 1; + const char *s = data.constData(); + for (int i = 0; i < items; i++) { + InformationData d; + d.handle = read_le(&s[pos]); + switch (format) { + case 1: + d.uuid = GatoUUID(read_le(&s[pos + 2])); + break; + case 2: + d.uuid = GatoUUID(read_le(&s[pos + 2])); + break; + } + + list.append(d); + + pos += item_len; + } + + return list; +} + +QList GatoAttClient::parseHandleInformation(const QByteArray &data) +{ + const int item_len = 2; + const int items = data.size() / item_len; + QList list; + list.reserve(items); + + int pos = 0; + const char *s = data.constData(); + for (int i = 0; i < items; i++) { + HandleInformation d; + d.start = read_le(&s[pos]); + d.end = read_le(&s[pos + 2]); + list.append(d); + + pos += item_len; + } + + return list; +} + +QList GatoAttClient::parseAttributeData(const QByteArray &data) +{ + const int item_len = data[0]; + const int items = (data.size() - 1) / item_len; + QList list; + list.reserve(items); + + int pos = 1; + const char *s = data.constData(); + for (int i = 0; i < items; i++) { + AttributeData d; + d.handle = read_le(&s[pos]); + d.value = data.mid(pos + 2, item_len - 2); + list.append(d); + + pos += item_len; + } + + return list; +} + +QList GatoAttClient::parseAttributeGroupData(const QByteArray &data) +{ + const int item_len = data[0]; + const int items = (data.size() - 1) / item_len; + QList list; + list.reserve(items); + + int pos = 1; + const char *s = data.constData(); + for (int i = 0; i < items; i++) { + AttributeGroupData d; + d.start = read_le(&s[pos]); + d.end = read_le(&s[pos + 2]); + d.value = data.mid(pos + 4, item_len - 4); + list.append(d); + + pos += item_len; + } + + return list; +} + +void GatoAttClient::handleSocketConnected() +{ + requestExchangeMTU(ATT_DEFAULT_LE_MTU, this, SLOT(handleServerMTU(quint8))); + emit connected(); +} + +void GatoAttClient::handleSocketDisconnected() +{ + emit disconnected(); +} + +void GatoAttClient::handleSocketReadyRead() +{ + QByteArray pkt = socket->receive(); + if (!pkt.isEmpty()) { +#if PROTOCOL_DEBUG + qDebug() << "Received" << pkt.size() << "bytes" << pkt.toHex(); +#endif + + // Check if it is an event + if (handleEvent(pkt)) { + return; + } + + // Otherwise, if we have a request waiting, check if this answers it + if (!pending_requests.isEmpty()) { + if (handleResponse(pending_requests.head(), pkt)) { + pending_requests.dequeue(); + // Proceed to next request + if (!pending_requests.isEmpty()) { + sendARequest(); + } + return; + } + } + + qDebug() << "No idea what this packet is"; + } +} + +void GatoAttClient::handleServerMTU(uint req, quint8 server_mtu) +{ + Q_UNUSED(req); + if (server_mtu != 0) { + mtu = server_mtu; + } +} + + diff --git a/gatoattclient.h b/gatoattclient.h new file mode 100644 index 0000000..e373a27 --- /dev/null +++ b/gatoattclient.h @@ -0,0 +1,98 @@ +#ifndef GATOATTCLIENT_H +#define GATOATTCLIENT_H + +#include +#include +#include "gatosocket.h" +#include "gatouuid.h" + +class GatoAttClient : public QObject +{ + Q_OBJECT + +public: + explicit GatoAttClient(QObject *parent = 0); + ~GatoAttClient(); + + GatoSocket::State state() const; + + bool connectTo(const GatoAddress& addr); + void close(); + + struct InformationData + { + GatoHandle handle; + GatoUUID uuid; + }; + struct HandleInformation + { + GatoHandle start; + GatoHandle end; + }; + struct AttributeData + { + GatoHandle handle; + QByteArray value; + }; + struct AttributeGroupData + { + GatoHandle start; + GatoHandle end; + QByteArray value; + }; + + uint request(int opcode, const QByteArray &data, QObject *receiver, const char *member); + uint requestExchangeMTU(quint8 client_mtu, QObject *receiver, const char *member); + uint requestFindInformation(GatoHandle start, GatoHandle end, QObject *receiver, const char *member); + uint requestFindByTypeValue(GatoHandle start, GatoHandle end, const GatoUUID &uuid, const QByteArray& value, QObject *receiver, const char *member); + uint requestReadByType(GatoHandle start, GatoHandle end, const GatoUUID &uuid, QObject *receiver, const char *member); + uint requestRead(GatoHandle handle, QObject *receiver, const char *member); + uint requestReadByGroupType(GatoHandle start, GatoHandle end, const GatoUUID &uuid, QObject *receiver, const char *member); + uint requestWrite(GatoHandle handle, const QByteArray &value, QObject *receiver, const char *member); + void cancelRequest(uint id); + + void command(int opcode, const QByteArray &data); + void commandWrite(GatoHandle handle, const QByteArray &value); + +signals: + void connected(); + void disconnected(); + + void attributeUpdated(GatoHandle handle, const QByteArray &value, bool confirmed); + +private: + struct Request + { + uint id; + quint8 opcode; + QByteArray pkt; + QObject *receiver; + QByteArray member; + }; + + void sendARequest(); + bool handleEvent(const QByteArray &event); + bool handleResponse(const Request& req, const QByteArray &response); + + void writeUuid16or128(QDataStream& s, const GatoUUID& uuid); + + QList parseInformationData(const QByteArray &data); + QList parseHandleInformation(const QByteArray &data); + QList parseAttributeData(const QByteArray &data); + QList parseAttributeGroupData(const QByteArray &data); + +private slots: + void handleSocketConnected(); + void handleSocketDisconnected(); + void handleSocketReadyRead(); + + void handleServerMTU(uint req, quint8 server_mtu); + +private: + GatoSocket *socket; + quint8 mtu; + uint next_id; + QQueue pending_requests; +}; + +#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))); + d, SLOT(handlePrimary(QList))); } else { qWarning() << "Not connected"; } @@ -176,7 +176,7 @@ void GatoPeripheral::discoverServices(const QList &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))); + d, SLOT(handlePrimaryForService(uint,QList))); 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))); + d, SLOT(handleCharacteristic(QList))); 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))); + d, SLOT(handleDescriptors(uint,QList))); 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 &list) +void GatoPeripheralPrivate::handlePrimary(uint req, const QList &list) { Q_Q(GatoPeripheral); Q_UNUSED(req); @@ -574,7 +583,7 @@ void GatoPeripheralPrivate::handlePrimary(uint req, const QListrequestReadByGroupType(last_handle + 1, 0xFFFF, GatoUUID::GattPrimaryService, - this, SLOT(handlePrimary(uint,QList))); + this, SLOT(handlePrimary(uint,QList))); } } -void GatoPeripheralPrivate::handlePrimaryForService(uint req, const QList &list) +void GatoPeripheralPrivate::handlePrimaryForService(uint req, const QList &list) { Q_Q(GatoPeripheral); @@ -612,7 +621,7 @@ void GatoPeripheralPrivate::handlePrimaryForService(uint req, const QListrequestFindByTypeValue(last_handle + 1, 0xFFFF, GatoUUID::GattPrimaryService, value, - this, SLOT(handlePrimaryForService(uint,QList))); + this, SLOT(handlePrimaryForService(uint,QList))); pending_primary_reqs.insert(req, uuid); } } -void GatoPeripheralPrivate::handleCharacteristic(uint req, const QList &list) +void GatoPeripheralPrivate::handleCharacteristic(uint req, const QList &list) { Q_Q(GatoPeripheral); @@ -664,7 +673,7 @@ void GatoPeripheralPrivate::handleCharacteristic(uint req, const QListrequestReadByType(last_handle + 1, service.endHandle(), GatoUUID::GattCharacteristic, - this, SLOT(handleCharacteristic(uint,QList))); + this, SLOT(handleCharacteristic(uint,QList))); pending_characteristic_reqs.insert(req, service.startHandle()); } } -void GatoPeripheralPrivate::handleDescriptors(uint req, const QList &list) +void GatoPeripheralPrivate::handleDescriptors(uint req, const QList &list) { Q_Q(GatoPeripheral); @@ -723,7 +732,7 @@ void GatoPeripheralPrivate::handleDescriptors(uint req, const QListrequestFindInformation(last_handle + 1, characteristic.endHandle(), - this, SLOT(handleDescriptors(uint,QList))); + this, SLOT(handleDescriptors(uint,QList))); 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 value_to_characteristic; QMap descriptor_to_characteristic; - GatoAtt *att; + GatoAttClient *att; QMap pending_primary_reqs; QMap pending_characteristic_reqs; QMap 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& list); - void handlePrimaryForService(uint req, const QList& list); - void handleCharacteristic(uint req, const QList &list); - void handleDescriptors(uint req, const QList &list); + void handlePrimary(uint req, const QList& list); + void handlePrimaryForService(uint req, const QList& list); + void handleCharacteristic(uint req, const QList &list); + void handleDescriptors(uint req, const QList &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 -- cgit v1.2.3