diff options
author | Andreas Buhr <andreas@andreasbuhr.de> | 2021-02-19 17:09:06 +0100 |
---|---|---|
committer | Andreas Buhr <andreas@andreasbuhr.de> | 2021-02-22 17:59:28 +0100 |
commit | 67c772e9509faa00d3fdc07e10169fdc1dc0ae9d (patch) | |
tree | 06c21d64b6af53cf429c7e3ab03ee9d8200a66f3 /examples/bluetooth/btchat | |
parent | 1092e968032a44ca73db81d124565a97505fb198 (diff) |
QtBluetooth examples: make server device discoverable
When trying the bluetooth examples on devices which do not know
each other, they do not find each other, because the have to be
paired first. This could lead to some frustration. This patch
sets the server device into discoverable mode first.
Change-Id: I2873f957d36a45cd86e282e274e198e560a243ad
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'examples/bluetooth/btchat')
-rw-r--r-- | examples/bluetooth/btchat/chat.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/examples/bluetooth/btchat/chat.cpp b/examples/bluetooth/btchat/chat.cpp index c26c7937..cec9c900 100644 --- a/examples/bluetooth/btchat/chat.cpp +++ b/examples/bluetooth/btchat/chat.cpp @@ -91,10 +91,12 @@ Chat::Chat(QWidget *parent) ui->firstAdapter->setChecked(true); connect(ui->firstAdapter, &QRadioButton::clicked, this, &Chat::newAdapterSelected); connect(ui->secondAdapter, &QRadioButton::clicked, this, &Chat::newAdapterSelected); - QBluetoothLocalDevice adapter(localAdapters.at(0).address()); - adapter.setHostMode(QBluetoothLocalDevice::HostDiscoverable); } + // make discoverable + QBluetoothLocalDevice adapter(localAdapters.at(0).address()); + adapter.setHostMode(QBluetoothLocalDevice::HostDiscoverable); + //! [Create Chat Server] server = new ChatServer(this); connect(server, QOverload<const QString &>::of(&ChatServer::clientConnected), |