summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-02-15 15:28:27 (UTC)
committer mickeyl <mickeyl>2004-02-15 15:28:27 (UTC)
commit4f5703de93628ec6920957ef18d6cd5c87a69ba1 (patch) (side-by-side diff)
tree674e0d5eeb30ccf52dd5f0491522e651c2383116
parent3d50523ac7782e08795fabb071c8678d79a71b13 (diff)
downloadopie-4f5703de93628ec6920957ef18d6cd5c87a69ba1.zip
opie-4f5703de93628ec6920957ef18d6cd5c87a69ba1.tar.gz
opie-4f5703de93628ec6920957ef18d6cd5c87a69ba1.tar.bz2
*** empty log message ***
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/TODO2
-rw-r--r--noncore/net/wellenreiter/gui/gps.cpp34
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.cpp15
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.h1
4 files changed, 32 insertions, 20 deletions
diff --git a/noncore/net/wellenreiter/TODO b/noncore/net/wellenreiter/TODO
index fd70fc7..b6ec617 100644
--- a/noncore/net/wellenreiter/TODO
+++ b/noncore/net/wellenreiter/TODO
@@ -27,12 +27,14 @@ ENGINE
- adaptive hopping scheme !
- gather interface capabilities
- enable sniffing in wired networks
+- fix autodetection (interface name)
+
---------
UI
---------
- display interface capabilities (or rewrite networksettings?)
diff --git a/noncore/net/wellenreiter/gui/gps.cpp b/noncore/net/wellenreiter/gui/gps.cpp
index b814427..5b1b4a4 100644
--- a/noncore/net/wellenreiter/gui/gps.cpp
+++ b/noncore/net/wellenreiter/gui/gps.cpp
@@ -42,33 +42,35 @@ bool GPS::open( const QString& host, int port )
}
GpsLocation GPS::position() const
{
char buf[256];
+ double lat = -111.0;
+ double lon = -111.0;
int result = _socket->writeBlock( "p\r\n", 3 );
_socket->flush();
if ( result )
{
int numAvail = _socket->bytesAvailable();
qDebug( "GPS write succeeded, %d bytes available for reading...", numAvail );
if ( numAvail )
- {
- QTextStream stream( _socket );
-
- QString str;
- stream.readRawBytes( &buf[0], 7 );
- float lat = -111;
- stream >> lat;
- stream.skipWhiteSpace();
- float lon = -111;
- stream >> lon;
- stream.readRawBytes( &buf[0], 200 ); // read and discard the stuff until EOF
-
- return GpsLocation( lat, lon );
+ {
+ int numRead = _socket->readBlock( &buf[0], sizeof buf );
+ int numScan = sscanf( &buf[0], "GPSD,P=%lg %lg", &lat, &lon);
+
+ if ( numRead < 7 || numScan != 2 )
+ {
+ qDebug( "GPS read %d bytes succeeded, invalid response: '%s'", numRead, &buf[0] );
+ return GpsLocation( -111, -111 );
+ }
+ else
+ {
+ return GpsLocation( lat, lon );
+ }
}
}
return GpsLocation( -111, -111 );
}
@@ -120,12 +122,6 @@ QString GpsLocation::dmsPosition() const
dms.append( "' " );
dms.append( QString::number( ::abs( seconds ) ) );
dms.append( "'' " );
return dms;
}
-
-
-
-
-
-
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp
index 05a8913..b462afd 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.cpp
+++ b/noncore/net/wellenreiter/gui/mainwindow.cpp
@@ -31,12 +31,13 @@
#include <qiconset.h>
#include <qmenubar.h>
#include <qmessagebox.h>
#include <qpopupmenu.h>
#include <qpushbutton.h>
#include <qstatusbar.h>
+#include <qspinbox.h>
#include <qtextstream.h>
#include <qtoolbutton.h>
#ifdef QWS
#include <qpe/resource.h>
#include <opie2/ofiledialog.h>
@@ -130,12 +131,13 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n
sniffer->setItemEnabled( startID, false );
stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) );
sniffer->setItemEnabled( stopID, false );
QPopupMenu* demo = new QPopupMenu( mb );
demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) );
+ demo->insertItem( tr( "&Read from GPSd" ), this, SLOT( demoReadFromGps() ) );
id = mb->insertItem( tr( "&File" ), file );
//id = mb->insertItem( tr( "&View" ), view );
//mb->setItemEnabled( id, false );
id = mb->insertItem( tr( "&Sniffer" ), sniffer );
@@ -220,22 +222,33 @@ WellenreiterMainWindow::~WellenreiterMainWindow()
qDebug( "Wellenreiter:: bye." );
};
void WellenreiterMainWindow::demoAddStations()
{
- //mw = 0; // test SIGSGV handling
+ //mw = 0; // test SIGSEGV handling
mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) );
mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) );
mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) );
mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) );
mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) );
}
+void WellenreiterMainWindow::demoReadFromGps()
+{
+ WellenreiterConfigWindow* configwindow = WellenreiterConfigWindow::instance();
+ GPS* gps = new GPS( this );
+ gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
+ GpsLocation loc = gps->position();
+
+ QMessageBox::information( this, "Wellenreiter/Opie", tr( "GPS said:\n$1" ).arg( loc.dmsPosition() ) );
+}
+
+
QString WellenreiterMainWindow::getFileName( bool save )
{
QMap<QString, QStringList> map;
map.insert( tr("All"), QStringList() );
QStringList text;
text << "text/*";
diff --git a/noncore/net/wellenreiter/gui/mainwindow.h b/noncore/net/wellenreiter/gui/mainwindow.h
index 8d4e768..a5cb7a5 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.h
+++ b/noncore/net/wellenreiter/gui/mainwindow.h
@@ -47,12 +47,13 @@ class WellenreiterMainWindow: public QMainWindow
virtual void closeEvent( QCloseEvent* );
void updateToolButtonState();
public slots:
void showConfigure();
void demoAddStations();
+ void demoReadFromGps();
void fileSaveLog();
void fileSaveHex();
void fileSaveSession();
void fileLoadSession();
void fileNew();
void uploadSession();