com.buglabs.bug.module.gsm
Class GSMModlet

java.lang.Object
  extended by com.buglabs.bug.module.gsm.GSMModlet
All Implemented Interfaces:
IGSMModuleControl, IModlet, IModuleControl, IModuleLEDController, PublicWSProvider, PublicWSProvider2

public class GSMModlet
extends java.lang.Object
implements IModlet, IGSMModuleControl, IModuleControl, PublicWSProvider2, 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_MODULE_NAME
           
 
Fields inherited from interface com.buglabs.services.ws.PublicWSProvider
DELETE, GET, PACKAGE_ID, POST, PUT
 
Constructor Summary
GSMModlet(BundleContext context, int slotId, java.lang.String moduleId, java.lang.String moduleName)
           
GSMModlet(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()
           
 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.
 java.lang.String getPublicName()
           
 int getSlotId()
           
 int LEDGreenOff()
           
 int LEDGreenOn()
           
 int LEDRedOff()
           
 int LEDRedOn()
           
 int resume()
          Resume the module.
 int setLEDGreen(boolean state)
           
 int setLEDRed(boolean state)
           
 boolean setModuleProperty(IModuleProperty property)
          Set a property.
 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

MODULE_ID

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

GSMModlet

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

GSMModlet

public GSMModlet(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

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

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

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