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
80ccf144
Commit
80ccf144
authored
Mar 15, 2019
by
Matej Frančeškin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Microhard - testing connect / reconnect to local and remote MH modems
parent
8bc0c95c
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
167 additions
and
269 deletions
+167
-269
MicrohardHandler.cc
src/Microhard/MicrohardHandler.cc
+0
-13
MicrohardHandler.h
src/Microhard/MicrohardHandler.h
+1
-2
MicrohardManager.cc
src/Microhard/MicrohardManager.cc
+105
-135
MicrohardManager.h
src/Microhard/MicrohardManager.h
+11
-22
MicrohardSettings.cc
src/Microhard/MicrohardSettings.cc
+31
-56
MicrohardSettings.h
src/Microhard/MicrohardSettings.h
+8
-7
MicrohardSettings.qml
src/Microhard/MicrohardSettings.qml
+11
-34
No files found.
src/Microhard/MicrohardHandler.cc
View file @
80ccf144
...
...
@@ -60,16 +60,3 @@ MicrohardHandler::_start(uint16_t port, QHostAddress addr)
return
true
;
}
//-----------------------------------------------------------------------------
void
MicrohardHandler
::
_socketDisconnected
()
{
if
(
_tcpSocket
)
{
qCDebug
(
MicrohardLog
)
<<
"Microhard TCP Connection Closed on port"
<<
_tcpSocket
->
localPort
();
_tcpSocket
->
close
();
_tcpSocket
->
deleteLater
();
_tcpSocket
=
nullptr
;
}
emit
disconnected
();
}
src/Microhard/MicrohardHandler.h
View file @
80ccf144
...
...
@@ -33,12 +33,11 @@ protected:
virtual
bool
_start
(
uint16_t
port
,
QHostAddress
addr
=
QHostAddress
::
AnyIPv4
);
protected
slots
:
virtual
void
_socketDisconnected
();
virtual
void
_readBytes
()
=
0
;
signals:
void
connected
();
void
disconnected
(
);
void
rssiUpdated
(
int
rssi
);
protected:
QTcpSocket
*
_tcpSocket
=
nullptr
;
...
...
src/Microhard/MicrohardManager.cc
View file @
80ccf144
This diff is collapsed.
Click to expand it.
src/Microhard/MicrohardManager.h
View file @
80ccf144
...
...
@@ -28,7 +28,6 @@ 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
(
int
uplinkRSSI
READ
uplinkRSSI
NOTIFY
linkChanged
)
Q_PROPERTY
(
int
downlinkRSSI
READ
downlinkRSSI
NOTIFY
linkChanged
)
Q_PROPERTY
(
QString
localIPAddr
READ
localIPAddr
NOTIFY
localIPAddrChanged
)
...
...
@@ -36,7 +35,7 @@ public:
Q_PROPERTY
(
QString
netMask
READ
netMask
NOTIFY
netMaskChanged
)
Q_PROPERTY
(
QString
configPassword
READ
configPassword
NOTIFY
configPasswordChanged
)
Q_INVOKABLE
bool
setIPSettings
(
QString
localIP
,
QString
remoteIP
,
QString
netMask
);
Q_INVOKABLE
bool
setIPSettings
(
QString
localIP
,
QString
remoteIP
,
QString
netMask
,
QString
cfgPassword
);
explicit
MicrohardManager
(
QGCApplication
*
app
,
QGCToolbox
*
toolbox
);
~
MicrohardManager
()
override
;
...
...
@@ -45,7 +44,6 @@ public:
bool
connected
()
{
return
_isConnected
;
}
bool
linkConnected
()
{
return
_linkConnected
;
}
bool
needReboot
()
{
return
_needReboot
;
}
int
uplinkRSSI
()
{
return
_downlinkRSSI
;
}
int
downlinkRSSI
()
{
return
_uplinkRSSI
;
}
QString
localIPAddr
()
{
return
_localIPAddr
;
}
...
...
@@ -63,15 +61,17 @@ signals:
void
localIPAddrChanged
();
void
remoteIPAddrChanged
();
void
netMaskChanged
();
void
needRebootChanged
();
void
configPasswordChanged
();
private
slots
:
void
_connected
();
void
_disconnected
();
void
_connectedLoc
();
void
_rssiUpdatedLoc
(
int
rssi
);
void
_connectedRem
();
void
_rssiUpdatedRem
(
int
rssi
);
void
_checkMicrohard
();
void
_updateSettings
(
QByteArray
jSonData
);
void
_setEnabled
();
void
_locTimeout
();
void
_remTimeout
();
private:
void
_close
();
...
...
@@ -79,27 +79,16 @@ private:
FactMetaData
*
_createMetadata
(
const
char
*
name
,
QStringList
enums
);
private:
enum
{
REQ_LINK_STATUS
=
1
,
REQ_DEV_INFO
=
2
,
REQ_FREQ_SCAN
=
4
,
REQ_VIDEO_SETTINGS
=
8
,
REQ_RADIO_SETTINGS
=
16
,
REQ_RTSP_SETTINGS
=
32
,
REQ_IP_SETTINGS
=
64
,
REQ_ALL
=
0xFFFFFFF
,
};
uint32_t
_reqMask
=
static_cast
<
uint32_t
>
(
REQ_ALL
);
bool
_running
=
false
;
bool
_isConnected
=
false
;
AppSettings
*
_appSettings
=
nullptr
;
MicrohardSettings
*
_mhSettings
=
nullptr
;
MicrohardSettings
*
_mhSettingsLoc
=
nullptr
;
MicrohardSettings
*
_mhSettingsRem
=
nullptr
;
bool
_enabled
=
true
;
bool
_linkConnected
=
false
;
bool
_needReboot
=
false
;
QTimer
_workTimer
;
QTimer
_locTimer
;
QTimer
_remTimer
;
int
_downlinkRSSI
=
0
;
int
_uplinkRSSI
=
0
;
QString
_localIPAddr
;
...
...
src/Microhard/MicrohardSettings.cc
View file @
80ccf144
...
...
@@ -14,9 +14,10 @@
#include "VideoManager.h"
//-----------------------------------------------------------------------------
MicrohardSettings
::
MicrohardSettings
(
QObject
*
parent
)
MicrohardSettings
::
MicrohardSettings
(
Q
String
address
,
Q
Object
*
parent
)
:
MicrohardHandler
(
parent
)
{
_address
=
address
;
}
//-----------------------------------------------------------------------------
...
...
@@ -24,54 +25,17 @@ bool
MicrohardSettings
::
start
()
{
qCDebug
(
MicrohardLog
)
<<
"Start Microhard Settings"
;
return
_start
(
MICROHARD_SETTINGS_PORT
,
QHostAddress
(
qgcApp
()
->
toolbox
()
->
microhardManager
()
->
remoteIPAddr
()));
_connectionState
=
0
;
return
_start
(
MICROHARD_SETTINGS_PORT
,
QHostAddress
(
_address
));
}
//-----------------------------------------------------------------------------
bool
MicrohardSettings
::
requestLinkStatus
()
{
return
_request
(
"/v1/baseband.json"
);
}
//-----------------------------------------------------------------------------
bool
MicrohardSettings
::
_request
(
const
QString
&
request
)
{
/*
if(_tcpSocket) {
QString req = QString(kGetReq).arg(request);
//qCDebug(MicrohardVerbose) << "Request" << req;
_tcpSocket->write(req.toUtf8());
return true;
}
*/
return
false
;
}
//-----------------------------------------------------------------------------
bool
MicrohardSettings
::
_post
(
const
QString
&
post
,
const
QString
&
postPayload
)
void
MicrohardSettings
::
getStatus
()
{
/*
if(_tcpSocket) {
QString req = QString(kPostReq).arg(post).arg(postPayload.size()).arg(postPayload);
qCDebug(MicrohardVerbose) << "Post" << req;
_tcpSocket->write(req.toUtf8());
return true;
if
(
_connectionState
==
1
)
{
_tcpSocket
->
write
(
"AT+MWSTATUS
\n
"
);
}
*/
return
false
;
}
//-----------------------------------------------------------------------------
bool
MicrohardSettings
::
setIPSettings
(
const
QString
&
localIP
,
const
QString
&
remoteIP
,
const
QString
&
netMask
)
{
return
false
;
// static const char* kRTSPPost = "{\"ipaddr\":\"%1\",\"netmask\":\"%2\",\"usbEthIp\":\"%3\"}";
// QString post = QString(kRTSPPost).arg(localIP).arg(netMask).arg(remoteIP);
// return _post(kIPAddrURI, post);
}
//-----------------------------------------------------------------------------
...
...
@@ -79,20 +43,31 @@ void
MicrohardSettings
::
_readBytes
()
{
QByteArray
bytesIn
=
_tcpSocket
->
read
(
_tcpSocket
->
bytesAvailable
());
QString
s_data
=
QString
::
fromStdString
(
bytesIn
.
toStdString
());
//-- 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
)
{
QByteArray
data
=
bytesIn
.
left
(
idx
+
1
);
emit
updateSettings
(
data
);
bytesIn
=
bytesIn
.
mid
(
idx
+
1
);
idx
=
bytesIn
.
indexOf
(
'{'
);
qCDebug
(
MicrohardVerbose
)
<<
"Read bytes: "
<<
bytesIn
;
if
(
_connectionState
==
1
)
{
int
i1
=
bytesIn
.
indexOf
(
"RSSI (dBm)"
);
if
(
i1
>
0
)
{
int
i2
=
bytesIn
.
indexOf
(
": "
,
i1
);
if
(
i2
>
0
)
{
i2
+=
2
;
int
i3
=
bytesIn
.
indexOf
(
" "
,
i2
);
int
val
=
bytesIn
.
mid
(
i2
,
i3
-
i2
).
toInt
();
if
(
val
<
0
)
{
_rssiVal
=
val
;
}
}
}
}
else
if
(
bytesIn
.
contains
(
"UserDevice login:"
))
{
_tcpSocket
->
write
(
"admin
\n
"
);
}
else
if
(
bytesIn
.
contains
(
"Password:"
))
{
std
::
string
pwd
=
qgcApp
()
->
toolbox
()
->
microhardManager
()
->
configPassword
().
toStdString
()
+
"
\n
"
;
_tcpSocket
->
write
(
pwd
.
c_str
());
}
else
if
(
bytesIn
.
contains
(
"UserDevice>"
))
{
_connectionState
=
1
;
}
emit
rssiUpdated
(
_rssiVal
);
}
src/Microhard/MicrohardSettings.h
View file @
80ccf144
...
...
@@ -15,18 +15,19 @@ class MicrohardSettings : public MicrohardHandler
{
Q_OBJECT
public:
explicit
MicrohardSettings
(
QObject
*
parent
=
nullptr
);
explicit
MicrohardSettings
(
Q
String
address
,
Q
Object
*
parent
=
nullptr
);
bool
start
()
override
;
bool
requestLinkStatus
();
bool
setIPSettings
(
const
QString
&
localIP
,
const
QString
&
remoteIP
,
const
QString
&
netMask
);
void
getStatus
();
signals:
void
updateSettings
(
QByteArray
jSonData
);
protected
slots
:
void
_readBytes
()
override
;
signals:
void
updateRSSI
(
int
rssi
);
private:
bool
_request
(
const
QString
&
request
);
bool
_post
(
const
QString
&
post
,
const
QString
&
postPayload
);
int
_connectionState
;
int
_rssiVal
;
QString
_address
;
};
src/Microhard/MicrohardSettings.qml
View file @
80ccf144
/****************************************************************************
*
* (c) 20
09-2016
QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
* (c) 20
19
QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
...
...
@@ -57,13 +57,6 @@ 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
.
microhardManager
.
needReboot
font.family
:
ScreenTools
.
demiboldFontFamily
anchors.horizontalCenter
:
parent
.
horizontalCenter
}
//-----------------------------------------------------------------
//-- General
Item
{
...
...
@@ -92,7 +85,7 @@ QGCView {
FactCheckBox
{
text
:
qsTr
(
"
Enable Microhard
"
)
fact
:
_microhardEnabledFact
enabled
:
!
QGroundControl
.
microhardManager
.
needReboot
enabled
:
true
visible
:
_microhardEnabledFact
.
visible
}
}
...
...
@@ -198,7 +191,7 @@ QGCView {
QGCTextField
{
id
:
localIP
text
:
QGroundControl
.
microhardManager
.
localIPAddr
enabled
:
!
QGroundControl
.
microhardManager
.
needReboot
enabled
:
true
inputMethodHints
:
Qt
.
ImhFormattedNumbersOnly
Layout.minimumWidth
:
_valueWidth
}
...
...
@@ -208,7 +201,7 @@ QGCView {
QGCTextField
{
id
:
remoteIP
text
:
QGroundControl
.
microhardManager
.
remoteIPAddr
enabled
:
!
QGroundControl
.
microhardManager
.
needReboot
enabled
:
true
inputMethodHints
:
Qt
.
ImhFormattedNumbersOnly
Layout.minimumWidth
:
_valueWidth
}
...
...
@@ -218,7 +211,7 @@ QGCView {
QGCTextField
{
id
:
netMask
text
:
QGroundControl
.
microhardManager
.
netMask
enabled
:
!
QGroundControl
.
microhardManager
.
needReboot
enabled
:
true
inputMethodHints
:
Qt
.
ImhFormattedNumbersOnly
Layout.minimumWidth
:
_valueWidth
}
...
...
@@ -228,7 +221,7 @@ QGCView {
QGCTextField
{
id
:
configPassword
text
:
QGroundControl
.
microhardManager
.
configPassword
enabled
:
!
QGroundControl
.
microhardManager
.
needReboot
enabled
:
true
inputMethodHints
:
Qt
.
ImhHiddenText
Layout.minimumWidth
:
_valueWidth
}
...
...
@@ -244,35 +237,19 @@ QGCView {
return
false
}
function
testEnabled
()
{
if
(
localIP
.
text
===
QGroundControl
.
microhardManager
.
localIPAddr
&&
remoteIP
.
text
===
QGroundControl
.
microhardManager
.
remoteIPAddr
&&
netMask
.
text
===
QGroundControl
.
microhardManager
.
netMask
)
if
(
localIP
.
text
===
QGroundControl
.
microhardManager
.
localIPAddr
&&
remoteIP
.
text
===
QGroundControl
.
microhardManager
.
remoteIPAddr
&&
netMask
.
text
===
QGroundControl
.
microhardManager
.
netMask
&&
configPassword
.
text
===
QGroundControl
.
microhardManager
.
configPassword
)
return
false
if
(
!
validateIPaddress
(
localIP
.
text
))
return
false
if
(
!
validateIPaddress
(
remoteIP
.
text
))
return
false
if
(
!
validateIPaddress
(
netMask
.
text
))
return
false
return
true
}
enabled
:
testEnabled
()
&&
!
QGroundControl
.
microhardManager
.
needReboot
enabled
:
testEnabled
()
text
:
qsTr
(
"
Apply
"
)
anchors.horizontalCenter
:
parent
.
horizontalCenter
onClicked
:
{
setIPDialog
.
open
()
}
MessageDialog
{
id
:
setIPDialog
icon
:
StandardIcon
.
Warning
standardButtons
:
StandardButton
.
Yes
|
StandardButton
.
No
title
:
qsTr
(
"
Set Network Settings
"
)
text
:
qsTr
(
"
Once changed, you will need to reboot the ground unit for the changes to take effect. The local IP address must match the one entered (%1).
\n\n
Confirm change?
"
).
arg
(
localIP
.
text
)
onYes
:
{
QGroundControl
.
microhardManager
.
setIPSettings
(
localIP
.
text
,
remoteIP
.
text
,
netMask
.
text
)
setIPDialog
.
close
()
}
onNo
:
{
setIPDialog
.
close
()
}
}
}
}
}
...
...
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