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
054fab6c
Commit
054fab6c
authored
Dec 05, 2015
by
dogmaphobic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bluetooth for Android complete.
parent
5b46a393
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
119 additions
and
148 deletions
+119
-148
qgroundcontrol.pro
qgroundcontrol.pro
+5
-3
BluetoothLink.cc
src/comm/BluetoothLink.cc
+51
-94
BluetoothLink.h
src/comm/BluetoothLink.h
+41
-20
LinkConfiguration.cc
src/comm/LinkConfiguration.cc
+3
-3
LinkConfiguration.h
src/comm/LinkConfiguration.h
+1
-1
LinkManager.cc
src/comm/LinkManager.cc
+7
-7
SerialLink.cc
src/comm/SerialLink.cc
+1
-1
main.cc
src/main.cc
+2
-2
QGCLinkConfiguration.cc
src/ui/QGCLinkConfiguration.cc
+1
-1
BluetoothSettings.qml
src/ui/preferences/BluetoothSettings.qml
+5
-15
LinkSettings.qml
src/ui/preferences/LinkSettings.qml
+1
-0
SerialSettings.qml
src/ui/preferences/SerialSettings.qml
+1
-1
No files found.
qgroundcontrol.pro
View file @
054fab6c
...
@@ -74,7 +74,7 @@ QT += \
...
@@ -74,7 +74,7 @@ QT += \
serialport
\
serialport
\
}
}
!
Windows
Build
{
Mobile
Build
{
QT
+=
\
QT
+=
\
bluetooth
\
bluetooth
\
}
}
...
@@ -309,7 +309,9 @@ HEADERS += \
...
@@ -309,7 +309,9 @@ HEADERS += \
WindowsBuild
{
WindowsBuild
{
PRECOMPILED_HEADER
+=
src
/
stable_headers
.
h
PRECOMPILED_HEADER
+=
src
/
stable_headers
.
h
HEADERS
+=
src
/
stable_headers
.
h
HEADERS
+=
src
/
stable_headers
.
h
}
else
{
}
MobileBuild
{
HEADERS
+=
\
HEADERS
+=
\
src
/
comm
/
BluetoothLink
.
h
\
src
/
comm
/
BluetoothLink
.
h
\
}
}
...
@@ -433,7 +435,7 @@ SOURCES += \
...
@@ -433,7 +435,7 @@ SOURCES += \
src
/
ui
/
SerialConfigurationWindow
.
cc
\
src
/
ui
/
SerialConfigurationWindow
.
cc
\
}
}
!
Windows
Build
{
Mobile
Build
{
SOURCES
+=
\
SOURCES
+=
\
src
/
comm
/
BluetoothLink
.
cc
\
src
/
comm
/
BluetoothLink
.
cc
\
}
}
...
...
src/comm/BluetoothLink.cc
View file @
054fab6c
...
@@ -42,6 +42,7 @@ This file is part of the QGROUNDCONTROL project
...
@@ -42,6 +42,7 @@ This file is part of the QGROUNDCONTROL project
#include "BluetoothLink.h"
#include "BluetoothLink.h"
#include "QGC.h"
#include "QGC.h"
/*
static void print_device_info(QBluetoothDeviceInfo info)
static void print_device_info(QBluetoothDeviceInfo info)
{
{
qDebug() << "Bluetooth: " << info.name();
qDebug() << "Bluetooth: " << info.name();
...
@@ -53,13 +54,14 @@ static void print_device_info(QBluetoothDeviceInfo info)
...
@@ -53,13 +54,14 @@ static void print_device_info(QBluetoothDeviceInfo info)
qDebug() << " Service UUID:" << info.serviceUuids();
qDebug() << " Service UUID:" << info.serviceUuids();
qDebug() << " Core Config:" << info.coreConfigurations();
qDebug() << " Core Config:" << info.coreConfigurations();
qDebug() << " Valid:" << info.isValid();
qDebug() << " Valid:" << info.isValid();
qDebug() << " Address:" << info.address().toString();
}
}
*/
BluetoothLink
::
BluetoothLink
(
BluetoothConfiguration
*
config
)
BluetoothLink
::
BluetoothLink
(
BluetoothConfiguration
*
config
)
:
_connectState
(
false
)
:
_connectState
(
false
)
,
_targetSocket
(
NULL
)
,
_targetSocket
(
NULL
)
,
_targetDevice
(
NULL
)
,
_targetDevice
(
NULL
)
,
_deviceDiscover
(
NULL
)
,
_running
(
false
)
,
_running
(
false
)
{
{
Q_ASSERT
(
config
!=
NULL
);
Q_ASSERT
(
config
!=
NULL
);
...
@@ -67,7 +69,7 @@ BluetoothLink::BluetoothLink(BluetoothConfiguration* config)
...
@@ -67,7 +69,7 @@ BluetoothLink::BluetoothLink(BluetoothConfiguration* config)
_config
->
setLink
(
this
);
_config
->
setLink
(
this
);
// We're doing it wrong - because the Qt folks got the API wrong:
// We're doing it wrong - because the Qt folks got the API wrong:
// http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/
// http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/
//
moveToThread(this);
moveToThread
(
this
);
}
}
BluetoothLink
::~
BluetoothLink
()
BluetoothLink
::~
BluetoothLink
()
...
@@ -85,39 +87,11 @@ BluetoothLink::~BluetoothLink()
...
@@ -85,39 +87,11 @@ BluetoothLink::~BluetoothLink()
void
BluetoothLink
::
run
()
void
BluetoothLink
::
run
()
{
{
while
(
!
_targetDevice
&&
_running
)
this
->
msleep
(
50
);
if
(
_running
&&
_hardwareConnect
())
{
if
(
_running
&&
_hardwareConnect
())
{
exec
();
exec
();
}
}
}
}
void
BluetoothLink
::
deviceDiscovered
(
QBluetoothDeviceInfo
info
)
{
if
(
info
.
name
()
==
_config
->
device
())
{
if
(
!
_targetDevice
)
{
print_device_info
(
info
);
_targetDevice
=
new
QBluetoothDeviceInfo
(
info
);
//-- Start Thread
_running
=
true
;
start
(
NormalPriority
);
}
}
}
void
BluetoothLink
::
doneScanning
()
{
if
(
!
_targetDevice
)
{
_connectState
=
false
;
qWarning
()
<<
"Bluetooth scanning did not find device"
<<
_config
->
device
();
emit
communicationError
(
"Bluetooth Link Error"
,
"Device Not Found"
);
_running
=
false
;
}
}
void
BluetoothLink
::
_restartConnection
()
void
BluetoothLink
::
_restartConnection
()
{
{
if
(
this
->
isConnected
())
if
(
this
->
isConnected
())
...
@@ -182,12 +156,6 @@ void BluetoothLink::_disconnect(void)
...
@@ -182,12 +156,6 @@ void BluetoothLink::_disconnect(void)
_targetSocket
=
NULL
;
_targetSocket
=
NULL
;
emit
disconnected
();
emit
disconnected
();
}
}
if
(
_deviceDiscover
)
{
_deviceDiscover
->
stop
();
delete
_deviceDiscover
;
_deviceDiscover
=
NULL
;
}
_connectState
=
false
;
_connectState
=
false
;
}
}
...
@@ -199,23 +167,14 @@ bool BluetoothLink::_connect(void)
...
@@ -199,23 +167,14 @@ bool BluetoothLink::_connect(void)
quit
();
quit
();
wait
();
wait
();
}
}
if
(
_deviceDiscover
)
{
_deviceDiscover
->
stop
();
delete
_deviceDiscover
;
_deviceDiscover
=
NULL
;
}
if
(
_targetDevice
)
if
(
_targetDevice
)
{
{
delete
_targetDevice
;
delete
_targetDevice
;
_targetDevice
=
NULL
;
_targetDevice
=
NULL
;
}
}
//-- Scan devices
//-- Start Thread
_deviceDiscover
=
new
QBluetoothDeviceDiscoveryAgent
();
_running
=
true
;
QObject
::
connect
(
_deviceDiscover
,
SIGNAL
(
deviceDiscovered
(
QBluetoothDeviceInfo
)),
this
,
SLOT
(
deviceDiscovered
(
QBluetoothDeviceInfo
)));
start
(
NormalPriority
);
QObject
::
connect
(
_deviceDiscover
,
SIGNAL
(
finished
()),
this
,
SLOT
(
doneScanning
()));
_deviceDiscover
->
setInquiryType
(
QBluetoothDeviceDiscoveryAgent
::
GeneralUnlimitedInquiry
);
_deviceDiscover
->
start
();
return
true
;
return
true
;
}
}
...
@@ -226,37 +185,19 @@ bool BluetoothLink::_hardwareConnect()
...
@@ -226,37 +185,19 @@ bool BluetoothLink::_hardwareConnect()
delete
_targetSocket
;
delete
_targetSocket
;
_targetSocket
=
NULL
;
_targetSocket
=
NULL
;
}
}
// Build Device Class Descriptor
_targetDevice
=
new
QBluetoothDeviceInfo
(
QBluetoothAddress
(
_config
->
device
().
address
),
_config
->
device
().
name
,
_config
->
device
().
bits
);
/*
quint32 device_class = 0;
device_class |= ((0x20 | 0x100) << 13); // Service Class
device_class |= (0x04 << 8); // Audio Device (CLASS MAJOR) The Crossfire presents itself as an "Audio Service"
device_class |= (0x01 << 2); // WearableHeadsetDevice (CLASS MINOR)
qDebug() << _config->address() << _config->device() << device_class;
_targetDevice = new QBluetoothDeviceInfo(QBluetoothAddress(_config->address()), _config->device(), device_class);
_targetDevice
->
setCoreConfigurations
(
QBluetoothDeviceInfo
::
BaseRateCoreConfiguration
);
_targetDevice
->
setCoreConfigurations
(
QBluetoothDeviceInfo
::
BaseRateCoreConfiguration
);
*/
_targetSocket
=
new
QBluetoothSocket
(
QBluetoothServiceInfo
::
RfcommProtocol
,
this
);
_targetSocket
=
new
QBluetoothSocket
(
QBluetoothServiceInfo
::
RfcommProtocol
,
this
);
_targetSocket
->
moveToThread
(
this
);
_targetSocket
->
moveToThread
(
this
);
//print_device_info(*_targetDevice);
qDebug
()
<<
"Connecting..."
;
print_device_info
(
*
_targetDevice
);
QObject
::
connect
(
_targetSocket
,
SIGNAL
(
connected
()),
this
,
SLOT
(
deviceConnected
()));
QObject
::
connect
(
_targetSocket
,
SIGNAL
(
connected
()),
this
,
SLOT
(
deviceConnected
()));
QObject
::
connect
(
_targetSocket
,
SIGNAL
(
error
(
QBluetoothSocket
::
SocketError
)),
this
,
SLOT
(
deviceError
(
QBluetoothSocket
::
SocketError
)));
QObject
::
connect
(
_targetSocket
,
SIGNAL
(
error
(
QBluetoothSocket
::
SocketError
)),
this
,
SLOT
(
deviceError
(
QBluetoothSocket
::
SocketError
)));
QObject
::
connect
(
_targetSocket
,
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readBytes
()));
QObject
::
connect
(
_targetSocket
,
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readBytes
()));
QObject
::
connect
(
_targetSocket
,
SIGNAL
(
disconnected
()),
this
,
SLOT
(
deviceDisconnected
()));
QObject
::
connect
(
_targetSocket
,
SIGNAL
(
disconnected
()),
this
,
SLOT
(
deviceDisconnected
()));
QObject
::
connect
(
_targetSocket
,
SIGNAL
(
stateChanged
(
QBluetoothSocket
::
SocketState
)),
this
,
SLOT
(
stateChanged
(
QBluetoothSocket
::
SocketState
)));
_targetSocket
->
connectToService
(
_targetDevice
->
address
(),
QBluetoothUuid
(
QBluetoothUuid
::
Rfcomm
));
_targetSocket
->
connectToService
(
_targetDevice
->
address
(),
QBluetoothUuid
(
QBluetoothUuid
::
Rfcomm
));
return
true
;
return
true
;
}
}
void
BluetoothLink
::
stateChanged
(
QBluetoothSocket
::
SocketState
state
)
{
qDebug
()
<<
"Bluetooth state:"
<<
state
;
}
void
BluetoothLink
::
deviceConnected
()
void
BluetoothLink
::
deviceConnected
()
{
{
_connectState
=
true
;
_connectState
=
true
;
...
@@ -310,8 +251,7 @@ BluetoothConfiguration::BluetoothConfiguration(BluetoothConfiguration* source)
...
@@ -310,8 +251,7 @@ BluetoothConfiguration::BluetoothConfiguration(BluetoothConfiguration* source)
:
LinkConfiguration
(
source
)
:
LinkConfiguration
(
source
)
,
_deviceDiscover
(
NULL
)
,
_deviceDiscover
(
NULL
)
{
{
_address
=
source
->
address
();
_device
=
source
->
device
();
_device
=
source
->
device
();
}
}
BluetoothConfiguration
::~
BluetoothConfiguration
()
BluetoothConfiguration
::~
BluetoothConfiguration
()
...
@@ -328,25 +268,24 @@ void BluetoothConfiguration::copyFrom(LinkConfiguration *source)
...
@@ -328,25 +268,24 @@ void BluetoothConfiguration::copyFrom(LinkConfiguration *source)
LinkConfiguration
::
copyFrom
(
source
);
LinkConfiguration
::
copyFrom
(
source
);
BluetoothConfiguration
*
usource
=
dynamic_cast
<
BluetoothConfiguration
*>
(
source
);
BluetoothConfiguration
*
usource
=
dynamic_cast
<
BluetoothConfiguration
*>
(
source
);
Q_ASSERT
(
usource
!=
NULL
);
Q_ASSERT
(
usource
!=
NULL
);
_address
=
usource
->
address
();
_device
=
usource
->
device
();
_device
=
usource
->
device
();
}
}
void
BluetoothConfiguration
::
saveSettings
(
QSettings
&
settings
,
const
QString
&
root
)
void
BluetoothConfiguration
::
saveSettings
(
QSettings
&
settings
,
const
QString
&
root
)
{
{
settings
.
beginGroup
(
root
);
settings
.
beginGroup
(
root
);
settings
.
setValue
(
"device"
,
_device
);
settings
.
setValue
(
"name"
,
_device
.
name
);
settings
.
setValue
(
"address"
,
_address
);
settings
.
setValue
(
"address"
,
_device
.
address
);
settings
.
setValue
(
"bits"
,
_device
.
bits
);
settings
.
endGroup
();
settings
.
endGroup
();
}
}
void
BluetoothConfiguration
::
loadSettings
(
QSettings
&
settings
,
const
QString
&
root
)
void
BluetoothConfiguration
::
loadSettings
(
QSettings
&
settings
,
const
QString
&
root
)
{
{
settings
.
beginGroup
(
root
);
settings
.
beginGroup
(
root
);
QString
device
=
settings
.
value
(
"device"
,
_device
).
toString
();
_device
.
name
=
settings
.
value
(
"name"
,
_device
.
name
).
toString
();
QString
address
=
settings
.
value
(
"address"
,
_address
).
toString
();
_device
.
address
=
settings
.
value
(
"address"
,
_device
.
address
).
toString
();
_device
=
device
;
_device
.
bits
=
settings
.
value
(
"bits"
,
_device
.
bits
).
toUInt
();
_address
=
address
;
settings
.
endGroup
();
settings
.
endGroup
();
}
}
...
@@ -364,7 +303,10 @@ void BluetoothConfiguration::stopScan()
...
@@ -364,7 +303,10 @@ void BluetoothConfiguration::stopScan()
{
{
if
(
_deviceDiscover
)
if
(
_deviceDiscover
)
{
{
_deviceDiscover
->
stop
();
_deviceDiscover
->
deleteLater
();
_deviceDiscover
=
NULL
;
emit
scanningChanged
();
}
}
}
}
...
@@ -373,27 +315,40 @@ void BluetoothConfiguration::startScan()
...
@@ -373,27 +315,40 @@ void BluetoothConfiguration::startScan()
if
(
!
_deviceDiscover
)
if
(
!
_deviceDiscover
)
{
{
_deviceDiscover
=
new
QBluetoothDeviceDiscoveryAgent
(
this
);
_deviceDiscover
=
new
QBluetoothDeviceDiscoveryAgent
(
this
);
connect
(
_deviceDiscover
,
&
QBluetoothDeviceDiscoveryAgent
::
deviceDiscovered
,
this
,
&
BluetoothConfiguration
::
deviceDiscovered
);
connect
(
_deviceDiscover
,
&
QBluetoothDeviceDiscoveryAgent
::
deviceDiscovered
,
this
,
&
BluetoothConfiguration
::
deviceDiscovered
);
connect
(
_deviceDiscover
,
&
QBluetoothDeviceDiscoveryAgent
::
finished
,
this
,
&
BluetoothConfiguration
::
doneScanning
);
connect
(
_deviceDiscover
,
&
QBluetoothDeviceDiscoveryAgent
::
finished
,
this
,
&
BluetoothConfiguration
::
doneScanning
);
emit
scanningChanged
();
emit
scanningChanged
();
}
}
else
else
{
{
_deviceDiscover
->
stop
();
_deviceDiscover
->
stop
();
}
}
_nameList
.
clear
();
_deviceList
.
clear
();
_deviceList
.
clear
();
_addressList
.
clear
();
emit
nameListChanged
();
emit
deviceListChanged
();
_deviceDiscover
->
setInquiryType
(
QBluetoothDeviceDiscoveryAgent
::
GeneralUnlimitedInquiry
);
_deviceDiscover
->
setInquiryType
(
QBluetoothDeviceDiscoveryAgent
::
GeneralUnlimitedInquiry
);
_deviceDiscover
->
start
();
_deviceDiscover
->
start
();
}
}
void
BluetoothConfiguration
::
deviceDiscovered
(
QBluetoothDeviceInfo
info
)
void
BluetoothConfiguration
::
deviceDiscovered
(
QBluetoothDeviceInfo
info
)
{
{
_deviceList
+=
info
.
name
();
//print_device_info(info);
_addressList
+=
info
.
address
().
toString
();
if
(
!
info
.
name
().
isEmpty
()
&&
info
.
isValid
())
print_device_info
(
info
);
{
emit
deviceListChanged
();
BluetoothData
data
;
data
.
name
=
info
.
name
();
data
.
address
=
info
.
address
().
toString
();
data
.
bits
|=
((
qint32
)
info
.
serviceClasses
()
<<
13
);
// Service Class
data
.
bits
|=
((
qint32
)
info
.
majorDeviceClass
()
<<
8
);
// CLASS MAJOR
data
.
bits
|=
((
qint32
)
info
.
minorDeviceClass
()
<<
2
);
// CLASS MINOR
if
(
!
_deviceList
.
contains
(
data
))
{
_deviceList
+=
data
;
_nameList
+=
data
.
name
;
emit
nameListChanged
();
return
;
}
}
}
}
void
BluetoothConfiguration
::
doneScanning
()
void
BluetoothConfiguration
::
doneScanning
()
...
@@ -406,15 +361,17 @@ void BluetoothConfiguration::doneScanning()
...
@@ -406,15 +361,17 @@ void BluetoothConfiguration::doneScanning()
}
}
}
}
void
BluetoothConfiguration
::
setDev
ice
(
QString
devic
e
)
void
BluetoothConfiguration
::
setDev
Name
(
const
QString
&
nam
e
)
{
{
int
idx
=
_deviceList
.
indexOf
(
device
);
foreach
(
const
BluetoothData
&
data
,
_deviceList
)
if
(
idx
>=
0
)
{
{
_address
=
_addressList
.
at
(
idx
);
if
(
data
.
name
==
name
)
_device
=
device
;
{
emit
deviceChanged
();
_device
=
data
;
emit
addressChanged
();
emit
devNameChanged
();
emit
addressChanged
();
return
;
}
}
}
}
}
src/comm/BluetoothLink.h
View file @
054fab6c
...
@@ -45,6 +45,33 @@ This file is part of the QGROUNDCONTROL project
...
@@ -45,6 +45,33 @@ This file is part of the QGROUNDCONTROL project
class
QBluetoothDeviceDiscoveryAgent
;
class
QBluetoothDeviceDiscoveryAgent
;
class
BluetoothData
{
public:
BluetoothData
()
{
bits
=
0
;
}
BluetoothData
(
const
BluetoothData
&
other
)
{
*
this
=
other
;
}
bool
operator
==
(
const
BluetoothData
&
other
)
{
return
bits
==
other
.
bits
&&
name
==
other
.
name
&&
address
==
other
.
address
;
}
BluetoothData
&
operator
=
(
const
BluetoothData
&
other
)
{
bits
=
other
.
bits
;
name
=
other
.
name
;
address
=
other
.
address
;
return
*
this
;
}
quint32
bits
;
QString
name
;
QString
address
;
};
class
BluetoothConfiguration
:
public
LinkConfiguration
class
BluetoothConfiguration
:
public
LinkConfiguration
{
{
Q_OBJECT
Q_OBJECT
...
@@ -55,21 +82,22 @@ public:
...
@@ -55,21 +82,22 @@ public:
BluetoothConfiguration
(
BluetoothConfiguration
*
source
);
BluetoothConfiguration
(
BluetoothConfiguration
*
source
);
~
BluetoothConfiguration
();
~
BluetoothConfiguration
();
Q_PROPERTY
(
QString
dev
ice
READ
device
WRITE
setDevice
NOTIFY
devic
eChanged
)
Q_PROPERTY
(
QString
dev
Name
READ
devName
WRITE
setDevName
NOTIFY
devNam
eChanged
)
Q_PROPERTY
(
QString
address
READ
address
WRITE
setAddress
NOTIFY
addressChanged
)
Q_PROPERTY
(
QString
address
READ
address
NOTIFY
addressChanged
)
Q_PROPERTY
(
QStringList
deviceList
READ
deviceList
NOTIFY
devic
eListChanged
)
Q_PROPERTY
(
QStringList
nameList
READ
nameList
NOTIFY
nam
eListChanged
)
Q_PROPERTY
(
bool
scanning
READ
scanning
NOTIFY
scanningChanged
)
Q_PROPERTY
(
bool
scanning
READ
scanning
NOTIFY
scanningChanged
)
Q_INVOKABLE
void
startScan
();
Q_INVOKABLE
void
startScan
();
Q_INVOKABLE
void
stopScan
();
Q_INVOKABLE
void
stopScan
();
QString
dev
ice
()
{
return
_devic
e
;
}
QString
dev
Name
()
{
return
_device
.
nam
e
;
}
QString
address
()
{
return
_address
;
}
QString
address
()
{
return
_
device
.
address
;
}
QStringList
deviceList
()
{
return
_devic
eList
;
}
QStringList
nameList
()
{
return
_nam
eList
;
}
bool
scanning
()
{
return
_deviceDiscover
!=
NULL
;
}
bool
scanning
()
{
return
_deviceDiscover
!=
NULL
;
}
void
setDevice
(
QString
device
);
BluetoothData
device
()
{
return
_device
;
}
void
setAddress
(
QString
address
)
{
_address
=
address
;
emit
addressChanged
();
}
void
setDevName
(
const
QString
&
name
);
/// From LinkConfiguration
/// From LinkConfiguration
LinkType
type
()
{
return
LinkConfiguration
::
TypeBluetooth
;
}
LinkType
type
()
{
return
LinkConfiguration
::
TypeBluetooth
;
}
...
@@ -85,19 +113,16 @@ public slots:
...
@@ -85,19 +113,16 @@ public slots:
signals:
signals:
void
newDevice
(
QBluetoothDeviceInfo
info
);
void
newDevice
(
QBluetoothDeviceInfo
info
);
void
dev
iceChanged
();
void
dev
NameChanged
();
void
addressChanged
();
void
addressChanged
();
void
deviceListChanged
();
void
nameListChanged
();
void
scanningChanged
();
void
scanningChanged
();
private:
private:
private:
QBluetoothDeviceDiscoveryAgent
*
_deviceDiscover
;
QBluetoothDeviceDiscoveryAgent
*
_deviceDiscover
;
QString
_device
;
BluetoothData
_device
;
QString
_address
;
QStringList
_nameList
;
QStringList
_deviceList
;
QList
<
BluetoothData
>
_deviceList
;
QStringList
_addressList
;
};
};
class
BluetoothLink
:
public
LinkInterface
class
BluetoothLink
:
public
LinkInterface
...
@@ -133,9 +158,6 @@ public slots:
...
@@ -133,9 +158,6 @@ public slots:
void
deviceConnected
();
void
deviceConnected
();
void
deviceDisconnected
();
void
deviceDisconnected
();
void
deviceError
(
QBluetoothSocket
::
SocketError
error
);
void
deviceError
(
QBluetoothSocket
::
SocketError
error
);
void
stateChanged
(
QBluetoothSocket
::
SocketState
state
);
void
deviceDiscovered
(
QBluetoothDeviceInfo
info
);
void
doneScanning
();
protected:
protected:
...
@@ -159,7 +181,6 @@ private:
...
@@ -159,7 +181,6 @@ private:
QBluetoothSocket
*
_targetSocket
;
QBluetoothSocket
*
_targetSocket
;
QBluetoothDeviceInfo
*
_targetDevice
;
QBluetoothDeviceInfo
*
_targetDevice
;
QBluetoothDeviceDiscoveryAgent
*
_deviceDiscover
;
bool
_running
;
bool
_running
;
};
};
...
...
src/comm/LinkConfiguration.cc
View file @
054fab6c
...
@@ -36,7 +36,7 @@ This file is part of the QGROUNDCONTROL project
...
@@ -36,7 +36,7 @@ This file is part of the QGROUNDCONTROL project
#ifndef __mobile__
#ifndef __mobile__
#include "LogReplayLink.h"
#include "LogReplayLink.h"
#endif
#endif
#if
ndef Q_OS_WIN
#if
def __mobile__
#include "BluetoothLink.h"
#include "BluetoothLink.h"
#endif
#endif
#ifdef QT_DEBUG
#ifdef QT_DEBUG
...
@@ -103,7 +103,7 @@ LinkConfiguration* LinkConfiguration::createSettings(int type, const QString& na
...
@@ -103,7 +103,7 @@ LinkConfiguration* LinkConfiguration::createSettings(int type, const QString& na
case
LinkConfiguration
:
:
TypeTcp
:
case
LinkConfiguration
:
:
TypeTcp
:
config
=
new
TCPConfiguration
(
name
);
config
=
new
TCPConfiguration
(
name
);
break
;
break
;
#if
ndef Q_OS_WIN
#if
def __mobile__
case
LinkConfiguration
:
:
TypeBluetooth
:
case
LinkConfiguration
:
:
TypeBluetooth
:
config
=
new
BluetoothConfiguration
(
name
);
config
=
new
BluetoothConfiguration
(
name
);
break
;
break
;
...
@@ -141,7 +141,7 @@ LinkConfiguration* LinkConfiguration::duplicateSettings(LinkConfiguration* sourc
...
@@ -141,7 +141,7 @@ LinkConfiguration* LinkConfiguration::duplicateSettings(LinkConfiguration* sourc
case
TypeTcp
:
case
TypeTcp
:
dupe
=
new
TCPConfiguration
(
dynamic_cast
<
TCPConfiguration
*>
(
source
));
dupe
=
new
TCPConfiguration
(
dynamic_cast
<
TCPConfiguration
*>
(
source
));
break
;
break
;
#if
ndef Q_OS_WIN
#if
def __mobile__
case
TypeBluetooth
:
case
TypeBluetooth
:
dupe
=
new
BluetoothConfiguration
(
dynamic_cast
<
BluetoothConfiguration
*>
(
source
));
dupe
=
new
BluetoothConfiguration
(
dynamic_cast
<
BluetoothConfiguration
*>
(
source
));
break
;
break
;
...
...
src/comm/LinkConfiguration.h
View file @
054fab6c
...
@@ -64,7 +64,7 @@ public:
...
@@ -64,7 +64,7 @@ public:
#endif
#endif
TypeUdp
,
///< UDP Link
TypeUdp
,
///< UDP Link
TypeTcp
,
///< TCP Link
TypeTcp
,
///< TCP Link
#if
ndef Q_OS_WIN
#if
def __mobile__
TypeBluetooth
,
///< Bluetooth Link
TypeBluetooth
,
///< Bluetooth Link
#endif
#endif
#if 0
#if 0
...
...
src/comm/LinkManager.cc
View file @
054fab6c
...
@@ -44,7 +44,7 @@ This file is part of the QGROUNDCONTROL project
...
@@ -44,7 +44,7 @@ This file is part of the QGROUNDCONTROL project
#include "QGCApplication.h"
#include "QGCApplication.h"
#include "UDPLink.h"
#include "UDPLink.h"
#include "TCPLink.h"
#include "TCPLink.h"
#if
ndef Q_OS_WIN
#if
def __mobile__
#include "BluetoothLink.h"
#include "BluetoothLink.h"
#endif
#endif
...
@@ -127,7 +127,7 @@ LinkInterface* LinkManager::createConnectedLink(LinkConfiguration* config)
...
@@ -127,7 +127,7 @@ LinkInterface* LinkManager::createConnectedLink(LinkConfiguration* config)
case
LinkConfiguration
:
:
TypeTcp
:
case
LinkConfiguration
:
:
TypeTcp
:
pLink
=
new
TCPLink
(
dynamic_cast
<
TCPConfiguration
*>
(
config
));
pLink
=
new
TCPLink
(
dynamic_cast
<
TCPConfiguration
*>
(
config
));
break
;
break
;
#if
ndef Q_OS_WIN
#if
def __mobile__
case
LinkConfiguration
:
:
TypeBluetooth
:
case
LinkConfiguration
:
:
TypeBluetooth
:
pLink
=
new
BluetoothLink
(
dynamic_cast
<
BluetoothConfiguration
*>
(
config
));
pLink
=
new
BluetoothLink
(
dynamic_cast
<
BluetoothConfiguration
*>
(
config
));
break
;
break
;
...
@@ -367,7 +367,7 @@ void LinkManager::loadLinkConfigurationList()
...
@@ -367,7 +367,7 @@ void LinkManager::loadLinkConfigurationList()
case
LinkConfiguration
:
:
TypeTcp
:
case
LinkConfiguration
:
:
TypeTcp
:
pLink
=
(
LinkConfiguration
*
)
new
TCPConfiguration
(
name
);
pLink
=
(
LinkConfiguration
*
)
new
TCPConfiguration
(
name
);
break
;
break
;
#if
ndef Q_OS_WIN
#if
def __mobile__
case
LinkConfiguration
:
:
TypeBluetooth
:
case
LinkConfiguration
:
:
TypeBluetooth
:
pLink
=
(
LinkConfiguration
*
)
new
BluetoothConfiguration
(
name
);
pLink
=
(
LinkConfiguration
*
)
new
BluetoothConfiguration
(
name
);
break
;
break
;
...
@@ -714,7 +714,7 @@ QStringList LinkManager::linkTypeStrings(void) const
...
@@ -714,7 +714,7 @@ QStringList LinkManager::linkTypeStrings(void) const
#endif
#endif
list
+=
"UDP"
;
list
+=
"UDP"
;
list
+=
"TCP"
;
list
+=
"TCP"
;
#if
ndef Q_OS_WIN
#if
def __mobile__
list
+=
"Bluetooth"
;
list
+=
"Bluetooth"
;
#endif
#endif
#ifdef QT_DEBUG
#ifdef QT_DEBUG
...
@@ -823,7 +823,7 @@ void LinkManager::_fixUnnamed(LinkConfiguration* config)
...
@@ -823,7 +823,7 @@ void LinkManager::_fixUnnamed(LinkConfiguration* config)
#ifndef __ios__
#ifndef __ios__
case
LinkConfiguration
:
:
TypeSerial
:
{
case
LinkConfiguration
:
:
TypeSerial
:
{
QString
tname
=
dynamic_cast
<
SerialConfiguration
*>
(
config
)
->
portName
();
QString
tname
=
dynamic_cast
<
SerialConfiguration
*>
(
config
)
->
portName
();
#ifdef Q_OS_WIN
32
#ifdef Q_OS_WIN
tname
.
replace
(
"
\\\\
.
\\
"
,
""
);
tname
.
replace
(
"
\\\\
.
\\
"
,
""
);
#else
#else
tname
.
replace
(
"/dev/cu."
,
""
);
tname
.
replace
(
"/dev/cu."
,
""
);
...
@@ -845,11 +845,11 @@ void LinkManager::_fixUnnamed(LinkConfiguration* config)
...
@@ -845,11 +845,11 @@ void LinkManager::_fixUnnamed(LinkConfiguration* config)
}
}
}
}
break
;
break
;
#if
ndef Q_OS_WIN
#if
def __mobile__
case
LinkConfiguration
:
:
TypeBluetooth
:
{
case
LinkConfiguration
:
:
TypeBluetooth
:
{
BluetoothConfiguration
*
tconfig
=
dynamic_cast
<
BluetoothConfiguration
*>
(
config
);
BluetoothConfiguration
*
tconfig
=
dynamic_cast
<
BluetoothConfiguration
*>
(
config
);
if
(
tconfig
)
{
if
(
tconfig
)
{
config
->
setName
(
QString
(
"
Bluetooth Device on %1"
).
arg
(
tconfig
->
device
()
));
config
->
setName
(
QString
(
"
%1 (Bluetooth Device)"
).
arg
(
tconfig
->
device
().
name
));
}
}
}
}
break
;
break
;
...
...
src/comm/SerialLink.cc
View file @
054fab6c
...
@@ -471,7 +471,7 @@ void SerialConfiguration::setPortName(const QString& portName)
...
@@ -471,7 +471,7 @@ void SerialConfiguration::setPortName(const QString& portName)
QString
SerialConfiguration
::
cleanPortDisplayname
(
const
QString
name
)
QString
SerialConfiguration
::
cleanPortDisplayname
(
const
QString
name
)
{
{
QString
pname
=
name
.
trimmed
();
QString
pname
=
name
.
trimmed
();
#ifdef Q_OS_WIN
32
#ifdef Q_OS_WIN
pname
.
replace
(
"
\\\\
.
\\
"
,
""
);
pname
.
replace
(
"
\\\\
.
\\
"
,
""
);
#else
#else
pname
.
replace
(
"/dev/cu."
,
""
);
pname
.
replace
(
"/dev/cu."
,
""
);
...
...
src/main.cc
View file @
054fab6c
...
@@ -50,7 +50,7 @@ This file is part of the QGROUNDCONTROL project
...
@@ -50,7 +50,7 @@ This file is part of the QGROUNDCONTROL project
#endif
#endif
#endif
#endif
#if
ndef Q_OS_WIN
#if
def __mobile__
#include <QtBluetooth/QBluetoothSocket>
#include <QtBluetooth/QBluetoothSocket>
#endif
#endif
...
@@ -140,7 +140,7 @@ int main(int argc, char *argv[])
...
@@ -140,7 +140,7 @@ int main(int argc, char *argv[])
#ifndef __ios__
#ifndef __ios__
qRegisterMetaType
<
QSerialPort
::
SerialPortError
>
();
qRegisterMetaType
<
QSerialPort
::
SerialPortError
>
();
#endif
#endif
#if
ndef Q_OS_WIN
#if
def __mobile__
qRegisterMetaType
<
QBluetoothSocket
::
SocketError
>
();
qRegisterMetaType
<
QBluetoothSocket
::
SocketError
>
();
qRegisterMetaType
<
QBluetoothServiceInfo
>
();
qRegisterMetaType
<
QBluetoothServiceInfo
>
();
#endif
#endif
...
...
src/ui/QGCLinkConfiguration.cc
View file @
054fab6c
...
@@ -143,7 +143,7 @@ void QGCLinkConfiguration::_fixUnnamed(LinkConfiguration* config)
...
@@ -143,7 +143,7 @@ void QGCLinkConfiguration::_fixUnnamed(LinkConfiguration* config)
#ifndef __ios__
#ifndef __ios__
case
LinkConfiguration
:
:
TypeSerial
:
{
case
LinkConfiguration
:
:
TypeSerial
:
{
QString
tname
=
dynamic_cast
<
SerialConfiguration
*>
(
config
)
->
portName
();
QString
tname
=
dynamic_cast
<
SerialConfiguration
*>
(
config
)
->
portName
();
#ifdef Q_OS_WIN
32
#ifdef Q_OS_WIN
tname
.
replace
(
"
\\\\
.
\\
"
,
""
);
tname
.
replace
(
"
\\\\
.
\\
"
,
""
);
#else
#else
tname
.
replace
(
"/dev/cu."
,
""
);
tname
.
replace
(
"/dev/cu."
,
""
);
...
...
src/ui/preferences/BluetoothSettings.qml
View file @
054fab6c
...
@@ -39,8 +39,6 @@ Item {
...
@@ -39,8 +39,6 @@ Item {
// No need
// No need
}
}
property
var
_currentDevice
:
""
Column
{
Column
{
id
:
btColumn
id
:
btColumn
spacing
:
ScreenTools
.
defaultFontPixelHeight
/
2
spacing
:
ScreenTools
.
defaultFontPixelHeight
/
2
...
@@ -73,7 +71,7 @@ Item {
...
@@ -73,7 +71,7 @@ Item {
}
}
QGCLabel
{
QGCLabel
{
id
:
deviceField
id
:
deviceField
text
:
subEditConfig
&&
subEditConfig
.
linkType
===
LinkConfiguration
.
TypeBluetooth
?
subEditConfig
.
dev
ic
e
:
""
text
:
subEditConfig
&&
subEditConfig
.
linkType
===
LinkConfiguration
.
TypeBluetooth
?
subEditConfig
.
dev
Nam
e
:
""
}
}
}
}
Row
{
Row
{
...
@@ -111,10 +109,10 @@ Item {
...
@@ -111,10 +109,10 @@ Item {
height
:
1
height
:
1
width
:
_secondColumn
width
:
_secondColumn
color
:
qgcPal
.
button
color
:
qgcPal
.
button
visible
:
subEditConfig
&&
subEditConfig
.
linkType
===
LinkConfiguration
.
TypeBluetooth
&&
subEditConfig
.
devic
eList
.
length
>
0
visible
:
subEditConfig
&&
subEditConfig
.
linkType
===
LinkConfiguration
.
TypeBluetooth
&&
subEditConfig
.
nam
eList
.
length
>
0
}
}
Repeater
{
Repeater
{
model
:
subEditConfig
&&
subEditConfig
.
linkType
===
LinkConfiguration
.
TypeBluetooth
?
subEditConfig
.
devic
eList
:
""
model
:
subEditConfig
&&
subEditConfig
.
linkType
===
LinkConfiguration
.
TypeBluetooth
?
subEditConfig
.
nam
eList
:
""
delegate
:
delegate
:
QGCButton
{
QGCButton
{
text
:
modelData
text
:
modelData
...
@@ -123,7 +121,8 @@ Item {
...
@@ -123,7 +121,8 @@ Item {
exclusiveGroup
:
linkGroup
exclusiveGroup
:
linkGroup
onClicked
:
{
onClicked
:
{
checked
=
true
checked
=
true
_btSettings
.
_currentDevice
=
modelData
if
(
subEditConfig
&&
modelData
!==
""
)
subEditConfig
.
devName
=
modelData
}
}
}
}
}
}
...
@@ -161,15 +160,6 @@ Item {
...
@@ -161,15 +160,6 @@ Item {
subEditConfig
.
stopScan
()
subEditConfig
.
stopScan
()
}
}
}
}
QGCButton
{
width
:
ScreenTools
.
defaultFontPixelWidth
*
10
enabled
:
_btSettings
.
_currentDevice
&&
_btSettings
.
_currentDevice
!==
""
text
:
"
Select
"
onClicked
:
{
if
(
subEditConfig
)
subEditConfig
.
device
=
_btSettings
.
_currentDevice
}
}
}
}
}
}
}
}
...
...
src/ui/preferences/LinkSettings.qml
View file @
054fab6c
...
@@ -202,6 +202,7 @@ Rectangle {
...
@@ -202,6 +202,7 @@ Rectangle {
}
}
}
}
Flickable
{
Flickable
{
id
:
settingsFlick
clip
:
true
clip
:
true
anchors.top
:
parent
.
top
anchors.top
:
parent
.
top
width
:
parent
.
width
width
:
parent
.
width
...
...
src/ui/preferences/SerialSettings.qml
View file @
054fab6c
...
@@ -75,7 +75,7 @@ Item {
...
@@ -75,7 +75,7 @@ Item {
}
}
Component
.
onCompleted
:
{
Component
.
onCompleted
:
{
if
(
subEditConfig
!=
null
)
{
if
(
subEditConfig
!=
null
)
{
if
(
subEditConfig
.
portDisplayName
===
""
)
if
(
subEditConfig
.
portDisplayName
===
""
&&
QGroundControl
.
linkManager
.
serialPorts
.
length
>
0
)
subEditConfig
.
portName
=
QGroundControl
.
linkManager
.
serialPorts
[
0
]
subEditConfig
.
portName
=
QGroundControl
.
linkManager
.
serialPorts
[
0
]
var
index
=
commPortCombo
.
find
(
subEditConfig
.
portDisplayName
)
var
index
=
commPortCombo
.
find
(
subEditConfig
.
portDisplayName
)
if
(
index
===
-
1
)
{
if
(
index
===
-
1
)
{
...
...
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