com.buglabs.bug.module.gps
Class GPSModlet

java.lang.Object
  extended by com.buglabs.bug.module.gps.GPSModlet
All Implemented Interfaces:
IGPSModuleControl, IPositionProvider, IModlet, IModuleControl, IModuleLEDController, PublicWSProvider, PublicWSProvider2

public class GPSModlet
extends java.lang.Object
implements IModlet, IGPSModuleControl, IModuleControl, PublicWSProvider2, IPositionProvider, IModuleLEDController

The Modlet exports the hardware-level services to the OSGi runtime.


Field Summary
static java.lang.String MODULE_ID
           
protected static java.lang.String PROPERTY_ANTENNA
           
protected static java.lang.String PROPERTY_ANTENNA_ACTIVE
           
protected static java.lang.String PROPERTY_ANTENNA_PASSIVE
           
protected static java.lang.String PROPERTY_GPS_FIX
           
protected static java.lang.String PROPERTY_IOX
           
protected static java.lang.String PROPERTY_MODULE_NAME
           
 
Fields inherited from interface com.buglabs.bug.module.gps.pub.IGPSModuleControl
STATUS_ACTIVE_ANTENNA, STATUS_PASSIVE_ANTENNA
 
Fields inherited from interface com.buglabs.services.ws.PublicWSProvider
DELETE, GET, PACKAGE_ID, POST, PUT
 
Constructor Summary
GPSModlet(BundleContext context, int slotId, java.lang.String moduleId, java.lang.String moduleName)
           
GPSModlet(BundleContext context, int slotId, java.lang.String moduleId, java.lang.String moduleName, BMIModuleProperties properties)
           
 
Method Summary
 PublicWSDefinition discover(int operation)
           
 IWSResponse execute(int operation, java.lang.String input)
          Execute a service.
 java.lang.String getDescription()
           
 LatLon getLatitudeLongitude()
           
 java.lang.String getModuleId()
          Return the MODULE ID.
 java.lang.String getModuleName()
          Get the human-readable name of this module.
 java.util.List getModuleProperties()
          Return a list of IModuleProperty elements.
 Position getPosition()
           
 java.lang.String getPublicName()
           
 int getSlotId()
           
 int getStatus()
          bit 0: GPS FIX Active Low.
 int LEDGreenOff()
           
 int LEDGreenOn()
           
 int LEDRedOff()
           
 int LEDRedOn()
           
 int resume()
          Resume the module.
 int setActiveAntenna()
          Use the active (external) antenna of the gps device.
 int setLEDGreen(boolean state)
           
 int setLEDRed(boolean state)
           
 boolean setModuleProperty(IModuleProperty property)
          Set a property.
 int setPassiveAntenna()
          Use the passive (internal) antenna of the gps device.
 void setPublicName(java.lang.String name)
          Set the name of the service.
 void setup()
          Connect to any devices or do any initialization.
 void start()
          Begin modlet.
 void stop()
          Unregister services and release any resources.
 int suspend()
          Suspend the module.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_MODULE_NAME

protected static final java.lang.String PROPERTY_MODULE_NAME
See Also:
Constant Field Values

PROPERTY_IOX

protected static final java.lang.String PROPERTY_IOX
See Also:
Constant Field Values

PROPERTY_GPS_FIX

protected static final java.lang.String PROPERTY_GPS_FIX
See Also:
Constant Field Values

PROPERTY_ANTENNA

protected static final java.lang.String PROPERTY_ANTENNA
See Also:
Constant Field Values

PROPERTY_ANTENNA_PASSIVE

protected static final java.lang.String PROPERTY_ANTENNA_PASSIVE
See Also:
Constant Field Values

PROPERTY_ANTENNA_ACTIVE

protected static final java.lang.String PROPERTY_ANTENNA_ACTIVE
See Also:
Constant Field Values

MODULE_ID

public static final java.lang.String MODULE_ID
See Also:
Constant Field Values
Constructor Detail

GPSModlet

public GPSModlet(BundleContext context,
                 int slotId,
                 java.lang.String moduleId,
                 java.lang.String moduleName)
Parameters:
context -
slotId -
moduleId -
moduleName -

GPSModlet

public GPSModlet(BundleContext context,
                 int slotId,
                 java.lang.String moduleId,
                 java.lang.String moduleName,
                 BMIModuleProperties properties)
Method Detail

start

public void start()
           throws java.lang.Exception
Description copied from interface: IModlet
Begin modlet. Any services that the modlet supports should be registered here.

Specified by:
start in interface IModlet
Throws:
java.lang.Exception

stop

public void stop()
          throws java.lang.Exception
Description copied from interface: IModlet
Unregister services and release any resources.

Specified by:
stop in interface IModlet
Throws:
java.lang.Exception

getPosition

public Position getPosition()
Specified by:
getPosition in interface IPositionProvider
Returns:
current position as Position object or null if unable to determine position.

getModuleProperties

public java.util.List getModuleProperties()
Description copied from interface: IModuleControl
Return a list of IModuleProperty elements.

Specified by:
getModuleProperties in interface IModuleControl
Returns:

setModuleProperty

public boolean setModuleProperty(IModuleProperty property)
Description copied from interface: IModuleControl
Set a property. This is from a client request.

Specified by:
setModuleProperty in interface IModuleControl
Returns:

getModuleName

public java.lang.String getModuleName()
Description copied from interface: IModuleControl
Get the human-readable name of this module.

Specified by:
getModuleName in interface IModuleControl
Returns:

getModuleId

public java.lang.String getModuleId()
Description copied from interface: IModlet
Return the MODULE ID. This comes from the hardware.

Specified by:
getModuleId in interface IModlet
Returns:

getSlotId

public int getSlotId()
Specified by:
getSlotId in interface IModlet
Specified by:
getSlotId in interface IModuleControl
Returns:
Slot that the Module is currently connected to.

resume

public int resume()
           throws java.io.IOException
Description copied from interface: IModuleControl
Resume the module.

Specified by:
resume in interface IModuleControl
Throws:
java.io.IOException

suspend

public int suspend()
            throws java.io.IOException
Description copied from interface: IModuleControl
Suspend the module.

Specified by:
suspend in interface IModuleControl
Throws:
java.io.IOException

discover

public PublicWSDefinition discover(int operation)
Specified by:
discover in interface PublicWSProvider
Parameters:
operation - HTTP operation. See IPublicServiceProvider.GET, etc.
Returns:
The description of what the service requires and provides.

execute

public IWSResponse execute(int operation,
                           java.lang.String input)
Description copied from interface: PublicWSProvider
Execute a service. This is a proxy to a native OSGi style service.

Specified by:
execute in interface PublicWSProvider
Parameters:
operation - PublicWSProvider.GET, .PUT, .POST, .DELETE
Returns:

getPublicName

public java.lang.String getPublicName()
Specified by:
getPublicName in interface PublicWSProvider
Returns:
Name that this service uses.

getDescription

public java.lang.String getDescription()
Specified by:
getDescription in interface PublicWSProvider
Returns:
A brief description of the service.

setup

public void setup()
           throws java.lang.Exception
Description copied from interface: IModlet
Connect to any devices or do any initialization. This is a good place to throw an exception if the expected hardware environment is not valid.

Specified by:
setup in interface IModlet
Throws:
java.lang.Exception

getLatitudeLongitude

public LatLon getLatitudeLongitude()
Specified by:
getLatitudeLongitude in interface IPositionProvider
Returns:
current position as LatLon object or null if unable to determine Lat/Long.

LEDGreenOff

public int LEDGreenOff()
                throws java.io.IOException
Throws:
java.io.IOException

LEDGreenOn

public int LEDGreenOn()
               throws java.io.IOException
Throws:
java.io.IOException

LEDRedOff

public int LEDRedOff()
              throws java.io.IOException
Throws:
java.io.IOException

LEDRedOn

public int LEDRedOn()
             throws java.io.IOException
Throws:
java.io.IOException

getStatus

public int getStatus()
              throws java.io.IOException
Description copied from interface: IGPSModuleControl
bit 0: GPS FIX Active Low. bit 1: Overcurrent condition caused by the active antenna path. Active Low. bit 2: Output to wake up device from sleep after push_to_fix. Active High. bit 3: Input to download firmware to flash. bit 4: Unused bit 5: Unused bit 7, 6: 0, 1 Passtive Antenna (External Antenna) 1, 0 Active Antenna (Internal Antenna)

Specified by:
getStatus in interface IGPSModuleControl
Returns:
the value of the IOX register
Throws:
java.io.IOException

setActiveAntenna

public int setActiveAntenna()
                     throws java.io.IOException
Description copied from interface: IGPSModuleControl
Use the active (external) antenna of the gps device.

Specified by:
setActiveAntenna in interface IGPSModuleControl
Returns:
value returned by ioctl.
Throws:
java.io.IOException

setPassiveAntenna

public int setPassiveAntenna()
                      throws java.io.IOException
Description copied from interface: IGPSModuleControl
Use the passive (internal) antenna of the gps device.

Specified by:
setPassiveAntenna in interface IGPSModuleControl
Returns:
value returned by ioctl.
Throws:
java.io.IOException

setLEDGreen

public int setLEDGreen(boolean state)
                throws java.io.IOException
Specified by:
setLEDGreen in interface IModuleLEDController
Throws:
java.io.IOException

setLEDRed

public int setLEDRed(boolean state)
              throws java.io.IOException
Specified by:
setLEDRed in interface IModuleLEDController
Parameters:
state - on = true, off = false;
Returns:
the return of the underlying ioctl.
Throws:
java.io.IOException

setPublicName

public void setPublicName(java.lang.String name)
Description copied from interface: PublicWSProvider2
Set the name of the service. This can be done on registration.

Specified by:
setPublicName in interface PublicWSProvider2