Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qohosbluetoothsocket_p.h
Go to the documentation of this file.
1
// Copyright (C) 2026 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
ifndef
QOHOSBLUETOOTHSOCKET_P_H
5
#
define
QOHOSBLUETOOTHSOCKET_P_H
6
7
//
8
// W A R N I N G
9
// -------------
10
//
11
// This file is not part of the Qt API. It exists purely as an
12
// implementation detail. This header file may change from version to
13
// version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#
include
<
QtBluetooth
/
private
/
qohosbluetoothcommon_p
.
h
>
19
20
#
include
<
QtCore
/
qbytearray
.
h
>
21
#
include
<
QtCore
/
qobject
.
h
>
22
#
include
<
QtCore
/
qstring
.
h
>
23
#
include
<
QtCore
/
qtconfigmacros
.
h
>
24
#
include
<
QtCore
/
qtypes
.
h
>
25
26
#
include
<
cstdint
>
27
#
include
<
memory
>
28
#
include
<
optional
>
29
#
include
<
string
>
30
#
include
<
unordered_map
>
31
32
QT_BEGIN_NAMESPACE
33
34
namespace
QtOhosBluetooth
{
35
36
constexpr
int
invalidSocketDescriptor
= -1;
37
38
std
::shared_ptr<
int
>
makeSppClientSocketHandle
(
int
socketDescriptor);
39
std
::shared_ptr<
int
>
makeSppServerSocketHandle
(
int
socketDescriptor);
40
41
class
QOhosBluetoothSocketProxy
:
public
QObject
42
{
43
Q_OBJECT
44
public
:
45
QOhosBluetoothSocketProxy
();
46
47
bool
connect
(
const
QString &deviceId,
const
QString &uuid,
bool
secure);
48
bool
takeOverSocket
(
std
::shared_ptr<
int
> socketHandle);
49
bool
write
(
const
char
*data, qint64 maxSize);
50
void
close
();
51
52
std
::
optional
<
QString
>
tryGetPeerDeviceAddress
()
const
;
53
std
::
optional
<
QString
>
tryGetPeerDeviceName
()
const
;
54
55
static
bool
registerPendingSocketHandle
(
std
::shared_ptr<
int
> socketHandle);
56
static
void
dropPendingSocketHandle
(
int
socketDescriptor);
57
static
std
::shared_ptr<
int
>
takePendingSocketHandle
(
int
socketDescriptor);
58
59
Q_SIGNALS
:
60
void
connected
(
int
socketDescriptor
);
61
void
disconnected
();
62
void
dataReceived
(
const
QByteArray &data);
63
void
errorOccurred
(QOhosBluetoothErrorCode errorCode);
64
65
private
:
66
void
onSocketConnected(
std
::uint64_t connectRequestId,
std
::shared_ptr<
int
> socketHandle);
67
void
onConnectFailed(
std
::uint64_t connectRequestId, QOhosBluetoothErrorCode errorCode);
68
void
reportError(QOhosBluetoothErrorCode errorCode);
69
70
struct
JsScopeData
71
{
72
std
::shared_ptr<
int
> socketHandle;
73
std
::shared_ptr<
void
> sppReadHandlerHandle;
74
};
75
76
std
::shared_ptr<JsScopeData> m_jsScopeData;
77
std
::optional<
std
::string> m_deviceId;
78
std
::uint64_t m_connectRequestsCounter = 0;
79
std
::optional<
std
::uint64_t> m_pendingConnectRequestId;
80
81
static
std::unordered_map<
int
, std::shared_ptr<
int
>> &pendingSocketHandles();
82
};
83
84
}
85
86
QT_END_NAMESPACE
87
88
#
endif
// QOHOSBLUETOOTHSOCKET_P_H
QtOhosBluetooth::QOhosBluetoothSocketProxy
Definition
qohosbluetoothsocket_p.h:42
QtOhosBluetooth::QOhosBluetoothSocketProxy::connect
bool connect(const QString &deviceId, const QString &uuid, bool secure)
Definition
qohosbluetoothsocket.cpp:242
QtOhosBluetooth::QOhosBluetoothSocketProxy::close
void close()
Definition
qohosbluetoothsocket.cpp:458
QtOhosBluetooth::QOhosBluetoothSocketProxy::dataReceived
void dataReceived(const QByteArray &data)
QtOhosBluetooth::QOhosBluetoothSocketProxy::tryGetPeerDeviceAddress
std::optional< QString > tryGetPeerDeviceAddress() const
Definition
qohosbluetoothsocket.cpp:470
QtOhosBluetooth::QOhosBluetoothSocketProxy::write
bool write(const char *data, qint64 maxSize)
Definition
qohosbluetoothsocket.cpp:406
QtOhosBluetooth::QOhosBluetoothSocketProxy::dropPendingSocketHandle
static void dropPendingSocketHandle(int socketDescriptor)
Definition
qohosbluetoothsocket.cpp:225
QtOhosBluetooth::QOhosBluetoothSocketProxy::disconnected
void disconnected()
QtOhosBluetooth::QOhosBluetoothSocketProxy::errorOccurred
void errorOccurred(QOhosBluetoothErrorCode errorCode)
QtOhosBluetooth::QOhosBluetoothSocketProxy::takePendingSocketHandle
static std::shared_ptr< int > takePendingSocketHandle(int socketDescriptor)
Definition
qohosbluetoothsocket.cpp:230
QtOhosBluetooth::QOhosBluetoothSocketProxy::tryGetPeerDeviceName
std::optional< QString > tryGetPeerDeviceName() const
Definition
qohosbluetoothsocket.cpp:484
QtOhosBluetooth::QOhosBluetoothSocketProxy::takeOverSocket
bool takeOverSocket(std::shared_ptr< int > socketHandle)
Definition
qohosbluetoothsocket.cpp:350
QtOhosBluetooth::QOhosBluetoothSocketProxy::registerPendingSocketHandle
static bool registerPendingSocketHandle(std::shared_ptr< int > socketHandle)
Definition
qohosbluetoothsocket.cpp:202
QtOhosBluetooth
Definition
qohosbluetoothaccess.cpp:21
QtOhosBluetooth::invalidSocketDescriptor
constexpr int invalidSocketDescriptor
Definition
qohosbluetoothsocket_p.h:36
QtOhosBluetooth::makeSppClientSocketHandle
std::shared_ptr< int > makeSppClientSocketHandle(int socketDescriptor)
Definition
qohosbluetoothsocket.cpp:57
QtOhosBluetooth::makeSppServerSocketHandle
std::shared_ptr< int > makeSppServerSocketHandle(int socketDescriptor)
Definition
qohosbluetoothsocket.cpp:62
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
Q_DECLARE_LOGGING_CATEGORY
QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcQIORing)
qtconnectivity
src
bluetooth
ohos
qohosbluetoothsocket_p.h
Generated on
for Qt by
1.18.0