author | mickeyl <mickeyl> | 2003-09-09 13:42:04 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-09-09 13:42:04 (UTC) |
commit | 807165ababca1b8c93b88d6b41f75ec96ce5e799 (patch) (side-by-side diff) | |
tree | 5042886f052d34d7d79bf4e784f87cbad171c86c | |
parent | fca4c73a5f0c672db9150f312eb85f1299e80e1b (diff) | |
download | opie-807165ababca1b8c93b88d6b41f75ec96ce5e799.zip opie-807165ababca1b8c93b88d6b41f75ec96ce5e799.tar.gz opie-807165ababca1b8c93b88d6b41f75ec96ce5e799.tar.bz2 |
reading GPS data from gpsd is now working. TODO: save the data
-rw-r--r-- | noncore/net/wellenreiter/gui/gps.cpp | 29 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/gps.h | 12 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 11 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 21 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.h | 6 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 8 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiterbase.cpp | 4 |
7 files changed, 64 insertions, 27 deletions
diff --git a/noncore/net/wellenreiter/gui/gps.cpp b/noncore/net/wellenreiter/gui/gps.cpp index 3206655..288afee 100644 --- a/noncore/net/wellenreiter/gui/gps.cpp +++ b/noncore/net/wellenreiter/gui/gps.cpp @@ -17,2 +17,5 @@ #include <unistd.h> + +#include <qtextstream.h> + GPS::GPS( QObject* parent, const char * name ) @@ -37,3 +40,3 @@ bool GPS::open( const QString& host, int port ) -float GPS::latitude() const +GpsLocation GPS::position() const { @@ -49,17 +52,17 @@ float GPS::latitude() const { + QTextStream stream( _socket ); - int num = _socket->readLine( &buf[0], sizeof buf ); - if ( num ) - { - qDebug( "GPS got %d bytes ['%s']", num, &buf[0] ); - return 0.0; - } + QString str; + stream.readRawBytes( &buf[0], 7 ); + float lat = -111.111; + stream >> lat; + stream.skipWhiteSpace(); + float lon = -111.111; + stream >> lon; + stream.readRawBytes( &buf[0], 200 ); // read and discard the stuff until EOF + + return GpsLocation( lat, lon ); } } - return -1.0; -} - - -float GPS::longitute() const -{ + return GpsLocation( -1.0, -1.0 ); } diff --git a/noncore/net/wellenreiter/gui/gps.h b/noncore/net/wellenreiter/gui/gps.h index ad0b6de..8143fe4 100644 --- a/noncore/net/wellenreiter/gui/gps.h +++ b/noncore/net/wellenreiter/gui/gps.h @@ -21,2 +21,11 @@ +struct GpsLocation +{ + GpsLocation( const float& lat, const float& lon ) : latitude(lat), longitude(lon) {}; + ~GpsLocation() {}; + float latitude; + float longitude; +}; + + class GPS : public QObject @@ -30,4 +39,3 @@ class GPS : public QObject bool open( const QString& host = "localhost", int port = 2947 ); - float latitude() const; - float longitute() const; + GpsLocation position() const; diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index 27ecae3..868b0b0 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp @@ -16,2 +16,3 @@ #include "configwindow.h" +#include "gps.h" #include "logwindow.h" @@ -220,7 +221,7 @@ void WellenreiterMainWindow::demoAddStations() - mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80 ); - mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10 ); - mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:A0:F8:E7:16:22"), false, 3, 10 ); - mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:AA:01:E7:56:62"), false, 3, 15 ); - mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:B0:8E:E7:56:E2"), false, 3, 20 ); + mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 10.10, 20.20 ) ); + 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:A0:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); + mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:AA:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); + mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:B0:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); } diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index f4cfe52..d695c17 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp @@ -49,2 +49,3 @@ const int col_firstseen = 8; const int col_lastseen = 9; +const int col_location = 10; @@ -77,2 +78,4 @@ MScanListView::MScanListView( QWidget* parent, const char* name ) setColumnAlignment( col_lastseen, AlignCenter ); + addColumn( tr( "Location" ) ); + setColumnAlignment( col_location, AlignCenter ); setRootIsDecorated( true ); @@ -115,3 +118,9 @@ void MScanListView::serializeFrom( QDataStream& s) -void MScanListView::addNewItem( const QString& type, const QString& essid, const OMacAddress& mac, bool wep, int channel, int signal ) +void MScanListView::addNewItem( const QString& type, + const QString& essid, + const OMacAddress& mac, + bool wep, + int channel, + int signal, + const GpsLocation& loc ) { @@ -181,2 +190,3 @@ void MScanListView::addNewItem( const QString& type, const QString& essid, const station->setManufacturer( mac.manufacturer() ); + station->setLocation( loc.latitude, loc.longitude ); @@ -470,2 +480,11 @@ void MScanListItem::setManufacturer( const QString& manufacturer ) +void MScanListItem::setLocation( const float& latitude, const float& longitude ) +{ + if ( latitude == 0.0 || longitude == 0.0 ) + setText( col_location, "N/A" ); + else + setText( col_location, QString().sprintf( "%.2f / %.2f", latitude, longitude ) ); +} + + void MScanListItem::playSound( const QString& sound ) const diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h index 5aba0d2..2703b6a 100644 --- a/noncore/net/wellenreiter/gui/scanlist.h +++ b/noncore/net/wellenreiter/gui/scanlist.h @@ -18,2 +18,4 @@ +#include "gps.h" + /* OPIE */ @@ -41,3 +43,4 @@ class MScanListView: public OListView public slots: - void addNewItem( const QString& type, const QString& essid, const OMacAddress& macaddr, bool wep, int channel, int signal ); + void addNewItem( const QString& type, const QString& essid, const OMacAddress& macaddr, bool wep, int channel, int signal, const GpsLocation& location ); + void fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); @@ -101,2 +104,3 @@ class MScanListItem: public OListViewItem void setManufacturer( const QString& manufacturer ); + void setLocation( const float& latitude, const float& longitude ); diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index c03debb..5dc2e79 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -173,10 +173,12 @@ void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) + GpsLocation loc( 0, 0 ); if ( configwindow->enableGPS->isChecked() ) { + // TODO: add check if GPS is working!? qDebug( "Wellenreiter::gathering GPS data..." ); - float lat = gps->latitude(); - qDebug( "Wellenreiter::GPS data received is ( %f , %f )", lat, 0.0 ); + loc = gps->position(); + qDebug( "Wellenreiter::GPS data received is ( %f , %f )", loc.latitude, loc.longitude ); } - netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0 ); + netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp index 36fbb9a..eac5d89 100644 --- a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp @@ -125,6 +125,6 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f "<hr>\n" +"Michael 'Mickey' Lauer<br><hr>\n" "Max Moser<br>\n" "Martin J. Muench<br>\n" -"Michael Lauer<br><hr>\n" -"<b>www.remote-exploit.org</b>\n" +"<b>www.wellenreiter.net</b>\n" "</p>" ) ); |