Fix bluetooth wifi setup for bluez backends
parent
336e21aabc
commit
871e2c0ce8
|
|
@ -166,10 +166,13 @@ void BluetoothDiscovery::onBluetoothHostModeChanged(const QBluetoothLocalDevice:
|
|||
connect(m_discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &BluetoothDiscovery::deviceDiscovered);
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||
connect(m_discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceUpdated, this, &BluetoothDiscovery::deviceDiscovered);
|
||||
#elif (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0))
|
||||
connect(m_discoveryAgent, &QBluetoothDeviceDiscoveryAgent::errorOccurred, this, &BluetoothDiscovery::onError);
|
||||
#else
|
||||
connect(m_discoveryAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)), this, SLOT(onError(QBluetoothDeviceDiscoveryAgent::Error)));
|
||||
#endif
|
||||
connect(m_discoveryAgent, &QBluetoothDeviceDiscoveryAgent::finished, this, &BluetoothDiscovery::discoveryFinished);
|
||||
connect(m_discoveryAgent, &QBluetoothDeviceDiscoveryAgent::canceled, this, &BluetoothDiscovery::discoveryCancelled);
|
||||
connect(m_discoveryAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)), this, SLOT(onError(QBluetoothDeviceDiscoveryAgent::Error)));
|
||||
}
|
||||
if (m_discoveryEnabled && !m_discoveryAgent->isActive()) {
|
||||
start();
|
||||
|
|
|
|||
|
|
@ -54,6 +54,10 @@ BtWiFiSetup::BtWiFiSetup(QObject *parent) : QObject(parent)
|
|||
{
|
||||
m_accessPoints = new WirelessAccessPoints(this);
|
||||
qRegisterMetaType<BluetoothDeviceInfo*>("const BluetoothDeviceInfo*");
|
||||
|
||||
connect(this, &BtWiFiSetup::bluetoothStatusChanged, this, [this](){
|
||||
qCDebug(dcBtWiFiSetup()) << "Bluetooth status changed" << m_bluetoothStatus;
|
||||
});
|
||||
}
|
||||
|
||||
BtWiFiSetup::~BtWiFiSetup()
|
||||
|
|
@ -81,13 +85,18 @@ void BtWiFiSetup::connectToDevice(const BluetoothDeviceInfo *device)
|
|||
}
|
||||
|
||||
m_btController = QLowEnergyController::createCentral(device->bluetoothDeviceInfo(), this);
|
||||
connect(m_btController, &QLowEnergyController::connected, this, [this](){
|
||||
qCInfo(dcBtWiFiSetup()) << "Bluetooth connected";
|
||||
connect(m_btController, &QLowEnergyController::connected, this, [this, device](){
|
||||
qCInfo(dcBtWiFiSetup()) << "Bluetooth connected" << device->address() << device->name();
|
||||
m_btController->discoverServices();
|
||||
m_bluetoothStatus = BluetoothStatusConnectedToBluetooth;
|
||||
emit bluetoothStatusChanged(m_bluetoothStatus);
|
||||
}, Qt::QueuedConnection);
|
||||
|
||||
|
||||
connect(m_btController, &QLowEnergyController::stateChanged, this, [](QLowEnergyController::ControllerState state){
|
||||
qCInfo(dcBtWiFiSetup()) << "Bluetooth constroller state changed" << state;
|
||||
});
|
||||
|
||||
connect(m_btController, &QLowEnergyController::disconnected, this, [this](){
|
||||
qCInfo(dcBtWiFiSetup()) << "Bluetooth disconnected";
|
||||
m_bluetoothStatus = BluetoothStatusDisconnected;
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ PlatformPermissions::PermissionStatus PlatformPermissionsAndroid::checkPermissio
|
|||
switch (platformPermission) {
|
||||
case PlatformPermissions::PermissionBluetooth: {
|
||||
QBluetoothPermission permission;
|
||||
// Only request scan/connect access; advertising isn't needed and isn't declared in the manifest.
|
||||
permission.setCommunicationModes(QBluetoothPermission::Access);
|
||||
|
||||
const auto permissionStatus = qApp->checkPermission(permission);
|
||||
|
||||
|
|
@ -194,7 +196,10 @@ void PlatformPermissionsAndroid::requestPermission(PlatformPermissions::Permissi
|
|||
switch (platformPermission) {
|
||||
case PlatformPermissions::PermissionBluetooth:
|
||||
qCDebug(dcPlatformPermissions()) << "Requesting bluetooth permission";
|
||||
qApp->requestPermission(QBluetoothPermission{}, [platformPermission](const QPermission &permission) {
|
||||
{
|
||||
QBluetoothPermission permission;
|
||||
permission.setCommunicationModes(QBluetoothPermission::Access);
|
||||
qApp->requestPermission(permission, [platformPermission](const QPermission &permission) {
|
||||
if (permission.status() == Qt::PermissionStatus::Denied) {
|
||||
qCWarning(dcPlatformPermissions()) << "Bluetooth permission denied.";
|
||||
s_instance->m_requestedButDeniedPermissions.append(platformPermission);
|
||||
|
|
@ -204,7 +209,8 @@ void PlatformPermissionsAndroid::requestPermission(PlatformPermissions::Permissi
|
|||
qCDebug(dcPlatformPermissions()) << "Bluetooth permission granted.";
|
||||
|
||||
emit s_instance->bluetoothPermissionChanged();
|
||||
});
|
||||
});
|
||||
}
|
||||
break;
|
||||
case PlatformPermissions::PermissionLocation: {
|
||||
QLocationPermission locationPermission;
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ WizardPageBase {
|
|||
callback: function() {
|
||||
var nymeaHost = hostsProxy.get(index);
|
||||
var connectionInfoDialog = Qt.createComponent("/ui/components/ConnectionInfoDialog.qml")
|
||||
print("**", connectionInfoDialog.errorString())
|
||||
console.log("**", connectionInfoDialog.errorString())
|
||||
var popup = connectionInfoDialog.createObject(app,{nymeaEngine: engine, nymeaHost: nymeaHost})
|
||||
popup.open()
|
||||
popup.connectionSelected.connect(function(connection) {
|
||||
|
|
@ -322,7 +322,7 @@ WizardPageBase {
|
|||
|
||||
onNext: {
|
||||
var rpcUrl = manualEntry.rpcUrl;
|
||||
print("Try to connect ", rpcUrl)
|
||||
console.log("Try to connect ", rpcUrl)
|
||||
var host = nymeaDiscovery.nymeaHosts.createWanHost("Manual connection", rpcUrl);
|
||||
engine.jsonRpcClient.connectToHost(host)
|
||||
}
|
||||
|
|
@ -390,8 +390,8 @@ WizardPageBase {
|
|||
BtWiFiSetup {
|
||||
id: wifiSetup
|
||||
|
||||
onBluetoothStatusChanged: {
|
||||
print("status changed", status)
|
||||
onBluetoothStatusChanged: (status) => {
|
||||
console.log("status changed", status)
|
||||
switch (status) {
|
||||
case BtWiFiSetup.BluetoothStatusDisconnected:
|
||||
pageStack.pop(wirelessBluetoothDiscoveryPage)
|
||||
|
|
@ -419,12 +419,12 @@ WizardPageBase {
|
|||
|
||||
onCurrentConnectionChanged: {
|
||||
if (wifiSetup.currentConnection) {
|
||||
print("**** connected!")
|
||||
console.log("**** connected!")
|
||||
pageStack.push(wirelessConnectionCompletedComponent, {wifiSetup: wifiSetup})
|
||||
}
|
||||
}
|
||||
onWirelessStatusChanged: {
|
||||
print("Wireless status changed:", wifiSetup.networkStatus)
|
||||
console.log("Wireless status changed:", wifiSetup.networkStatus)
|
||||
if (wifiSetup.wirelessStatus === BtWiFiSetup.WirelessStatusFailed) {
|
||||
pageStack.pop()
|
||||
}
|
||||
|
|
@ -452,7 +452,9 @@ WizardPageBase {
|
|||
|
||||
BusyIndicator {
|
||||
anchors.centerIn: parent
|
||||
visible: bluetoothDiscovery.discovering && deviceInfosProxy.count == 0 && bluetoothDiscovery.bluetoothAvailable && bluetoothDiscovery.bluetoothEnabled && PlatformHelper.locationServicesEnabled
|
||||
visible: bluetoothDiscovery.discovering && deviceInfosProxy.count === 0 &&
|
||||
bluetoothDiscovery.bluetoothAvailable && bluetoothDiscovery.bluetoothEnabled &&
|
||||
PlatformHelper.locationServicesEnabled
|
||||
}
|
||||
|
||||
delegate: NymeaSwipeDelegate {
|
||||
|
|
@ -609,7 +611,7 @@ WizardPageBase {
|
|||
}
|
||||
|
||||
onClicked: {
|
||||
print("Connect to ", model.ssid, " --> ", model.macAddress)
|
||||
console.log("Connect to ", model.ssid, " --> ", model.macAddress)
|
||||
if (model.selectedNetwork) {
|
||||
pageStack.push(networkInformationPage, { ssid: model.ssid})
|
||||
} else {
|
||||
|
|
@ -642,7 +644,7 @@ WizardPageBase {
|
|||
onBack: pageStack.pop();
|
||||
|
||||
onNext: {
|
||||
print("connecting to", ssidTextField.text, passwordTextField.password)
|
||||
console.log("connecting to", ssidTextField.text, passwordTextField.password)
|
||||
wifiSetup.connectDeviceToWiFi(ssidTextField.text, passwordTextField.password, true)
|
||||
pageStack.push(wirelessConnectingWiFiComponent)
|
||||
}
|
||||
|
|
@ -690,7 +692,7 @@ WizardPageBase {
|
|||
showNextButton: passwordTextField.isValidPassword
|
||||
|
||||
onNext: {
|
||||
print("connecting to", ssid, passwordTextField.password)
|
||||
console.log("connecting to", ssid, passwordTextField.password)
|
||||
wifiSetup.connectDeviceToWiFi(ssid, passwordTextField.password)
|
||||
pageStack.push(wirelessConnectingWiFiComponent)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue