[kismac] [binaervarianz] r143 - in trunk/Sources: Core Support Views
- From: svn@xxxxxxxxxxxxxxxx
- To: kismac@xxxxxxxxxxxxx
- Date: Thu, 27 Apr 2006 12:59:46 +0200
Author: robin
Date: 2006-04-27 12:59:45 +0200 (Thu, 27 Apr 2006)
New Revision: 143
Modified:
trunk/Sources/Core/WaveNet.mm
trunk/Sources/Support/GPSController.m
trunk/Sources/Views/NetView.m
Log:
* Fix for nets without GPS data being drawn onto map
* Improved some logic in GPS data handling (e.g. loss of GPS position, some
GPSd handling)
Modified: trunk/Sources/Core/WaveNet.mm
===================================================================
--- trunk/Sources/Core/WaveNet.mm 2006-04-27 06:02:14 UTC (rev 142)
+++ trunk/Sources/Core/WaveNet.mm 2006-04-27 10:59:45 UTC (rev 143)
@@ -65,14 +65,21 @@
@implementation WaveNet
-(id)initWithID:(int)netID {
+ waypoint cp;
+ GPSController *gpsc;
+
self = [super init];
if (!self) return nil;
_dataLock = [[NSRecursiveLock alloc] init];
[_dataLock lock];
- _netView = [[NetView alloc] initWithNetwork:self];
-
+ // we should only create a _netView for this network if we have the
information to see it
+ // check with GPSController if we have a location or not!
+ gpsc = [WaveHelper gpsController];
+ cp = [gpsc currentPoint];
+ if (cp._lat != 100) _netView = [[NetView alloc] initWithNetwork:self];
+
_ID = nil;
graphData = &zeroGraphData;
@@ -210,11 +217,13 @@
if (_primaryChannel == 0) _primaryChannel = _channel;
_gotData = NO;
- _netView = [[NetView alloc] initWithNetwork:self];
- [_netView setWep:_isWep];
- [_netView setName:_SSID];
- [_netView setCoord:wp];
-
+ if (wp._long != 100) {
+ _netView = [[NetView alloc] initWithNetwork:self];
+ [_netView setWep:_isWep];
+ [_netView setName:_SSID];
+ [_netView setCoord:wp];
+ }
+
_firstPacket = NO;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(updateSettings:) name:KisMACUserDefaultsChanged object:nil];
@@ -281,11 +290,13 @@
wp._long = ew_coord * (ew_dir == 'E' ? 1.0 : -1.0);
wp._elevation = 0;
- _netView = [[NetView alloc] initWithNetwork:self];
- [_netView setWep:_isWep];
- [_netView setName:_SSID];
- [_netView setCoord:wp];
-
+ if (!(wp._long == 100 || (wp._lat == 0 && wp._long == 0))) {
+ _netView = [[NetView alloc] initWithNetwork:self];
+ [_netView setWep:_isWep];
+ [_netView setName:_SSID];
+ [_netView setCoord:wp];
+ }
+
_packetsLog = [[NSMutableArray arrayWithCapacity:20] retain];
_ARPLog = [[NSMutableArray arrayWithCapacity:20] retain];
_ACKLog = [[NSMutableArray arrayWithCapacity:20] retain];
@@ -443,11 +454,13 @@
if (_primaryChannel == 0) _primaryChannel = _channel;
_gotData = NO;
- _netView = [[NetView alloc] initWithNetwork:self];
- [_netView setWep:_isWep];
- [_netView setName:_SSID];
- [_netView setCoord:wp];
-
+ if(wp._long != 100) {
+ _netView = [[NetView alloc] initWithNetwork:self];
+ [_netView setWep:_isWep];
+ [_netView setName:_SSID];
+ [_netView setCoord:wp];
+ }
+
_firstPacket = NO;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(updateSettings:) name:KisMACUserDefaultsChanged object:nil];
@@ -588,7 +601,7 @@
} else {
[WaveHelper secureReplace:&_SSID withObject:newSSID];
}
-
+
[_netView setName:_SSID];
if (!_firstPacket) [[NSNotificationCenter defaultCenter]
postNotificationName:KisMACViewItemChanged object:self];
@@ -631,14 +644,14 @@
//after the first packet we should play some sound
if (_date == Nil) {
if (cp._lat != 100) {
- // we have a GPS position and this is the first
time we've seen the network - initialise _netView
+ // we have a new network with a GPS position -
initialise _netView
_netView = [[NetView alloc]
initWithNetwork:self];
[_netView setWep:_isWep];
- if (_SSID==Nil) [_netView setName:_BSSID];
//draw BSSID into the map
+ if (_SSID==Nil) [_netView setName:_BSSID]; //
use BSSID for map label
else [_netView setName:_SSID];
[_netView setCoord:cp];
}
-
+
if (_isWep >= encryptionTypeWEP) [[NSSound
soundNamed:[[NSUserDefaults standardUserDefaults] objectForKey:@"WEPSound"]]
play];
else [[NSSound soundNamed:[[NSUserDefaults
standardUserDefaults] objectForKey:@"noWEPSound"]] play];
@@ -669,17 +682,25 @@
if ((v==Nil) || ([v intValue]<_curSignal))
[_coordinates setObject:[NSNumber numberWithInt:_curSignal]
forKey:pV];
[pV release];
+ if(_curSignal>=_maxSignal || ([aLat floatValue] == 0)) {
+ if(!_netView) {
+ // we didn't have a GPS position when
this was first found, so initialise _netView now
+ NSLog(@"First GPS fix for net %@ -
initialising",_BSSID);
+ _netView = [[NetView alloc]
initWithNetwork:self];
+ [_netView setWep:_isWep];
+ if (_SSID==Nil) [_netView
setName:_BSSID]; // use BSSID for map label
+ else [_netView setName:_SSID];
+ }
+ gpsc = [WaveHelper gpsController];
+ s = [gpsc NSCoord];
+ if (s) [WaveHelper secureReplace:&aLat
withObject:s];
+ s = [gpsc EWCoord];
+ if (s) [WaveHelper secureReplace:&aLong
withObject:s];
+ s = [gpsc ElevCoord];
+ if (s) [WaveHelper secureReplace:&aElev
withObject:s];
+ [_netView setCoord:cp];
+ }
}
- if(_curSignal>=_maxSignal || ([aLat floatValue] == 0 && [aLong
floatValue] == 0)) {
- gpsc = [WaveHelper gpsController];
- s = [gpsc NSCoord];
- if (s) [WaveHelper secureReplace:&aLat withObject:s];
- s = [gpsc EWCoord];
- if (s) [WaveHelper secureReplace:&aLong withObject:s];
- s = [gpsc ElevCoord];
- if (s) [WaveHelper secureReplace:&aElev withObject:s];
- [_netView setCoord:cp];
- }
}
if(_curSignal>=_maxSignal) _maxSignal=_curSignal;
Modified: trunk/Sources/Support/GPSController.m
===================================================================
--- trunk/Sources/Support/GPSController.m 2006-04-27 06:02:14 UTC (rev
142)
+++ trunk/Sources/Support/GPSController.m 2006-04-27 10:59:45 UTC (rev
143)
@@ -203,22 +203,20 @@
NSLocalizedString(@"Time", "GPS
status string."),
[self lastUpdate],[self
QualData]];
else
- return [NSString stringWithFormat:@"%@: %@ %@\n%@: %@\n%@:
%@%@%@",
+ return [NSString stringWithFormat:@"%@: %@ %@\n%@: %@\n%@:
%@%@",
NSLocalizedString(@"Position", "GPS status string."),
[self NSCoord],[self EWCoord],
NSLocalizedString(@"Elevation", "GPS status string."),
[self ElevCoord],
NSLocalizedString(@"Time", "GPS
status string."),
[self lastUpdate],
- _reliable ? @"" : NSLocalizedString(@" -- NO FIX",
"GPS status string. Needs leading space"),
- [self QualData]];
+ _reliable ? [self QualData] : NSLocalizedString(@" --
NO FIX", "GPS status string. Needs leading space")];
else
- return [NSString stringWithFormat:@"%@: %@ %@\n%@%@",
+ return [NSString stringWithFormat:@"%@: %@ %@\n%@",
NSLocalizedString(@"Position", "GPS status string."),
[self NSCoord],[self EWCoord],
[self lastUpdate],
- _reliable ? @"" : NSLocalizedString(@" -- NO FIX", "GPS status
string. Needs leading space"),
- [self QualData]];
+ _reliable ? [self QualData] : NSLocalizedString(@" -- NO FIX",
"GPS status string. Needs leading space")];
else if ([(NSString*)[[NSUserDefaults standardUserDefaults]
objectForKey:@"GPSDevice"] length]) {
if (_gpsThreadUp) return NSLocalizedString(@"GPS subsystem works, but
there is no data.\nIf you are using gpsd, there may be no GPS
connected.\nOtherwise, your GPS is probably connected but not yet reporting a
position.", "GPS status string");
@@ -526,65 +524,63 @@
timeinterval = [date timeIntervalSinceDate:_lastUpdate];
[WaveHelper secureReplace:&_lastUpdate withObject:date];
+ } else {
+ _reliable = NO;
+ }
+ if ((_reliable)||(_onNoFix==0)) {
+ if (ns >= 0) _ns.dir = 'N';
+ else _ns.dir = 'S';
+
+ if (ew >= 0) _ew.dir = 'E';
+ else _ew.dir = 'W';
+
+ _ns.coordinates = fabs(ns);
+ _ew.coordinates = fabs(ew);
+ _elev.coordinates = elev;
+ if ((velkt > 0) && (_velkt==0)) {
+ _peakvel = 0;
+ _sectordist = 0;
+ _sectortime = 0;
+ [WaveHelper secureReplace:&_sectorStart
withObject:date];
+ } else if ((velkt > 0) || (_velkt > 0)) {
+ // update distances only if we're moving (or just
stopped)
+ displacement = (velkt + _velkt)*timeinterval/7200;
+ _sectordist += displacement;
+ _sectortime += timeinterval;
+ _totaldist += displacement;
+ }
+ _velkt = velkt;
+ veldir = (int)fveldir;
+ _veldir = veldir;
+ if (velkt > _peakvel) _peakvel = velkt;
+ if (velkt > _maxvel) _maxvel = velkt;
- if ((_reliable)||(_onNoFix==0)) {
- if (ns >= 0) _ns.dir = 'N';
- else _ns.dir = 'S';
-
- if (ew >= 0) _ew.dir = 'E';
- else _ew.dir = 'W';
-
- _ns.coordinates = fabs(ns);
- _ew.coordinates = fabs(ew);
- _elev.coordinates = elev;
- if ((velkt > 0) && (_velkt==0)) {
- _peakvel = 0;
- _sectordist = 0;
- _sectortime = 0;
- [WaveHelper secureReplace:&_sectorStart
withObject:date];
- } else if ((velkt > 0) || (_velkt > 0)) {
- // update distances only if we're moving (or
just stopped)
- displacement = (velkt +
_velkt)*timeinterval/7200;
- _sectordist += displacement;
- _sectortime += timeinterval;
- _totaldist += displacement;
- }
- _velkt = velkt;
- veldir = (int)fveldir;
- _veldir = veldir;
- if (velkt > _peakvel) _peakvel = velkt;
- if (velkt > _maxvel) _maxvel = velkt;
+ if (numsat > -1) {
+ _numsat = numsat;
+ _hdop = hdop;
+ }
+ } else if(_onNoFix==2) {
+ _ns.dir = 'N';
+ _ew.dir = 'E';
+
+ _elev.coordinates = -10000;
+ _ns.coordinates = 100;
+ _ew.coordinates = 0;
+ _velkt = 0;
+ }
- if (numsat > -1) {
- _numsat = numsat;
- _hdop = hdop;
- }
- } else if(_onNoFix==2) {
- _ns.dir = 'N';
- _ew.dir = 'E';
-
- _elev.coordinates = -10000;
- _ns.coordinates = 100;
- _ew.coordinates = 0;
- _velkt = 0;
- }
+ if (_reliable) {
+ if (([_lastUpdate
timeIntervalSinceDate:_lastAdd]>_traceInterval) && (_traceInterval != 100)) {
+ waypoint w;
+ w._lat = _ns.coordinates * ((_ns.dir=='N') ? 1.0 :
-1.0);
+ w._long = _ew.coordinates * ((_ew.dir=='E') ? 1.0 :
-1.0);
+ if ([[WaveHelper trace] addPoint:w]) [WaveHelper
secureReplace:&_lastAdd withObject:date];
+ }
+ } else {
+ [[WaveHelper trace] cut];
+ }
- if (_reliable) {
- if (([_lastUpdate timeIntervalSinceDate:_lastAdd]>_traceInterval)
&& (_traceInterval != 100)) {
- waypoint w;
- w._lat = _ns.coordinates * ((_ns.dir=='N') ? 1.0 : -1.0);
- w._long = _ew.coordinates * ((_ew.dir=='E') ? 1.0 : -1.0);
- if ([[WaveHelper trace] addPoint:w]) [WaveHelper
secureReplace:&_lastAdd withObject:date];
- }
- } else {
- [[WaveHelper trace] cut];
- }
-
- } else {
-// be quiet for now
-// NSLog(@"GPSd parsing failure - received: %s",gpsbuf);
- }
[date release];
[subpool release];
Modified: trunk/Sources/Views/NetView.m
===================================================================
--- trunk/Sources/Views/NetView.m 2006-04-27 06:02:14 UTC (rev 142)
+++ trunk/Sources/Views/NetView.m 2006-04-27 10:59:45 UTC (rev 143)
@@ -55,7 +55,7 @@
_netImg = [_networkUnkEnc retain];
_netColor = [[NSColor yellowColor] retain];
_wep = 0;
- _wp._lat = 0;
+ _wp._lat = 100;
_wp._long = 0;
_wp._elevation = 0;
_network = network;
Other related posts:
- » [kismac] [binaervarianz] r143 - in trunk/Sources: Core Support Views