Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[qble] call bluez::adapter::RemoveDevice() to unpair device #466

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion daemon/src/deviceinterface.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "deviceinterface.h"

#include "bluezadapter.h"
#include "deviceinfoservice.h"
#include "alertnotificationservice.h"
#include "hrmservice.h"
Expand Down Expand Up @@ -147,6 +147,17 @@ void DeviceInterface::disconnect()
}
}

void DeviceInterface::unpair()
{
qDebug() << Q_FUNC_INFO;
if (m_device) {
BluezAdapter adapter;
adapter.setAdapterPath(AmazfishConfig::instance()->localAdapter());
adapter.removeDevice(m_deviceAddress);

}
}

QString DeviceInterface::connectionState() const
{
if (!m_device) {
Expand Down
1 change: 1 addition & 0 deletions daemon/src/deviceinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class DeviceInterface : public QObject
Q_INVOKABLE QString pair(const QString &name, const QString &address);
Q_INVOKABLE void connectToDevice(const QString &address);
Q_INVOKABLE void disconnect();
Q_INVOKABLE void unpair();
Q_INVOKABLE QString connectionState() const;
Q_INVOKABLE bool operationRunning();
Q_INVOKABLE bool supportsFeature(int f);
Expand Down
2 changes: 1 addition & 1 deletion qble
4 changes: 4 additions & 0 deletions ui/qml/pages/FirstPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ PagePL {

function unpairAccepted() {
DaemonInterfaceInstance.disconnect();
DaemonInterfaceInstance.unpair()
AmazfishConfig.pairedAddress = "";
AmazfishConfig.pairedName = "";

}

pageMenu: PageMenuPL {
Expand Down
2 changes: 0 additions & 2 deletions ui/qml/pages/PairPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ PageListPL {
contentHeight: styler.themeItemSizeLarge
// visible: model.FriendlyName.indexOf(deviceType) >= 0
onClicked: {
AmazfishConfig.pairedAddress = "";
AmazfishConfig.pairedName = "";
stopDiscovery();
_deviceName = model.FriendlyName;
_deviceAddress = AmazfishConfig.localAdapter+"/dev_" + model.Address.replace(/:/g, '_');
Expand Down
9 changes: 9 additions & 0 deletions ui/src/daemoninterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ void DaemonInterface::disconnect()
iface->call(QStringLiteral("disconnect"));
}

void DaemonInterface::unpair()
{
if (!iface || !iface->isValid()) {
return;
}
iface->call(QStringLiteral("unpair"));
}


bool DaemonInterface::supportsFeature(Amazfish::Feature f)
{
if (!iface || !iface->isValid()) {
Expand Down
1 change: 1 addition & 0 deletions ui/src/daemoninterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class DaemonInterface : public QObject

Q_INVOKABLE void connectToDevice(const QString &address);
Q_INVOKABLE void disconnect();
Q_INVOKABLE void unpair();
Q_INVOKABLE bool supportsFeature(Amazfish::Feature f);
Q_INVOKABLE int supportedFeatures();

Expand Down
Loading