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
Expand all
Hide 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
)
...
...
@@ -33,9 +36,12 @@ TaisyncManager::TaisyncManager(QGCApplication* app, QGCToolbox* toolbox)
_workTimer
.
setSingleShot
(
true
);
QSettings
settings
;
settings
.
beginGroup
(
kTAISYNC_GROUP
);
_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
();
_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
(
'{'
);
if
(
idx
>
0
)
{
emit
updateSettings
(
bytesIn
.
mid
(
idx
));
//-- We may receive more than one response within one TCP packet.
while
(
idx
>=
0
)
{
bytesIn
=
bytesIn
.
mid
(
idx
);
idx
=
bytesIn
.
indexOf
(
'}'
);
if
(
idx
>
0
)
{
QByteArray
data
=
bytesIn
.
left
(
idx
+
1
);
emit
updateSettings
(
data
);
bytesIn
=
bytesIn
.
mid
(
idx
+
1
);
idx
=
bytesIn
.
indexOf
(
'{'
);
}
}
}
src/Taisync/TaisyncSettings.qml
View file @
72f1a42b
This diff is collapsed.
Click to expand it.
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