org.placelab.spotter
Class WiFiSpotter

java.lang.Object
  extended byorg.placelab.spotter.AbstractSpotter
      extended byorg.placelab.spotter.SyncSpotter
          extended byorg.placelab.spotter.WiFiSpotter
All Implemented Interfaces:
PeriodicScannable, Spotter

public class WiFiSpotter
extends SyncSpotter
implements PeriodicScannable

WiFiSpotter depends on a native code library to poll the WiFi hardware.


Constructor Summary
WiFiSpotter()
          create a spotter with a default scanning interval; the scanning interval is relevant only if the spotter is used in continuous scanning mode
WiFiSpotter(long scanIntervalMillis)
          create a spotter with the specified scanning interval.
 
Method Summary
 void close()
          Unloads resources used by the spotter.
protected  Measurement getMeasurementImpl()
          Collects and returns a single Measurement.
 long getPeriodicScanInterval()
           
protected  long nextScanInterval()
           
 void open()
          Load resources used by the spotter.
 void setPeriodicScanInterval(long intervalMillis)
          Sets the minimum amount of time between SpotterListener.gotMeasurement(Spotter, Measurement) callbacks to listeners.
 void spotter_init(java.lang.String wifiInterface)
          Initialize the spotter
 java.lang.String[] spotter_poll()
          Poll the spotter.
 void spotter_shutdown()
          Shutdown the spotter.
 void startScanning(EventSystem evs)
          Start scanning for Measurements.
 
Methods inherited from class org.placelab.spotter.SyncSpotter
errorInBackgroundThreadAndThreadDeath, getMeasurement, scanUsingBackgroundThread, scanUsingEventSystem, startScanning, stopScanning
 
Methods inherited from class org.placelab.spotter.AbstractSpotter
addListener, notifyEndOfScan, notifyEndOfScan, notifyGotException, notifyGotException, notifyGotMeasurement, notifyGotMeasurement, removeListener, scanOnce, scanOnce, waitForThread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WiFiSpotter

public WiFiSpotter()
create a spotter with a default scanning interval; the scanning interval is relevant only if the spotter is used in continuous scanning mode


WiFiSpotter

public WiFiSpotter(long scanIntervalMillis)
create a spotter with the specified scanning interval. The scanning interval is relevant only if the spotter is used in continuous scanning mode. This form of the contructor will result in a new thread getting created to perform continuous scans

Method Detail

spotter_init

public void spotter_init(java.lang.String wifiInterface)
                  throws SpotterException
Initialize the spotter

Parameters:
wifiInterface - The wireless interface to use. If null or the empty string "", use the first found wireless interface.
Returns:
true on successful init
Throws:
SpotterException

spotter_shutdown

public void spotter_shutdown()
                      throws SpotterException
Shutdown the spotter.

Throws:
SpotterException

spotter_poll

public java.lang.String[] spotter_poll()
                                throws SpotterException
Poll the spotter.

Returns:
an array of BSSID strings
Throws:
SpotterException

setPeriodicScanInterval

public void setPeriodicScanInterval(long intervalMillis)
Description copied from interface: PeriodicScannable
Sets the minimum amount of time between SpotterListener.gotMeasurement(Spotter, Measurement) callbacks to listeners.

Specified by:
setPeriodicScanInterval in interface PeriodicScannable

getPeriodicScanInterval

public long getPeriodicScanInterval()
Specified by:
getPeriodicScanInterval in interface PeriodicScannable

open

public void open()
          throws SpotterException
Description copied from interface: Spotter
Load resources used by the spotter. Applications should be able to invoke this methods multiple times in sequence and have the "right" things happen. All Spotters should be opened before being used.

Specified by:
open in interface Spotter
Throws:
SpotterException - if the necessary hardware or software for this spotter is not present

close

public void close()
Description copied from interface: Spotter
Unloads resources used by the spotter. Multiple calls to close are ok.

Specified by:
close in interface Spotter

startScanning

public void startScanning(EventSystem evs)
Description copied from interface: Spotter
Start scanning for Measurements. This method may or may not create a new thread internally, but should never expose that thread to the application. Instead callbacks to SpotterListeners should be invoked via the Eventsystem.notifyTransientEvent() method, so that the callbacks get run through the EventSystem thread.

Specified by:
startScanning in interface Spotter
Overrides:
startScanning in class SyncSpotter

nextScanInterval

protected long nextScanInterval()
Specified by:
nextScanInterval in class SyncSpotter
Returns:
the interval that the spotter should wait before invoking the next scan

getMeasurementImpl

protected Measurement getMeasurementImpl()
                                  throws SpotterException
Description copied from class: SyncSpotter
Collects and returns a single Measurement.

Specified by:
getMeasurementImpl in class SyncSpotter
Throws:
SpotterException