Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
41351f80
Commit
41351f80
authored
Aug 27, 2019
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove debugging code
parent
0f974ebc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
55 deletions
+59
-55
PairingIndicator.qml
custom-example/res/PairingIndicator.qml
+1
-1
PairingManager.cc
src/PairingManager/PairingManager.cc
+19
-17
PairingManager.h
src/PairingManager/PairingManager.h
+39
-37
No files found.
custom-example/res/PairingIndicator.qml
View file @
41351f80
...
...
@@ -443,7 +443,7 @@ Item {
Repeater
{
model
:
parent
.
_pairModel
delegate
:
QGCLabel
{
text
:
modelData
+
'
'
+
QGroundControl
.
pairingManager
.
pairedDeviceNameList
.
length
text
:
modelData
Layout.row
:
index
Layout.column
:
0
Layout.minimumWidth
:
ScreenTools
.
defaultFontPixelWidth
*
14
...
...
src/PairingManager/PairingManager.cc
View file @
41351f80
...
...
@@ -62,6 +62,8 @@ void
PairingManager
::
setToolbox
(
QGCToolbox
*
toolbox
)
{
QGCTool
::
setToolbox
(
toolbox
);
_updatePairedDeviceNameList
();
emit
pairedListChanged
();
}
//-----------------------------------------------------------------------------
...
...
@@ -71,19 +73,20 @@ PairingManager::_pairingCompleted(QString name)
_writeJson
(
_jsonDoc
,
_pairingCacheFile
(
name
));
_remotePairingMap
[
"NM"
]
=
name
;
_lastPaired
=
name
;
_updatePairedDeviceNameList
();
emit
pairedListChanged
();
emit
pairedVehicleChanged
();
_app
->
informationMessageBoxOnMainThread
(
""
,
tr
(
"Paired with %1"
).
arg
(
name
));
//
_app->informationMessageBoxOnMainThread("", tr("Paired with %1").arg(name));
setPairingStatus
(
PairingSuccess
,
tr
(
"Pairing Successfull"
));
}
//-----------------------------------------------------------------------------
void
PairingManager
::
_connectionCompleted
(
QString
name
)
PairingManager
::
_connectionCompleted
(
QString
/*name*/
)
{
//QString pwd = _remotePairingMap["PWD"].toString();
//_toolbox->microhardManager()->switchToConnectionEncryptionKey(pwd);
_app
->
informationMessageBoxOnMainThread
(
""
,
tr
(
"Connected to %1"
).
arg
(
name
));
//
_app->informationMessageBoxOnMainThread("", tr("Connected to %1").arg(name));
setPairingStatus
(
PairingConnected
,
tr
(
"Connection Successfull"
));
}
...
...
@@ -128,7 +131,7 @@ PairingManager::_stopUpload()
//-----------------------------------------------------------------------------
void
PairingManager
::
_uploadFinished
(
void
)
PairingManager
::
_uploadFinished
()
{
QMutexLocker
lock
(
&
_uploadMutex
);
QNetworkReply
*
reply
=
qobject_cast
<
QNetworkReply
*>
(
QObject
::
sender
());
...
...
@@ -198,22 +201,21 @@ PairingManager::removePairedDevice(QString name)
{
QFile
file
(
_pairingCacheFile
(
name
));
file
.
remove
();
_updatePairedDeviceNameList
();
emit
pairedListChanged
();
}
//-----------------------------------------------------------------------------
QStringList
PairingManager
::
pairedDeviceNameList
(
void
)
void
PairingManager
::
_updatePairedDeviceNameList
(
)
{
QStringList
list
;
_deviceList
.
clear
()
;
QDirIterator
it
(
_pairingCacheDir
().
absolutePath
(),
QDir
::
Files
);
while
(
it
.
hasNext
())
{
QFileInfo
fileInfo
(
it
.
next
());
l
ist
.
append
(
fileInfo
.
fileName
());
_deviceL
ist
.
append
(
fileInfo
.
fileName
());
qCDebug
(
PairingManagerLog
)
<<
"Listing: "
<<
fileInfo
.
fileName
();
}
return
list
;
}
//-----------------------------------------------------------------------------
...
...
@@ -226,9 +228,9 @@ PairingManager::_assumeMicrohardPairingJson()
jsonObject
.
insert
(
"LT"
,
"MH"
);
jsonObject
.
insert
(
"IP"
,
"192.168.168.10"
);
jsonObject
.
insert
(
"AIP"
,
_toolbox
->
microhardManager
()
->
remoteIPAddr
());
jsonObject
.
insert
(
"CU"
,
_toolbox
->
microhardManager
()
->
configUserName
());
jsonObject
.
insert
(
"CP"
,
_toolbox
->
microhardManager
()
->
configPassword
());
jsonObject
.
insert
(
"EK"
,
_toolbox
->
microhardManager
()
->
encryptionKey
());
jsonObject
.
insert
(
"CU"
,
_toolbox
->
microhardManager
()
->
configUserName
());
jsonObject
.
insert
(
"CP"
,
_toolbox
->
microhardManager
()
->
configPassword
());
jsonObject
.
insert
(
"EK"
,
_toolbox
->
microhardManager
()
->
encryptionKey
());
json
.
setObject
(
jsonObject
);
return
QString
(
json
.
toJson
(
QJsonDocument
::
Compact
));
...
...
@@ -266,8 +268,8 @@ PairingManager::_parsePairingJson(QString jsonEnc)
}
_remotePairingMap
=
jsonObj
.
toVariantMap
();
QString
linkType
=
_remotePairingMap
[
"LT"
].
toString
();
QString
pport
=
_remotePairingMap
[
"PP"
].
toString
();
QString
linkType
=
_remotePairingMap
[
"LT"
].
toString
();
QString
pport
=
_remotePairingMap
[
"PP"
].
toString
();
if
(
pport
.
length
()
==
0
)
{
pport
=
"29351"
;
}
...
...
@@ -449,7 +451,7 @@ PairingManager::_createMicrohardConnectJson(QString cert2)
//-----------------------------------------------------------------------------
QStringList
PairingManager
::
pairingLinkTypeStrings
(
void
)
PairingManager
::
pairingLinkTypeStrings
()
{
//-- Must follow same order as enum LinkType in LinkConfiguration.h
static
QStringList
list
;
...
...
@@ -478,7 +480,7 @@ PairingManager::_setPairingStatus(PairingStatus status, QString statusStr)
//-----------------------------------------------------------------------------
QString
PairingManager
::
pairingStatusStr
(
void
)
const
PairingManager
::
pairingStatusStr
()
const
{
return
_statusString
;
}
...
...
src/PairingManager/PairingManager.h
View file @
41351f80
...
...
@@ -61,13 +61,13 @@ public:
Q_ENUM
(
PairingStatus
)
QStringList
pairingLinkTypeStrings
(
void
);
QString
pairingStatusStr
(
void
)
const
;
QStringList
pairedDeviceNameList
(
void
);
QStringList
pairingLinkTypeStrings
();
QString
pairingStatusStr
()
const
;
QStringList
pairedDeviceNameList
(
)
{
return
_deviceList
;
}
PairingStatus
pairingStatus
()
{
return
_status
;
}
QString
pairedVehicle
()
{
return
_lastPaired
;
}
int
nfcIndex
(
void
)
{
return
_nfcIndex
;
}
int
microhardIndex
(
void
)
{
return
_microhardIndex
;
}
int
nfcIndex
()
{
return
_nfcIndex
;
}
int
microhardIndex
()
{
return
_microhardIndex
;
}
bool
firstBoot
()
{
return
_firstBoot
;
}
bool
errorState
()
{
return
_status
==
PairingRejected
||
_status
==
PairingConnectionRejected
||
_status
==
PairingError
;
}
void
setStatusMessage
(
PairingStatus
status
,
QString
statusStr
)
{
emit
setPairingStatus
(
status
,
statusStr
);
}
...
...
@@ -98,23 +98,23 @@ public:
Q_PROPERTY
(
bool
firstBoot
READ
firstBoot
WRITE
setFirstBoot
NOTIFY
firstBootChanged
)
signals:
void
startUpload
(
QString
pairURL
,
QJsonDocument
);
void
closeConnection
();
void
pairingConfigurationsChanged
();
void
nameListChanged
();
void
pairingStatusChanged
();
void
parsePairingJson
(
QString
json
);
void
setPairingStatus
(
PairingStatus
status
,
QString
pairingStatus
);
void
pairedListChanged
();
void
pairedVehicleChanged
();
void
firstBootChanged
();
void
startUpload
(
QString
pairURL
,
QJsonDocument
);
void
closeConnection
();
void
pairingConfigurationsChanged
();
void
nameListChanged
();
void
pairingStatusChanged
();
void
parsePairingJson
(
QString
json
);
void
setPairingStatus
(
PairingStatus
status
,
QString
pairingStatus
);
void
pairedListChanged
();
void
pairedVehicleChanged
();
void
firstBootChanged
();
private
slots
:
void
_startUpload
(
QString
pairURL
,
QJsonDocument
);
void
_stopUpload
();
void
_startUploadRequest
();
void
_parsePairingJson
(
QString
jsonEnc
);
void
_setPairingStatus
(
PairingStatus
status
,
QString
pairingStatus
);
void
_startUpload
(
QString
pairURL
,
QJsonDocument
);
void
_stopUpload
();
void
_startUploadRequest
();
void
_parsePairingJson
(
QString
jsonEnc
);
void
_setPairingStatus
(
PairingStatus
status
,
QString
pairingStatus
);
private:
QString
_statusString
;
...
...
@@ -131,24 +131,26 @@ private:
QNetworkAccessManager
*
_uploadManager
=
nullptr
;
QString
_uploadURL
{};
QString
_uploadData
{};
void
_parsePairingJsonFile
();
QJsonDocument
_createZeroTierConnectJson
(
QString
cert2
);
QJsonDocument
_createMicrohardConnectJson
(
QString
cert2
);
QJsonDocument
_createZeroTierPairingJson
(
QString
cert1
);
QJsonDocument
_createMicrohardPairingJson
(
QString
pwd
,
QString
cert1
);
QString
_assumeMicrohardPairingJson
();
void
_writeJson
(
QJsonDocument
&
jsonDoc
,
QString
fileName
);
QString
_getLocalIPInNetwork
(
QString
remoteIP
,
int
num
);
void
_uploadFinished
(
void
);
void
_uploadError
(
QNetworkReply
::
NetworkError
code
);
void
_pairingCompleted
(
QString
name
);
void
_connectionCompleted
(
QString
name
);
QDir
_pairingCacheDir
();
QString
_pairingCacheFile
(
QString
uavName
);
bool
_firstBoot
=
true
;
bool
_firstBoot
=
true
;
QStringList
_deviceList
;
void
_parsePairingJsonFile
();
QJsonDocument
_createZeroTierConnectJson
(
QString
cert2
);
QJsonDocument
_createMicrohardConnectJson
(
QString
cert2
);
QJsonDocument
_createZeroTierPairingJson
(
QString
cert1
);
QJsonDocument
_createMicrohardPairingJson
(
QString
pwd
,
QString
cert1
);
QString
_assumeMicrohardPairingJson
();
void
_writeJson
(
QJsonDocument
&
jsonDoc
,
QString
fileName
);
QString
_getLocalIPInNetwork
(
QString
remoteIP
,
int
num
);
void
_uploadFinished
();
void
_uploadError
(
QNetworkReply
::
NetworkError
code
);
void
_pairingCompleted
(
QString
name
);
void
_connectionCompleted
(
QString
name
);
QDir
_pairingCacheDir
();
QString
_pairingCacheFile
(
QString
uavName
);
void
_updatePairedDeviceNameList
();
#if defined QGC_ENABLE_NFC || defined QGC_ENABLE_QTNFC
PairingNFC
pairingNFC
;
PairingNFC
pairingNFC
;
#endif
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment