From 47ada94baa424e56d2ded256fddc91e6aa4d3090 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Tue, 3 Dec 2013 03:05:47 +0100 Subject: initial import --- gatoperipheral.h | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 gatoperipheral.h (limited to 'gatoperipheral.h') diff --git a/gatoperipheral.h b/gatoperipheral.h new file mode 100644 index 0000000..6ad6782 --- /dev/null +++ b/gatoperipheral.h @@ -0,0 +1,67 @@ +#ifndef GATOPERIPHERAL_H +#define GATOPERIPHERAL_H + +#include +#include "libgato_global.h" +#include "gatouuid.h" +#include "gatoaddress.h" + +class GatoService; +class GatoCharacteristic; +class GatoDescriptor; +class GatoPeripheralPrivate; + +class LIBGATO_EXPORT GatoPeripheral : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(GatoPeripheral) + Q_ENUMS(State) + Q_PROPERTY(GatoAddress address READ address) + Q_PROPERTY(QString name READ name NOTIFY nameChanged) + +public: + GatoPeripheral(const GatoAddress& addr, QObject *parent = 0); + ~GatoPeripheral(); + + enum State { + StateDisconnected, + StateConnecting, + StateConnected + }; + + State state() const; + GatoAddress address() const; + QString name() const; + QList services() const; + + void parseEIR(quint8 data[], int len); + +public slots: + void connectPeripheral(); + void disconnectPeripheral(); + void discoverServices(); + void discoverServices(const QList& serviceUUIDs); + void discoverCharacteristics(const GatoService &service); + void discoverCharacteristics(const GatoService &service, const QList& characteristicUUIDs); + 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 GatoDescriptor &descriptor, const QByteArray &data); + void setNotification(const GatoCharacteristic &characteristic, bool enabled); + +signals: + void connected(); + void disconnected(); + void nameChanged(); + void servicesDiscovered(); + void characteristicsDiscovered(const GatoService &service); + void descriptorsDiscovered(const GatoCharacteristic &characteristic); + void valueUpdated(const GatoCharacteristic &characteristic, const QByteArray &value); + void descriptorValueUpdated(const GatoDescriptor &descriptor, const QByteArray &value); + +private: + GatoPeripheralPrivate *const d_ptr; +}; + +#endif // GATOPERIPHERAL_H -- cgit v1.2.3