File: bleiodevice.h

package info (click to toggle)
qt6-remoteobjects 6.8.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 3,832 kB
  • sloc: cpp: 20,582; sh: 29; makefile: 23
file content (45 lines) | stat: -rw-r--r-- 1,280 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (C) 2022 The Qt Company Ltd.
// Copyright (C) 2019 Ford Motor Company
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#pragma once

#include <QtBluetooth/QBluetoothUuid>
#include <QtBluetooth/QLowEnergyCharacteristic>
#include <QtBluetooth/QLowEnergyService>

#include <QtCore/QIODevice>
#include <QtCore/QPointer>

class BLEIoDevice : public QIODevice
{
    Q_OBJECT
public:
    BLEIoDevice(QLowEnergyService *service, const QBluetoothUuid &rx,
                const QBluetoothUuid &tx, QObject *parent = nullptr);

    static const QBluetoothUuid SERVICE_UUID;
    static const QBluetoothUuid CLIENT_TX_SERVER_RX_CHAR_UUID;
    static const QBluetoothUuid CLIENT_RX_SERVER_TX_CHAR_UUID;
    static const QByteArray CLIENT_READY_SIGNAL;

signals:
    void disconnected();
    void closing();

    // QIODevice interface
public:
    qint64 bytesAvailable() const override;
    bool isSequential() const override;
    void close() override;

protected:
    qint64 readData(char *data, qint64 maxlen) override;
    qint64 writeData(const char *data, qint64 len) override;

private:
    QPointer<QLowEnergyService> m_service;
    QLowEnergyCharacteristic m_txCharacteristic;
    QBluetoothUuid m_rxCharacteristicUuid;
    QByteArray m_rxBuffer;
};