Fix the UI
This commit is contained in:
parent
8df96a2d53
commit
c293474fd4
@ -74,7 +74,6 @@
|
|||||||
#include "configuration/mqttpolicy.h"
|
#include "configuration/mqttpolicy.h"
|
||||||
#include "configuration/mqttpolicies.h"
|
#include "configuration/mqttpolicies.h"
|
||||||
#include "wifisetup/btwifisetup.h"
|
#include "wifisetup/btwifisetup.h"
|
||||||
#include "wifisetup/networkmanagercontroller.h"
|
|
||||||
#include "types/wirelessaccesspoint.h"
|
#include "types/wirelessaccesspoint.h"
|
||||||
#include "types/wirelessaccesspoints.h"
|
#include "types/wirelessaccesspoints.h"
|
||||||
#include "models/wirelessaccesspointsproxy.h"
|
#include "models/wirelessaccesspointsproxy.h"
|
||||||
@ -272,11 +271,9 @@ void registerQmlTypes() {
|
|||||||
qmlRegisterType<TagListProxyModel>(uri, 1, 0, "TagListProxyModel");
|
qmlRegisterType<TagListProxyModel>(uri, 1, 0, "TagListProxyModel");
|
||||||
|
|
||||||
qmlRegisterType<BtWiFiSetup>(uri, 1, 0, "BtWiFiSetup");
|
qmlRegisterType<BtWiFiSetup>(uri, 1, 0, "BtWiFiSetup");
|
||||||
qmlRegisterType<NetworkManagerController>(uri, 1, 0, "NetworkManagerController");
|
|
||||||
qmlRegisterType<BluetoothDiscovery>(uri, 1, 0, "BluetoothDiscovery");
|
qmlRegisterType<BluetoothDiscovery>(uri, 1, 0, "BluetoothDiscovery");
|
||||||
qmlRegisterUncreatableType<BluetoothDeviceInfo>(uri, 1, 0, "BluetoothDeviceInfo", "Can't create this in QML. Get it from the DeviceInfos.");
|
qmlRegisterUncreatableType<BluetoothDeviceInfo>(uri, 1, 0, "BluetoothDeviceInfo", "Can't create this in QML. Get it from the DeviceInfos.");
|
||||||
qmlRegisterUncreatableType<BluetoothDeviceInfos>(uri, 1, 0, "BluetoothDeviceInfos", "Can't create this in QML. Get it from the BluetoothDiscovery.");
|
qmlRegisterUncreatableType<BluetoothDeviceInfos>(uri, 1, 0, "BluetoothDeviceInfos", "Can't create this in QML. Get it from the BluetoothDiscovery.");
|
||||||
qmlRegisterUncreatableType<WirelessSetupManager>(uri, 1, 0, "WirelessSetupManager", "Can't create this in QML. Get it from the NetworkManagerControler.");
|
|
||||||
qmlRegisterUncreatableType<WirelessAccessPoint>(uri, 1, 0, "WirelessAccessPoint", "Can't create this in QML. Get it from the WirelessAccessPoints.");
|
qmlRegisterUncreatableType<WirelessAccessPoint>(uri, 1, 0, "WirelessAccessPoint", "Can't create this in QML. Get it from the WirelessAccessPoints.");
|
||||||
qmlRegisterUncreatableType<WirelessAccessPoints>(uri, 1, 0, "WirelessAccessPoints", "Can't create this in QML. Get it from the Engine instance.");
|
qmlRegisterUncreatableType<WirelessAccessPoints>(uri, 1, 0, "WirelessAccessPoints", "Can't create this in QML. Get it from the Engine instance.");
|
||||||
qmlRegisterType<WirelessAccessPointsProxy>(uri, 1, 0, "WirelessAccessPointsProxy");
|
qmlRegisterType<WirelessAccessPointsProxy>(uri, 1, 0, "WirelessAccessPointsProxy");
|
||||||
|
|||||||
@ -134,8 +134,6 @@ SOURCES += \
|
|||||||
$${PWD}/wifisetup/bluetoothdeviceinfo.cpp \
|
$${PWD}/wifisetup/bluetoothdeviceinfo.cpp \
|
||||||
$${PWD}/wifisetup/bluetoothdeviceinfos.cpp \
|
$${PWD}/wifisetup/bluetoothdeviceinfos.cpp \
|
||||||
$${PWD}/wifisetup/bluetoothdiscovery.cpp \
|
$${PWD}/wifisetup/bluetoothdiscovery.cpp \
|
||||||
$${PWD}/wifisetup/wirelesssetupmanager.cpp \
|
|
||||||
$${PWD}/wifisetup/networkmanagercontroller.cpp \
|
|
||||||
$${PWD}/models/logsmodelng.cpp \
|
$${PWD}/models/logsmodelng.cpp \
|
||||||
$${PWD}/models/interfacesproxy.cpp \
|
$${PWD}/models/interfacesproxy.cpp \
|
||||||
$${PWD}/models/tagsproxymodel.cpp \
|
$${PWD}/models/tagsproxymodel.cpp \
|
||||||
@ -281,8 +279,6 @@ HEADERS += \
|
|||||||
$${PWD}/wifisetup/bluetoothdeviceinfo.h \
|
$${PWD}/wifisetup/bluetoothdeviceinfo.h \
|
||||||
$${PWD}/wifisetup/bluetoothdeviceinfos.h \
|
$${PWD}/wifisetup/bluetoothdeviceinfos.h \
|
||||||
$${PWD}/wifisetup/bluetoothdiscovery.h \
|
$${PWD}/wifisetup/bluetoothdiscovery.h \
|
||||||
$${PWD}/wifisetup/wirelesssetupmanager.h \
|
|
||||||
$${PWD}/wifisetup/networkmanagercontroller.h \
|
|
||||||
$${PWD}/libnymea-app-core.h \
|
$${PWD}/libnymea-app-core.h \
|
||||||
$${PWD}/models/logsmodelng.h \
|
$${PWD}/models/logsmodelng.h \
|
||||||
$${PWD}/models/interfacesproxy.h \
|
$${PWD}/models/interfacesproxy.h \
|
||||||
|
|||||||
@ -9,6 +9,7 @@ static QBluetoothUuid wifiServiceUuid = QBluetoothUuid(QUuid("e0
|
|||||||
static QBluetoothUuid wifiCommanderCharacteristicUuid = QBluetoothUuid(QUuid("e081fec1-f757-4449-b9c9-bfa83133f7fc"));
|
static QBluetoothUuid wifiCommanderCharacteristicUuid = QBluetoothUuid(QUuid("e081fec1-f757-4449-b9c9-bfa83133f7fc"));
|
||||||
static QBluetoothUuid wifiResponseCharacteristicUuid = QBluetoothUuid(QUuid("e081fec2-f757-4449-b9c9-bfa83133f7fc"));
|
static QBluetoothUuid wifiResponseCharacteristicUuid = QBluetoothUuid(QUuid("e081fec2-f757-4449-b9c9-bfa83133f7fc"));
|
||||||
static QBluetoothUuid wifiStatusCharacteristicUuid = QBluetoothUuid(QUuid("e081fec3-f757-4449-b9c9-bfa83133f7fc"));
|
static QBluetoothUuid wifiStatusCharacteristicUuid = QBluetoothUuid(QUuid("e081fec3-f757-4449-b9c9-bfa83133f7fc"));
|
||||||
|
static QBluetoothUuid wifiModeCharacteristicUuid = QBluetoothUuid(QUuid("e081fec4-f757-4449-b9c9-bfa83133f7fc"));
|
||||||
|
|
||||||
static QBluetoothUuid networkServiceUuid = QBluetoothUuid(QUuid("ef6d6610-b8af-49e0-9eca-ab343513641c"));
|
static QBluetoothUuid networkServiceUuid = QBluetoothUuid(QUuid("ef6d6610-b8af-49e0-9eca-ab343513641c"));
|
||||||
static QBluetoothUuid networkStatusCharacteristicUuid = QBluetoothUuid(QUuid("ef6d6611-b8af-49e0-9eca-ab343513641c"));
|
static QBluetoothUuid networkStatusCharacteristicUuid = QBluetoothUuid(QUuid("ef6d6611-b8af-49e0-9eca-ab343513641c"));
|
||||||
@ -32,6 +33,9 @@ void BtWiFiSetup::connectToDevice(const BluetoothDeviceInfo *device)
|
|||||||
qDebug() << "device" << device;
|
qDebug() << "device" << device;
|
||||||
if (m_btController) {
|
if (m_btController) {
|
||||||
delete m_btController;
|
delete m_btController;
|
||||||
|
m_currentConnection = nullptr;
|
||||||
|
currentConnectionChanged();
|
||||||
|
m_accessPoints->clearModel();
|
||||||
m_status = StatusDisconnected;
|
m_status = StatusDisconnected;
|
||||||
emit statusChanged(m_status);
|
emit statusChanged(m_status);
|
||||||
|
|
||||||
@ -47,6 +51,11 @@ void BtWiFiSetup::connectToDevice(const BluetoothDeviceInfo *device)
|
|||||||
qDebug() << "Bluetooth disconnected";
|
qDebug() << "Bluetooth disconnected";
|
||||||
m_status = StatusDisconnected;
|
m_status = StatusDisconnected;
|
||||||
emit statusChanged(m_status);
|
emit statusChanged(m_status);
|
||||||
|
m_btController->deleteLater();
|
||||||
|
m_btController = nullptr;
|
||||||
|
m_currentConnection = nullptr;
|
||||||
|
emit currentConnectionChanged();
|
||||||
|
m_accessPoints->clearModel();
|
||||||
});
|
});
|
||||||
|
|
||||||
typedef void (QLowEnergyController::*errorsSignal)(QLowEnergyController::Error);
|
typedef void (QLowEnergyController::*errorsSignal)(QLowEnergyController::Error);
|
||||||
@ -69,8 +78,6 @@ void BtWiFiSetup::disconnectFromDevice()
|
|||||||
{
|
{
|
||||||
if (m_btController) {
|
if (m_btController) {
|
||||||
m_btController->disconnectFromDevice();
|
m_btController->disconnectFromDevice();
|
||||||
m_btController->deleteLater();
|
|
||||||
m_btController = nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +93,39 @@ void BtWiFiSetup::connectDeviceToWiFi(const QString &ssid, const QString &passwo
|
|||||||
parameters.insert("e", ssid);
|
parameters.insert("e", ssid);
|
||||||
parameters.insert("p", password);
|
parameters.insert("p", password);
|
||||||
request.insert("p", parameters);
|
request.insert("p", parameters);
|
||||||
streamData(request);
|
streamData(m_wifiService, wifiCommanderCharacteristicUuid, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BtWiFiSetup::disconnectDeviceFromWiFi()
|
||||||
|
{
|
||||||
|
if (m_status != StatusConnectedToWiFi) {
|
||||||
|
qWarning() << "Cannot disconnect from wifi in state" << m_status;
|
||||||
|
}
|
||||||
|
QLowEnergyCharacteristic ssidCharacteristic = m_wifiService->characteristic(wifiCommanderCharacteristicUuid);
|
||||||
|
QVariantMap request;
|
||||||
|
request.insert("c", (int)WirelessServiceCommandDisconnect);
|
||||||
|
streamData(m_wifiService, wifiCommanderCharacteristicUuid, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BtWiFiSetup::scanWiFi()
|
||||||
|
{
|
||||||
|
QLowEnergyCharacteristic characteristic = m_wifiService->characteristic(wifiCommanderCharacteristicUuid);
|
||||||
|
QVariantMap request;
|
||||||
|
request.insert("c", (int)WirelessServiceCommandScan);
|
||||||
|
streamData(m_wifiService, wifiCommanderCharacteristicUuid, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BtWiFiSetup::pressPushButton()
|
||||||
|
{
|
||||||
|
if (!m_systemService) {
|
||||||
|
qDebug() << "System service not available. Cannot perform push button pairing";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QLowEnergyCharacteristic commanderCharacteristic = m_systemService->characteristic(systemCommanderCharacteristicUuid);
|
||||||
|
QVariantMap request;
|
||||||
|
request.insert("c", (int)SystemServiceCommandPushAuthentication);
|
||||||
|
|
||||||
|
streamData(m_systemService, systemCommanderCharacteristicUuid, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
BtWiFiSetup::Status BtWiFiSetup::status() const
|
BtWiFiSetup::Status BtWiFiSetup::status() const
|
||||||
@ -134,11 +173,23 @@ bool BtWiFiSetup::networkingEnabled() const
|
|||||||
return m_networkingEnabled;
|
return m_networkingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BtWiFiSetup::setNetworkingEnabled(bool networkingEnabled)
|
||||||
|
{
|
||||||
|
QLowEnergyCharacteristic characteristic = m_networkService->characteristic(networkCommanderCharacteristicUuid);
|
||||||
|
m_networkService->writeCharacteristic(characteristic, networkingEnabled ? QByteArray::fromHex("00") : QByteArray::fromHex("01"));
|
||||||
|
}
|
||||||
|
|
||||||
bool BtWiFiSetup::wirelessEnabled() const
|
bool BtWiFiSetup::wirelessEnabled() const
|
||||||
{
|
{
|
||||||
return m_wirelessEnabled;
|
return m_wirelessEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BtWiFiSetup::setWirelessEnabled(bool wirelessEnabled) const
|
||||||
|
{
|
||||||
|
QLowEnergyCharacteristic characteristic = m_networkService->characteristic(networkCommanderCharacteristicUuid);
|
||||||
|
m_networkService->writeCharacteristic(characteristic, wirelessEnabled ? QByteArray::fromHex("02") : QByteArray::fromHex("03"));
|
||||||
|
}
|
||||||
|
|
||||||
WirelessAccessPoints *BtWiFiSetup::accessPoints() const
|
WirelessAccessPoints *BtWiFiSetup::accessPoints() const
|
||||||
{
|
{
|
||||||
return m_accessPoints;
|
return m_accessPoints;
|
||||||
@ -151,6 +202,7 @@ WirelessAccessPoint *BtWiFiSetup::currentConnection() const
|
|||||||
|
|
||||||
void BtWiFiSetup::setupServices()
|
void BtWiFiSetup::setupServices()
|
||||||
{
|
{
|
||||||
|
qDebug() << "Setting up services";
|
||||||
m_deviceInformationService = m_btController->createServiceObject(QBluetoothUuid::DeviceInformation, m_btController);
|
m_deviceInformationService = m_btController->createServiceObject(QBluetoothUuid::DeviceInformation, m_btController);
|
||||||
m_networkService = m_btController->createServiceObject(networkServiceUuid, m_btController);
|
m_networkService = m_btController->createServiceObject(networkServiceUuid, m_btController);
|
||||||
m_wifiService = m_btController->createServiceObject(wifiServiceUuid, m_btController);
|
m_wifiService = m_btController->createServiceObject(wifiServiceUuid, m_btController);
|
||||||
@ -223,6 +275,7 @@ void BtWiFiSetup::setupServices()
|
|||||||
m_wifiService->writeDescriptor(m_wifiService->characteristic(wifiResponseCharacteristicUuid).descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
|
m_wifiService->writeDescriptor(m_wifiService->characteristic(wifiResponseCharacteristicUuid).descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
|
||||||
m_wifiService->writeDescriptor(m_wifiService->characteristic(wifiStatusCharacteristicUuid).descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
|
m_wifiService->writeDescriptor(m_wifiService->characteristic(wifiStatusCharacteristicUuid).descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
|
||||||
|
|
||||||
|
qDebug() << "Fetching networks after init";
|
||||||
loadNetworks();
|
loadNetworks();
|
||||||
});
|
});
|
||||||
connect(m_wifiService, &QLowEnergyService::characteristicChanged, this, &BtWiFiSetup::characteristicChanged);
|
connect(m_wifiService, &QLowEnergyService::characteristicChanged, this, &BtWiFiSetup::characteristicChanged);
|
||||||
@ -236,22 +289,15 @@ void BtWiFiSetup::setupServices()
|
|||||||
return;
|
return;
|
||||||
qDebug() << "System service discovered";
|
qDebug() << "System service discovered";
|
||||||
m_systemService->writeDescriptor(m_systemService->characteristic(systemResponseCharacteristicUuid).descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
|
m_systemService->writeDescriptor(m_systemService->characteristic(systemResponseCharacteristicUuid).descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
|
||||||
|
|
||||||
});
|
});
|
||||||
m_systemService->discoverDetails();
|
m_systemService->discoverDetails();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BtWiFiSetup::streamData(const QVariantMap &request)
|
void BtWiFiSetup::streamData(QLowEnergyService *service, const QUuid &characteristicUuid, const QVariantMap &request)
|
||||||
{
|
{
|
||||||
QLowEnergyCharacteristic characteristic = m_wifiService->characteristic(wifiCommanderCharacteristicUuid);
|
QLowEnergyCharacteristic characteristic = service->characteristic(characteristicUuid);
|
||||||
if (!characteristic.isValid()) {
|
|
||||||
qWarning() << "WifiSetupManager: WirelessService: Wireless commander characteristic not valid";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray data = QJsonDocument::fromVariant(request).toJson(QJsonDocument::Compact) + '\n';
|
QByteArray data = QJsonDocument::fromVariant(request).toJson(QJsonDocument::Compact) + '\n';
|
||||||
qDebug() << "WifiSetupManager: WirelessService: Start streaming response data:" << data.count() << "bytes";
|
|
||||||
|
|
||||||
int sentDataLength = 0;
|
int sentDataLength = 0;
|
||||||
QByteArray remainingData = data;
|
QByteArray remainingData = data;
|
||||||
@ -261,8 +307,6 @@ void BtWiFiSetup::streamData(const QVariantMap &request)
|
|||||||
m_wifiService->writeCharacteristic(characteristic, package);
|
m_wifiService->writeCharacteristic(characteristic, package);
|
||||||
remainingData = remainingData.remove(0, package.count());
|
remainingData = remainingData.remove(0, package.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "WifiSetupManager: WirelessService: Finished streaming request data";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BtWiFiSetup::processWiFiPacket(const QVariantMap &data)
|
void BtWiFiSetup::processWiFiPacket(const QVariantMap &data)
|
||||||
@ -278,11 +322,19 @@ void BtWiFiSetup::processWiFiPacket(const QVariantMap &data)
|
|||||||
switch (command) {
|
switch (command) {
|
||||||
case WirelessServiceCommandGetNetworks:
|
case WirelessServiceCommandGetNetworks:
|
||||||
|
|
||||||
m_accessPoints->clearModel();
|
|
||||||
|
|
||||||
foreach (const QVariant &data, data.value("p").toList()) {
|
foreach (const QVariant &data, data.value("p").toList()) {
|
||||||
WirelessAccessPoint *accessPoint = new WirelessAccessPoint(this);
|
bool found = false;
|
||||||
|
for (int i = 0; i < m_accessPoints->rowCount(); i++) {
|
||||||
|
WirelessAccessPoint *existingAp = m_accessPoints->get(i);
|
||||||
|
if (existingAp->macAddress() == data.toMap().value("m").toString()) {
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
WirelessAccessPoint *accessPoint = new WirelessAccessPoint(this);
|
||||||
accessPoint->setSsid(data.toMap().value("e").toString());
|
accessPoint->setSsid(data.toMap().value("e").toString());
|
||||||
accessPoint->setMacAddress(data.toMap().value("m").toString());
|
accessPoint->setMacAddress(data.toMap().value("m").toString());
|
||||||
accessPoint->setSignalStrength(data.toMap().value("s").toInt());
|
accessPoint->setSignalStrength(data.toMap().value("s").toInt());
|
||||||
@ -296,6 +348,29 @@ void BtWiFiSetup::processWiFiPacket(const QVariantMap &data)
|
|||||||
m_status = StatusConnectingToWiFi;
|
m_status = StatusConnectingToWiFi;
|
||||||
emit statusChanged(m_status);
|
emit statusChanged(m_status);
|
||||||
break;
|
break;
|
||||||
|
case WirelessServiceCommandGetCurrentConnection:
|
||||||
|
// Find current network
|
||||||
|
m_currentConnection = nullptr;
|
||||||
|
foreach (WirelessAccessPoint *accessPoint, m_accessPoints->wirelessAccessPoints()) {
|
||||||
|
QVariantMap currentConnection = data.value("p").toMap();
|
||||||
|
QString macAddress = currentConnection.value("m").toString();
|
||||||
|
if (accessPoint->macAddress() == macAddress) {
|
||||||
|
// Set the current network
|
||||||
|
m_currentConnection = accessPoint;
|
||||||
|
accessPoint->setHostAddress(currentConnection.value("i").toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qDebug() << "current connection is:" << m_currentConnection;
|
||||||
|
emit currentConnectionChanged();
|
||||||
|
break;
|
||||||
|
case WirelessServiceCommandScan:
|
||||||
|
if (responseCode == WirelessServiceResponseSuccess) {
|
||||||
|
qDebug() << "Fetching networks after wifi scan";
|
||||||
|
loadNetworks();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qWarning() << "Unhandled command reply";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,28 +378,29 @@ void BtWiFiSetup::loadNetworks()
|
|||||||
{
|
{
|
||||||
QVariantMap request;
|
QVariantMap request;
|
||||||
request.insert("c", (int)WirelessServiceCommandGetNetworks);
|
request.insert("c", (int)WirelessServiceCommandGetNetworks);
|
||||||
streamData(request);
|
streamData(m_wifiService, wifiCommanderCharacteristicUuid, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BtWiFiSetup::loadCurrentConnection()
|
void BtWiFiSetup::loadCurrentConnection()
|
||||||
{
|
{
|
||||||
QVariantMap request;
|
QVariantMap request;
|
||||||
request.insert("c", (int)WirelessServiceCommandGetCurrentConnection);
|
request.insert("c", (int)WirelessServiceCommandGetCurrentConnection);
|
||||||
streamData(request);
|
streamData(m_wifiService, wifiCommanderCharacteristicUuid, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BtWiFiSetup::characteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &data)
|
void BtWiFiSetup::characteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &value)
|
||||||
{
|
{
|
||||||
if (characteristic.uuid() == wifiResponseCharacteristicUuid) {
|
if (characteristic.uuid() == wifiResponseCharacteristicUuid) {
|
||||||
m_inputBuffers[characteristic.uuid()].append(data);
|
|
||||||
|
m_inputBuffers[characteristic.uuid()].append(value);
|
||||||
if (!m_inputBuffers[characteristic.uuid()].endsWith("\n")) {
|
if (!m_inputBuffers[characteristic.uuid()].endsWith("\n")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QByteArray data = m_inputBuffers.take(characteristic.uuid());
|
QByteArray data = m_inputBuffers.take(characteristic.uuid());
|
||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error);
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(data.trimmed(), &error);
|
||||||
if (error.error != QJsonParseError::NoError) {
|
if (error.error != QJsonParseError::NoError) {
|
||||||
qWarning() << "Invalid json data received:" << error.errorString() << data << "from characteristic:" << characteristic.uuid();
|
qWarning() << "Invalid json data received:" << error.errorString() << data.trimmed() << "from characteristic:" << characteristic.uuid();
|
||||||
m_btController->disconnectFromDevice();
|
m_btController->disconnectFromDevice();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -332,7 +408,7 @@ void BtWiFiSetup::characteristicChanged(const QLowEnergyCharacteristic &characte
|
|||||||
|
|
||||||
} else if (characteristic.uuid() == wifiStatusCharacteristicUuid) {
|
} else if (characteristic.uuid() == wifiStatusCharacteristicUuid) {
|
||||||
|
|
||||||
m_wirelessStatus = static_cast<WirelessStatus>(data.toHex().toInt(nullptr, 16));
|
m_wirelessStatus = static_cast<WirelessStatus>(value.toHex().toInt(nullptr, 16));
|
||||||
qDebug() << "Wireless status changed" << m_wirelessStatus;
|
qDebug() << "Wireless status changed" << m_wirelessStatus;
|
||||||
emit wirelessStatusChanged();
|
emit wirelessStatusChanged();
|
||||||
|
|
||||||
@ -342,8 +418,14 @@ void BtWiFiSetup::characteristicChanged(const QLowEnergyCharacteristic &characte
|
|||||||
loadCurrentConnection();
|
loadCurrentConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: wirelessEnabled characterristic seems broken server-side. Let's check the wifiStatus for it being enabled or not
|
||||||
|
if (m_wirelessEnabled != (m_wirelessStatus != WirelessStatusUnavailable)) {
|
||||||
|
m_wirelessEnabled = m_wirelessStatus != WirelessStatusUnavailable;
|
||||||
|
emit wirelessEnabledChanged();
|
||||||
|
}
|
||||||
|
|
||||||
} else if (characteristic.uuid() == networkStatusCharacteristicUuid) {
|
} else if (characteristic.uuid() == networkStatusCharacteristicUuid) {
|
||||||
m_networkStatus = static_cast<NetworkStatus>(data.toHex().toInt(nullptr, 16));
|
m_networkStatus = static_cast<NetworkStatus>(value.toHex().toInt(nullptr, 16));
|
||||||
qDebug() << "Network status changed:" << m_networkStatus;
|
qDebug() << "Network status changed:" << m_networkStatus;
|
||||||
if (m_networkStatus == NetworkStatusGlobal) {
|
if (m_networkStatus == NetworkStatusGlobal) {
|
||||||
m_status = StatusConnectedToWiFi;
|
m_status = StatusConnectedToWiFi;
|
||||||
@ -352,6 +434,12 @@ void BtWiFiSetup::characteristicChanged(const QLowEnergyCharacteristic &characte
|
|||||||
loadCurrentConnection();
|
loadCurrentConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: networkingEnabled characterristic seems broken server-side. Let's check the networkStatus for it being enabled or not
|
||||||
|
if (m_wirelessEnabled != (m_networkStatus != NetworkStatusAsleep)) {
|
||||||
|
m_networkingEnabled = m_networkStatus != NetworkStatusAsleep;
|
||||||
|
emit wirelessEnabledChanged();
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "Unhandled packet from characteristic" << characteristic.uuid();
|
qWarning() << "Unhandled packet from characteristic" << characteristic.uuid();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,8 +22,8 @@ class BtWiFiSetup : public QObject
|
|||||||
|
|
||||||
Q_PROPERTY(NetworkStatus networkStatus READ networkStatus NOTIFY networkStatusChanged)
|
Q_PROPERTY(NetworkStatus networkStatus READ networkStatus NOTIFY networkStatusChanged)
|
||||||
Q_PROPERTY(WirelessStatus wirelessStatus READ wirelessStatus NOTIFY wirelessStatusChanged)
|
Q_PROPERTY(WirelessStatus wirelessStatus READ wirelessStatus NOTIFY wirelessStatusChanged)
|
||||||
Q_PROPERTY(bool networkingEnabled READ networkingEnabled NOTIFY networkingEnabledChanged)
|
Q_PROPERTY(bool networkingEnabled READ networkingEnabled WRITE setNetworkingEnabled NOTIFY networkingEnabledChanged)
|
||||||
Q_PROPERTY(bool wirelessEnabled READ wirelessEnabled NOTIFY wirelessEnabledChanged)
|
Q_PROPERTY(bool wirelessEnabled READ wirelessEnabled WRITE setWirelessEnabled NOTIFY wirelessEnabledChanged)
|
||||||
|
|
||||||
Q_PROPERTY(WirelessAccessPoints *accessPoints READ accessPoints CONSTANT)
|
Q_PROPERTY(WirelessAccessPoints *accessPoints READ accessPoints CONSTANT)
|
||||||
Q_PROPERTY(WirelessAccessPoint *currentConnection READ currentConnection NOTIFY currentConnectionChanged)
|
Q_PROPERTY(WirelessAccessPoint *currentConnection READ currentConnection NOTIFY currentConnectionChanged)
|
||||||
@ -128,6 +128,9 @@ public:
|
|||||||
Q_INVOKABLE void connectToDevice(const BluetoothDeviceInfo *device);
|
Q_INVOKABLE void connectToDevice(const BluetoothDeviceInfo *device);
|
||||||
Q_INVOKABLE void disconnectFromDevice();
|
Q_INVOKABLE void disconnectFromDevice();
|
||||||
Q_INVOKABLE void connectDeviceToWiFi(const QString &ssid, const QString &password);
|
Q_INVOKABLE void connectDeviceToWiFi(const QString &ssid, const QString &password);
|
||||||
|
Q_INVOKABLE void disconnectDeviceFromWiFi();
|
||||||
|
Q_INVOKABLE void scanWiFi();
|
||||||
|
Q_INVOKABLE void pressPushButton();
|
||||||
|
|
||||||
Status status() const;
|
Status status() const;
|
||||||
|
|
||||||
@ -140,7 +143,10 @@ public:
|
|||||||
NetworkStatus networkStatus() const;
|
NetworkStatus networkStatus() const;
|
||||||
WirelessStatus wirelessStatus() const;
|
WirelessStatus wirelessStatus() const;
|
||||||
bool networkingEnabled() const;
|
bool networkingEnabled() const;
|
||||||
|
void setNetworkingEnabled(bool networkingEnabled);
|
||||||
|
|
||||||
bool wirelessEnabled() const;
|
bool wirelessEnabled() const;
|
||||||
|
void setWirelessEnabled(bool wirelessEnabled) const;
|
||||||
|
|
||||||
WirelessAccessPoints *accessPoints() const;
|
WirelessAccessPoints *accessPoints() const;
|
||||||
WirelessAccessPoint *currentConnection() const;
|
WirelessAccessPoint *currentConnection() const;
|
||||||
@ -165,14 +171,14 @@ signals:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void setupServices();
|
void setupServices();
|
||||||
void streamData(const QVariantMap &request);
|
void streamData(QLowEnergyService *service, const QUuid &characteristicUuid, const QVariantMap &request);
|
||||||
void processWiFiPacket(const QVariantMap &data);
|
void processWiFiPacket(const QVariantMap &data);
|
||||||
|
|
||||||
void loadNetworks();
|
void loadNetworks();
|
||||||
void loadCurrentConnection();
|
void loadCurrentConnection();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void characteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &data);
|
void characteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Status m_status = StatusDisconnected;
|
Status m_status = StatusDisconnected;
|
||||||
|
|||||||
@ -1,78 +0,0 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
*
|
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
|
||||||
* Contact: contact@nymea.io
|
|
||||||
*
|
|
||||||
* This file is part of nymea.
|
|
||||||
* This project including source code and documentation is protected by
|
|
||||||
* copyright law, and remains the property of nymea GmbH. All rights, including
|
|
||||||
* reproduction, publication, editing and translation, are reserved. The use of
|
|
||||||
* this project is subject to the terms of a license agreement to be concluded
|
|
||||||
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
|
|
||||||
* under https://nymea.io/license
|
|
||||||
*
|
|
||||||
* GNU General Public License Usage
|
|
||||||
* Alternatively, this project may be redistributed and/or modified under the
|
|
||||||
* terms of the GNU General Public License as published by the Free Software
|
|
||||||
* Foundation, GNU version 3. This project is distributed in the hope that it
|
|
||||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
||||||
* Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with
|
|
||||||
* this project. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* For any further details and any questions please contact us under
|
|
||||||
* contact@nymea.io or see our FAQ/Licensing Information on
|
|
||||||
* https://nymea.io/license/faq
|
|
||||||
*
|
|
||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
||||||
|
|
||||||
#include "networkmanagercontroller.h"
|
|
||||||
|
|
||||||
NetworkManagerController::NetworkManagerController(QObject *parent) : QObject(parent)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
BluetoothDeviceInfo *NetworkManagerController::bluetoothDeviceInfo() const
|
|
||||||
{
|
|
||||||
return m_bluetoothDeviceInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkManagerController::setBluetoothDeviceInfo(BluetoothDeviceInfo *bluetoothDeviceInfo)
|
|
||||||
{
|
|
||||||
if (m_bluetoothDeviceInfo != bluetoothDeviceInfo) {
|
|
||||||
m_bluetoothDeviceInfo = bluetoothDeviceInfo;
|
|
||||||
emit bluetoothDeviceInfoChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WirelessSetupManager *NetworkManagerController::manager()
|
|
||||||
{
|
|
||||||
return m_wirelessSetupManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkManagerController::connectDevice()
|
|
||||||
{
|
|
||||||
if (!m_bluetoothDeviceInfo) {
|
|
||||||
qWarning() << "Can't connect to device. bluetoothDeviceInfo not set.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_wirelessSetupManager) {
|
|
||||||
delete m_wirelessSetupManager;
|
|
||||||
m_wirelessSetupManager = nullptr;
|
|
||||||
emit managerChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_bluetoothDeviceInfo) {
|
|
||||||
qDebug() << "Could not connect to device. There is no device info for" << m_bluetoothDeviceInfo->name() << m_bluetoothDeviceInfo->address();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_wirelessSetupManager = new WirelessSetupManager(m_bluetoothDeviceInfo->bluetoothDeviceInfo(), this);
|
|
||||||
emit managerChanged();
|
|
||||||
|
|
||||||
m_wirelessSetupManager->connectDevice();
|
|
||||||
}
|
|
||||||
@ -1,68 +0,0 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
*
|
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
|
||||||
* Contact: contact@nymea.io
|
|
||||||
*
|
|
||||||
* This file is part of nymea.
|
|
||||||
* This project including source code and documentation is protected by
|
|
||||||
* copyright law, and remains the property of nymea GmbH. All rights, including
|
|
||||||
* reproduction, publication, editing and translation, are reserved. The use of
|
|
||||||
* this project is subject to the terms of a license agreement to be concluded
|
|
||||||
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
|
|
||||||
* under https://nymea.io/license
|
|
||||||
*
|
|
||||||
* GNU General Public License Usage
|
|
||||||
* Alternatively, this project may be redistributed and/or modified under the
|
|
||||||
* terms of the GNU General Public License as published by the Free Software
|
|
||||||
* Foundation, GNU version 3. This project is distributed in the hope that it
|
|
||||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
||||||
* Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with
|
|
||||||
* this project. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* For any further details and any questions please contact us under
|
|
||||||
* contact@nymea.io or see our FAQ/Licensing Information on
|
|
||||||
* https://nymea.io/license/faq
|
|
||||||
*
|
|
||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
||||||
|
|
||||||
#ifndef NETWORKMANAGERCONTROLLER_H
|
|
||||||
#define NETWORKMANAGERCONTROLLER_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QBluetoothDeviceInfo>
|
|
||||||
|
|
||||||
#include "bluetoothdeviceinfo.h"
|
|
||||||
#include "wirelesssetupmanager.h"
|
|
||||||
|
|
||||||
class NetworkManagerController : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(BluetoothDeviceInfo* bluetoothDeviceInfo READ bluetoothDeviceInfo WRITE setBluetoothDeviceInfo)
|
|
||||||
Q_PROPERTY(WirelessSetupManager *manager READ manager NOTIFY managerChanged)
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit NetworkManagerController(QObject *parent = nullptr);
|
|
||||||
|
|
||||||
BluetoothDeviceInfo* bluetoothDeviceInfo() const;
|
|
||||||
void setBluetoothDeviceInfo(BluetoothDeviceInfo* bluetoothDeviceInfo);
|
|
||||||
|
|
||||||
WirelessSetupManager *manager();
|
|
||||||
|
|
||||||
Q_INVOKABLE void connectDevice();
|
|
||||||
|
|
||||||
private:
|
|
||||||
BluetoothDeviceInfo* m_bluetoothDeviceInfo = nullptr;
|
|
||||||
|
|
||||||
WirelessSetupManager *m_wirelessSetupManager = nullptr;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void managerChanged();
|
|
||||||
void nameChanged();
|
|
||||||
void bluetoothDeviceInfoChanged();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // NETWORKMANAGERCONTROLLER_H
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,275 +0,0 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
*
|
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
|
||||||
* Contact: contact@nymea.io
|
|
||||||
*
|
|
||||||
* This file is part of nymea.
|
|
||||||
* This project including source code and documentation is protected by
|
|
||||||
* copyright law, and remains the property of nymea GmbH. All rights, including
|
|
||||||
* reproduction, publication, editing and translation, are reserved. The use of
|
|
||||||
* this project is subject to the terms of a license agreement to be concluded
|
|
||||||
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
|
|
||||||
* under https://nymea.io/license
|
|
||||||
*
|
|
||||||
* GNU General Public License Usage
|
|
||||||
* Alternatively, this project may be redistributed and/or modified under the
|
|
||||||
* terms of the GNU General Public License as published by the Free Software
|
|
||||||
* Foundation, GNU version 3. This project is distributed in the hope that it
|
|
||||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
||||||
* Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with
|
|
||||||
* this project. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* For any further details and any questions please contact us under
|
|
||||||
* contact@nymea.io or see our FAQ/Licensing Information on
|
|
||||||
* https://nymea.io/license/faq
|
|
||||||
*
|
|
||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
||||||
|
|
||||||
#ifndef WIRELESSSETUPMANAGER_H
|
|
||||||
#define WIRELESSSETUPMANAGER_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QBluetoothDeviceInfo>
|
|
||||||
|
|
||||||
#include "bluetoothdevice.h"
|
|
||||||
|
|
||||||
class WirelessAccessPoint;
|
|
||||||
class WirelessAccessPoints;
|
|
||||||
class WirelessAccessPointsProxy;
|
|
||||||
|
|
||||||
class WirelessSetupManager : public BluetoothDevice
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(bool working READ working NOTIFY workingChanged)
|
|
||||||
Q_PROPERTY(bool initialized READ initialized NOTIFY initializedChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(WirelessAccessPoints *accessPoints READ accessPoints CONSTANT)
|
|
||||||
Q_PROPERTY(WirelessAccessPoint *currentConnection READ currentConnection NOTIFY currentConnectionChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(QString modelNumber READ modelNumber NOTIFY modelNumberChanged)
|
|
||||||
Q_PROPERTY(QString manufacturer READ manufacturer NOTIFY manufacturerChanged)
|
|
||||||
Q_PROPERTY(QString softwareRevision READ softwareRevision NOTIFY softwareRevisionChanged)
|
|
||||||
Q_PROPERTY(QString firmwareRevision READ firmwareRevision NOTIFY firmwareRevisionChanged)
|
|
||||||
Q_PROPERTY(QString hardwareRevision READ hardwareRevision NOTIFY hardwareRevisionChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(NetworkStatus networkStatus READ networkStatus NOTIFY networkStatusChanged)
|
|
||||||
Q_PROPERTY(WirelessStatus wirelessStatus READ wirelessStatus NOTIFY wirelessStatusChanged)
|
|
||||||
Q_PROPERTY(bool networkingEnabled READ networkingEnabled NOTIFY networkingEnabledChanged)
|
|
||||||
Q_PROPERTY(bool wirelessEnabled READ wirelessEnabled NOTIFY wirelessEnabledChanged)
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
enum WirelessServiceCommand {
|
|
||||||
WirelessServiceCommandInvalid = -1,
|
|
||||||
WirelessServiceCommandGetNetworks = 0x00,
|
|
||||||
WirelessServiceCommandConnect = 0x01,
|
|
||||||
WirelessServiceCommandConnectHidden = 0x02,
|
|
||||||
WirelessServiceCommandDisconnect = 0x03,
|
|
||||||
WirelessServiceCommandScan = 0x04,
|
|
||||||
WirelessServiceCommandGetCurrentConnection = 0x05
|
|
||||||
};
|
|
||||||
Q_ENUM(WirelessServiceCommand)
|
|
||||||
|
|
||||||
enum WirelessServiceResponse {
|
|
||||||
WirelessServiceResponseSuccess = 0x00,
|
|
||||||
WirelessServiceResponseIvalidCommand = 0x01,
|
|
||||||
WirelessServiceResponseIvalidParameters = 0x02,
|
|
||||||
WirelessServiceResponseNetworkManagerNotAvailable = 0x03,
|
|
||||||
WirelessServiceResponseWirelessNotAvailable = 0x04,
|
|
||||||
WirelessServiceResponseWirelessNotEnabled = 0x05,
|
|
||||||
WirelessServiceResponseNetworkingNotEnabled = 0x06,
|
|
||||||
WirelessServiceResponseUnknownError = 0x07
|
|
||||||
};
|
|
||||||
Q_ENUM(WirelessServiceResponse)
|
|
||||||
|
|
||||||
enum NetworkServiceCommand {
|
|
||||||
NetworkServiceCommandInvalid = -1,
|
|
||||||
NetworkServiceCommandEnableNetworking = 0x00,
|
|
||||||
NetworkServiceCommandDisableNetworking = 0x01,
|
|
||||||
NetworkServiceCommandEnableWireless = 0x02,
|
|
||||||
NetworkServiceCommandDisableWireless = 0x03
|
|
||||||
};
|
|
||||||
Q_ENUM(NetworkServiceCommand)
|
|
||||||
|
|
||||||
enum NetworkServiceResponse {
|
|
||||||
NetworkServiceResponseSuccess = 0x00,
|
|
||||||
NetworkServiceResponseIvalidValue = 0x01,
|
|
||||||
NetworkServiceResponseNetworkManagerNotAvailable = 0x02,
|
|
||||||
NetworkServiceResponseWirelessNotAvailable = 0x03,
|
|
||||||
NetworkServiceResponseUnknownError = 0x04,
|
|
||||||
};
|
|
||||||
Q_ENUM(NetworkServiceResponse)
|
|
||||||
|
|
||||||
enum SystemServiceCommand {
|
|
||||||
SystemServiceCommandInvalid = -1,
|
|
||||||
SystemServiceCommandPushAuthentication = 0x00
|
|
||||||
};
|
|
||||||
Q_ENUM(SystemServiceCommand)
|
|
||||||
|
|
||||||
enum SystemServiceResponse {
|
|
||||||
SystemServiceResponseSuccess = 0x00,
|
|
||||||
SystemServiceResponseUnknownError = 0x01,
|
|
||||||
SystemServiceResponseInvalidCommand = 0x02,
|
|
||||||
SystemServiceResponseInvalidValue = 0x03,
|
|
||||||
SystemServiceResponsePushServiceUnavailable = 0x04,
|
|
||||||
};
|
|
||||||
Q_ENUM(SystemServiceResponse)
|
|
||||||
|
|
||||||
enum NetworkStatus {
|
|
||||||
NetworkStatusUnknown = 0x00,
|
|
||||||
NetworkStatusAsleep = 0x01,
|
|
||||||
NetworkStatusDisconnected = 0x02,
|
|
||||||
NetworkStatusDisconnecting = 0x03,
|
|
||||||
NetworkStatusConnecting = 0x04,
|
|
||||||
NetworkStatusLocal = 0x05,
|
|
||||||
NetworkStatusConnectedSite = 0x06,
|
|
||||||
NetworkStatusGlobal = 0x07
|
|
||||||
};
|
|
||||||
Q_ENUM(NetworkStatus)
|
|
||||||
|
|
||||||
enum WirelessStatus {
|
|
||||||
WirelessStatusUnknown = 0x00,
|
|
||||||
WirelessStatusUnmanaged = 0x01,
|
|
||||||
WirelessStatusUnavailable = 0x02,
|
|
||||||
WirelessStatusDisconnected = 0x03,
|
|
||||||
WirelessStatusPrepare = 0x04,
|
|
||||||
WirelessStatusConfig = 0x05,
|
|
||||||
WirelessStatusNeedAuth = 0x06,
|
|
||||||
WirelessStatusIpConfig = 0x07,
|
|
||||||
WirelessStatusIpCheck = 0x08,
|
|
||||||
WirelessStatusSecondaries = 0x09,
|
|
||||||
WirelessStatusActivated = 0x0A,
|
|
||||||
WirelessStatusDeactivating = 0x0B,
|
|
||||||
WirelessStatusFailed = 0x0C
|
|
||||||
};
|
|
||||||
Q_ENUM(WirelessStatus)
|
|
||||||
|
|
||||||
explicit WirelessSetupManager(const QBluetoothDeviceInfo &deviceInfo, QObject *parent = nullptr);
|
|
||||||
|
|
||||||
QString modelNumber() const;
|
|
||||||
QString manufacturer() const;
|
|
||||||
QString softwareRevision() const;
|
|
||||||
QString firmwareRevision() const;
|
|
||||||
QString hardwareRevision() const;
|
|
||||||
|
|
||||||
bool initialized() const;
|
|
||||||
bool working() const;
|
|
||||||
|
|
||||||
NetworkStatus networkStatus() const;
|
|
||||||
WirelessSetupManager::WirelessStatus wirelessStatus() const;
|
|
||||||
|
|
||||||
bool networkingEnabled() const;
|
|
||||||
bool wirelessEnabled() const;
|
|
||||||
|
|
||||||
WirelessAccessPoints *accessPoints() const;
|
|
||||||
WirelessAccessPoint *currentConnection() const;
|
|
||||||
|
|
||||||
void reloadData();
|
|
||||||
|
|
||||||
// Wireless commands
|
|
||||||
Q_INVOKABLE void loadNetworks();
|
|
||||||
Q_INVOKABLE void loadCurrentConnection();
|
|
||||||
Q_INVOKABLE void performWifiScan();
|
|
||||||
Q_INVOKABLE void enableNetworking(bool enable);
|
|
||||||
Q_INVOKABLE void enableWireless(bool enable);
|
|
||||||
Q_INVOKABLE void connectWirelessNetwork(const QString &ssid, const QString &password = QString());
|
|
||||||
Q_INVOKABLE void disconnectWirelessNetwork();
|
|
||||||
Q_INVOKABLE void pressPushButton();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void modelNumberChanged();
|
|
||||||
void manufacturerChanged();
|
|
||||||
void softwareRevisionChanged();
|
|
||||||
void firmwareRevisionChanged();
|
|
||||||
void hardwareRevisionChanged();
|
|
||||||
|
|
||||||
void initializedChanged();
|
|
||||||
void workingChanged();
|
|
||||||
|
|
||||||
void networkStatusChanged();
|
|
||||||
void wirelessStatusChanged();
|
|
||||||
void networkingEnabledChanged();
|
|
||||||
void wirelessEnabledChanged();
|
|
||||||
|
|
||||||
void currentConnectionChanged();
|
|
||||||
|
|
||||||
void errorOccurred(const QString &errorMessage);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onConnectedChanged();
|
|
||||||
void onServiceDiscoveryFinished();
|
|
||||||
|
|
||||||
void onDeviceInformationStateChanged(const QLowEnergyService::ServiceState &state);
|
|
||||||
void onDeviceInformationCharacteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &value);
|
|
||||||
void onDeviceInformationReadFinished(const QLowEnergyCharacteristic &characteristic, const QByteArray &value);
|
|
||||||
|
|
||||||
void onNetworkServiceStateChanged(const QLowEnergyService::ServiceState &state);
|
|
||||||
void onNetworkServiceCharacteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &value);
|
|
||||||
void onNetworkServiceReadFinished(const QLowEnergyCharacteristic &characteristic, const QByteArray &value);
|
|
||||||
|
|
||||||
void onWifiServiceStateChanged(const QLowEnergyService::ServiceState &state);
|
|
||||||
void onWifiServiceCharacteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &value);
|
|
||||||
void onWifiServiceReadFinished(const QLowEnergyCharacteristic &characteristic, const QByteArray &value);
|
|
||||||
|
|
||||||
void onSystemServiceStateChanged(const QLowEnergyService::ServiceState &state);
|
|
||||||
void onSystemServiceCharacteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &value);
|
|
||||||
void onSystemServiceReadFinished(const QLowEnergyCharacteristic &characteristic, const QByteArray &value);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QLowEnergyService *m_deviceInformationService = nullptr;
|
|
||||||
QLowEnergyService *m_netwokService = nullptr;
|
|
||||||
QLowEnergyService *m_wifiService = nullptr;
|
|
||||||
QLowEnergyService *m_systemService = nullptr;
|
|
||||||
|
|
||||||
WirelessAccessPoints *m_accessPoints = nullptr;
|
|
||||||
WirelessAccessPoint *m_currentConnection = nullptr;
|
|
||||||
|
|
||||||
QString m_modelNumber;
|
|
||||||
QString m_manufacturer;
|
|
||||||
QString m_softwareRevision;
|
|
||||||
QString m_firmwareRevision;
|
|
||||||
QString m_hardwareRevision;
|
|
||||||
|
|
||||||
bool m_networkingEnabled = false;
|
|
||||||
bool m_wirelessEnabled = false;
|
|
||||||
|
|
||||||
bool m_working = false;
|
|
||||||
bool m_initialized = false;
|
|
||||||
|
|
||||||
NetworkStatus m_networkStatus = NetworkStatusUnknown;
|
|
||||||
WirelessStatus m_wirelessStatus = WirelessStatusUnknown;
|
|
||||||
|
|
||||||
bool m_readingResponse = false;
|
|
||||||
QByteArray m_inputDataStream;
|
|
||||||
|
|
||||||
QString m_ssid;
|
|
||||||
QString m_password;
|
|
||||||
|
|
||||||
QVariantList m_accessPointsVariantList;
|
|
||||||
|
|
||||||
void checkInitialized();
|
|
||||||
|
|
||||||
// Private set methods for read only properties
|
|
||||||
void setModelNumber(const QString &modelNumber);
|
|
||||||
void setManufacturer(const QString &manufacturer);
|
|
||||||
void setSoftwareRevision(const QString &softwareRevision);
|
|
||||||
void setFirmwareRevision(const QString &firmwareRevision);
|
|
||||||
void setHardwareRevision(const QString &hardwareRevision);
|
|
||||||
|
|
||||||
void setNetworkStatus(int networkStatus);
|
|
||||||
void setWirelessStatus(int wirelessStatus);
|
|
||||||
void setNetworkingEnabled(bool networkingEnabled);
|
|
||||||
void setWirelessEnabled(bool wirelessEnabled);
|
|
||||||
|
|
||||||
// Data methods
|
|
||||||
void streamData(const QVariantMap &request);
|
|
||||||
void processNetworkResponse(const QVariantMap &response);
|
|
||||||
void processWifiResponse(const QVariantMap &response);
|
|
||||||
void processSystemResponse(const QVariantMap &response);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // WIRELESSSETUPMANAGER_H
|
|
||||||
@ -130,13 +130,11 @@ ApplicationWindow {
|
|||||||
anchors.bottomMargin: keyboardRect.height
|
anchors.bottomMargin: keyboardRect.height
|
||||||
}
|
}
|
||||||
|
|
||||||
NymeaDiscovery {
|
property NymeaDiscovery nymeaDiscovery: NymeaDiscovery {
|
||||||
id: discovery
|
|
||||||
objectName: "discovery"
|
objectName: "discovery"
|
||||||
awsClient: AWSClient
|
awsClient: AWSClient
|
||||||
// discovering: pageStack.currentItem.objectName === "discoveryPage"
|
// discovering: pageStack.currentItem.objectName === "discoveryPage"
|
||||||
}
|
}
|
||||||
property alias _discovery: discovery
|
|
||||||
|
|
||||||
property var supportedInterfaces: [
|
property var supportedInterfaces: [
|
||||||
"light",
|
"light",
|
||||||
|
|||||||
@ -84,7 +84,7 @@ Item {
|
|||||||
d.pushSettingsPage("connection/wifisetup/BluetoothDiscoveryPage.qml");
|
d.pushSettingsPage("connection/wifisetup/BluetoothDiscoveryPage.qml");
|
||||||
}
|
}
|
||||||
function startDemoMode() {
|
function startDemoMode() {
|
||||||
var host = discovery.nymeaHosts.createWanHost("Demo server", "nymea://nymea.nymea.io:2222")
|
var host = nymeaDiscovery.nymeaHosts.createWanHost("Demo server", "nymea://nymea.nymea.io:2222")
|
||||||
root.currentEngine.jsonRpcClient.connectToHost(host)
|
root.currentEngine.jsonRpcClient.connectToHost(host)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Binding {
|
Binding {
|
||||||
target: _discovery
|
target: nymeaDiscovery
|
||||||
property: "discovering"
|
property: "discovering"
|
||||||
value: engine.jsonRpcClient.currentHost === null
|
value: engine.jsonRpcClient.currentHost === null
|
||||||
}
|
}
|
||||||
@ -180,11 +180,11 @@ Item {
|
|||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
setupPushNotifications();
|
setupPushNotifications();
|
||||||
if (autoConnectHost.length > 0) {
|
if (autoConnectHost.length > 0) {
|
||||||
var host = discovery.nymeaHosts.createLanHost("Manual connection", autoConnectHost);
|
var host = nymeaDiscovery.nymeaHosts.createLanHost("Manual connection", autoConnectHost);
|
||||||
engine.jsonRpcClient.connectToHost(host)
|
engine.jsonRpcClient.connectToHost(host)
|
||||||
} else if (tabSettings.lastConnectedHost.length > 0) {
|
} else if (tabSettings.lastConnectedHost.length > 0) {
|
||||||
print("Last connected host was", tabSettings.lastConnectedHost)
|
print("Last connected host was", tabSettings.lastConnectedHost)
|
||||||
var cachedHost = discovery.nymeaHosts.find(tabSettings.lastConnectedHost);
|
var cachedHost = nymeaDiscovery.nymeaHosts.find(tabSettings.lastConnectedHost);
|
||||||
if (cachedHost) {
|
if (cachedHost) {
|
||||||
engine.jsonRpcClient.connectToHost(cachedHost)
|
engine.jsonRpcClient.connectToHost(cachedHost)
|
||||||
return;
|
return;
|
||||||
@ -343,14 +343,14 @@ Item {
|
|||||||
var popup = certDialogComponent.createObject(root);
|
var popup = certDialogComponent.createObject(root);
|
||||||
popup.accepted.connect(function(){
|
popup.accepted.connect(function(){
|
||||||
engine.jsonRpcClient.acceptCertificate(serverUuid, pem);
|
engine.jsonRpcClient.acceptCertificate(serverUuid, pem);
|
||||||
engine.jsonRpcClient.connectToHost(discovery.nymeaHosts.find(serverUuid));
|
engine.jsonRpcClient.connectToHost(nymeaDiscovery.nymeaHosts.find(serverUuid));
|
||||||
})
|
})
|
||||||
popup.open();
|
popup.open();
|
||||||
}
|
}
|
||||||
onConnectedChanged: {
|
onConnectedChanged: {
|
||||||
print("json client connected changed", engine.jsonRpcClient.connected)
|
print("json client connected changed", engine.jsonRpcClient.connected)
|
||||||
if (engine.jsonRpcClient.connected) {
|
if (engine.jsonRpcClient.connected) {
|
||||||
discovery.cacheHost(engine.jsonRpcClient.currentHost)
|
nymeaDiscovery.cacheHost(engine.jsonRpcClient.currentHost)
|
||||||
tabSettings.lastConnectedHost = engine.jsonRpcClient.serverUuid
|
tabSettings.lastConnectedHost = engine.jsonRpcClient.serverUuid
|
||||||
}
|
}
|
||||||
init();
|
init();
|
||||||
|
|||||||
@ -126,7 +126,7 @@ SettingsPageBase {
|
|||||||
onClicked: {
|
onClicked: {
|
||||||
print("clicked, connected:", engine.jsonRpcClient.connected, model.id)
|
print("clicked, connected:", engine.jsonRpcClient.connected, model.id)
|
||||||
if (!engine.jsonRpcClient.connected) {
|
if (!engine.jsonRpcClient.connected) {
|
||||||
var host = discovery.nymeaHosts.find(model.id)
|
var host = nymeaDiscovery.nymeaHosts.find(model.id)
|
||||||
engine.jsonRpcClient.connectToHost(host);
|
engine.jsonRpcClient.connectToHost(host);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,7 +70,7 @@ Page {
|
|||||||
|
|
||||||
NymeaHostsFilterModel {
|
NymeaHostsFilterModel {
|
||||||
id: hostsProxy
|
id: hostsProxy
|
||||||
discovery: _discovery
|
discovery: nymeaDiscovery
|
||||||
showUnreachableBearers: false
|
showUnreachableBearers: false
|
||||||
jsonRpcClient: engine.jsonRpcClient
|
jsonRpcClient: engine.jsonRpcClient
|
||||||
showUnreachableHosts: false
|
showUnreachableHosts: false
|
||||||
@ -220,16 +220,16 @@ Page {
|
|||||||
Layout.leftMargin: app.margins
|
Layout.leftMargin: app.margins
|
||||||
Layout.rightMargin: app.margins
|
Layout.rightMargin: app.margins
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
visible: discovery.nymeaHosts.count === 0
|
visible: nymeaDiscovery.nymeaHosts.count === 0
|
||||||
text: qsTr("Do you have a %1:core but it's not connected to your network yet? Use the wireless setup to connect it!").arg(app.systemName)
|
text: qsTr("Do you have a %1:core but it's not connected to your network yet? Use the wireless setup to connect it!").arg(app.systemName)
|
||||||
}
|
}
|
||||||
Button {
|
Button {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.leftMargin: app.margins
|
Layout.leftMargin: app.margins
|
||||||
Layout.rightMargin: app.margins
|
Layout.rightMargin: app.margins
|
||||||
visible: discovery.nymeaHosts.count === 0
|
visible: nymeaDiscovery.nymeaHosts.count === 0
|
||||||
text: qsTr("Start wireless setup")
|
text: qsTr("Start wireless setup")
|
||||||
onClicked: pageStack.push(Qt.resolvedUrl("wifisetup/BluetoothDiscoveryPage.qml"), {nymeaDiscovery: discovery})
|
onClicked: pageStack.push(Qt.resolvedUrl("wifisetup/BluetoothDiscoveryPage.qml"))
|
||||||
}
|
}
|
||||||
Button {
|
Button {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
@ -245,10 +245,10 @@ Page {
|
|||||||
Layout.leftMargin: app.margins
|
Layout.leftMargin: app.margins
|
||||||
Layout.rightMargin: app.margins
|
Layout.rightMargin: app.margins
|
||||||
Layout.bottomMargin: app.margins
|
Layout.bottomMargin: app.margins
|
||||||
visible: discovery.nymeaHosts.count === 0
|
visible: nymeaDiscovery.nymeaHosts.count === 0
|
||||||
text: qsTr("Demo mode (online)")
|
text: qsTr("Demo mode (online)")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var host = discovery.nymeaHosts.createWanHost("Demo server", "nymea://nymea.nymea.io:2222")
|
var host = nymeaDiscovery.nymeaHosts.createWanHost("Demo server", "nymea://nymea.nymea.io:2222")
|
||||||
engine.jsonRpcClient.connectToHost(host)
|
engine.jsonRpcClient.connectToHost(host)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -124,7 +124,7 @@ Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
print("Try to connect ", rpcUrl)
|
print("Try to connect ", rpcUrl)
|
||||||
var host = discovery.nymeaHosts.createLanHost("Manual connection", rpcUrl);
|
var host = nymeaDiscovery.nymeaHosts.createLanHost("Manual connection", rpcUrl);
|
||||||
engine.jsonRpcClient.connectToHost(host)
|
engine.jsonRpcClient.connectToHost(host)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,57 +41,70 @@ Page {
|
|||||||
onBackPressed: pageStack.pop()
|
onBackPressed: pageStack.pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
property var nymeaDiscovery: null
|
|
||||||
|
|
||||||
BluetoothDiscovery {
|
BluetoothDiscovery {
|
||||||
id: bluetoothDiscovery
|
id: bluetoothDiscovery
|
||||||
discoveryEnabled: pageStack.currentItem === root
|
discoveryEnabled: pageStack.currentItem === root
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkManagerController {
|
BtWiFiSetup {
|
||||||
id: networkManager
|
id: wifiSetup
|
||||||
|
|
||||||
|
onStatusChanged: {
|
||||||
|
print("status changed", status)
|
||||||
|
switch (status) {
|
||||||
|
case BtWiFiSetup.StatusDisconnected:
|
||||||
|
pageStack.pop(root)
|
||||||
|
break;
|
||||||
|
case BtWiFiSetup.StatusConnectingToBluetooth:
|
||||||
|
break;
|
||||||
|
case BtWiFiSetup.StatusConnectedToBluetooth:
|
||||||
|
if (!wifiSetup.networkingEnabled) {
|
||||||
|
wifiSetup.networkingEnabled = true;
|
||||||
|
}
|
||||||
|
if (!wifiSetup.wirelessEnabled) {
|
||||||
|
wifiSetup.wirelessEnabled = true;
|
||||||
|
}
|
||||||
|
setupDevice()
|
||||||
|
break;
|
||||||
|
case BtWiFiSetup.StatusConnectingToWiFi:
|
||||||
|
break;
|
||||||
|
case BtWiFiSetup.StatusConnectedToWiFi:
|
||||||
|
print("Connected to wifi!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onBluetoothConnectionError: {
|
||||||
|
print("Error")
|
||||||
|
pageStack.pop(root)
|
||||||
|
}
|
||||||
|
onWirelessEnabledChanged: {
|
||||||
|
if (wirelessEnabled) {
|
||||||
|
scanWiFi();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function connectDevice(btDeviceInfo) {
|
function connectDevice(btDeviceInfo) {
|
||||||
networkManager.bluetoothDeviceInfo = btDeviceInfo
|
wifiSetup.connectToDevice(btDeviceInfo)
|
||||||
networkManager.connectDevice();
|
|
||||||
print("**** connecting")
|
print("**** connecting")
|
||||||
pageStack.push(connectingPageComponent, {deviceName: btDeviceInfo.name})
|
pageStack.push(connectingPageComponent, {deviceName: btDeviceInfo.name})
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupDevice() {
|
function setupDevice() {
|
||||||
pageStack.pop(root, StackView.Immediate)
|
pageStack.pop(root, StackView.Immediate)
|
||||||
if (networkManager.manager.currentConnection) {
|
if (wifiSetup.currentConnection) {
|
||||||
print("***** pushing WirelessSetupPage with networkManager:", networkManager)
|
var page = pageStack.push(Qt.resolvedUrl("WirelessSetupPage.qml"), { wifiSetup: wifiSetup } )
|
||||||
var page = pageStack.push(Qt.resolvedUrl("WirelessSetupPage.qml"), { networkManagerController: networkManager, nymeaDiscovery: root.nymeaDiscovery } )
|
|
||||||
page.done.connect(function() {
|
page.done.connect(function() {
|
||||||
pageStack.pop(root, StackView.Immediate);
|
pageStack.pop(root, StackView.Immediate);
|
||||||
pageStack.pop();
|
pageStack.pop();
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
var page = pageStack.push(Qt.resolvedUrl("ConnectWiFiPage.qml"), { networkManagerController: networkManager } )
|
var page = pageStack.push(Qt.resolvedUrl("ConnectWiFiPage.qml"), { wifiSetup: wifiSetup } )
|
||||||
page.connected.connect(function() {
|
page.connected.connect(function() {
|
||||||
setupDevice();
|
setupDevice();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: networkManager.manager
|
|
||||||
onInitializedChanged: {
|
|
||||||
if (networkManager.manager.initialized) {
|
|
||||||
setupDevice()
|
|
||||||
} else {
|
|
||||||
pageStack.pop(root)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onConnectedChanged: {
|
|
||||||
if (!networkManager.manager.connected) {
|
|
||||||
pageStack.pop(root)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|||||||
@ -41,7 +41,7 @@ Page {
|
|||||||
onBackPressed: pageStack.pop()
|
onBackPressed: pageStack.pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
property var networkManagerController: null
|
property BtWiFiSetup wifiSetup: null
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors { left: parent.left; top: parent.top; right: parent.right }
|
anchors { left: parent.left; top: parent.top; right: parent.right }
|
||||||
@ -50,31 +50,31 @@ Page {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
progressive: false
|
progressive: false
|
||||||
text: qsTr("System UUID")
|
text: qsTr("System UUID")
|
||||||
subText: networkManagerController.manager.modelNumber
|
subText: wifiSetup.modelNumber
|
||||||
}
|
}
|
||||||
NymeaSwipeDelegate {
|
NymeaSwipeDelegate {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
progressive: false
|
progressive: false
|
||||||
text: qsTr("Manufacturer")
|
text: qsTr("Manufacturer")
|
||||||
subText: networkManagerController.manager.manufacturer
|
subText: wifiSetup.manufacturer
|
||||||
}
|
}
|
||||||
NymeaSwipeDelegate {
|
NymeaSwipeDelegate {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
progressive: false
|
progressive: false
|
||||||
text: qsTr("Software revision")
|
text: qsTr("Software revision")
|
||||||
subText: networkManagerController.manager.softwareRevision
|
subText: wifiSetup.softwareRevision
|
||||||
}
|
}
|
||||||
NymeaSwipeDelegate {
|
NymeaSwipeDelegate {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
progressive: false
|
progressive: false
|
||||||
text: qsTr("Firmware revision")
|
text: qsTr("Firmware revision")
|
||||||
subText: networkManagerController.manager.firmwareRevision
|
subText: wifiSetup.firmwareRevision
|
||||||
}
|
}
|
||||||
NymeaSwipeDelegate {
|
NymeaSwipeDelegate {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
progressive: false
|
progressive: false
|
||||||
text: qsTr("Hardware revision")
|
text: qsTr("Hardware revision")
|
||||||
subText: networkManagerController.manager.hardwareRevision
|
subText: wifiSetup.hardwareRevision
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@ import Nymea 1.0
|
|||||||
Page {
|
Page {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property var networkManagerController: null
|
property BtWiFiSetup wifiSetup: null
|
||||||
|
|
||||||
signal connected();
|
signal connected();
|
||||||
|
|
||||||
@ -50,13 +50,13 @@ Page {
|
|||||||
HeaderButton {
|
HeaderButton {
|
||||||
imageSource: "../images/info.svg"
|
imageSource: "../images/info.svg"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
pageStack.push(Qt.resolvedUrl("BoxInfoPage.qml"), {networkManagerController: root.networkManagerController})
|
pageStack.push(Qt.resolvedUrl("BoxInfoPage.qml"), {wifiSetup: root.wifiSetup})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HeaderButton {
|
HeaderButton {
|
||||||
imageSource: "../images/settings.svg"
|
imageSource: "../images/settings.svg"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
pageStack.push(Qt.resolvedUrl("NetworkSettingsPage.qml"), {networkManagerController: root.networkManagerController})
|
pageStack.push(Qt.resolvedUrl("NetworkSettingsPage.qml"), {wifiSetup: root.wifiSetup})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -69,14 +69,26 @@ Page {
|
|||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
|
||||||
model: WirelessAccessPointsProxy {
|
model: WirelessAccessPointsProxy {
|
||||||
accessPoints: networkManagerController.manager.accessPoints
|
accessPoints: wifiSetup.accessPoints
|
||||||
}
|
}
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
interval: 5000
|
||||||
|
repeat: true
|
||||||
|
onTriggered: wifiSetup.scanWiFi()
|
||||||
|
running: wifiSetup.accessPoints.count === 0
|
||||||
|
}
|
||||||
|
|
||||||
|
BusyIndicator {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
visible: wifiSetup.accessPoints.count === 0
|
||||||
|
running: visible
|
||||||
|
}
|
||||||
|
|
||||||
delegate: NymeaSwipeDelegate {
|
delegate: NymeaSwipeDelegate {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
text: model.ssid !== "" ? model.ssid : qsTr("Hidden Network")
|
text: model.ssid !== "" ? model.ssid : qsTr("Hidden Network")
|
||||||
enabled: !networkManagerController.manager.working
|
|
||||||
subText: model.hostAddress
|
subText: model.hostAddress
|
||||||
|
|
||||||
iconColor: model.selectedNetwork ? Style.accentColor : "#808080"
|
iconColor: model.selectedNetwork ? Style.accentColor : "#808080"
|
||||||
@ -136,16 +148,16 @@ Page {
|
|||||||
property string macAddress
|
property string macAddress
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: root.networkManagerController.manager
|
target: root.wifiSetup
|
||||||
onCurrentConnectionChanged: {
|
onCurrentConnectionChanged: {
|
||||||
if (root.networkManagerController.manager.currentConnection && root.networkManagerController.manager.currentConnection.ssid === authenticationPage.ssid) {
|
if (root.wifiSetup.currentConnection && root.wifiSetup.currentConnection.ssid === authenticationPage.ssid) {
|
||||||
print("**** connected!")
|
print("**** connected!")
|
||||||
root.connected();
|
root.connected();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onWirelessStatusChanged: {
|
onWirelessStatusChanged: {
|
||||||
print("Wireless status changed:", networkManagerController.manager.networkStatus)
|
print("Wireless status changed:", wifiSetup.networkStatus)
|
||||||
if (networkManagerController.manager.wirelessStatus === WirelessSetupManager.WirelessStatusFailed) {
|
if (wifiSetup.wirelessStatus === BtWiFiSetup.WirelessStatusFailed) {
|
||||||
wrongPasswordText.visible = true
|
wrongPasswordText.visible = true
|
||||||
pageStack.pop(authenticationPage)
|
pageStack.pop(authenticationPage)
|
||||||
}
|
}
|
||||||
@ -199,7 +211,7 @@ Page {
|
|||||||
text: qsTr("OK")
|
text: qsTr("OK")
|
||||||
enabled: passwordTextField.displayText.length >= 8
|
enabled: passwordTextField.displayText.length >= 8
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.networkManagerController.manager.connectWirelessNetwork(authenticationPage.ssid, passwordTextField.text)
|
root.wifiSetup.connectDeviceToWiFi(authenticationPage.ssid, passwordTextField.text)
|
||||||
pageStack.push(connectingWifiWaitPageComponent, {ssid: authenticationPage.ssid })
|
pageStack.push(connectingWifiWaitPageComponent, {ssid: authenticationPage.ssid })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,7 +41,7 @@ Page {
|
|||||||
onBackPressed: pageStack.pop()
|
onBackPressed: pageStack.pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
property var networkManagerController: null
|
property BtWiFiSetup wifiSetup: null
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors { left: parent.left; top: parent.top; right: parent.right }
|
anchors { left: parent.left; top: parent.top; right: parent.right }
|
||||||
@ -49,17 +49,17 @@ Page {
|
|||||||
SwitchDelegate {
|
SwitchDelegate {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: qsTr("Networking")
|
text: qsTr("Networking")
|
||||||
checked: networkManagerController.manager.networkingEnabled
|
checked: wifiSetup.networkingEnabled
|
||||||
onClicked: networkManagerController.manager.enableNetworking(checked)
|
onClicked: wifiSetup.networkingEnabled = checked
|
||||||
}
|
}
|
||||||
|
|
||||||
SwitchDelegate {
|
SwitchDelegate {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
enabled: networkManagerController.manager.networkingEnabled
|
enabled: wifiSetup.networkingEnabled
|
||||||
text: qsTr("Wireless network")
|
text: qsTr("Wireless network")
|
||||||
checked: networkManagerController.manager.wirelessEnabled
|
checked: wifiSetup.wirelessEnabled
|
||||||
onClicked: {
|
onClicked: {
|
||||||
networkManagerController.manager.enableWireless(checked)
|
wifiSetup.wirelessEnabled = checked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ Page {
|
|||||||
Layout.leftMargin: app.margins
|
Layout.leftMargin: app.margins
|
||||||
Layout.rightMargin: app.margins
|
Layout.rightMargin: app.margins
|
||||||
text: qsTr("Trigger a wireless scan on the device.")
|
text: qsTr("Trigger a wireless scan on the device.")
|
||||||
onClicked: networkManagerController.manager.performWifiScan()
|
onClicked: wifiSetup.scanWiFi()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,8 +37,7 @@ import Nymea 1.0
|
|||||||
Page {
|
Page {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property var networkManagerController: null
|
property BtWiFiSetup wifiSetup: null
|
||||||
property var nymeaDiscovery: null
|
|
||||||
|
|
||||||
signal done()
|
signal done()
|
||||||
|
|
||||||
@ -51,25 +50,24 @@ Page {
|
|||||||
HeaderButton {
|
HeaderButton {
|
||||||
imageSource: "../images/info.svg"
|
imageSource: "../images/info.svg"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
pageStack.push(Qt.resolvedUrl("BoxInfoPage.qml"), {networkManagerController: root.networkManagerController})
|
pageStack.push(Qt.resolvedUrl("BoxInfoPage.qml"), {wifiSetup: root.wifiSetup})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HeaderButton {
|
HeaderButton {
|
||||||
imageSource: "../images/settings.svg"
|
imageSource: "../images/settings.svg"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
pageStack.push(Qt.resolvedUrl("NetworkSettingsPage.qml"), {networkManagerController: root.networkManagerController})
|
pageStack.push(Qt.resolvedUrl("NetworkSettingsPage.qml"), {wifiSetup: root.wifiSetup})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
print("created with networkmanagercontroller:", root.networkManagerController)
|
|
||||||
updateConnectButton();
|
updateConnectButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: root.networkManagerController.manager
|
target: root.wifiSetup
|
||||||
onErrorOccurred: {
|
onWifiSetupError: {
|
||||||
print("Error occurred", errorMessage)
|
print("Error occurred", errorMessage)
|
||||||
var errorDialog = Qt.createComponent(Qt.resolvedUrl("../components/ErrorDialog.qml"));
|
var errorDialog = Qt.createComponent(Qt.resolvedUrl("../components/ErrorDialog.qml"));
|
||||||
var popup = errorDialog.createObject(app, {text: errorMessage})
|
var popup = errorDialog.createObject(app, {text: errorMessage})
|
||||||
@ -82,25 +80,25 @@ Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: root.nymeadiscovery.nymeaHosts
|
target: nymeaDiscovery.nymeaHosts
|
||||||
onCountChanged: updateConnectButton();
|
onCountChanged: updateConnectButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateConnectButton() {
|
function updateConnectButton() {
|
||||||
if (!root.networkManagerController.manager.currentConnection) {
|
if (!root.wifiSetup.currentConnection) {
|
||||||
connectButton.url = "";
|
connectButton.url = "";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: We should rather look for the UUID here, but nymea-networkmanager doesn't support getting us the nymea uuid (yet)
|
// FIXME: We should rather look for the UUID here, but nymea-networkmanager doesn't support getting us the nymea uuid (yet)
|
||||||
for (var i = 0; i < root.nymeadiscovery.nymeaHosts.count; i++) {
|
for (var i = 0; i < nymeaDiscovery.nymeaHosts.count; i++) {
|
||||||
for (var j = 0; j < root.nymeadiscovery.nymeaHosts.get(i).connections.count; j++) {
|
for (var j = 0; j < nymeaDiscovery.nymeaHosts.get(i).connections.count; j++) {
|
||||||
if (root.nymeadiscovery.nymeaHosts.get(i).connections.get(j).url.toString().indexOf(root.networkManagerController.manager.currentConnection.hostAddress) >= 0) {
|
if (nymeaDiscovery.nymeaHosts.get(i).connections.get(j).url.toString().indexOf(root.wifiSetup.currentConnection.hostAddress) >= 0) {
|
||||||
connectButton.url = root.nymeadiscovery.nymeaHosts.get(i).connections.get(j).url
|
connectButton.host = nymeaDiscovery.nymeaHosts.get(i)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
root.nymeadiscovery.nymeaHosts.get(i).connections.countChanged.connect(function() {
|
nymeaDiscovery.nymeaHosts.get(i).connections.countChanged.connect(function() {
|
||||||
updateConnectButton();
|
updateConnectButton();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -121,15 +119,15 @@ Page {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
text: root.networkManagerController.manager.currentConnection
|
text: root.wifiSetup.currentConnection
|
||||||
? qsTr("Your %1:core is connected to %2").arg(app.systemName).arg(root.networkManagerController.manager.currentConnection.ssid)
|
? qsTr("Your %1:core is connected to %2").arg(app.systemName).arg(root.wifiSetup.currentConnection.ssid)
|
||||||
: ""
|
: ""
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
||||||
text: qsTr("IP address: %1").arg(root.networkManagerController.manager.currentConnection.hostAddress)
|
text: qsTr("IP address: %1").arg(root.wifiSetup.currentConnection.hostAddress)
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,13 +145,14 @@ Page {
|
|||||||
|
|
||||||
Button {
|
Button {
|
||||||
id: connectButton
|
id: connectButton
|
||||||
visible: url != ""
|
visible: host !== null
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
||||||
text: qsTr("Connect to %1:core").arg(app.systemName)
|
text: qsTr("Connect to %1:core").arg(app.systemName)
|
||||||
property string url
|
property NymeaHost host: null
|
||||||
onClicked: {
|
onClicked: {
|
||||||
engine.jsonRpcClient.connectToHost(url)
|
print("connecting to", host)
|
||||||
|
engine.jsonRpcClient.connectToHost(host)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +161,7 @@ Page {
|
|||||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
||||||
text: qsTr("Change network")
|
text: qsTr("Change network")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var page = pageStack.push(Qt.resolvedUrl("ConnectWiFiPage.qml"), {networkManagerController: root.networkManagerController})
|
var page = pageStack.push(Qt.resolvedUrl("ConnectWiFiPage.qml"), {wifiSetup: root.wifiSetup})
|
||||||
page.connected.connect(function() {
|
page.connected.connect(function() {
|
||||||
pageStack.pop(root)
|
pageStack.pop(root)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user