Merge PR #504: Rename DeviceDiscovery to ThingDiscovery
This commit is contained in:
commit
4484b04a87
@ -39,7 +39,7 @@
|
||||
#include "deviceclassesproxy.h"
|
||||
#include "devicesproxy.h"
|
||||
#include "pluginsproxy.h"
|
||||
#include "devicediscovery.h"
|
||||
#include "thingdiscovery.h"
|
||||
#include "interfacesmodel.h"
|
||||
#include "rulemanager.h"
|
||||
#include "models/rulesfiltermodel.h"
|
||||
@ -73,7 +73,7 @@
|
||||
#include "configuration/serverconfigurations.h"
|
||||
#include "configuration/mqttpolicy.h"
|
||||
#include "configuration/mqttpolicies.h"
|
||||
#include "wifisetup/networkmanagercontroller.h"
|
||||
#include "wifisetup/btwifisetup.h"
|
||||
#include "types/wirelessaccesspoint.h"
|
||||
#include "types/wirelessaccesspoints.h"
|
||||
#include "models/wirelessaccesspointsproxy.h"
|
||||
@ -199,12 +199,10 @@ void registerQmlTypes() {
|
||||
qmlRegisterUncreatableType<DeviceClass>(uri, 1, 0, "DeviceClass", "Can't create this in QML. Get it from the DeviceClasses.");
|
||||
qmlRegisterUncreatableType<DeviceClasses>(uri, 1, 0, "DeviceClasses", "Can't create this in QML. Get it from the DeviceManager.");
|
||||
qmlRegisterType<DeviceClassesProxy>(uri, 1, 0, "DeviceClassesProxy");
|
||||
qmlRegisterType<DeviceDiscovery>(uri, 1, 0, "DeviceDiscovery");
|
||||
qmlRegisterType<DeviceDiscovery>(uri, 1, 0, "ThingDiscovery");
|
||||
qmlRegisterType<DeviceDiscoveryProxy>(uri, 1, 0, "DeviceDiscoveryProxy");
|
||||
qmlRegisterType<DeviceDiscoveryProxy>(uri, 1, 0, "ThingDiscoveryProxy");
|
||||
qmlRegisterUncreatableType<DeviceDescriptor>(uri, 1, 0, "DeviceDescriptor", "Get it from DeviceDiscovery");
|
||||
qmlRegisterUncreatableType<DeviceDescriptor>(uri, 1, 0, "ThingDescriptor", "Get it from ThingDiscovery");
|
||||
qmlRegisterType<ThingDiscovery>(uri, 1, 0, "ThingDiscovery");
|
||||
qmlRegisterType<ThingDiscoveryProxy>(uri, 1, 0, "ThingDiscoveryProxy");
|
||||
qmlRegisterUncreatableType<ThingDescriptor>(uri, 1, 0, "DeviceDescriptor", "Get it from DeviceDiscovery");
|
||||
qmlRegisterUncreatableType<ThingDescriptor>(uri, 1, 0, "ThingDescriptor", "Get it from ThingDiscovery");
|
||||
|
||||
qmlRegisterType<DeviceModel>(uri, 1, 0, "DeviceModel");
|
||||
|
||||
@ -270,12 +268,11 @@ void registerQmlTypes() {
|
||||
qmlRegisterType<TagListModel>(uri, 1, 0, "TagListModel");
|
||||
qmlRegisterType<TagListProxyModel>(uri, 1, 0, "TagListProxyModel");
|
||||
|
||||
qmlRegisterType<NetworkManagerController>(uri, 1, 0, "NetworkManagerController");
|
||||
qmlRegisterType<BtWiFiSetup>(uri, 1, 0, "BtWiFiSetup");
|
||||
qmlRegisterType<BluetoothDiscovery>(uri, 1, 0, "BluetoothDiscovery");
|
||||
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<WirelessSetupManager>(uri, 1, 0, "WirelessSetupManager", "Can't create this in QML. Get it from the NetworkManagerControler.");
|
||||
qmlRegisterUncreatableType<WirelessAccessPoint>(uri, 1, 0, "WirelessAccessPoints", "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.");
|
||||
qmlRegisterType<WirelessAccessPointsProxy>(uri, 1, 0, "WirelessAccessPointsProxy");
|
||||
|
||||
|
||||
318
libnymea-app/libnymea-app.pri
Normal file
318
libnymea-app/libnymea-app.pri
Normal file
@ -0,0 +1,318 @@
|
||||
!win32:!nozeroconf {
|
||||
# To enable this on Windows we'd need to install Bonjour
|
||||
# https://support.apple.com/kb/DL999
|
||||
message("Building with QtZeroConf")
|
||||
DEFINES += QZEROCONF_STATIC
|
||||
DEFINES += WITH_ZEROCONF
|
||||
include(../QtZeroConf/qtzeroconf.pri)
|
||||
} else {
|
||||
message("Building without QtZeroConf")
|
||||
}
|
||||
|
||||
include(../nymea-remoteproxy/libnymea-remoteproxyclient/libnymea-remoteproxyclient.pri)
|
||||
|
||||
|
||||
QT -= gui
|
||||
QT += network websockets bluetooth charts quick
|
||||
|
||||
LIBS += -lssl -lcrypto
|
||||
|
||||
INCLUDEPATH += \
|
||||
$${PWD} \
|
||||
$$top_srcdir/QtZeroConf
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/wifisetup/btwifisetup.cpp \
|
||||
$${PWD}/configuration/networkmanager.cpp \
|
||||
$${PWD}/engine.cpp \
|
||||
$${PWD}/models/barseriesadapter.cpp \
|
||||
$${PWD}/models/sortfilterproxymodel.cpp \
|
||||
$${PWD}/models/xyseriesadapter.cpp \
|
||||
$${PWD}/ruletemplates/calendaritemtemplate.cpp \
|
||||
$${PWD}/ruletemplates/timedescriptortemplate.cpp \
|
||||
$${PWD}/ruletemplates/timeeventitemtemplate.cpp \
|
||||
$${PWD}/scripting/scriptautosaver.cpp \
|
||||
$${PWD}/types/browseritem.cpp \
|
||||
$${PWD}/types/browseritems.cpp \
|
||||
$${PWD}/types/networkdevice.cpp \
|
||||
$${PWD}/types/networkdevices.cpp \
|
||||
$${PWD}/types/package.cpp \
|
||||
$${PWD}/types/packages.cpp \
|
||||
$${PWD}/types/repositories.cpp \
|
||||
$${PWD}/types/repository.cpp \
|
||||
$${PWD}/types/script.cpp \
|
||||
$${PWD}/types/scripts.cpp \
|
||||
$${PWD}/types/types.cpp \
|
||||
$${PWD}/types/vendor.cpp \
|
||||
$${PWD}/types/vendors.cpp \
|
||||
$${PWD}/types/deviceclass.cpp \
|
||||
$${PWD}/types/device.cpp \
|
||||
$${PWD}/types/param.cpp \
|
||||
$${PWD}/types/params.cpp \
|
||||
$${PWD}/types/paramtype.cpp \
|
||||
$${PWD}/types/paramtypes.cpp \
|
||||
$${PWD}/types/statetype.cpp \
|
||||
$${PWD}/types/statetypes.cpp \
|
||||
$${PWD}/types/statetypesproxy.cpp \
|
||||
$${PWD}/types/eventtype.cpp \
|
||||
$${PWD}/types/eventtypes.cpp \
|
||||
$${PWD}/types/actiontype.cpp \
|
||||
$${PWD}/types/actiontypes.cpp \
|
||||
$${PWD}/types/state.cpp \
|
||||
$${PWD}/types/states.cpp \
|
||||
$${PWD}/types/statesproxy.cpp \
|
||||
$${PWD}/types/plugin.cpp \
|
||||
$${PWD}/types/plugins.cpp \
|
||||
$${PWD}/types/rules.cpp \
|
||||
$${PWD}/types/rule.cpp \
|
||||
$${PWD}/types/eventdescriptor.cpp \
|
||||
$${PWD}/types/eventdescriptors.cpp \
|
||||
$${PWD}/types/ruleaction.cpp \
|
||||
$${PWD}/types/ruleactions.cpp \
|
||||
$${PWD}/types/ruleactionparams.cpp \
|
||||
$${PWD}/types/ruleactionparam.cpp \
|
||||
$${PWD}/types/logentry.cpp \
|
||||
$${PWD}/types/stateevaluators.cpp \
|
||||
$${PWD}/types/stateevaluator.cpp \
|
||||
$${PWD}/types/statedescriptor.cpp \
|
||||
$${PWD}/types/paramdescriptor.cpp \
|
||||
$${PWD}/types/paramdescriptors.cpp \
|
||||
$${PWD}/types/interface.cpp \
|
||||
$${PWD}/types/interfaces.cpp \
|
||||
$${PWD}/types/timedescriptor.cpp \
|
||||
$${PWD}/types/timeeventitem.cpp \
|
||||
$${PWD}/types/calendaritem.cpp \
|
||||
$${PWD}/types/timeeventitems.cpp \
|
||||
$${PWD}/types/calendaritems.cpp \
|
||||
$${PWD}/types/repeatingoption.cpp \
|
||||
$${PWD}/types/tag.cpp \
|
||||
$${PWD}/types/tags.cpp \
|
||||
$${PWD}/types/wirelessaccesspoint.cpp \
|
||||
$${PWD}/types/wirelessaccesspoints.cpp \
|
||||
$${PWD}/types/tokeninfo.cpp \
|
||||
$${PWD}/types/tokeninfos.cpp \
|
||||
$${PWD}/types/userinfo.cpp \
|
||||
$${PWD}/types/ioconnection.cpp \
|
||||
$${PWD}/types/ioconnections.cpp \
|
||||
$${PWD}/types/ioconnectionwatcher.cpp \
|
||||
$${PWD}/connection/nymeahost.cpp \
|
||||
$${PWD}/connection/nymeahosts.cpp \
|
||||
$${PWD}/connection/nymeaconnection.cpp \
|
||||
$${PWD}/connection/nymeatransportinterface.cpp \
|
||||
$${PWD}/connection/websockettransport.cpp \
|
||||
$${PWD}/connection/tcpsockettransport.cpp \
|
||||
$${PWD}/connection/bluetoothtransport.cpp \
|
||||
$${PWD}/connection/awsclient.cpp \
|
||||
$${PWD}/connection/discovery/nymeadiscovery.cpp \
|
||||
$${PWD}/connection/discovery/upnpdiscovery.cpp \
|
||||
$${PWD}/connection/discovery/zeroconfdiscovery.cpp \
|
||||
$${PWD}/connection/discovery/bluetoothservicediscovery.cpp \
|
||||
$${PWD}/devicemanager.cpp \
|
||||
$${PWD}/jsonrpc/jsontypes.cpp \
|
||||
$${PWD}/jsonrpc/jsonrpcclient.cpp \
|
||||
$${PWD}/jsonrpc/jsonhandler.cpp \
|
||||
$${PWD}/devices.cpp \
|
||||
$${PWD}/devicesproxy.cpp \
|
||||
$${PWD}/deviceclasses.cpp \
|
||||
$${PWD}/deviceclassesproxy.cpp \
|
||||
$${PWD}/thingdiscovery.cpp \
|
||||
$${PWD}/models/packagesfiltermodel.cpp \
|
||||
$${PWD}/models/taglistmodel.cpp \
|
||||
$${PWD}/scripting/codecompletion.cpp \
|
||||
$${PWD}/scripting/completionmodel.cpp \
|
||||
$${PWD}/scriptmanager.cpp \
|
||||
$${PWD}/scriptsyntaxhighlighter.cpp \
|
||||
$${PWD}/usermanager.cpp \
|
||||
$${PWD}/vendorsproxy.cpp \
|
||||
$${PWD}/pluginsproxy.cpp \
|
||||
$${PWD}/interfacesmodel.cpp \
|
||||
$${PWD}/rulemanager.cpp \
|
||||
$${PWD}/models/rulesfiltermodel.cpp \
|
||||
$${PWD}/models/logsmodel.cpp \
|
||||
$${PWD}/logmanager.cpp \
|
||||
$${PWD}/wifisetup/bluetoothdevice.cpp \
|
||||
$${PWD}/wifisetup/bluetoothdeviceinfo.cpp \
|
||||
$${PWD}/wifisetup/bluetoothdeviceinfos.cpp \
|
||||
$${PWD}/wifisetup/bluetoothdiscovery.cpp \
|
||||
$${PWD}/models/logsmodelng.cpp \
|
||||
$${PWD}/models/interfacesproxy.cpp \
|
||||
$${PWD}/models/tagsproxymodel.cpp \
|
||||
$${PWD}/tagsmanager.cpp \
|
||||
$${PWD}/models/wirelessaccesspointsproxy.cpp \
|
||||
$${PWD}/ruletemplates/ruletemplate.cpp \
|
||||
$${PWD}/ruletemplates/ruletemplates.cpp \
|
||||
$${PWD}/ruletemplates/eventdescriptortemplate.cpp \
|
||||
$${PWD}/ruletemplates/ruleactiontemplate.cpp \
|
||||
$${PWD}/ruletemplates/stateevaluatortemplate.cpp \
|
||||
$${PWD}/ruletemplates/statedescriptortemplate.cpp \
|
||||
$${PWD}/connection/cloudtransport.cpp \
|
||||
$${PWD}/connection/sigv4utils.cpp \
|
||||
$${PWD}/ruletemplates/ruleactionparamtemplate.cpp \
|
||||
$${PWD}/configuration/serverconfiguration.cpp \
|
||||
$${PWD}/configuration/serverconfigurations.cpp \
|
||||
$${PWD}/configuration/nymeaconfiguration.cpp \
|
||||
$${PWD}/configuration/mqttpolicy.cpp \
|
||||
$${PWD}/configuration/mqttpolicies.cpp \
|
||||
$${PWD}/models/devicemodel.cpp \
|
||||
$${PWD}/system/systemcontroller.cpp \
|
||||
$${PWD}/thinggroup.cpp \
|
||||
$${PWD}/zigbee/zigbeeadapters.cpp \
|
||||
$${PWD}/zigbee/zigbeeadaptersproxy.cpp \
|
||||
$${PWD}/zigbee/zigbeemanager.cpp \
|
||||
$${PWD}/zigbee/zigbeeadapter.cpp \
|
||||
$${PWD}/zigbee/zigbeenetwork.cpp \
|
||||
$${PWD}/zigbee/zigbeenetworks.cpp
|
||||
|
||||
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/wifisetup/btwifisetup.h \
|
||||
$${PWD}/configuration/networkmanager.h \
|
||||
$${PWD}/engine.h \
|
||||
$${PWD}/models/barseriesadapter.h \
|
||||
$${PWD}/models/sortfilterproxymodel.h \
|
||||
$${PWD}/models/xyseriesadapter.h \
|
||||
$${PWD}/ruletemplates/calendaritemtemplate.h \
|
||||
$${PWD}/ruletemplates/timedescriptortemplate.h \
|
||||
$${PWD}/ruletemplates/timeeventitemtemplate.h \
|
||||
$${PWD}/scripting/scriptautosaver.h \
|
||||
$${PWD}/types/browseritem.h \
|
||||
$${PWD}/types/browseritems.h \
|
||||
$${PWD}/types/networkdevice.h \
|
||||
$${PWD}/types/networkdevices.h \
|
||||
$${PWD}/types/package.h \
|
||||
$${PWD}/types/packages.h \
|
||||
$${PWD}/types/repositories.h \
|
||||
$${PWD}/types/repository.h \
|
||||
$${PWD}/types/script.h \
|
||||
$${PWD}/types/scripts.h \
|
||||
$${PWD}/types/types.h \
|
||||
$${PWD}/types/vendor.h \
|
||||
$${PWD}/types/vendors.h \
|
||||
$${PWD}/types/deviceclass.h \
|
||||
$${PWD}/types/device.h \
|
||||
$${PWD}/types/param.h \
|
||||
$${PWD}/types/params.h \
|
||||
$${PWD}/types/paramtype.h \
|
||||
$${PWD}/types/paramtypes.h \
|
||||
$${PWD}/types/statetype.h \
|
||||
$${PWD}/types/statetypes.h \
|
||||
$${PWD}/types/statetypesproxy.h \
|
||||
$${PWD}/types/eventtype.h \
|
||||
$${PWD}/types/eventtypes.h \
|
||||
$${PWD}/types/actiontype.h \
|
||||
$${PWD}/types/actiontypes.h \
|
||||
$${PWD}/types/state.h \
|
||||
$${PWD}/types/states.h \
|
||||
$${PWD}/types/statesproxy.h \
|
||||
$${PWD}/types/plugin.h \
|
||||
$${PWD}/types/plugins.h \
|
||||
$${PWD}/types/rules.h \
|
||||
$${PWD}/types/rule.h \
|
||||
$${PWD}/types/eventdescriptor.h \
|
||||
$${PWD}/types/eventdescriptors.h \
|
||||
$${PWD}/types/ruleaction.h \
|
||||
$${PWD}/types/ruleactions.h \
|
||||
$${PWD}/types/ruleactionparams.h \
|
||||
$${PWD}/types/ruleactionparam.h \
|
||||
$${PWD}/types/logentry.h \
|
||||
$${PWD}/types/stateevaluators.h \
|
||||
$${PWD}/types/stateevaluator.h \
|
||||
$${PWD}/types/statedescriptor.h \
|
||||
$${PWD}/types/paramdescriptor.h \
|
||||
$${PWD}/types/paramdescriptors.h \
|
||||
$${PWD}/types/interface.h \
|
||||
$${PWD}/types/interfaces.h \
|
||||
$${PWD}/types/timedescriptor.h \
|
||||
$${PWD}/types/timeeventitem.h \
|
||||
$${PWD}/types/calendaritem.h \
|
||||
$${PWD}/types/timeeventitems.h \
|
||||
$${PWD}/types/calendaritems.h \
|
||||
$${PWD}/types/repeatingoption.h \
|
||||
$${PWD}/types/tag.h \
|
||||
$${PWD}/types/tags.h \
|
||||
$${PWD}/types/wirelessaccesspoint.h \
|
||||
$${PWD}/types/wirelessaccesspoints.h \
|
||||
$${PWD}/types/tokeninfo.h \
|
||||
$${PWD}/types/tokeninfos.h \
|
||||
$${PWD}/types/userinfo.h \
|
||||
$${PWD}/types/ioconnection.h \
|
||||
$${PWD}/types/ioconnections.h \
|
||||
$${PWD}/types/ioconnectionwatcher.h \
|
||||
$${PWD}/connection/nymeahost.h \
|
||||
$${PWD}/connection/nymeahosts.h \
|
||||
$${PWD}/connection/nymeaconnection.h \
|
||||
$${PWD}/connection/nymeatransportinterface.h \
|
||||
$${PWD}/connection/websockettransport.h \
|
||||
$${PWD}/connection/tcpsockettransport.h \
|
||||
$${PWD}/connection/bluetoothtransport.h \
|
||||
$${PWD}/connection/awsclient.h \
|
||||
$${PWD}/connection/sigv4utils.h \
|
||||
$${PWD}/connection/discovery/nymeadiscovery.h \
|
||||
$${PWD}/connection/discovery/upnpdiscovery.h \
|
||||
$${PWD}/connection/discovery/zeroconfdiscovery.h \
|
||||
$${PWD}/connection/discovery/bluetoothservicediscovery.h \
|
||||
$${PWD}/devicemanager.h \
|
||||
$${PWD}/jsonrpc/jsontypes.h \
|
||||
$${PWD}/jsonrpc/jsonrpcclient.h \
|
||||
$${PWD}/jsonrpc/jsonhandler.h \
|
||||
$${PWD}/devices.h \
|
||||
$${PWD}/devicesproxy.h \
|
||||
$${PWD}/deviceclasses.h \
|
||||
$${PWD}/deviceclassesproxy.h \
|
||||
$${PWD}/thingdiscovery.h \
|
||||
$${PWD}/models/packagesfiltermodel.h \
|
||||
$${PWD}/models/taglistmodel.h \
|
||||
$${PWD}/scripting/codecompletion.h \
|
||||
$${PWD}/scripting/completionmodel.h \
|
||||
$${PWD}/scriptmanager.h \
|
||||
$${PWD}/scriptsyntaxhighlighter.h \
|
||||
$${PWD}/usermanager.h \
|
||||
$${PWD}/vendorsproxy.h \
|
||||
$${PWD}/pluginsproxy.h \
|
||||
$${PWD}/interfacesmodel.h \
|
||||
$${PWD}/rulemanager.h \
|
||||
$${PWD}/models/rulesfiltermodel.h \
|
||||
$${PWD}/models/logsmodel.h \
|
||||
$${PWD}/logmanager.h \
|
||||
$${PWD}/wifisetup/bluetoothdevice.h \
|
||||
$${PWD}/wifisetup/bluetoothdeviceinfo.h \
|
||||
$${PWD}/wifisetup/bluetoothdeviceinfos.h \
|
||||
$${PWD}/wifisetup/bluetoothdiscovery.h \
|
||||
$${PWD}/libnymea-app-core.h \
|
||||
$${PWD}/models/logsmodelng.h \
|
||||
$${PWD}/models/interfacesproxy.h \
|
||||
$${PWD}/tagsmanager.h \
|
||||
$${PWD}/models/tagsproxymodel.h \
|
||||
$${PWD}/models/wirelessaccesspointsproxy.h \
|
||||
$${PWD}/ruletemplates/ruletemplate.h \
|
||||
$${PWD}/ruletemplates/ruletemplates.h \
|
||||
$${PWD}/ruletemplates/eventdescriptortemplate.h \
|
||||
$${PWD}/ruletemplates/ruleactiontemplate.h \
|
||||
$${PWD}/ruletemplates/stateevaluatortemplate.h \
|
||||
$${PWD}/ruletemplates/statedescriptortemplate.h \
|
||||
$${PWD}/connection/cloudtransport.h \
|
||||
$${PWD}/ruletemplates/ruleactionparamtemplate.h \
|
||||
$${PWD}/configuration/serverconfiguration.h \
|
||||
$${PWD}/configuration/serverconfigurations.h \
|
||||
$${PWD}/configuration/nymeaconfiguration.h \
|
||||
$${PWD}/configuration/mqttpolicy.h \
|
||||
$${PWD}/configuration/mqttpolicies.h \
|
||||
$${PWD}/models/devicemodel.h \
|
||||
$${PWD}/system/systemcontroller.h \
|
||||
$${PWD}/thinggroup.h \
|
||||
$${PWD}/zigbee/zigbeeadapters.h \
|
||||
$${PWD}/zigbee/zigbeeadaptersproxy.h \
|
||||
$${PWD}/zigbee/zigbeemanager.h \
|
||||
$${PWD}/zigbee/zigbeeadapter.h \
|
||||
$${PWD}/zigbee/zigbeenetwork.h \
|
||||
$${PWD}/zigbee/zigbeenetworks.h
|
||||
|
||||
ubports: {
|
||||
DEFINES += UBPORTS
|
||||
}
|
||||
|
||||
# https://bugreports.qt.io/browse/QTBUG-83165
|
||||
android: {
|
||||
DESTDIR = $${ANDROID_TARGET_ARCH}
|
||||
}
|
||||
@ -3,321 +3,4 @@ TEMPLATE = lib
|
||||
CONFIG += staticlib
|
||||
|
||||
include(../config.pri)
|
||||
!win32:!nozeroconf {
|
||||
# To enable this on Windows we'd need to install Bonjour
|
||||
# https://support.apple.com/kb/DL999
|
||||
message("Building with QtZeroConf")
|
||||
DEFINES += QZEROCONF_STATIC
|
||||
DEFINES += WITH_ZEROCONF
|
||||
include(../QtZeroConf/qtzeroconf.pri)
|
||||
} else {
|
||||
message("Building without QtZeroConf")
|
||||
}
|
||||
|
||||
include(../nymea-remoteproxy/libnymea-remoteproxyclient/libnymea-remoteproxyclient.pri)
|
||||
|
||||
|
||||
QT -= gui
|
||||
QT += network websockets bluetooth charts quick
|
||||
|
||||
LIBS += -lssl -lcrypto
|
||||
|
||||
INCLUDEPATH += $$top_srcdir/QtZeroConf
|
||||
|
||||
SOURCES += \
|
||||
configuration/networkmanager.cpp \
|
||||
engine.cpp \
|
||||
models/barseriesadapter.cpp \
|
||||
models/sortfilterproxymodel.cpp \
|
||||
models/xyseriesadapter.cpp \
|
||||
ruletemplates/calendaritemtemplate.cpp \
|
||||
ruletemplates/timedescriptortemplate.cpp \
|
||||
ruletemplates/timeeventitemtemplate.cpp \
|
||||
scripting/scriptautosaver.cpp \
|
||||
types/browseritem.cpp \
|
||||
types/browseritems.cpp \
|
||||
types/networkdevice.cpp \
|
||||
types/networkdevices.cpp \
|
||||
types/package.cpp \
|
||||
types/packages.cpp \
|
||||
types/repositories.cpp \
|
||||
types/repository.cpp \
|
||||
types/script.cpp \
|
||||
types/scripts.cpp \
|
||||
types/types.cpp \
|
||||
types/vendor.cpp \
|
||||
types/vendors.cpp \
|
||||
types/deviceclass.cpp \
|
||||
types/device.cpp \
|
||||
types/param.cpp \
|
||||
types/params.cpp \
|
||||
types/paramtype.cpp \
|
||||
types/paramtypes.cpp \
|
||||
types/statetype.cpp \
|
||||
types/statetypes.cpp \
|
||||
types/statetypesproxy.cpp \
|
||||
types/eventtype.cpp \
|
||||
types/eventtypes.cpp \
|
||||
types/actiontype.cpp \
|
||||
types/actiontypes.cpp \
|
||||
types/state.cpp \
|
||||
types/states.cpp \
|
||||
types/statesproxy.cpp \
|
||||
types/plugin.cpp \
|
||||
types/plugins.cpp \
|
||||
types/rules.cpp \
|
||||
types/rule.cpp \
|
||||
types/eventdescriptor.cpp \
|
||||
types/eventdescriptors.cpp \
|
||||
types/ruleaction.cpp \
|
||||
types/ruleactions.cpp \
|
||||
types/ruleactionparams.cpp \
|
||||
types/ruleactionparam.cpp \
|
||||
types/logentry.cpp \
|
||||
types/stateevaluators.cpp \
|
||||
types/stateevaluator.cpp \
|
||||
types/statedescriptor.cpp \
|
||||
types/paramdescriptor.cpp \
|
||||
types/paramdescriptors.cpp \
|
||||
types/interface.cpp \
|
||||
types/interfaces.cpp \
|
||||
types/timedescriptor.cpp \
|
||||
types/timeeventitem.cpp \
|
||||
types/calendaritem.cpp \
|
||||
types/timeeventitems.cpp \
|
||||
types/calendaritems.cpp \
|
||||
types/repeatingoption.cpp \
|
||||
types/tag.cpp \
|
||||
types/tags.cpp \
|
||||
types/wirelessaccesspoint.cpp \
|
||||
types/wirelessaccesspoints.cpp \
|
||||
types/tokeninfo.cpp \
|
||||
types/tokeninfos.cpp \
|
||||
types/userinfo.cpp \
|
||||
types/ioconnection.cpp \
|
||||
types/ioconnections.cpp \
|
||||
types/ioconnectionwatcher.cpp \
|
||||
connection/nymeahost.cpp \
|
||||
connection/nymeahosts.cpp \
|
||||
connection/nymeaconnection.cpp \
|
||||
connection/nymeatransportinterface.cpp \
|
||||
connection/websockettransport.cpp \
|
||||
connection/tcpsockettransport.cpp \
|
||||
connection/bluetoothtransport.cpp \
|
||||
connection/awsclient.cpp \
|
||||
connection/discovery/nymeadiscovery.cpp \
|
||||
connection/discovery/upnpdiscovery.cpp \
|
||||
connection/discovery/zeroconfdiscovery.cpp \
|
||||
connection/discovery/bluetoothservicediscovery.cpp \
|
||||
devicemanager.cpp \
|
||||
jsonrpc/jsontypes.cpp \
|
||||
jsonrpc/jsonrpcclient.cpp \
|
||||
jsonrpc/jsonhandler.cpp \
|
||||
devices.cpp \
|
||||
devicesproxy.cpp \
|
||||
deviceclasses.cpp \
|
||||
deviceclassesproxy.cpp \
|
||||
devicediscovery.cpp \
|
||||
models/packagesfiltermodel.cpp \
|
||||
models/taglistmodel.cpp \
|
||||
scripting/codecompletion.cpp \
|
||||
scripting/completionmodel.cpp \
|
||||
scriptmanager.cpp \
|
||||
scriptsyntaxhighlighter.cpp \
|
||||
usermanager.cpp \
|
||||
vendorsproxy.cpp \
|
||||
pluginsproxy.cpp \
|
||||
interfacesmodel.cpp \
|
||||
rulemanager.cpp \
|
||||
models/rulesfiltermodel.cpp \
|
||||
models/logsmodel.cpp \
|
||||
logmanager.cpp \
|
||||
wifisetup/bluetoothdevice.cpp \
|
||||
wifisetup/bluetoothdeviceinfo.cpp \
|
||||
wifisetup/bluetoothdeviceinfos.cpp \
|
||||
wifisetup/bluetoothdiscovery.cpp \
|
||||
wifisetup/wirelesssetupmanager.cpp \
|
||||
wifisetup/networkmanagercontroller.cpp \
|
||||
models/logsmodelng.cpp \
|
||||
models/interfacesproxy.cpp \
|
||||
models/tagsproxymodel.cpp \
|
||||
tagsmanager.cpp \
|
||||
models/wirelessaccesspointsproxy.cpp \
|
||||
ruletemplates/ruletemplate.cpp \
|
||||
ruletemplates/ruletemplates.cpp \
|
||||
ruletemplates/eventdescriptortemplate.cpp \
|
||||
ruletemplates/ruleactiontemplate.cpp \
|
||||
ruletemplates/stateevaluatortemplate.cpp \
|
||||
ruletemplates/statedescriptortemplate.cpp \
|
||||
connection/cloudtransport.cpp \
|
||||
connection/sigv4utils.cpp \
|
||||
ruletemplates/ruleactionparamtemplate.cpp \
|
||||
configuration/serverconfiguration.cpp \
|
||||
configuration/serverconfigurations.cpp \
|
||||
configuration/nymeaconfiguration.cpp \
|
||||
configuration/mqttpolicy.cpp \
|
||||
configuration/mqttpolicies.cpp \
|
||||
models/devicemodel.cpp \
|
||||
system/systemcontroller.cpp \
|
||||
thinggroup.cpp \
|
||||
zigbee/zigbeeadapters.cpp \
|
||||
zigbee/zigbeeadaptersproxy.cpp \
|
||||
zigbee/zigbeemanager.cpp \
|
||||
zigbee/zigbeeadapter.cpp \
|
||||
zigbee/zigbeenetwork.cpp \
|
||||
zigbee/zigbeenetworks.cpp
|
||||
|
||||
|
||||
|
||||
HEADERS += \
|
||||
configuration/networkmanager.h \
|
||||
engine.h \
|
||||
models/barseriesadapter.h \
|
||||
models/sortfilterproxymodel.h \
|
||||
models/xyseriesadapter.h \
|
||||
ruletemplates/calendaritemtemplate.h \
|
||||
ruletemplates/timedescriptortemplate.h \
|
||||
ruletemplates/timeeventitemtemplate.h \
|
||||
scripting/scriptautosaver.h \
|
||||
types/browseritem.h \
|
||||
types/browseritems.h \
|
||||
types/networkdevice.h \
|
||||
types/networkdevices.h \
|
||||
types/package.h \
|
||||
types/packages.h \
|
||||
types/repositories.h \
|
||||
types/repository.h \
|
||||
types/script.h \
|
||||
types/scripts.h \
|
||||
types/types.h \
|
||||
types/vendor.h \
|
||||
types/vendors.h \
|
||||
types/deviceclass.h \
|
||||
types/device.h \
|
||||
types/param.h \
|
||||
types/params.h \
|
||||
types/paramtype.h \
|
||||
types/paramtypes.h \
|
||||
types/statetype.h \
|
||||
types/statetypes.h \
|
||||
types/statetypesproxy.h \
|
||||
types/eventtype.h \
|
||||
types/eventtypes.h \
|
||||
types/actiontype.h \
|
||||
types/actiontypes.h \
|
||||
types/state.h \
|
||||
types/states.h \
|
||||
types/statesproxy.h \
|
||||
types/plugin.h \
|
||||
types/plugins.h \
|
||||
types/rules.h \
|
||||
types/rule.h \
|
||||
types/eventdescriptor.h \
|
||||
types/eventdescriptors.h \
|
||||
types/ruleaction.h \
|
||||
types/ruleactions.h \
|
||||
types/ruleactionparams.h \
|
||||
types/ruleactionparam.h \
|
||||
types/logentry.h \
|
||||
types/stateevaluators.h \
|
||||
types/stateevaluator.h \
|
||||
types/statedescriptor.h \
|
||||
types/paramdescriptor.h \
|
||||
types/paramdescriptors.h \
|
||||
types/interface.h \
|
||||
types/interfaces.h \
|
||||
types/timedescriptor.h \
|
||||
types/timeeventitem.h \
|
||||
types/calendaritem.h \
|
||||
types/timeeventitems.h \
|
||||
types/calendaritems.h \
|
||||
types/repeatingoption.h \
|
||||
types/tag.h \
|
||||
types/tags.h \
|
||||
types/wirelessaccesspoint.h \
|
||||
types/wirelessaccesspoints.h \
|
||||
types/tokeninfo.h \
|
||||
types/tokeninfos.h \
|
||||
types/userinfo.h \
|
||||
types/ioconnection.h \
|
||||
types/ioconnections.h \
|
||||
types/ioconnectionwatcher.h \
|
||||
connection/nymeahost.h \
|
||||
connection/nymeahosts.h \
|
||||
connection/nymeaconnection.h \
|
||||
connection/nymeatransportinterface.h \
|
||||
connection/websockettransport.h \
|
||||
connection/tcpsockettransport.h \
|
||||
connection/bluetoothtransport.h \
|
||||
connection/awsclient.h \
|
||||
connection/sigv4utils.h \
|
||||
connection/discovery/nymeadiscovery.h \
|
||||
connection/discovery/upnpdiscovery.h \
|
||||
connection/discovery/zeroconfdiscovery.h \
|
||||
connection/discovery/bluetoothservicediscovery.h \
|
||||
devicemanager.h \
|
||||
jsonrpc/jsontypes.h \
|
||||
jsonrpc/jsonrpcclient.h \
|
||||
jsonrpc/jsonhandler.h \
|
||||
devices.h \
|
||||
devicesproxy.h \
|
||||
deviceclasses.h \
|
||||
deviceclassesproxy.h \
|
||||
devicediscovery.h \
|
||||
models/packagesfiltermodel.h \
|
||||
models/taglistmodel.h \
|
||||
scripting/codecompletion.h \
|
||||
scripting/completionmodel.h \
|
||||
scriptmanager.h \
|
||||
scriptsyntaxhighlighter.h \
|
||||
usermanager.h \
|
||||
vendorsproxy.h \
|
||||
pluginsproxy.h \
|
||||
interfacesmodel.h \
|
||||
rulemanager.h \
|
||||
models/rulesfiltermodel.h \
|
||||
models/logsmodel.h \
|
||||
logmanager.h \
|
||||
wifisetup/bluetoothdevice.h \
|
||||
wifisetup/bluetoothdeviceinfo.h \
|
||||
wifisetup/bluetoothdeviceinfos.h \
|
||||
wifisetup/bluetoothdiscovery.h \
|
||||
wifisetup/wirelesssetupmanager.h \
|
||||
wifisetup/networkmanagercontroller.h \
|
||||
libnymea-app-core.h \
|
||||
models/logsmodelng.h \
|
||||
models/interfacesproxy.h \
|
||||
tagsmanager.h \
|
||||
models/tagsproxymodel.h \
|
||||
models/wirelessaccesspointsproxy.h \
|
||||
ruletemplates/ruletemplate.h \
|
||||
ruletemplates/ruletemplates.h \
|
||||
ruletemplates/eventdescriptortemplate.h \
|
||||
ruletemplates/ruleactiontemplate.h \
|
||||
ruletemplates/stateevaluatortemplate.h \
|
||||
ruletemplates/statedescriptortemplate.h \
|
||||
connection/cloudtransport.h \
|
||||
ruletemplates/ruleactionparamtemplate.h \
|
||||
configuration/serverconfiguration.h \
|
||||
configuration/serverconfigurations.h \
|
||||
configuration/nymeaconfiguration.h \
|
||||
configuration/mqttpolicy.h \
|
||||
configuration/mqttpolicies.h \
|
||||
models/devicemodel.h \
|
||||
system/systemcontroller.h \
|
||||
thinggroup.h \
|
||||
zigbee/zigbeeadapters.h \
|
||||
zigbee/zigbeeadaptersproxy.h \
|
||||
zigbee/zigbeemanager.h \
|
||||
zigbee/zigbeeadapter.h \
|
||||
zigbee/zigbeenetwork.h \
|
||||
zigbee/zigbeenetworks.h
|
||||
|
||||
ubports: {
|
||||
DEFINES += UBPORTS
|
||||
}
|
||||
|
||||
# https://bugreports.qt.io/browse/QTBUG-83165
|
||||
android: {
|
||||
DESTDIR = $${ANDROID_TARGET_ARCH}
|
||||
}
|
||||
include(libnymea-app.pri)
|
||||
|
||||
@ -28,22 +28,22 @@
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "devicediscovery.h"
|
||||
#include "thingdiscovery.h"
|
||||
|
||||
#include "engine.h"
|
||||
|
||||
DeviceDiscovery::DeviceDiscovery(QObject *parent) :
|
||||
ThingDiscovery::ThingDiscovery(QObject *parent) :
|
||||
QAbstractListModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
int DeviceDiscovery::rowCount(const QModelIndex &parent) const
|
||||
int ThingDiscovery::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return m_foundDevices.count();
|
||||
}
|
||||
|
||||
QVariant DeviceDiscovery::data(const QModelIndex &index, int role) const
|
||||
QVariant ThingDiscovery::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
switch (role) {
|
||||
case RoleId:
|
||||
@ -53,13 +53,13 @@ QVariant DeviceDiscovery::data(const QModelIndex &index, int role) const
|
||||
case RoleDescription:
|
||||
return m_foundDevices.at(index.row())->description();
|
||||
case RoleDeviceId:
|
||||
return m_foundDevices.at(index.row())->deviceId();
|
||||
return m_foundDevices.at(index.row())->thingId();
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> DeviceDiscovery::roleNames() const
|
||||
QHash<int, QByteArray> ThingDiscovery::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
roles.insert(RoleId, "id");
|
||||
@ -69,7 +69,7 @@ QHash<int, QByteArray> DeviceDiscovery::roleNames() const
|
||||
return roles;
|
||||
}
|
||||
|
||||
void DeviceDiscovery::discoverDevices(const QUuid &deviceClassId, const QVariantList &discoveryParams)
|
||||
void ThingDiscovery::discoverThings(const QUuid &deviceClassId, const QVariantList &discoveryParams)
|
||||
{
|
||||
if (m_busy) {
|
||||
qWarning() << "Busy... not restarting discovery";
|
||||
@ -94,13 +94,13 @@ void DeviceDiscovery::discoverDevices(const QUuid &deviceClassId, const QVariant
|
||||
if (!discoveryParams.isEmpty()) {
|
||||
params.insert("discoveryParams", discoveryParams);
|
||||
}
|
||||
m_engine->jsonRpcClient()->sendCommand("Devices.GetDiscoveredDevices", params, this, "discoverDevicesResponse");
|
||||
m_engine->jsonRpcClient()->sendCommand("Devices.GetDiscoveredDevices", params, this, "discoverThingsResponse");
|
||||
m_busy = true;
|
||||
m_displayMessage.clear();
|
||||
emit busyChanged();
|
||||
}
|
||||
|
||||
DeviceDescriptor *DeviceDiscovery::get(int index) const
|
||||
ThingDescriptor *ThingDiscovery::get(int index) const
|
||||
{
|
||||
if (index < 0 || index >= m_foundDevices.count()) {
|
||||
return nullptr;
|
||||
@ -108,12 +108,12 @@ DeviceDescriptor *DeviceDiscovery::get(int index) const
|
||||
return m_foundDevices.at(index);
|
||||
}
|
||||
|
||||
Engine *DeviceDiscovery::engine() const
|
||||
Engine *ThingDiscovery::engine() const
|
||||
{
|
||||
return m_engine;
|
||||
}
|
||||
|
||||
void DeviceDiscovery::setEngine(Engine *engine)
|
||||
void ThingDiscovery::setEngine(Engine *engine)
|
||||
{
|
||||
if (m_engine != engine) {
|
||||
m_engine = engine;
|
||||
@ -121,25 +121,25 @@ void DeviceDiscovery::setEngine(Engine *engine)
|
||||
}
|
||||
}
|
||||
|
||||
bool DeviceDiscovery::busy() const
|
||||
bool ThingDiscovery::busy() const
|
||||
{
|
||||
return m_busy;
|
||||
}
|
||||
|
||||
QString DeviceDiscovery::displayMessage() const
|
||||
QString ThingDiscovery::displayMessage() const
|
||||
{
|
||||
return m_displayMessage;
|
||||
}
|
||||
|
||||
void DeviceDiscovery::discoverDevicesResponse(int /*commandId*/, const QVariantMap ¶ms)
|
||||
void ThingDiscovery::discoverThingsResponse(int /*commandId*/, const QVariantMap ¶ms)
|
||||
{
|
||||
// qDebug() << "response received" << params;
|
||||
qDebug() << "response received" << params;
|
||||
QVariantList descriptors = params.value("deviceDescriptors").toList();
|
||||
foreach (const QVariant &descriptorVariant, descriptors) {
|
||||
qDebug() << "Found device. Descriptor:" << descriptorVariant;
|
||||
if (!contains(descriptorVariant.toMap().value("id").toUuid())) {
|
||||
beginInsertRows(QModelIndex(), m_foundDevices.count(), m_foundDevices.count());
|
||||
DeviceDescriptor *descriptor = new DeviceDescriptor(descriptorVariant.toMap().value("id").toUuid(),
|
||||
ThingDescriptor *descriptor = new ThingDescriptor(descriptorVariant.toMap().value("id").toUuid(),
|
||||
descriptorVariant.toMap().value("deviceId").toString(),
|
||||
descriptorVariant.toMap().value("title").toString(),
|
||||
descriptorVariant.toMap().value("description").toString());
|
||||
@ -159,9 +159,9 @@ void DeviceDiscovery::discoverDevicesResponse(int /*commandId*/, const QVariantM
|
||||
emit busyChanged();
|
||||
}
|
||||
|
||||
bool DeviceDiscovery::contains(const QUuid &deviceDescriptorId) const
|
||||
bool ThingDiscovery::contains(const QUuid &deviceDescriptorId) const
|
||||
{
|
||||
foreach (DeviceDescriptor *descriptor, m_foundDevices) {
|
||||
foreach (ThingDescriptor *descriptor, m_foundDevices) {
|
||||
if (descriptor->id() == deviceDescriptorId) {
|
||||
return true;
|
||||
}
|
||||
@ -169,10 +169,10 @@ bool DeviceDiscovery::contains(const QUuid &deviceDescriptorId) const
|
||||
return false;
|
||||
}
|
||||
|
||||
DeviceDescriptor::DeviceDescriptor(const QUuid &id, const QUuid &deviceId, const QString &name, const QString &description, QObject *parent):
|
||||
ThingDescriptor::ThingDescriptor(const QUuid &id, const QUuid &thingId, const QString &name, const QString &description, QObject *parent):
|
||||
QObject(parent),
|
||||
m_id(id),
|
||||
m_deviceId(deviceId),
|
||||
m_thingId(thingId),
|
||||
m_name(name),
|
||||
m_description(description),
|
||||
m_params(new Params(this))
|
||||
@ -180,60 +180,60 @@ DeviceDescriptor::DeviceDescriptor(const QUuid &id, const QUuid &deviceId, const
|
||||
|
||||
}
|
||||
|
||||
QUuid DeviceDescriptor::id() const
|
||||
QUuid ThingDescriptor::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
QUuid DeviceDescriptor::deviceId() const
|
||||
QUuid ThingDescriptor::thingId() const
|
||||
{
|
||||
return m_deviceId;
|
||||
return m_thingId;
|
||||
}
|
||||
|
||||
QString DeviceDescriptor::name() const
|
||||
QString ThingDescriptor::name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
QString DeviceDescriptor::description() const
|
||||
QString ThingDescriptor::description() const
|
||||
{
|
||||
return m_description;
|
||||
}
|
||||
|
||||
Params* DeviceDescriptor::params() const
|
||||
Params* ThingDescriptor::params() const
|
||||
{
|
||||
return m_params;
|
||||
}
|
||||
|
||||
DeviceDiscoveryProxy::DeviceDiscoveryProxy(QObject *parent):
|
||||
ThingDiscoveryProxy::ThingDiscoveryProxy(QObject *parent):
|
||||
QSortFilterProxyModel (parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DeviceDiscovery *DeviceDiscoveryProxy::deviceDiscovery() const
|
||||
ThingDiscovery *ThingDiscoveryProxy::thingDiscovery() const
|
||||
{
|
||||
return m_deviceDiscovery;
|
||||
return m_thingDiscovery;
|
||||
}
|
||||
|
||||
void DeviceDiscoveryProxy::setDeviceDiscovery(DeviceDiscovery *deviceDiscovery)
|
||||
void ThingDiscoveryProxy::setThingDiscovery(ThingDiscovery *thingDiscovery)
|
||||
{
|
||||
if (m_deviceDiscovery != deviceDiscovery) {
|
||||
m_deviceDiscovery = deviceDiscovery;
|
||||
setSourceModel(deviceDiscovery);
|
||||
emit deviceDiscoveryChanged();
|
||||
if (m_thingDiscovery != thingDiscovery) {
|
||||
m_thingDiscovery = thingDiscovery;
|
||||
setSourceModel(thingDiscovery);
|
||||
emit thingDiscoveryChanged();
|
||||
emit countChanged();
|
||||
connect(m_deviceDiscovery, &DeviceDiscovery::countChanged, this, &DeviceDiscoveryProxy::countChanged);
|
||||
connect(m_thingDiscovery, &ThingDiscovery::countChanged, this, &ThingDiscoveryProxy::countChanged);
|
||||
invalidateFilter();
|
||||
}
|
||||
}
|
||||
|
||||
bool DeviceDiscoveryProxy::showAlreadyAdded() const
|
||||
bool ThingDiscoveryProxy::showAlreadyAdded() const
|
||||
{
|
||||
return m_showAlreadyAdded;
|
||||
}
|
||||
|
||||
void DeviceDiscoveryProxy::setShowAlreadyAdded(bool showAlreadyAdded)
|
||||
void ThingDiscoveryProxy::setShowAlreadyAdded(bool showAlreadyAdded)
|
||||
{
|
||||
if (m_showAlreadyAdded != showAlreadyAdded) {
|
||||
m_showAlreadyAdded = showAlreadyAdded;
|
||||
@ -243,12 +243,12 @@ void DeviceDiscoveryProxy::setShowAlreadyAdded(bool showAlreadyAdded)
|
||||
}
|
||||
}
|
||||
|
||||
bool DeviceDiscoveryProxy::showNew() const
|
||||
bool ThingDiscoveryProxy::showNew() const
|
||||
{
|
||||
return m_showNew;
|
||||
}
|
||||
|
||||
void DeviceDiscoveryProxy::setShowNew(bool showNew)
|
||||
void ThingDiscoveryProxy::setShowNew(bool showNew)
|
||||
{
|
||||
if (m_showNew != showNew) {
|
||||
m_showNew = showNew;
|
||||
@ -258,37 +258,37 @@ void DeviceDiscoveryProxy::setShowNew(bool showNew)
|
||||
}
|
||||
}
|
||||
|
||||
QUuid DeviceDiscoveryProxy::filterDeviceId() const
|
||||
QUuid ThingDiscoveryProxy::filterThingId() const
|
||||
{
|
||||
return m_filterDeviceId;
|
||||
return m_filterThingId;
|
||||
}
|
||||
|
||||
void DeviceDiscoveryProxy::setFilterDeviceId(const QUuid &filterDeviceId)
|
||||
void ThingDiscoveryProxy::setFilterThingId(const QUuid &filterDeviceId)
|
||||
{
|
||||
if (m_filterDeviceId != filterDeviceId) {
|
||||
m_filterDeviceId = filterDeviceId;
|
||||
emit filterDeviceIdChanged();
|
||||
if (m_filterThingId != filterDeviceId) {
|
||||
m_filterThingId = filterDeviceId;
|
||||
emit filterThingIdChanged();
|
||||
invalidateFilter();
|
||||
emit countChanged();
|
||||
}
|
||||
}
|
||||
|
||||
DeviceDescriptor *DeviceDiscoveryProxy::get(int index) const
|
||||
ThingDescriptor *ThingDiscoveryProxy::get(int index) const
|
||||
{
|
||||
return m_deviceDiscovery->get(mapToSource(this->index(index, 0)).row());
|
||||
return m_thingDiscovery->get(mapToSource(this->index(index, 0)).row());
|
||||
}
|
||||
|
||||
bool DeviceDiscoveryProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
bool ThingDiscoveryProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
{
|
||||
Q_UNUSED(sourceParent)
|
||||
DeviceDescriptor* dev = m_deviceDiscovery->get(sourceRow);
|
||||
if (!m_showAlreadyAdded && !dev->deviceId().isNull()) {
|
||||
ThingDescriptor* dev = m_thingDiscovery->get(sourceRow);
|
||||
if (!m_showAlreadyAdded && !dev->thingId().isNull()) {
|
||||
return false;
|
||||
}
|
||||
if (!m_showNew && dev->deviceId().isNull()) {
|
||||
if (!m_showNew && dev->thingId().isNull()) {
|
||||
return false;
|
||||
}
|
||||
if (!m_filterDeviceId.isNull() && dev->deviceId() != m_filterDeviceId) {
|
||||
if (!m_filterThingId.isNull() && dev->thingId() != m_filterThingId) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -28,39 +28,39 @@
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#ifndef DEVICEDISCOVERY_H
|
||||
#define DEVICEDISCOVERY_H
|
||||
#ifndef THINGDISCOVERY_H
|
||||
#define THINGDISCOVERY_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QUuid>
|
||||
|
||||
#include "engine.h"
|
||||
|
||||
class DeviceDescriptor: public QObject {
|
||||
class ThingDescriptor: public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QUuid id READ id CONSTANT)
|
||||
Q_PROPERTY(QUuid deviceId READ deviceId CONSTANT)
|
||||
Q_PROPERTY(QUuid thingId READ thingId CONSTANT)
|
||||
Q_PROPERTY(QString name READ name CONSTANT)
|
||||
Q_PROPERTY(QString description READ description CONSTANT)
|
||||
Q_PROPERTY(Params* params READ params CONSTANT)
|
||||
public:
|
||||
DeviceDescriptor(const QUuid &id, const QUuid &deviceId, const QString &name, const QString &description, QObject *parent = nullptr);
|
||||
ThingDescriptor(const QUuid &id, const QUuid &thingId, const QString &name, const QString &description, QObject *parent = nullptr);
|
||||
|
||||
QUuid id() const;
|
||||
QUuid deviceId() const;
|
||||
QUuid thingId() const;
|
||||
QString name() const;
|
||||
QString description() const;
|
||||
Params* params() const;
|
||||
|
||||
private:
|
||||
QUuid m_id;
|
||||
QUuid m_deviceId;
|
||||
QUuid m_thingId;
|
||||
QString m_name;
|
||||
QString m_description;
|
||||
Params *m_params = nullptr;
|
||||
};
|
||||
|
||||
class DeviceDiscovery : public QAbstractListModel
|
||||
class ThingDiscovery : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(Engine* engine READ engine WRITE setEngine)
|
||||
@ -75,16 +75,16 @@ public:
|
||||
RoleDescription
|
||||
};
|
||||
|
||||
DeviceDiscovery(QObject *parent = nullptr);
|
||||
ThingDiscovery(QObject *parent = nullptr);
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
|
||||
Q_INVOKABLE void discoverDevices(const QUuid &deviceClassId, const QVariantList &discoveryParams = {});
|
||||
Q_INVOKABLE void discoverThings(const QUuid &thingClassId, const QVariantList &discoveryParams = {});
|
||||
|
||||
Q_INVOKABLE DeviceDescriptor* get(int index) const;
|
||||
Q_INVOKABLE ThingDescriptor* get(int index) const;
|
||||
|
||||
Engine* engine() const;
|
||||
void setEngine(Engine *jsonRpcClient);
|
||||
@ -93,7 +93,7 @@ public:
|
||||
QString displayMessage() const;
|
||||
|
||||
private slots:
|
||||
void discoverDevicesResponse(int commandId, const QVariantMap ¶ms);
|
||||
void discoverThingsResponse(int commandId, const QVariantMap ¶ms);
|
||||
|
||||
signals:
|
||||
void busyChanged();
|
||||
@ -106,23 +106,23 @@ private:
|
||||
QString m_displayMessage;
|
||||
|
||||
bool contains(const QUuid &deviceDescriptorId) const;
|
||||
QList<DeviceDescriptor*> m_foundDevices;
|
||||
QList<ThingDescriptor*> m_foundDevices;
|
||||
};
|
||||
|
||||
class DeviceDiscoveryProxy: public QSortFilterProxyModel
|
||||
class ThingDiscoveryProxy: public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
|
||||
Q_PROPERTY(DeviceDiscovery* deviceDiscovery READ deviceDiscovery WRITE setDeviceDiscovery NOTIFY deviceDiscoveryChanged)
|
||||
Q_PROPERTY(ThingDiscovery* thingDiscovery READ thingDiscovery WRITE setThingDiscovery NOTIFY thingDiscoveryChanged)
|
||||
Q_PROPERTY(bool showAlreadyAdded READ showAlreadyAdded WRITE setShowAlreadyAdded NOTIFY showAlreadyAddedChanged)
|
||||
Q_PROPERTY(bool showNew READ showNew WRITE setShowNew NOTIFY showNewChanged)
|
||||
Q_PROPERTY(QUuid filterDeviceId READ filterDeviceId WRITE setFilterDeviceId NOTIFY filterDeviceIdChanged)
|
||||
Q_PROPERTY(QUuid filterThingId READ filterThingId WRITE setFilterThingId NOTIFY filterThingIdChanged)
|
||||
|
||||
public:
|
||||
DeviceDiscoveryProxy(QObject *parent = nullptr);
|
||||
ThingDiscoveryProxy(QObject *parent = nullptr);
|
||||
|
||||
DeviceDiscovery* deviceDiscovery() const;
|
||||
void setDeviceDiscovery(DeviceDiscovery* deviceDiscovery);
|
||||
ThingDiscovery* thingDiscovery() const;
|
||||
void setThingDiscovery(ThingDiscovery* thingDiscovery);
|
||||
|
||||
bool showAlreadyAdded() const;
|
||||
void setShowAlreadyAdded(bool showAlreadyAdded);
|
||||
@ -130,26 +130,26 @@ public:
|
||||
bool showNew() const;
|
||||
void setShowNew(bool showNew);
|
||||
|
||||
QUuid filterDeviceId() const;
|
||||
void setFilterDeviceId(const QUuid &filterDeviceId);
|
||||
QUuid filterThingId() const;
|
||||
void setFilterThingId(const QUuid &filterDeviceId);
|
||||
|
||||
Q_INVOKABLE DeviceDescriptor* get(int index) const;
|
||||
Q_INVOKABLE ThingDescriptor* get(int index) const;
|
||||
|
||||
signals:
|
||||
void countChanged();
|
||||
void deviceDiscoveryChanged();
|
||||
void thingDiscoveryChanged();
|
||||
void showAlreadyAddedChanged();
|
||||
void showNewChanged();
|
||||
void filterDeviceIdChanged();
|
||||
void filterThingIdChanged();
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
||||
|
||||
private:
|
||||
DeviceDiscovery* m_deviceDiscovery = nullptr;
|
||||
ThingDiscovery* m_thingDiscovery = nullptr;
|
||||
bool m_showAlreadyAdded = false;
|
||||
bool m_showNew = true;
|
||||
QUuid m_filterDeviceId;
|
||||
QUuid m_filterThingId;
|
||||
};
|
||||
|
||||
#endif // DEVICEDISCOVERY_H
|
||||
#endif // THINGDISCOVERY_H
|
||||
@ -41,6 +41,11 @@ BluetoothDeviceInfo::BluetoothDeviceInfo(const QBluetoothDeviceInfo &deviceInfo)
|
||||
m_deviceInfo = deviceInfo;
|
||||
}
|
||||
|
||||
BluetoothDeviceInfo::~BluetoothDeviceInfo()
|
||||
{
|
||||
qDebug() << "~BluetoothDeviceInfo";
|
||||
}
|
||||
|
||||
QString BluetoothDeviceInfo::address() const
|
||||
{
|
||||
#ifdef Q_OS_MAC
|
||||
@ -62,7 +67,7 @@ bool BluetoothDeviceInfo::isLowEnergy() const
|
||||
return m_deviceInfo.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
|
||||
}
|
||||
|
||||
QBluetoothDeviceInfo BluetoothDeviceInfo::getBluetoothDeviceInfo() const
|
||||
QBluetoothDeviceInfo BluetoothDeviceInfo::bluetoothDeviceInfo() const
|
||||
{
|
||||
return m_deviceInfo;
|
||||
}
|
||||
|
||||
@ -45,12 +45,13 @@ class BluetoothDeviceInfo : public QObject
|
||||
public:
|
||||
BluetoothDeviceInfo();
|
||||
BluetoothDeviceInfo(const QBluetoothDeviceInfo &deviceInfo);
|
||||
~BluetoothDeviceInfo();
|
||||
|
||||
QString address() const;
|
||||
QString name() const;
|
||||
bool isLowEnergy() const;
|
||||
|
||||
QBluetoothDeviceInfo getBluetoothDeviceInfo() const;
|
||||
QBluetoothDeviceInfo bluetoothDeviceInfo() const;
|
||||
void setBluetoothDeviceInfo(const QBluetoothDeviceInfo &deviceInfo);
|
||||
|
||||
signals:
|
||||
|
||||
@ -174,34 +174,26 @@ void BluetoothDiscovery::onBluetoothHostModeChanged(const QBluetoothLocalDevice:
|
||||
|
||||
void BluetoothDiscovery::deviceDiscovered(const QBluetoothDeviceInfo &deviceInfo)
|
||||
{
|
||||
if (!deviceInfo.isValid())
|
||||
return;
|
||||
|
||||
BluetoothDeviceInfo *deviceInformation = new BluetoothDeviceInfo(deviceInfo);
|
||||
bool isLowEnergy = deviceInfo.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
|
||||
|
||||
qDebug() << "BluetoothDiscovery: [+]" << deviceInformation->name() << "(" << deviceInformation->address() << ")" << (isLowEnergy ? "LE" : "");
|
||||
|
||||
if (!isLowEnergy || deviceInformation->name().isEmpty()) {
|
||||
delete deviceInformation;
|
||||
if (!deviceInfo.isValid()
|
||||
|| !deviceInfo.coreConfigurations().testFlag(QBluetoothDeviceInfo::LowEnergyCoreConfiguration)
|
||||
|| deviceInfo.name().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if we already have added this device info
|
||||
foreach (BluetoothDeviceInfo *di, m_deviceInfos->deviceInfos()) {
|
||||
if (di->address() == deviceInformation->address()) {
|
||||
qWarning() << "BluetoothDiscover: device" << deviceInformation->name() << "(" << deviceInformation->address() << ") already added";
|
||||
deviceInformation->deleteLater();
|
||||
if (di->address() == deviceInfo.address().toString()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BluetoothDeviceInfo *deviceInformation = new BluetoothDeviceInfo(deviceInfo);
|
||||
// qDebug() << "BluetoothDiscovery: [+]" << deviceInformation->name() << "(" << deviceInformation->address() << ")" << (isLowEnergy ? "LE" : "") << deviceInfo.majorDeviceClass() << deviceInfo.minorDeviceClass() << deviceInfo.serviceClasses();
|
||||
m_deviceInfos->addBluetoothDeviceInfo(deviceInformation);
|
||||
}
|
||||
|
||||
void BluetoothDiscovery::discoveryFinished()
|
||||
{
|
||||
qDebug() << "BluetoothDiscovery: Discovery finished";
|
||||
qDebug() << "BluetoothDiscovery: Discovery finished" << m_discoveryEnabled << this;
|
||||
if (m_discoveryEnabled) {
|
||||
qDebug() << "BluetoothDiscovery: Restarting discovery";
|
||||
m_discoveryAgent->start();
|
||||
@ -240,9 +232,9 @@ void BluetoothDiscovery::start()
|
||||
m_discoveryAgent->stop();
|
||||
}
|
||||
|
||||
m_deviceInfos->clearModel();
|
||||
// m_deviceInfos->clearModel();
|
||||
|
||||
qDebug() << "BluetoothDiscovery: Start discovering.";
|
||||
qDebug() << "BluetoothDiscovery: Starting discovery.";
|
||||
m_discoveryAgent->start();
|
||||
emit discoveringChanged();
|
||||
}
|
||||
|
||||
464
libnymea-app/wifisetup/btwifisetup.cpp
Normal file
464
libnymea-app/wifisetup/btwifisetup.cpp
Normal file
@ -0,0 +1,464 @@
|
||||
#include "btwifisetup.h"
|
||||
#include "bluetoothdeviceinfo.h"
|
||||
#include "types/wirelessaccesspoints.h"
|
||||
#include "types/wirelessaccesspoint.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
|
||||
static QBluetoothUuid wifiServiceUuid = QBluetoothUuid(QUuid("e081fec0-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 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 networkStatusCharacteristicUuid = QBluetoothUuid(QUuid("ef6d6611-b8af-49e0-9eca-ab343513641c"));
|
||||
static QBluetoothUuid networkCommanderCharacteristicUuid = QBluetoothUuid(QUuid("ef6d6612-b8af-49e0-9eca-ab343513641c"));
|
||||
static QBluetoothUuid networkResponseCharacteristicUuid = QBluetoothUuid(QUuid("ef6d6613-b8af-49e0-9eca-ab343513641c"));
|
||||
static QBluetoothUuid networkingEnabledCharacteristicUuid = QBluetoothUuid(QUuid("ef6d6614-b8af-49e0-9eca-ab343513641c"));
|
||||
static QBluetoothUuid wirelessEnabledCharacteristicUuid = QBluetoothUuid(QUuid("ef6d6615-b8af-49e0-9eca-ab343513641c"));
|
||||
|
||||
static QBluetoothUuid systemServiceUuid = QBluetoothUuid(QUuid("e081fed0-f757-4449-b9c9-bfa83133f7fc"));
|
||||
static QBluetoothUuid systemCommanderCharacteristicUuid = QBluetoothUuid(QUuid("e081fed1-f757-4449-b9c9-bfa83133f7fc"));
|
||||
static QBluetoothUuid systemResponseCharacteristicUuid = QBluetoothUuid(QUuid("e081fed2-f757-4449-b9c9-bfa83133f7fc"));
|
||||
|
||||
BtWiFiSetup::BtWiFiSetup(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_accessPoints = new WirelessAccessPoints(this);
|
||||
qRegisterMetaType<BluetoothDeviceInfo*>("const BluetoothDeviceInfo*");
|
||||
}
|
||||
|
||||
void BtWiFiSetup::connectToDevice(const BluetoothDeviceInfo *device)
|
||||
{
|
||||
qDebug() << "device" << device;
|
||||
if (m_btController) {
|
||||
delete m_btController;
|
||||
m_currentConnection = nullptr;
|
||||
currentConnectionChanged();
|
||||
m_accessPoints->clearModel();
|
||||
m_bluetoothStatus = BluetoothStatusDisconnected;
|
||||
emit bluetoothStatusChanged(m_bluetoothStatus);
|
||||
|
||||
}
|
||||
|
||||
m_btController = QLowEnergyController::createCentral(device->bluetoothDeviceInfo(), this);
|
||||
connect(m_btController, &QLowEnergyController::connected, this, [this](){
|
||||
qDebug() << "Bluetooth connected";
|
||||
m_btController->discoverServices();
|
||||
m_bluetoothStatus = BluetoothStatusConnectedToBluetooth;
|
||||
emit bluetoothStatusChanged(m_bluetoothStatus);
|
||||
});
|
||||
|
||||
connect(m_btController, &QLowEnergyController::disconnected, this, [this](){
|
||||
qDebug() << "Bluetooth disconnected";
|
||||
m_bluetoothStatus = BluetoothStatusDisconnected;
|
||||
emit bluetoothStatusChanged(m_bluetoothStatus);
|
||||
m_btController->deleteLater();
|
||||
m_btController = nullptr;
|
||||
m_currentConnection = nullptr;
|
||||
emit currentConnectionChanged();
|
||||
m_accessPoints->clearModel();
|
||||
});
|
||||
|
||||
typedef void (QLowEnergyController::*errorsSignal)(QLowEnergyController::Error);
|
||||
connect(m_btController, static_cast<errorsSignal>(&QLowEnergyController::error), this, [this](QLowEnergyController::Error error){
|
||||
qDebug() << "Bluetooth error:" << error;
|
||||
emit this->bluetoothConnectionError();
|
||||
});
|
||||
|
||||
connect(m_btController, &QLowEnergyController::discoveryFinished, this, [this](){
|
||||
qDebug() << "Bluetooth service discovery finished";
|
||||
setupServices();
|
||||
});
|
||||
|
||||
m_bluetoothStatus = BluetoothStatusConnectingToBluetooth;
|
||||
emit bluetoothStatusChanged(m_bluetoothStatus);
|
||||
m_btController->connectToDevice();
|
||||
}
|
||||
|
||||
void BtWiFiSetup::disconnectFromDevice()
|
||||
{
|
||||
if (m_btController) {
|
||||
m_btController->disconnectFromDevice();
|
||||
}
|
||||
}
|
||||
|
||||
void BtWiFiSetup::connectDeviceToWiFi(const QString &ssid, const QString &password)
|
||||
{
|
||||
if (m_bluetoothStatus != BluetoothStatusConnectedToBluetooth) {
|
||||
qWarning() << "Cannot connect to wifi in state" << m_bluetoothStatus;
|
||||
}
|
||||
|
||||
QVariantMap request;
|
||||
request.insert("c", (int)WirelessServiceCommandConnect);
|
||||
QVariantMap parameters;
|
||||
parameters.insert("e", ssid);
|
||||
parameters.insert("p", password);
|
||||
request.insert("p", parameters);
|
||||
streamData(m_wifiService, wifiCommanderCharacteristicUuid, request);
|
||||
}
|
||||
|
||||
void BtWiFiSetup::disconnectDeviceFromWiFi()
|
||||
{
|
||||
if (m_bluetoothStatus != BluetoothStatusConnectedToBluetooth) {
|
||||
qWarning() << "Cannot disconnect from wifi in state" << m_bluetoothStatus;
|
||||
}
|
||||
QVariantMap request;
|
||||
request.insert("c", (int)WirelessServiceCommandDisconnect);
|
||||
streamData(m_wifiService, wifiCommanderCharacteristicUuid, request);
|
||||
}
|
||||
|
||||
void BtWiFiSetup::scanWiFi()
|
||||
{
|
||||
if (m_bluetoothStatus != BluetoothStatusConnectedToBluetooth) {
|
||||
qWarning() << "Cannot disconnect from wifi in state" << m_bluetoothStatus;
|
||||
}
|
||||
QVariantMap request;
|
||||
request.insert("c", (int)WirelessServiceCommandScan);
|
||||
streamData(m_wifiService, wifiCommanderCharacteristicUuid, request);
|
||||
}
|
||||
|
||||
bool BtWiFiSetup::pressPushButton()
|
||||
{
|
||||
if (!m_systemService) {
|
||||
qDebug() << "System service not available. Cannot perform push button pairing";
|
||||
return false;
|
||||
}
|
||||
QVariantMap request;
|
||||
request.insert("c", (int)SystemServiceCommandPushAuthentication);
|
||||
|
||||
streamData(m_systemService, systemCommanderCharacteristicUuid, request);
|
||||
return true;
|
||||
}
|
||||
|
||||
BtWiFiSetup::BluetoothStatus BtWiFiSetup::bluetoothStatus() const
|
||||
{
|
||||
return m_bluetoothStatus;
|
||||
}
|
||||
|
||||
QString BtWiFiSetup::modelNumber() const
|
||||
{
|
||||
return m_modelNumber;
|
||||
}
|
||||
|
||||
QString BtWiFiSetup::manufacturer() const
|
||||
{
|
||||
return m_manufacturer;
|
||||
}
|
||||
|
||||
QString BtWiFiSetup::softwareRevision() const
|
||||
{
|
||||
return m_softwareRevision;
|
||||
}
|
||||
|
||||
QString BtWiFiSetup::firmwareRevision() const
|
||||
{
|
||||
return m_firmwareRevision;
|
||||
}
|
||||
|
||||
QString BtWiFiSetup::hardwareRevision() const
|
||||
{
|
||||
return m_hardwareRevision;
|
||||
}
|
||||
|
||||
BtWiFiSetup::NetworkStatus BtWiFiSetup::networkStatus() const
|
||||
{
|
||||
return m_networkStatus;
|
||||
}
|
||||
|
||||
BtWiFiSetup::WirelessStatus BtWiFiSetup::wirelessStatus() const
|
||||
{
|
||||
return m_wirelessStatus;
|
||||
}
|
||||
|
||||
bool BtWiFiSetup::networkingEnabled() const
|
||||
{
|
||||
return m_networkingEnabled;
|
||||
}
|
||||
|
||||
void BtWiFiSetup::setNetworkingEnabled(bool networkingEnabled)
|
||||
{
|
||||
if (m_bluetoothStatus != BluetoothStatusConnectedToBluetooth) {
|
||||
qWarning() << "Cannot disconnect from wifi in state" << m_bluetoothStatus;
|
||||
}
|
||||
QLowEnergyCharacteristic characteristic = m_networkService->characteristic(networkCommanderCharacteristicUuid);
|
||||
m_networkService->writeCharacteristic(characteristic, networkingEnabled ? QByteArray::fromHex("00") : QByteArray::fromHex("01"));
|
||||
}
|
||||
|
||||
bool BtWiFiSetup::wirelessEnabled() const
|
||||
{
|
||||
return m_wirelessEnabled;
|
||||
}
|
||||
|
||||
void BtWiFiSetup::setWirelessEnabled(bool wirelessEnabled) const
|
||||
{
|
||||
if (m_bluetoothStatus != BluetoothStatusConnectedToBluetooth) {
|
||||
qWarning() << "Cannot disconnect from wifi in state" << m_bluetoothStatus;
|
||||
}
|
||||
QLowEnergyCharacteristic characteristic = m_networkService->characteristic(networkCommanderCharacteristicUuid);
|
||||
m_networkService->writeCharacteristic(characteristic, wirelessEnabled ? QByteArray::fromHex("02") : QByteArray::fromHex("03"));
|
||||
}
|
||||
|
||||
WirelessAccessPoints *BtWiFiSetup::accessPoints() const
|
||||
{
|
||||
return m_accessPoints;
|
||||
}
|
||||
|
||||
WirelessAccessPoint *BtWiFiSetup::currentConnection() const
|
||||
{
|
||||
return m_currentConnection;
|
||||
}
|
||||
|
||||
void BtWiFiSetup::setupServices()
|
||||
{
|
||||
qDebug() << "Setting up Bluetooth services";
|
||||
m_deviceInformationService = m_btController->createServiceObject(QBluetoothUuid::DeviceInformation, m_btController);
|
||||
m_networkService = m_btController->createServiceObject(networkServiceUuid, m_btController);
|
||||
m_wifiService = m_btController->createServiceObject(wifiServiceUuid, m_btController);
|
||||
m_systemService = m_btController->createServiceObject(systemServiceUuid, m_btController);
|
||||
|
||||
if (!m_wifiService || !m_deviceInformationService || !m_networkService) {
|
||||
qWarning() << "Required services not found on remote device.";
|
||||
m_btController->disconnectFromDevice();
|
||||
return;
|
||||
}
|
||||
|
||||
// Device information
|
||||
connect(m_deviceInformationService, &QLowEnergyService::stateChanged, this, [this](QLowEnergyService::ServiceState state) {
|
||||
if (state != QLowEnergyService::ServiceDiscovered)
|
||||
return;
|
||||
qDebug() << "Device info service discovered";
|
||||
m_manufacturer = QString::fromUtf8(m_deviceInformationService->characteristic(QBluetoothUuid::ManufacturerNameString).value());
|
||||
emit manufacturerChanged();
|
||||
m_modelNumber = QString::fromUtf8(m_deviceInformationService->characteristic(QBluetoothUuid::ModelNumberString).value());
|
||||
emit modelNumberChanged();
|
||||
m_softwareRevision = QString::fromUtf8(m_deviceInformationService->characteristic(QBluetoothUuid::SoftwareRevisionString).value());
|
||||
emit softwareRevisionChanged();
|
||||
m_firmwareRevision = QString::fromUtf8(m_deviceInformationService->characteristic(QBluetoothUuid::FirmwareRevisionString).value());
|
||||
emit firmwareRevisionChanged();
|
||||
m_hardwareRevision = QString::fromUtf8(m_deviceInformationService->characteristic(QBluetoothUuid::HardwareRevisionString).value());
|
||||
emit hardwareRevisionChanged();
|
||||
});
|
||||
m_deviceInformationService->discoverDetails();
|
||||
|
||||
|
||||
// network service
|
||||
connect(m_networkService, &QLowEnergyService::stateChanged, this, [this](QLowEnergyService::ServiceState state){
|
||||
if (state != QLowEnergyService::ServiceDiscovered)
|
||||
return;
|
||||
qDebug() << "Network service discovered";
|
||||
QLowEnergyCharacteristic networkCharacteristic = m_networkService->characteristic(networkStatusCharacteristicUuid);
|
||||
QLowEnergyCharacteristic networkingEnabledCharacteristic = m_networkService->characteristic(networkingEnabledCharacteristicUuid);
|
||||
QLowEnergyCharacteristic wirelessEnabledCharacteristic = m_networkService->characteristic(wirelessEnabledCharacteristicUuid);
|
||||
if (!networkCharacteristic.isValid() || !networkingEnabledCharacteristic.isValid() || !wirelessEnabledCharacteristic.isValid()) {
|
||||
qWarning() << "Required characteristics not found on remote device (NetworkService)";
|
||||
m_btController->disconnectFromDevice();
|
||||
return;
|
||||
}
|
||||
// Enable notifications
|
||||
m_networkService->writeDescriptor(networkCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
|
||||
m_networkService->writeDescriptor(networkingEnabledCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
|
||||
m_networkService->writeDescriptor(wirelessEnabledCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
|
||||
|
||||
m_networkStatus = static_cast<NetworkStatus>(networkCharacteristic.value().toHex().toUInt(nullptr, 16));
|
||||
emit networkStatusChanged();
|
||||
m_networkingEnabled = networkingEnabledCharacteristic.value().toHex().toUInt(nullptr, 16);
|
||||
emit networkingEnabledChanged();
|
||||
m_wirelessEnabled = wirelessEnabledCharacteristic.value().toHex().toUInt(nullptr, 16);
|
||||
emit wirelessEnabledChanged();
|
||||
|
||||
});
|
||||
connect(m_networkService, &QLowEnergyService::characteristicChanged, this, &BtWiFiSetup::characteristicChanged);
|
||||
m_networkService->discoverDetails();
|
||||
|
||||
// Wifi service
|
||||
connect(m_wifiService, &QLowEnergyService::stateChanged, this, [this](QLowEnergyService::ServiceState state){
|
||||
if (state != QLowEnergyService::ServiceDiscovered)
|
||||
return;
|
||||
|
||||
qDebug() << "Wifi service discovered";
|
||||
|
||||
// Enable notifations
|
||||
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"));
|
||||
|
||||
qDebug() << "Fetching networks after init";
|
||||
loadNetworks();
|
||||
});
|
||||
connect(m_wifiService, &QLowEnergyService::characteristicChanged, this, &BtWiFiSetup::characteristicChanged);
|
||||
m_wifiService->discoverDetails();
|
||||
|
||||
|
||||
// System service (optional)
|
||||
if (m_systemService) {
|
||||
connect(m_systemService, &QLowEnergyService::stateChanged, this, [this](QLowEnergyService::ServiceState state){
|
||||
if (state != QLowEnergyService::ServiceDiscovered)
|
||||
return;
|
||||
qDebug() << "System service discovered";
|
||||
m_systemService->writeDescriptor(m_systemService->characteristic(systemResponseCharacteristicUuid).descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), QByteArray::fromHex("0100"));
|
||||
});
|
||||
m_systemService->discoverDetails();
|
||||
}
|
||||
}
|
||||
|
||||
void BtWiFiSetup::streamData(QLowEnergyService *service, const QUuid &characteristicUuid, const QVariantMap &request)
|
||||
{
|
||||
QLowEnergyCharacteristic characteristic = service->characteristic(characteristicUuid);
|
||||
QByteArray data = QJsonDocument::fromVariant(request).toJson(QJsonDocument::Compact) + '\n';
|
||||
|
||||
int sentDataLength = 0;
|
||||
QByteArray remainingData = data;
|
||||
while (!remainingData.isEmpty()) {
|
||||
QByteArray package = remainingData.left(20);
|
||||
sentDataLength += package.count();
|
||||
m_wifiService->writeCharacteristic(characteristic, package);
|
||||
remainingData = remainingData.remove(0, package.count());
|
||||
}
|
||||
}
|
||||
|
||||
void BtWiFiSetup::processWiFiPacket(const QVariantMap &data)
|
||||
{
|
||||
WirelessServiceCommand command = static_cast<WirelessServiceCommand>(data.value("c").toInt());
|
||||
WirelessServiceResponse responseCode = (WirelessServiceResponse)data.value("r").toInt();
|
||||
if (responseCode != WirelessServiceResponseSuccess) {
|
||||
qWarning() << "Error in wifi command" << command << ":" << responseCode;
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "command reply:" << command;
|
||||
switch (command) {
|
||||
case WirelessServiceCommandGetNetworks:
|
||||
|
||||
foreach (const QVariant &data, data.value("p").toList()) {
|
||||
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->setMacAddress(data.toMap().value("m").toString());
|
||||
accessPoint->setSignalStrength(data.toMap().value("s").toInt());
|
||||
accessPoint->setProtected(data.toMap().value("p").toBool());
|
||||
accessPoint->setHostAddress("");
|
||||
m_accessPoints->addWirelessAccessPoint(accessPoint);
|
||||
|
||||
}
|
||||
loadCurrentConnection();
|
||||
break;
|
||||
case WirelessServiceCommandConnect:
|
||||
qDebug() << "Connect call succeeded";
|
||||
break;
|
||||
case WirelessServiceCommandGetCurrentConnection:
|
||||
// Find current network
|
||||
if (!data.value("p").toMap().value("m").toString().isEmpty() && data.value("p").toMap().value("i").toString().isEmpty()) {
|
||||
// There's a bug in libnymea-networkmanager that sometimes it emits current connection before it actually obtained the IP address
|
||||
qDebug() << "Retring to fetch the current connection because IP is not set yet.";
|
||||
loadCurrentConnection();
|
||||
return;
|
||||
}
|
||||
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();
|
||||
|
||||
if (m_bluetoothStatus != BluetoothStatusLoaded) {
|
||||
m_bluetoothStatus = BluetoothStatusLoaded;
|
||||
emit bluetoothStatusChanged(m_bluetoothStatus);
|
||||
}
|
||||
|
||||
break;
|
||||
case WirelessServiceCommandScan:
|
||||
if (responseCode == WirelessServiceResponseSuccess) {
|
||||
qDebug() << "Fetching networks after wifi scan";
|
||||
loadNetworks();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
qWarning() << "Unhandled command reply";
|
||||
}
|
||||
}
|
||||
|
||||
void BtWiFiSetup::loadNetworks()
|
||||
{
|
||||
QVariantMap request;
|
||||
request.insert("c", (int)WirelessServiceCommandGetNetworks);
|
||||
streamData(m_wifiService, wifiCommanderCharacteristicUuid, request);
|
||||
}
|
||||
|
||||
void BtWiFiSetup::loadCurrentConnection()
|
||||
{
|
||||
QVariantMap request;
|
||||
request.insert("c", (int)WirelessServiceCommandGetCurrentConnection);
|
||||
streamData(m_wifiService, wifiCommanderCharacteristicUuid, request);
|
||||
}
|
||||
|
||||
void BtWiFiSetup::characteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &value)
|
||||
{
|
||||
if (characteristic.uuid() == wifiResponseCharacteristicUuid) {
|
||||
|
||||
m_inputBuffers[characteristic.uuid()].append(value);
|
||||
if (!m_inputBuffers[characteristic.uuid()].endsWith("\n")) {
|
||||
return;
|
||||
}
|
||||
QByteArray data = m_inputBuffers.take(characteristic.uuid());
|
||||
QJsonParseError error;
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(data.trimmed(), &error);
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qWarning() << "Invalid json data received:" << error.errorString() << data.trimmed() << "from characteristic:" << characteristic.uuid();
|
||||
m_btController->disconnectFromDevice();
|
||||
return;
|
||||
}
|
||||
processWiFiPacket(jsonDoc.toVariant().toMap());
|
||||
|
||||
} else if (characteristic.uuid() == wifiStatusCharacteristicUuid) {
|
||||
|
||||
m_wirelessStatus = static_cast<WirelessStatus>(value.toHex().toInt(nullptr, 16));
|
||||
qDebug() << "Wireless status changed" << m_wirelessStatus;
|
||||
emit wirelessStatusChanged();
|
||||
|
||||
if (m_wirelessStatus == WirelessStatusFailed) {
|
||||
emit wifiSetupError();
|
||||
} else if (m_wirelessStatus == WirelessStatusActivated) {
|
||||
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) {
|
||||
m_networkStatus = static_cast<NetworkStatus>(value.toHex().toInt(nullptr, 16));
|
||||
qDebug() << "Network status changed:" << m_networkStatus;
|
||||
if (m_networkStatus == NetworkStatusGlobal || m_networkStatus == NetworkStatusLocal || m_networkStatus == NetworkStatusConnectedSite) {
|
||||
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 {
|
||||
qWarning() << "Unhandled packet from characteristic" << characteristic.uuid();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,53 +1,18 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* 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
|
||||
#ifndef BTWIFISETUP_H
|
||||
#define BTWIFISETUP_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QBluetoothDeviceInfo>
|
||||
#include <QLowEnergyController>
|
||||
|
||||
#include "bluetoothdevice.h"
|
||||
|
||||
class WirelessAccessPoint;
|
||||
class BluetoothDeviceInfo;
|
||||
class WirelessAccessPoints;
|
||||
class WirelessAccessPointsProxy;
|
||||
class WirelessAccessPoint;
|
||||
|
||||
class WirelessSetupManager : public BluetoothDevice
|
||||
class BtWiFiSetup : public QObject
|
||||
{
|
||||
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(BluetoothStatus bluetoothStatus READ bluetoothStatus NOTIFY bluetoothStatusChanged)
|
||||
|
||||
Q_PROPERTY(QString modelNumber READ modelNumber NOTIFY modelNumberChanged)
|
||||
Q_PROPERTY(QString manufacturer READ manufacturer NOTIFY manufacturerChanged)
|
||||
@ -57,10 +22,49 @@ class WirelessSetupManager : public BluetoothDevice
|
||||
|
||||
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)
|
||||
Q_PROPERTY(bool networkingEnabled READ networkingEnabled WRITE setNetworkingEnabled NOTIFY networkingEnabledChanged)
|
||||
Q_PROPERTY(bool wirelessEnabled READ wirelessEnabled WRITE setWirelessEnabled NOTIFY wirelessEnabledChanged)
|
||||
|
||||
Q_PROPERTY(WirelessAccessPoints *accessPoints READ accessPoints CONSTANT)
|
||||
Q_PROPERTY(WirelessAccessPoint *currentConnection READ currentConnection NOTIFY currentConnectionChanged)
|
||||
|
||||
public:
|
||||
enum BluetoothStatus {
|
||||
BluetoothStatusDisconnected,
|
||||
BluetoothStatusConnectingToBluetooth,
|
||||
BluetoothStatusConnectedToBluetooth,
|
||||
BluetoothStatusLoaded,
|
||||
};
|
||||
Q_ENUM(BluetoothStatus)
|
||||
|
||||
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)
|
||||
|
||||
enum WirelessServiceCommand {
|
||||
WirelessServiceCommandInvalid = -1,
|
||||
@ -118,36 +122,17 @@ public:
|
||||
};
|
||||
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 BtWiFiSetup(QObject *parent = nullptr);
|
||||
|
||||
explicit WirelessSetupManager(const QBluetoothDeviceInfo &deviceInfo, QObject *parent = nullptr);
|
||||
Q_INVOKABLE void connectToDevice(const BluetoothDeviceInfo *device);
|
||||
Q_INVOKABLE void disconnectFromDevice();
|
||||
Q_INVOKABLE void connectDeviceToWiFi(const QString &ssid, const QString &password);
|
||||
Q_INVOKABLE void disconnectDeviceFromWiFi();
|
||||
Q_INVOKABLE void scanWiFi();
|
||||
Q_INVOKABLE bool pressPushButton();
|
||||
|
||||
BluetoothStatus bluetoothStatus() const;
|
||||
|
||||
QString modelNumber() const;
|
||||
QString manufacturer() const;
|
||||
@ -155,40 +140,28 @@ public:
|
||||
QString firmwareRevision() const;
|
||||
QString hardwareRevision() const;
|
||||
|
||||
bool initialized() const;
|
||||
bool working() const;
|
||||
|
||||
NetworkStatus networkStatus() const;
|
||||
WirelessSetupManager::WirelessStatus wirelessStatus() const;
|
||||
|
||||
WirelessStatus wirelessStatus() const;
|
||||
bool networkingEnabled() const;
|
||||
void setNetworkingEnabled(bool networkingEnabled);
|
||||
|
||||
bool wirelessEnabled() const;
|
||||
void setWirelessEnabled(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 bluetoothStatusChanged(BluetoothStatus status);
|
||||
void bluetoothConnectionError();
|
||||
void wifiSetupError();
|
||||
|
||||
void modelNumberChanged();
|
||||
void manufacturerChanged();
|
||||
void softwareRevisionChanged();
|
||||
void firmwareRevisionChanged();
|
||||
void hardwareRevisionChanged();
|
||||
|
||||
void initializedChanged();
|
||||
void workingChanged();
|
||||
|
||||
void networkStatusChanged();
|
||||
void wirelessStatusChanged();
|
||||
void networkingEnabledChanged();
|
||||
@ -196,36 +169,27 @@ signals:
|
||||
|
||||
void currentConnectionChanged();
|
||||
|
||||
void errorOccurred(const QString &errorMessage);
|
||||
private:
|
||||
void setupServices();
|
||||
void streamData(QLowEnergyService *service, const QUuid &characteristicUuid, const QVariantMap &request);
|
||||
void processWiFiPacket(const QVariantMap &data);
|
||||
|
||||
void loadNetworks();
|
||||
void loadCurrentConnection();
|
||||
|
||||
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);
|
||||
void characteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &value);
|
||||
|
||||
private:
|
||||
BluetoothStatus m_bluetoothStatus = BluetoothStatusDisconnected;
|
||||
QLowEnergyController *m_btController = nullptr;
|
||||
|
||||
QLowEnergyService *m_deviceInformationService = nullptr;
|
||||
QLowEnergyService *m_netwokService = nullptr;
|
||||
QLowEnergyService *m_networkService = nullptr;
|
||||
QLowEnergyService *m_wifiService = nullptr;
|
||||
QLowEnergyService *m_systemService = nullptr;
|
||||
|
||||
WirelessAccessPoints *m_accessPoints = nullptr;
|
||||
WirelessAccessPoint *m_currentConnection = nullptr;
|
||||
QHash<QUuid, QByteArray> m_inputBuffers;
|
||||
|
||||
QString m_modelNumber;
|
||||
QString m_manufacturer;
|
||||
@ -233,43 +197,14 @@ private:
|
||||
QString m_firmwareRevision;
|
||||
QString m_hardwareRevision;
|
||||
|
||||
NetworkStatus m_networkStatus = NetworkStatusUnknown;
|
||||
WirelessStatus m_wirelessStatus = WirelessStatusUnknown;
|
||||
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);
|
||||
WirelessAccessPoints *m_accessPoints = nullptr;
|
||||
WirelessAccessPoint *m_currentConnection = nullptr;
|
||||
|
||||
};
|
||||
|
||||
#endif // WIRELESSSETUPMANAGER_H
|
||||
#endif // BTWIFISETUP_H
|
||||
@ -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->getBluetoothDeviceInfo(), 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
@ -130,13 +130,11 @@ ApplicationWindow {
|
||||
anchors.bottomMargin: keyboardRect.height
|
||||
}
|
||||
|
||||
NymeaDiscovery {
|
||||
id: discovery
|
||||
property NymeaDiscovery nymeaDiscovery: NymeaDiscovery {
|
||||
objectName: "discovery"
|
||||
awsClient: AWSClient
|
||||
// discovering: pageStack.currentItem.objectName === "discoveryPage"
|
||||
}
|
||||
property alias _discovery: discovery
|
||||
|
||||
property var supportedInterfaces: [
|
||||
"light",
|
||||
|
||||
@ -84,7 +84,7 @@ Item {
|
||||
d.pushSettingsPage("connection/wifisetup/BluetoothDiscoveryPage.qml");
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
@ -164,7 +164,7 @@ Item {
|
||||
}
|
||||
|
||||
Binding {
|
||||
target: _discovery
|
||||
target: nymeaDiscovery
|
||||
property: "discovering"
|
||||
value: engine.jsonRpcClient.currentHost === null
|
||||
}
|
||||
@ -180,11 +180,11 @@ Item {
|
||||
Component.onCompleted: {
|
||||
setupPushNotifications();
|
||||
if (autoConnectHost.length > 0) {
|
||||
var host = discovery.nymeaHosts.createLanHost("Manual connection", autoConnectHost);
|
||||
var host = nymeaDiscovery.nymeaHosts.createLanHost("Manual connection", autoConnectHost);
|
||||
engine.jsonRpcClient.connectToHost(host)
|
||||
} else if (tabSettings.lastConnectedHost.length > 0) {
|
||||
print("Last connected host was", tabSettings.lastConnectedHost)
|
||||
var cachedHost = discovery.nymeaHosts.find(tabSettings.lastConnectedHost);
|
||||
var cachedHost = nymeaDiscovery.nymeaHosts.find(tabSettings.lastConnectedHost);
|
||||
if (cachedHost) {
|
||||
engine.jsonRpcClient.connectToHost(cachedHost)
|
||||
return;
|
||||
@ -343,14 +343,14 @@ Item {
|
||||
var popup = certDialogComponent.createObject(root);
|
||||
popup.accepted.connect(function(){
|
||||
engine.jsonRpcClient.acceptCertificate(serverUuid, pem);
|
||||
engine.jsonRpcClient.connectToHost(discovery.nymeaHosts.find(serverUuid));
|
||||
engine.jsonRpcClient.connectToHost(nymeaDiscovery.nymeaHosts.find(serverUuid));
|
||||
})
|
||||
popup.open();
|
||||
}
|
||||
onConnectedChanged: {
|
||||
print("json client connected changed", engine.jsonRpcClient.connected)
|
||||
if (engine.jsonRpcClient.connected) {
|
||||
discovery.cacheHost(engine.jsonRpcClient.currentHost)
|
||||
nymeaDiscovery.cacheHost(engine.jsonRpcClient.currentHost)
|
||||
tabSettings.lastConnectedHost = engine.jsonRpcClient.serverUuid
|
||||
}
|
||||
init();
|
||||
|
||||
@ -126,7 +126,7 @@ SettingsPageBase {
|
||||
onClicked: {
|
||||
print("clicked, connected:", engine.jsonRpcClient.connected, model.id)
|
||||
if (!engine.jsonRpcClient.connected) {
|
||||
var host = discovery.nymeaHosts.find(model.id)
|
||||
var host = nymeaDiscovery.nymeaHosts.find(model.id)
|
||||
engine.jsonRpcClient.connectToHost(host);
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ Page {
|
||||
|
||||
NymeaHostsFilterModel {
|
||||
id: hostsProxy
|
||||
discovery: _discovery
|
||||
discovery: nymeaDiscovery
|
||||
showUnreachableBearers: false
|
||||
jsonRpcClient: engine.jsonRpcClient
|
||||
showUnreachableHosts: false
|
||||
@ -220,16 +220,16 @@ Page {
|
||||
Layout.leftMargin: app.margins
|
||||
Layout.rightMargin: app.margins
|
||||
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)
|
||||
}
|
||||
Button {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: app.margins
|
||||
Layout.rightMargin: app.margins
|
||||
visible: discovery.nymeaHosts.count === 0
|
||||
visible: nymeaDiscovery.nymeaHosts.count === 0
|
||||
text: qsTr("Start wireless setup")
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("wifisetup/BluetoothDiscoveryPage.qml"), {nymeaDiscovery: discovery})
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("wifisetup/BluetoothDiscoveryPage.qml"))
|
||||
}
|
||||
Button {
|
||||
Layout.fillWidth: true
|
||||
@ -245,10 +245,10 @@ Page {
|
||||
Layout.leftMargin: app.margins
|
||||
Layout.rightMargin: app.margins
|
||||
Layout.bottomMargin: app.margins
|
||||
visible: discovery.nymeaHosts.count === 0
|
||||
visible: nymeaDiscovery.nymeaHosts.count === 0
|
||||
text: qsTr("Demo mode (online)")
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ Page {
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,57 +41,72 @@ Page {
|
||||
onBackPressed: pageStack.pop()
|
||||
}
|
||||
|
||||
property var nymeaDiscovery: null
|
||||
|
||||
BluetoothDiscovery {
|
||||
id: bluetoothDiscovery
|
||||
discoveryEnabled: pageStack.currentItem === root
|
||||
}
|
||||
|
||||
NetworkManagerController {
|
||||
id: networkManager
|
||||
BtWiFiSetup {
|
||||
id: wifiSetup
|
||||
|
||||
onBluetoothStatusChanged: {
|
||||
print("status changed", status)
|
||||
switch (status) {
|
||||
case BtWiFiSetup.BluetoothStatusDisconnected:
|
||||
pageStack.pop(root)
|
||||
break;
|
||||
case BtWiFiSetup.BluetoothStatusConnectingToBluetooth:
|
||||
break;
|
||||
case BtWiFiSetup.BluetoothStatusConnectedToBluetooth:
|
||||
break;
|
||||
case BtWiFiSetup.BluetoothStatusLoaded:
|
||||
if (!wifiSetup.networkingEnabled) {
|
||||
wifiSetup.networkingEnabled = true;
|
||||
}
|
||||
if (!wifiSetup.wirelessEnabled) {
|
||||
wifiSetup.wirelessEnabled = true;
|
||||
}
|
||||
setupDevice()
|
||||
break;
|
||||
}
|
||||
}
|
||||
onWirelessStatusChanged: {
|
||||
|
||||
}
|
||||
|
||||
onBluetoothConnectionError: {
|
||||
print("Error")
|
||||
pageStack.pop(root)
|
||||
}
|
||||
onWirelessEnabledChanged: {
|
||||
if (wirelessEnabled) {
|
||||
scanWiFi();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function connectDevice(btDeviceInfo) {
|
||||
networkManager.bluetoothDeviceInfo = btDeviceInfo
|
||||
networkManager.connectDevice();
|
||||
wifiSetup.connectToDevice(btDeviceInfo)
|
||||
print("**** connecting")
|
||||
pageStack.push(connectingPageComponent, {deviceName: btDeviceInfo.name})
|
||||
}
|
||||
|
||||
function setupDevice() {
|
||||
pageStack.pop(root, StackView.Immediate)
|
||||
if (networkManager.manager.currentConnection) {
|
||||
print("***** pushing WirelessSetupPage with networkManager:", networkManager)
|
||||
var page = pageStack.push(Qt.resolvedUrl("WirelessSetupPage.qml"), { networkManagerController: networkManager, nymeaDiscovery: root.nymeaDiscovery } )
|
||||
if (wifiSetup.currentConnection) {
|
||||
var page = pageStack.push(Qt.resolvedUrl("WirelessSetupPage.qml"), { wifiSetup: wifiSetup } )
|
||||
page.done.connect(function() {
|
||||
pageStack.pop(root, StackView.Immediate);
|
||||
pageStack.pop();
|
||||
})
|
||||
} 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() {
|
||||
setupDevice();
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: networkManager.manager
|
||||
onInitializedChanged: {
|
||||
if (networkManager.manager.initialized) {
|
||||
setupDevice()
|
||||
} else {
|
||||
pageStack.pop(root)
|
||||
}
|
||||
}
|
||||
|
||||
onConnectedChanged: {
|
||||
if (!networkManager.manager.connected) {
|
||||
pageStack.pop(root)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
|
||||
@ -41,7 +41,7 @@ Page {
|
||||
onBackPressed: pageStack.pop()
|
||||
}
|
||||
|
||||
property var networkManagerController: null
|
||||
property BtWiFiSetup wifiSetup: null
|
||||
|
||||
ColumnLayout {
|
||||
anchors { left: parent.left; top: parent.top; right: parent.right }
|
||||
@ -50,31 +50,31 @@ Page {
|
||||
Layout.fillWidth: true
|
||||
progressive: false
|
||||
text: qsTr("System UUID")
|
||||
subText: networkManagerController.manager.modelNumber
|
||||
subText: wifiSetup.modelNumber
|
||||
}
|
||||
NymeaSwipeDelegate {
|
||||
Layout.fillWidth: true
|
||||
progressive: false
|
||||
text: qsTr("Manufacturer")
|
||||
subText: networkManagerController.manager.manufacturer
|
||||
subText: wifiSetup.manufacturer
|
||||
}
|
||||
NymeaSwipeDelegate {
|
||||
Layout.fillWidth: true
|
||||
progressive: false
|
||||
text: qsTr("Software revision")
|
||||
subText: networkManagerController.manager.softwareRevision
|
||||
subText: wifiSetup.softwareRevision
|
||||
}
|
||||
NymeaSwipeDelegate {
|
||||
Layout.fillWidth: true
|
||||
progressive: false
|
||||
text: qsTr("Firmware revision")
|
||||
subText: networkManagerController.manager.firmwareRevision
|
||||
subText: wifiSetup.firmwareRevision
|
||||
}
|
||||
NymeaSwipeDelegate {
|
||||
Layout.fillWidth: true
|
||||
progressive: false
|
||||
text: qsTr("Hardware revision")
|
||||
subText: networkManagerController.manager.hardwareRevision
|
||||
subText: wifiSetup.hardwareRevision
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ import Nymea 1.0
|
||||
Page {
|
||||
id: root
|
||||
|
||||
property var networkManagerController: null
|
||||
property BtWiFiSetup wifiSetup: null
|
||||
|
||||
signal connected();
|
||||
|
||||
@ -50,13 +50,13 @@ Page {
|
||||
HeaderButton {
|
||||
imageSource: "../images/info.svg"
|
||||
onClicked: {
|
||||
pageStack.push(Qt.resolvedUrl("BoxInfoPage.qml"), {networkManagerController: root.networkManagerController})
|
||||
pageStack.push(Qt.resolvedUrl("BoxInfoPage.qml"), {wifiSetup: root.wifiSetup})
|
||||
}
|
||||
}
|
||||
HeaderButton {
|
||||
imageSource: "../images/settings.svg"
|
||||
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
|
||||
|
||||
model: WirelessAccessPointsProxy {
|
||||
accessPoints: networkManagerController.manager.accessPoints
|
||||
accessPoints: wifiSetup.accessPoints
|
||||
}
|
||||
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 {
|
||||
width: parent.width
|
||||
text: model.ssid !== "" ? model.ssid : qsTr("Hidden Network")
|
||||
enabled: !networkManagerController.manager.working
|
||||
subText: model.hostAddress
|
||||
|
||||
iconColor: model.selectedNetwork ? Style.accentColor : "#808080"
|
||||
@ -136,16 +148,16 @@ Page {
|
||||
property string macAddress
|
||||
|
||||
Connections {
|
||||
target: root.networkManagerController.manager
|
||||
target: root.wifiSetup
|
||||
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!")
|
||||
root.connected();
|
||||
}
|
||||
}
|
||||
onWirelessStatusChanged: {
|
||||
print("Wireless status changed:", networkManagerController.manager.networkStatus)
|
||||
if (networkManagerController.manager.wirelessStatus === WirelessSetupManager.WirelessStatusFailed) {
|
||||
print("Wireless status changed:", wifiSetup.networkStatus)
|
||||
if (wifiSetup.wirelessStatus === BtWiFiSetup.WirelessStatusFailed) {
|
||||
wrongPasswordText.visible = true
|
||||
pageStack.pop(authenticationPage)
|
||||
}
|
||||
@ -199,7 +211,7 @@ Page {
|
||||
text: qsTr("OK")
|
||||
enabled: passwordTextField.displayText.length >= 8
|
||||
onClicked: {
|
||||
root.networkManagerController.manager.connectWirelessNetwork(authenticationPage.ssid, passwordTextField.text)
|
||||
root.wifiSetup.connectDeviceToWiFi(authenticationPage.ssid, passwordTextField.text)
|
||||
pageStack.push(connectingWifiWaitPageComponent, {ssid: authenticationPage.ssid })
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ Page {
|
||||
onBackPressed: pageStack.pop()
|
||||
}
|
||||
|
||||
property var networkManagerController: null
|
||||
property BtWiFiSetup wifiSetup: null
|
||||
|
||||
ColumnLayout {
|
||||
anchors { left: parent.left; top: parent.top; right: parent.right }
|
||||
@ -49,17 +49,17 @@ Page {
|
||||
SwitchDelegate {
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("Networking")
|
||||
checked: networkManagerController.manager.networkingEnabled
|
||||
onClicked: networkManagerController.manager.enableNetworking(checked)
|
||||
checked: wifiSetup.networkingEnabled
|
||||
onClicked: wifiSetup.networkingEnabled = checked
|
||||
}
|
||||
|
||||
SwitchDelegate {
|
||||
Layout.fillWidth: true
|
||||
enabled: networkManagerController.manager.networkingEnabled
|
||||
enabled: wifiSetup.networkingEnabled
|
||||
text: qsTr("Wireless network")
|
||||
checked: networkManagerController.manager.wirelessEnabled
|
||||
checked: wifiSetup.wirelessEnabled
|
||||
onClicked: {
|
||||
networkManagerController.manager.enableWireless(checked)
|
||||
wifiSetup.wirelessEnabled = checked
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ Page {
|
||||
Layout.leftMargin: app.margins
|
||||
Layout.rightMargin: app.margins
|
||||
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 {
|
||||
id: root
|
||||
|
||||
property var networkManagerController: null
|
||||
property var nymeaDiscovery: null
|
||||
property BtWiFiSetup wifiSetup: null
|
||||
|
||||
signal done()
|
||||
|
||||
@ -51,25 +50,24 @@ Page {
|
||||
HeaderButton {
|
||||
imageSource: "../images/info.svg"
|
||||
onClicked: {
|
||||
pageStack.push(Qt.resolvedUrl("BoxInfoPage.qml"), {networkManagerController: root.networkManagerController})
|
||||
pageStack.push(Qt.resolvedUrl("BoxInfoPage.qml"), {wifiSetup: root.wifiSetup})
|
||||
}
|
||||
}
|
||||
HeaderButton {
|
||||
imageSource: "../images/settings.svg"
|
||||
onClicked: {
|
||||
pageStack.push(Qt.resolvedUrl("NetworkSettingsPage.qml"), {networkManagerController: root.networkManagerController})
|
||||
pageStack.push(Qt.resolvedUrl("NetworkSettingsPage.qml"), {wifiSetup: root.wifiSetup})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
print("created with networkmanagercontroller:", root.networkManagerController)
|
||||
updateConnectButton();
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: root.networkManagerController.manager
|
||||
onErrorOccurred: {
|
||||
target: root.wifiSetup
|
||||
onWifiSetupError: {
|
||||
print("Error occurred", errorMessage)
|
||||
var errorDialog = Qt.createComponent(Qt.resolvedUrl("../components/ErrorDialog.qml"));
|
||||
var popup = errorDialog.createObject(app, {text: errorMessage})
|
||||
@ -82,29 +80,29 @@ Page {
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: root.nymeadiscovery.nymeaHosts
|
||||
target: nymeaDiscovery.nymeaHosts
|
||||
onCountChanged: updateConnectButton();
|
||||
}
|
||||
|
||||
function updateConnectButton() {
|
||||
if (!root.networkManagerController.manager.currentConnection) {
|
||||
connectButton.url = "";
|
||||
if (!root.wifiSetup.currentConnection) {
|
||||
connectButton.host = null;
|
||||
return;
|
||||
}
|
||||
|
||||
// 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 j = 0; j < root.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) {
|
||||
connectButton.url = root.nymeadiscovery.nymeaHosts.get(i).connections.get(j).url
|
||||
for (var i = 0; i < nymeaDiscovery.nymeaHosts.count; i++) {
|
||||
for (var j = 0; j < nymeaDiscovery.nymeaHosts.get(i).connections.count; j++) {
|
||||
if (nymeaDiscovery.nymeaHosts.get(i).connections.get(j).url.toString().indexOf(root.wifiSetup.currentConnection.hostAddress) >= 0) {
|
||||
connectButton.host = nymeaDiscovery.nymeaHosts.get(i)
|
||||
return;
|
||||
}
|
||||
}
|
||||
root.nymeadiscovery.nymeaHosts.get(i).connections.countChanged.connect(function() {
|
||||
nymeaDiscovery.nymeaHosts.get(i).connections.countChanged.connect(function() {
|
||||
updateConnectButton();
|
||||
})
|
||||
}
|
||||
connectButton.url = "";
|
||||
connectButton.host = null;
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
@ -121,15 +119,15 @@ Page {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
||||
wrapMode: Text.WordWrap
|
||||
text: root.networkManagerController.manager.currentConnection
|
||||
? qsTr("Your %1:core is connected to %2").arg(app.systemName).arg(root.networkManagerController.manager.currentConnection.ssid)
|
||||
text: root.wifiSetup.currentConnection
|
||||
? qsTr("Your %1:core is connected to %2").arg(app.systemName).arg(root.wifiSetup.currentConnection.ssid)
|
||||
: ""
|
||||
}
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
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
|
||||
}
|
||||
|
||||
@ -147,13 +145,14 @@ Page {
|
||||
|
||||
Button {
|
||||
id: connectButton
|
||||
visible: url != ""
|
||||
visible: host !== null
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
||||
text: qsTr("Connect to %1:core").arg(app.systemName)
|
||||
property string url
|
||||
property NymeaHost host: null
|
||||
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
|
||||
text: qsTr("Change network")
|
||||
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() {
|
||||
pageStack.pop(root)
|
||||
})
|
||||
|
||||
@ -69,7 +69,6 @@ Page {
|
||||
id: d
|
||||
property var vendorId: null
|
||||
property ThingDescriptor thingDescriptor: null
|
||||
property alias deviceDescriptor: d.thingDescriptor
|
||||
property var discoveryParams: []
|
||||
property string deviceName: ""
|
||||
property int pairRequestId: 0
|
||||
@ -86,7 +85,7 @@ Page {
|
||||
internalPageStack.push(discoveryParamsPage)
|
||||
} else {
|
||||
print("Starting discovery...")
|
||||
discovery.discoverDevices(deviceClass.id)
|
||||
discovery.discoverThings(deviceClass.id)
|
||||
internalPageStack.push(discoveryPage, {deviceClass: deviceClass})
|
||||
}
|
||||
} else if (root.deviceClass.createMethods.indexOf("CreateMethodUser") !== -1) {
|
||||
@ -171,7 +170,7 @@ Page {
|
||||
}
|
||||
}
|
||||
|
||||
DeviceDiscovery {
|
||||
ThingDiscovery {
|
||||
id: discovery
|
||||
engine: _engine
|
||||
}
|
||||
@ -218,7 +217,7 @@ Page {
|
||||
param["value"] = paramRepeater.itemAt(i).value
|
||||
d.discoveryParams.push(param);
|
||||
}
|
||||
discovery.discoverDevices(root.deviceClass.id, d.discoveryParams)
|
||||
discovery.discoverThings(root.deviceClass.id, d.discoveryParams)
|
||||
internalPageStack.push(discoveryPage, {deviceClass: root.deviceClass})
|
||||
}
|
||||
}
|
||||
@ -259,12 +258,12 @@ Page {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
clip: true
|
||||
model: DeviceDiscoveryProxy {
|
||||
model: ThingDiscoveryProxy {
|
||||
id: discoveryProxy
|
||||
deviceDiscovery: discovery
|
||||
thingDiscovery: discovery
|
||||
showAlreadyAdded: root.device !== null
|
||||
showNew: root.device === null
|
||||
filterDeviceId: root.device ? root.device.id : ""
|
||||
filterThingId: root.device ? root.device.id : ""
|
||||
}
|
||||
delegate: NymeaSwipeDelegate {
|
||||
width: parent.width
|
||||
@ -273,7 +272,7 @@ Page {
|
||||
subText: model.description
|
||||
iconName: app.interfacesToIcon(discoveryView.deviceClass.interfaces)
|
||||
onClicked: {
|
||||
d.deviceDescriptor = discoveryProxy.get(index);
|
||||
d.thingDescriptor = discoveryProxy.get(index);
|
||||
d.deviceName = model.name;
|
||||
internalPageStack.push(paramsPage)
|
||||
}
|
||||
@ -284,7 +283,7 @@ Page {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
||||
text: qsTr("Search again")
|
||||
onClicked: discovery.discoverDevices(root.deviceClass.id, d.discoveryParams)
|
||||
onClicked: discovery.discoverThings(root.deviceClass.id, d.discoveryParams)
|
||||
visible: !discovery.busy
|
||||
}
|
||||
|
||||
@ -384,7 +383,7 @@ Page {
|
||||
|
||||
Repeater {
|
||||
id: paramRepeater
|
||||
model: engine.jsonRpcClient.ensureServerVersion("1.12") || d.deviceDescriptor == null ? root.deviceClass.paramTypes : null
|
||||
model: engine.jsonRpcClient.ensureServerVersion("1.12") || d.thingDescriptor == null ? root.deviceClass.paramTypes : null
|
||||
delegate: ParamDelegate {
|
||||
// Layout.preferredHeight: 60
|
||||
Layout.fillWidth: true
|
||||
@ -441,14 +440,14 @@ Page {
|
||||
switch (root.deviceClass.setupMethod) {
|
||||
case 0:
|
||||
if (root.device) {
|
||||
if (d.deviceDescriptor) {
|
||||
engine.deviceManager.reconfigureDiscoveredDevice(root.device.id, d.deviceDescriptor.id, params);
|
||||
if (d.thingDescriptor) {
|
||||
engine.deviceManager.reconfigureDiscoveredDevice(root.device.id, d.thingDescriptor.id, params);
|
||||
} else {
|
||||
engine.deviceManager.reconfigureDevice(root.device.id, params);
|
||||
}
|
||||
} else {
|
||||
if (d.deviceDescriptor) {
|
||||
engine.deviceManager.addDiscoveredDevice(root.deviceClass.id, d.deviceDescriptor.id, nameTextField.text, params);
|
||||
if (d.thingDescriptor) {
|
||||
engine.deviceManager.addDiscoveredDevice(root.deviceClass.id, d.thingDescriptor.id, nameTextField.text, params);
|
||||
} else {
|
||||
engine.deviceManager.addDevice(root.deviceClass.id, nameTextField.text, params);
|
||||
}
|
||||
@ -460,15 +459,15 @@ Page {
|
||||
case 4:
|
||||
case 5:
|
||||
if (root.device) {
|
||||
if (d.deviceDescriptor) {
|
||||
engine.deviceManager.pairDiscoveredDevice(root.deviceClass.id, d.deviceDescriptor.id, params, nameTextField.text);
|
||||
if (d.thingDescriptor) {
|
||||
engine.deviceManager.pairDiscoveredDevice(root.deviceClass.id, d.thingDescriptor.id, params, nameTextField.text);
|
||||
} else {
|
||||
engine.deviceManager.rePairDevice(root.device.id, params, nameTextField.text);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
if (d.deviceDescriptor) {
|
||||
engine.deviceManager.pairDiscoveredDevice(root.deviceClass.id, d.deviceDescriptor.id, params, nameTextField.text);
|
||||
if (d.thingDescriptor) {
|
||||
engine.deviceManager.pairDiscoveredDevice(root.deviceClass.id, d.thingDescriptor.id, params, nameTextField.text);
|
||||
} else {
|
||||
engine.deviceManager.pairDevice(root.deviceClass.id, params, nameTextField.text);
|
||||
}
|
||||
|
||||
@ -54,6 +54,10 @@ SettingsPageBase {
|
||||
text: root.thingClass.displayName
|
||||
subText: root.thingClass.id.toString().replace(/[{}]/g, "")
|
||||
progressive: false
|
||||
onClicked: {
|
||||
PlatformHelper.toClipBoard(subText);
|
||||
ToolTip.show(qsTr("ID copied to clipboard"), 500);
|
||||
}
|
||||
}
|
||||
|
||||
SettingsPageSectionHeader {
|
||||
|
||||
Reference in New Issue
Block a user