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
72f1a42b
Commit
72f1a42b
authored
Dec 26, 2018
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Done with desktop
parent
68a5ab42
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
129 additions
and
26 deletions
+129
-26
TaisyncManager.cc
src/Taisync/TaisyncManager.cc
+63
-5
TaisyncManager.h
src/Taisync/TaisyncManager.h
+6
-0
TaisyncSettings.cc
src/Taisync/TaisyncSettings.cc
+10
-4
TaisyncSettings.qml
src/Taisync/TaisyncSettings.qml
+50
-17
No files found.
src/Taisync/TaisyncManager.cc
View file @
72f1a42b
...
...
@@ -24,6 +24,9 @@ static const char *kVIDEO_RATE = "VideoRate";
static
const
char
*
kLOCAL_IP
=
"LocalIP"
;
static
const
char
*
kREMOTE_IP
=
"RemoteIP"
;
static
const
char
*
kNET_MASK
=
"NetMask"
;
static
const
char
*
kRTSP_URI
=
"RTSPURI"
;
static
const
char
*
kRTSP_ACCOUNT
=
"RTSPAccount"
;
static
const
char
*
kRTSP_PASSWORD
=
"RTSPPassword"
;
//-----------------------------------------------------------------------------
TaisyncManager
::
TaisyncManager
(
QGCApplication
*
app
,
QGCToolbox
*
toolbox
)
...
...
@@ -36,6 +39,9 @@ TaisyncManager::TaisyncManager(QGCApplication* app, QGCToolbox* toolbox)
_localIPAddr
=
settings
.
value
(
kLOCAL_IP
,
QString
(
"192.168.199.33"
)).
toString
();
_remoteIPAddr
=
settings
.
value
(
kREMOTE_IP
,
QString
(
"192.168.199.16"
)).
toString
();
_netMask
=
settings
.
value
(
kNET_MASK
,
QString
(
"255.255.255.0"
)).
toString
();
_rtspURI
=
settings
.
value
(
kRTSP_URI
,
QString
(
"rtsp://192.168.0.2"
)).
toString
();
_rtspAccount
=
settings
.
value
(
kRTSP_ACCOUNT
,
QString
(
"admin"
)).
toString
();
_rtspPassword
=
settings
.
value
(
kRTSP_PASSWORD
,
QString
(
"12345678"
)).
toString
();
settings
.
endGroup
();
}
...
...
@@ -80,6 +86,8 @@ TaisyncManager::_reset()
_close
();
_isConnected
=
false
;
emit
connectedChanged
();
_linkConnected
=
false
;
emit
linkConnectedChanged
();
_taiSettings
=
new
TaisyncSettings
(
this
);
connect
(
_taiSettings
,
&
TaisyncSettings
::
updateSettings
,
this
,
&
TaisyncManager
::
_updateSettings
);
connect
(
_taiSettings
,
&
TaisyncSettings
::
connected
,
this
,
&
TaisyncManager
::
_connected
);
...
...
@@ -186,7 +194,23 @@ bool
TaisyncManager
::
setRTSPSettings
(
QString
uri
,
QString
account
,
QString
password
)
{
if
(
_taiSettings
)
{
return
_taiSettings
->
setRTSPSettings
(
uri
,
account
,
password
);
if
(
_taiSettings
->
setRTSPSettings
(
uri
,
account
,
password
))
{
_rtspURI
=
uri
;
_rtspAccount
=
account
;
_rtspPassword
=
password
;
QSettings
settings
;
settings
.
beginGroup
(
kTAISYNC_GROUP
);
settings
.
setValue
(
kRTSP_URI
,
_rtspURI
);
settings
.
setValue
(
kRTSP_ACCOUNT
,
_rtspAccount
);
settings
.
setValue
(
kRTSP_PASSWORD
,
_rtspPassword
);
settings
.
endGroup
();
emit
rtspURIChanged
();
emit
rtspAccountChanged
();
emit
rtspPasswordChanged
();
_needReboot
=
true
;
emit
needRebootChanged
();
return
true
;
}
}
return
false
;
}
...
...
@@ -198,10 +222,14 @@ TaisyncManager::setIPSettings(QString localIP_, QString remoteIP_, QString netMa
bool
res
=
false
;
if
(
_localIPAddr
!=
localIP_
||
_remoteIPAddr
!=
remoteIP_
||
_netMask
!=
netMask_
)
{
//-- If we are connected to the Taisync
if
(
_
link
Connected
)
{
if
(
_
is
Connected
)
{
if
(
_taiSettings
)
{
//-- Change IP settings
res
=
_taiSettings
->
setIPSettings
(
localIP_
,
remoteIP_
,
netMask_
);
if
(
res
)
{
_needReboot
=
true
;
emit
needRebootChanged
();
}
}
}
else
{
//-- We're not connected. Record the change and restart.
...
...
@@ -369,6 +397,8 @@ TaisyncManager::_connected()
qCDebug
(
TaisyncLog
)
<<
"Taisync Settings Connected"
;
_isConnected
=
true
;
emit
connectedChanged
();
_needReboot
=
false
;
emit
needRebootChanged
();
}
//-----------------------------------------------------------------------------
...
...
@@ -378,6 +408,10 @@ TaisyncManager::_disconnected()
qCDebug
(
TaisyncLog
)
<<
"Taisync Settings Disconnected"
;
_isConnected
=
false
;
emit
connectedChanged
();
_needReboot
=
false
;
emit
needRebootChanged
();
_linkConnected
=
false
;
emit
linkConnectedChanged
();
_reset
();
}
...
...
@@ -424,6 +458,17 @@ TaisyncManager::_checkTaisync()
_taiSettings
->
requestIPSettings
();
break
;
}
//-- Check link status
if
(
_timeoutTimer
.
elapsed
()
>
3000
)
{
//-- Give up and restart
_disconnected
();
break
;
}
//-- If it's been too long since we last heard, ping it.
if
(
_timeoutTimer
.
elapsed
()
>
1000
)
{
_taiSettings
->
requestLinkStatus
();
break
;
}
break
;
}
}
...
...
@@ -435,6 +480,7 @@ TaisyncManager::_checkTaisync()
void
TaisyncManager
::
_updateSettings
(
QByteArray
jSonData
)
{
_timeoutTimer
.
start
();
qCDebug
(
TaisyncVerbose
)
<<
jSonData
;
QJsonParseError
jsonParseError
;
QJsonDocument
doc
=
QJsonDocument
::
fromJson
(
jSonData
,
&
jsonParseError
);
...
...
@@ -522,20 +568,32 @@ TaisyncManager::_updateSettings(QByteArray jSonData)
//-- RTSP URI Settings?
}
else
if
(
jSonData
.
contains
(
"
\"
rtspURI
\"
:"
))
{
QString
value
;
bool
changed
=
false
;
value
=
jObj
[
"rtspURI"
].
toString
(
_rtspURI
);
if
(
value
!=
_rtspURI
)
{
_rtspURI
=
value
;
changed
=
true
;
emit
rtspURIChanged
();
}
value
=
jObj
[
"account"
].
toString
(
_rtspAccount
);
if
(
value
!=
_rtspAccount
)
{
_rtspAccount
=
value
;
changed
=
true
;
emit
rtspAccountChanged
();
}
value
=
jObj
[
"passwd"
].
toString
(
_rtspPassword
);
if
(
value
!=
_rtspPassword
)
{
_rtspPassword
=
value
;
changed
=
true
;
emit
rtspPasswordChanged
();
}
if
(
changed
)
{
QSettings
settings
;
settings
.
beginGroup
(
kTAISYNC_GROUP
);
settings
.
setValue
(
kRTSP_URI
,
_rtspURI
);
settings
.
setValue
(
kRTSP_ACCOUNT
,
_rtspAccount
);
settings
.
setValue
(
kRTSP_PASSWORD
,
_rtspPassword
);
settings
.
endGroup
();
}
}
}
src/Taisync/TaisyncManager.h
View file @
72f1a42b
...
...
@@ -19,6 +19,7 @@
#endif
#include <QTimer>
#include <QTime>
class
AppSettings
;
class
QGCApplication
;
...
...
@@ -31,6 +32,7 @@ public:
Q_PROPERTY
(
bool
connected
READ
connected
NOTIFY
connectedChanged
)
Q_PROPERTY
(
bool
linkConnected
READ
linkConnected
NOTIFY
linkConnectedChanged
)
Q_PROPERTY
(
bool
needReboot
READ
needReboot
NOTIFY
needRebootChanged
)
Q_PROPERTY
(
QString
linkVidFormat
READ
linkVidFormat
NOTIFY
linkChanged
)
Q_PROPERTY
(
int
uplinkRSSI
READ
uplinkRSSI
NOTIFY
linkChanged
)
Q_PROPERTY
(
int
downlinkRSSI
READ
downlinkRSSI
NOTIFY
linkChanged
)
...
...
@@ -58,6 +60,7 @@ public:
bool
connected
()
{
return
_isConnected
;
}
bool
linkConnected
()
{
return
_linkConnected
;
}
bool
needReboot
()
{
return
_needReboot
;
}
QString
linkVidFormat
()
{
return
_linkVidFormat
;
}
int
uplinkRSSI
()
{
return
_downlinkRSSI
;
}
int
downlinkRSSI
()
{
return
_uplinkRSSI
;
}
...
...
@@ -88,6 +91,7 @@ signals:
void
localIPAddrChanged
();
void
remoteIPAddrChanged
();
void
netMaskChanged
();
void
needRebootChanged
();
private
slots
:
void
_connected
();
...
...
@@ -135,6 +139,7 @@ private:
bool
_enableVideo
=
true
;
bool
_enabled
=
true
;
bool
_linkConnected
=
false
;
bool
_needReboot
=
false
;
QTimer
_workTimer
;
QString
_linkVidFormat
;
int
_downlinkRSSI
=
0
;
...
...
@@ -163,4 +168,5 @@ private:
QString
_localIPAddr
;
QString
_remoteIPAddr
;
QString
_netMask
;
QTime
_timeoutTimer
;
};
src/Taisync/TaisyncSettings.cc
View file @
72f1a42b
...
...
@@ -158,12 +158,18 @@ void
TaisyncSettings
::
_readBytes
()
{
QByteArray
bytesIn
=
_tcpSocket
->
read
(
_tcpSocket
->
bytesAvailable
());
//qCDebug(TaisyncVerbose) << "Taisync settings data:" << bytesIn.size();
//qCDebug(TaisyncVerbose) << QString(bytesIn);
//-- Go straight to Json payload
int
idx
=
bytesIn
.
indexOf
(
'{'
);
//-- We may receive more than one response within one TCP packet.
while
(
idx
>=
0
)
{
bytesIn
=
bytesIn
.
mid
(
idx
);
idx
=
bytesIn
.
indexOf
(
'}'
);
if
(
idx
>
0
)
{
emit
updateSettings
(
bytesIn
.
mid
(
idx
));
QByteArray
data
=
bytesIn
.
left
(
idx
+
1
);
emit
updateSettings
(
data
);
bytesIn
=
bytesIn
.
mid
(
idx
+
1
);
idx
=
bytesIn
.
indexOf
(
'{'
);
}
}
}
src/Taisync/TaisyncSettings.qml
View file @
72f1a42b
...
...
@@ -58,6 +58,13 @@ QGCView {
width
:
_qgcView
.
width
spacing
:
ScreenTools
.
defaultFontPixelHeight
*
0.5
anchors.margins
:
ScreenTools
.
defaultFontPixelWidth
QGCLabel
{
text
:
qsTr
(
"
Reboot ground unit for changes to take effect.
"
)
color
:
qgcPal
.
colorOrange
visible
:
QGroundControl
.
taisyncManager
.
needReboot
font.family
:
ScreenTools
.
demiboldFontFamily
anchors.horizontalCenter
:
parent
.
horizontalCenter
}
//-----------------------------------------------------------------
//-- General
Item
{
...
...
@@ -86,13 +93,14 @@ QGCView {
FactCheckBox
{
text
:
qsTr
(
"
Enable Taisync
"
)
fact
:
_taisyncEnabledFact
enabled
:
!
QGroundControl
.
taisyncManager
.
needReboot
visible
:
_taisyncEnabledFact
.
visible
}
FactCheckBox
{
text
:
qsTr
(
"
Enable Taisync Video
"
)
fact
:
_taisyncVideoEnabledFact
visible
:
_taisyncVideoEnabledFact
.
visible
enabled
:
_taisyncEnabled
enabled
:
_taisyncEnabled
&&
!
QGroundControl
.
taisyncManager
.
needReboot
}
}
}
...
...
@@ -245,7 +253,7 @@ QGCView {
FactComboBox
{
fact
:
QGroundControl
.
taisyncManager
.
radioMode
indexModel
:
true
enabled
:
QGroundControl
.
taisyncManager
.
linkConnected
enabled
:
QGroundControl
.
taisyncManager
.
linkConnected
&&
!
QGroundControl
.
taisyncManager
.
needReboot
Layout.minimumWidth
:
_valueWidth
}
QGCLabel
{
...
...
@@ -254,7 +262,7 @@ QGCView {
FactComboBox
{
fact
:
QGroundControl
.
taisyncManager
.
radioChannel
indexModel
:
true
enabled
:
QGroundControl
.
taisyncManager
.
linkConnected
&&
QGroundControl
.
taisyncManager
.
radioMode
.
rawValue
>
0
enabled
:
QGroundControl
.
taisyncManager
.
linkConnected
&&
QGroundControl
.
taisyncManager
.
radioMode
.
rawValue
>
0
&&
!
QGroundControl
.
taisyncManager
.
needReboot
Layout.minimumWidth
:
_valueWidth
}
}
...
...
@@ -298,7 +306,7 @@ QGCView {
FactComboBox
{
fact
:
QGroundControl
.
taisyncManager
.
videoOutput
indexModel
:
true
enabled
:
QGroundControl
.
taisyncManager
.
linkConnected
enabled
:
QGroundControl
.
taisyncManager
.
linkConnected
&&
!
QGroundControl
.
taisyncManager
.
needReboot
Layout.minimumWidth
:
_valueWidth
}
QGCLabel
{
...
...
@@ -307,7 +315,7 @@ QGCView {
FactComboBox
{
fact
:
QGroundControl
.
taisyncManager
.
videoMode
indexModel
:
true
enabled
:
QGroundControl
.
taisyncManager
.
linkConnected
enabled
:
QGroundControl
.
taisyncManager
.
linkConnected
&&
!
QGroundControl
.
taisyncManager
.
needReboot
Layout.minimumWidth
:
_valueWidth
}
QGCLabel
{
...
...
@@ -316,7 +324,7 @@ QGCView {
FactComboBox
{
fact
:
QGroundControl
.
taisyncManager
.
videoRate
indexModel
:
true
enabled
:
QGroundControl
.
taisyncManager
.
linkConnected
enabled
:
QGroundControl
.
taisyncManager
.
linkConnected
&&
!
QGroundControl
.
taisyncManager
.
needReboot
Layout.minimumWidth
:
_valueWidth
}
}
...
...
@@ -329,7 +337,7 @@ QGCView {
height
:
rtspSettingsLabel
.
height
anchors.margins
:
ScreenTools
.
defaultFontPixelWidth
anchors.horizontalCenter
:
parent
.
horizontalCenter
visible
:
_taisyncEnabled
&&
QGroundControl
.
taisyncManager
.
linkC
onnected
visible
:
_taisyncEnabled
&&
QGroundControl
.
taisyncManager
.
c
onnected
QGCLabel
{
id
:
rtspSettingsLabel
text
:
qsTr
(
"
Streaming Settings
"
)
...
...
@@ -340,7 +348,7 @@ QGCView {
height
:
rtspSettingsCol
.
height
+
(
ScreenTools
.
defaultFontPixelHeight
*
2
)
width
:
_panelWidth
color
:
qgcPal
.
windowShade
visible
:
_taisyncEnabled
&&
QGroundControl
.
taisyncManager
.
linkC
onnected
visible
:
_taisyncEnabled
&&
QGroundControl
.
taisyncManager
.
c
onnected
anchors.margins
:
ScreenTools
.
defaultFontPixelWidth
anchors.horizontalCenter
:
parent
.
horizontalCenter
Column
{
...
...
@@ -360,7 +368,7 @@ QGCView {
QGCTextField
{
id
:
rtspURI
text
:
QGroundControl
.
taisyncManager
.
rtspURI
enabled
:
QGroundControl
.
taisyncManager
.
linkConnected
enabled
:
QGroundControl
.
taisyncManager
.
connected
&&
!
QGroundControl
.
taisyncManager
.
needReboot
inputMethodHints
:
Qt
.
ImhUrlCharactersOnly
Layout.minimumWidth
:
_valueWidth
}
...
...
@@ -370,7 +378,7 @@ QGCView {
QGCTextField
{
id
:
rtspAccount
text
:
QGroundControl
.
taisyncManager
.
rtspAccount
enabled
:
QGroundControl
.
taisyncManager
.
linkConnected
enabled
:
QGroundControl
.
taisyncManager
.
connected
&&
!
QGroundControl
.
taisyncManager
.
needReboot
Layout.minimumWidth
:
_valueWidth
}
QGCLabel
{
...
...
@@ -379,28 +387,46 @@ QGCView {
QGCTextField
{
id
:
rtspPassword
text
:
QGroundControl
.
taisyncManager
.
rtspPassword
enabled
:
QGroundControl
.
taisyncManager
.
linkConnected
enabled
:
QGroundControl
.
taisyncManager
.
connected
&&
!
QGroundControl
.
taisyncManager
.
needReboot
inputMethodHints
:
Qt
.
ImhHiddenText
Layout.minimumWidth
:
_valueWidth
}
}
Item
{
width
:
1
height
:
ScreenTools
.
defaultFontPixelHeight
}
QGCButton
{
function
testEnabled
()
{
if
(
!
QGroundControl
.
taisyncManager
.
linkC
onnected
)
if
(
!
QGroundControl
.
taisyncManager
.
c
onnected
)
return
false
if
(
rtspPassword
.
text
===
QGroundControl
.
taisyncManager
.
rtspPassword
&&
rtspAccount
===
QGroundControl
.
taisyncManager
.
rtspAccount
&&
rtspURI
===
QGroundControl
.
taisyncManager
.
rtspURI
)
rtspAccount
.
text
===
QGroundControl
.
taisyncManager
.
rtspAccount
&&
rtspURI
.
text
===
QGroundControl
.
taisyncManager
.
rtspURI
)
return
false
if
(
rtspURI
===
""
)
return
false
return
true
}
enabled
:
testEnabled
()
enabled
:
testEnabled
()
&&
!
QGroundControl
.
taisyncManager
.
needReboot
text
:
qsTr
(
"
Apply
"
)
anchors.horizontalCenter
:
parent
.
horizontalCenter
onClicked
:
{
setRTSPDialog
.
open
()
}
MessageDialog
{
id
:
setRTSPDialog
icon
:
StandardIcon
.
Warning
standardButtons
:
StandardButton
.
Yes
|
StandardButton
.
No
title
:
qsTr
(
"
Set Streaming Settings
"
)
text
:
qsTr
(
"
Once changed, you will need to reboot the ground unit for the changes to take effect.
\n\n
Confirm change?
"
)
onYes
:
{
QGroundControl
.
taisyncManager
.
setRTSPSettings
(
rtspURI
.
text
,
rtspAccount
.
text
,
rtspPassword
.
text
)
setRTSPDialog
.
close
()
}
onNo
:
{
setRTSPDialog
.
close
()
}
}
}
}
...
...
@@ -443,6 +469,7 @@ QGCView {
QGCTextField
{
id
:
localIP
text
:
QGroundControl
.
taisyncManager
.
localIPAddr
enabled
:
!
QGroundControl
.
taisyncManager
.
needReboot
inputMethodHints
:
Qt
.
ImhFormattedNumbersOnly
Layout.minimumWidth
:
_valueWidth
}
...
...
@@ -452,6 +479,7 @@ QGCView {
QGCTextField
{
id
:
remoteIP
text
:
QGroundControl
.
taisyncManager
.
remoteIPAddr
enabled
:
!
QGroundControl
.
taisyncManager
.
needReboot
inputMethodHints
:
Qt
.
ImhFormattedNumbersOnly
Layout.minimumWidth
:
_valueWidth
}
...
...
@@ -461,10 +489,15 @@ QGCView {
QGCTextField
{
id
:
netMask
text
:
QGroundControl
.
taisyncManager
.
netMask
enabled
:
!
QGroundControl
.
taisyncManager
.
needReboot
inputMethodHints
:
Qt
.
ImhFormattedNumbersOnly
Layout.minimumWidth
:
_valueWidth
}
}
Item
{
width
:
1
height
:
ScreenTools
.
defaultFontPixelHeight
}
QGCButton
{
function
validateIPaddress
(
ipaddress
)
{
if
(
/^
(
25
[
0-5
]
|2
[
0-4
][
0-9
]
|
[
01
]?[
0-9
][
0-9
]?)\.(
25
[
0-5
]
|2
[
0-4
][
0-9
]
|
[
01
]?[
0-9
][
0-9
]?)\.(
25
[
0-5
]
|2
[
0-4
][
0-9
]
|
[
01
]?[
0-9
][
0-9
]?)\.(
25
[
0-5
]
|2
[
0-4
][
0-9
]
|
[
01
]?[
0-9
][
0-9
]?)
$/
.
test
(
ipaddress
))
...
...
@@ -481,7 +514,7 @@ QGCView {
if
(
!
validateIPaddress
(
netMask
.
text
))
return
false
return
true
}
enabled
:
testEnabled
()
enabled
:
testEnabled
()
&&
!
QGroundControl
.
taisyncManager
.
needReboot
text
:
qsTr
(
"
Apply
"
)
anchors.horizontalCenter
:
parent
.
horizontalCenter
onClicked
:
{
...
...
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