27 QTcpSocket *socket = qobject_cast< QTcpSocket * >(
mSource );
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 );
34 void QgsGpsdConnection::connected()
37 QTcpSocket *socket = qobject_cast< QTcpSocket * >(
mSource );
38 socket->write( QStringLiteral(
"?WATCH={\"enable\":true,\"nmea\":true,\"raw\":true%1};" ).arg( mDevice.isEmpty() ? mDevice : QStringLiteral(
",\"device\":%1" ).arg( mDevice ) ).toUtf8() );
41 void QgsGpsdConnection::error( QAbstractSocket::SocketError socketError )
44 QTcpSocket *socket = qobject_cast< QTcpSocket * >(
mSource );
45 QgsDebugMsg( QString(
"error: %1 %2" ).arg( socketError ).arg( socket->errorString() ) );
47 Q_UNUSED( socketError );
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.