27 QTcpSocket *socket = qobject_cast< QTcpSocket * >(
mSource.get() );
29 QObject::connect( socket, SIGNAL( connected() ),
this, SLOT( connected() ) );
30 QObject::connect( socket, SIGNAL( error( QAbstractSocket::SocketError ) ),
this, SLOT( error( QAbstractSocket::SocketError ) ) );
31 socket->connectToHost( host, port );
34void QgsGpsdConnection::connected()
37 QTcpSocket *socket = qobject_cast< QTcpSocket * >(
mSource.get() );
38 socket->write( QStringLiteral(
"?WATCH={\"enable\":true,\"nmea\":true,\"raw\":true%1};" ).arg( mDevice.isEmpty() ? mDevice : QStringLiteral(
",\"device\":%1" ).arg( mDevice ) ).toUtf8() );
41void QgsGpsdConnection::error( QAbstractSocket::SocketError socketError )
44 QTcpSocket *socket = qobject_cast< QTcpSocket * >(
mSource.get() );
45 QgsDebugMsg( QStringLiteral(
"error: %1 %2" ).arg( socketError ).arg( socket->errorString() ) );
47 Q_UNUSED( socketError )
std::unique_ptr< QIODevice > mSource
Data source (e.g. serial device, socket, file,...)
QgsGpsdConnection(const QString &host, qint16 port, const QString &device)
Evaluates NMEA sentences coming from a GPS device.
#define QgsDebugMsgLevel(str, level)