frog.plugin.spot.onspot
Class FrogSpot

java.lang.Object
  extended by javax.microedition.midlet.MIDlet
      extended by frog.plugin.spot.onspot.FrogSpot
All Implemented Interfaces:
TimerCounterBits, ISwitchListener, Frog_Spot_Constants

public class FrogSpot
extends MIDlet
implements Frog_Spot_Constants, ISwitchListener, TimerCounterBits

Main class for FROG interaction using a Sun SPOT. Provides access to all SunSPOT facilities and sets up all the Managers.

Author:
Team Better Recognize
See Also:
AccelManager, FilterManager, ConnectionManager

Field Summary
(package private) static LIS3L02AQAccelerometer accel
           
(package private) static byte ACCEL_FAILURE
          Status light
protected  AccelManager accelManager
           
protected  ConnectionManager conn
           
(package private) static byte CONNECTED
          Status light
(package private) static byte DISCOVER_FAILURE
          Status light
(package private) static EDemoBoard e
           
protected  FilterManager filter
           
(package private) static byte FILTER_FAILURE
          Status light
(package private) static byte FINDING_HOST
          Status light
(package private) static ITriColorLED[] leds
           
(package private) static byte RECEIVE_FAILURE
          Status light
(package private) static IRadioPolicyManager rpm
           
(package private) static byte SEND_FAILURE
          Status light
(package private) static ISpot spot
           
(package private) static ISwitch sw1
           
(package private) static ISwitch sw2
           
(package private) static IAT91_TC timer
           
(package private) static byte TURN_OFF
          Status light
(package private) static byte WATCHER_FAILURE
          Status light
 
Fields inherited from interface frog.plugin.spot.Frog_Spot_Constants
CORRUPT_DATA, END_OF_DATA, INT_CORRUPT_DATA, INT_END_OF_DATA, MSG_ACK, MSG_ADD_FILTER, MSG_ALIVE, MSG_DISCONNECT, MSG_DISCOVER, MSG_END_OF_DATA, MSG_ERROR, MSG_GESTURE, MSG_REMOVE_FILTERS, MSG_RESEND, MSG_SAMPLE_RATE, PORT_BCAST, PORT_MAX, PORT_REPLY, PORT_START, SPOT1, SPOT1_PORT, SPOT2, SPOT2_PORT, SPOT3, SPOT3_PORT, SPOT4, SPOT4_PORT, SPOT5, SPOT5_PORT, SPOT6, SPOT6_PORT, SPOT7, SPOT7_PORT, SPOT8, SPOT8_PORT, SPOTB1, SPOTB1_PORT, SPOTB2, SPOTB2_PORT, SPOTB3, SPOTB3_PORT, SPOTB4, SPOTB4_PORT
 
Fields inherited from interface com.sun.spot.peripheral.TimerCounterBits
TC_ABETRG, TC_ABETRG_TIOA, TC_ABETRG_TIOB, TC_ACPA, TC_ACPA_CLEAR_OUTPUT, TC_ACPA_OUTPUT_NONE, TC_ACPA_SET_OUTPUT, TC_ACPA_TOGGLE_OUTPUT, TC_ACPC, TC_ACPC_CLEAR_OUTPUT, TC_ACPC_OUTPUT_NONE, TC_ACPC_SET_OUTPUT, TC_ACPC_TOGGLE_OUTPUT, TC_AEEVT, TC_AEEVT_CLEAR_OUTPUT, TC_AEEVT_OUTPUT_NONE, TC_AEEVT_SET_OUTPUT, TC_AEEVT_TOGGLE_OUTPUT, TC_ASWTRG, TC_ASWTRG_CLEAR_OUTPUT, TC_ASWTRG_OUTPUT_NONE, TC_ASWTRG_SET_OUTPUT, TC_ASWTRG_TOGGLE_OUTPUT, TC_BCPB, TC_BCPB_CLEAR_OUTPUT, TC_BCPB_OUTPUT_NONE, TC_BCPB_SET_OUTPUT, TC_BCPB_TOGGLE_OUTPUT, TC_BCPC, TC_BCPC_CLEAR_OUTPUT, TC_BCPC_OUTPUT_NONE, TC_BCPC_SET_OUTPUT, TC_BCPC_TOGGLE_OUTPUT, TC_BEEVT, TC_BEEVT_CLEAR_OUTPUT, TC_BEEVT_OUTPUT_NONE, TC_BEEVT_SET_OUTPUT, TC_BEEVT_TOGGLE_OUTPUT, TC_BSWTRG, TC_BSWTRG_CLEAR_OUTPUT, TC_BSWTRG_OUTPUT_NONE, TC_BSWTRG_SET_OUTPUT, TC_BSWTRG_TOGGLE_OUTPUT, TC_BURST, TC_BURST_NONE, TC_BURST_XC1, TC_BURST_XC2, TC_BUSRT_XC0, TC_CAPT, TC_CLKDIS, TC_CLKEN, TC_CLKI, TC_CLKS, TC_CLKS_MCK128, TC_CLKS_MCK2, TC_CLKS_MCK32, TC_CLKS_MCK8, TC_CLKS_SLCK, TC_CLKS_XC0, TC_CLKS_XC1, TC_CLKS_XC2, TC_CLKSTA, TC_COVFS, TC_CPAS, TC_CPBS, TC_CPCDIS, TC_CPCS, TC_CPCSTOP, TC_CPCTRG, TC_EEVT, TC_EEVT_TIOB, TC_EEVT_XC0, TC_EEVT_XC1, TC_EEVT_XC2, TC_EEVTEDG, TC_EEVTEDG_BOTH_EDGE, TC_EEVTEDG_EDGE_NONE, TC_EEVTEDG_FALLING_EDGE, TC_EEVTEDG_RISING_EDGE, TC_ENETRG, TC_ETRGEDG, TC_ETRGEDG_BOTH_EDGE, TC_ETRGEDG_EDGE_NONE, TC_ETRGEDG_FALLING_EDGE, TC_ETRGEDG_RISING_EDGE, TC_ETRGS, TC_LDBDIS, TC_LDBSTOP, TC_LDRA, TC_LDRA_BOTH_EDGE, TC_LDRA_EDGE_NONE, TC_LDRA_FALLING_EDGE, TC_LDRA_RISING_EDGE, TC_LDRAS, TC_LDRB, TC_LDRB_BOTH_EDGE, TC_LDRB_EDGE_NONE, TC_LDRB_FALLING_EDGE, TC_LDRB_RISING_EDGE, TC_LDRBS, TC_LOVRS, TC_MTIOA, TC_MTIOB, TC_NONEXC0, TC_NONEXC1, TC_NONEXC2, TC_SWTRG, TC_SYNC, TC_TC0XC0S, TC_TC1XC1S, TC_TC2XC2S, TC_TCLK0XC0, TC_TCLK1XC1, TC_TCLK2XC2, TC_TIOA0XC1, TC_TIOA0XC2, TC_TIOA1XC0, TC_TIOA1XC2, TC_TIOA2XC0, TC_TIOA2XC1, TC_WAVE, TC_WAVSEL_UP_AUTO_TRG_CP, TC_WAVSEL_UPDOWN_AUTO_TRG_CP, TC_WAVSEL_UPDOWN_NO_TRG_CP
 
Constructor Summary
FrogSpot()
          FrogSpot is constructed from the main method of the Squawk VM.
 
Method Summary
protected  void destroyApp(boolean unconditional)
          Called by the Squawk VM when the reset button is pressed.
(package private) static void enableLights(byte status)
          Sets the LEDs on the SPOT to a given status code.
protected  void pauseApp()
          Deprecated. Never called. Not used by the Squawk VM.
 void shutdown()
          Silently catches any exceptions from destroyApp(boolean) and reboots the SPOT.
protected  void startApp()
          Squawk VM starts execution here.
 void switchPressed(ISwitch sw2)
          Reboots the Sun SPOT.
 void switchReleased(ISwitch sw2)
          Deprecated. unused
 
Methods inherited from class javax.microedition.midlet.MIDlet
getAppProperty, notifyDestroyed, notifyPaused, resumeRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

e

static final EDemoBoard e

accel

static final LIS3L02AQAccelerometer accel

leds

static final ITriColorLED[] leds

spot

static final ISpot spot

rpm

static final IRadioPolicyManager rpm

sw1

static final ISwitch sw1

sw2

static final ISwitch sw2

timer

static final IAT91_TC timer

TURN_OFF

static final byte TURN_OFF
Status light

See Also:
Constant Field Values

FINDING_HOST

static final byte FINDING_HOST
Status light

See Also:
Constant Field Values

CONNECTED

static final byte CONNECTED
Status light

See Also:
Constant Field Values

DISCOVER_FAILURE

static final byte DISCOVER_FAILURE
Status light

See Also:
Constant Field Values

ACCEL_FAILURE

static final byte ACCEL_FAILURE
Status light

See Also:
Constant Field Values

FILTER_FAILURE

static final byte FILTER_FAILURE
Status light

See Also:
Constant Field Values

SEND_FAILURE

static final byte SEND_FAILURE
Status light

See Also:
Constant Field Values

RECEIVE_FAILURE

static final byte RECEIVE_FAILURE
Status light

See Also:
Constant Field Values

WATCHER_FAILURE

static final byte WATCHER_FAILURE
Status light

See Also:
Constant Field Values

accelManager

protected final AccelManager accelManager

filter

protected final FilterManager filter

conn

protected final ConnectionManager conn
Constructor Detail

FrogSpot

public FrogSpot()
         throws Throwable
FrogSpot is constructed from the main method of the Squawk VM. The constructor puts the SPOT into discoverable and goes no farther until a host has requested a connection to the SPOT.

Throws:
Throwable - if anything goes wrong setting up this MIDlet
Method Detail

destroyApp

protected void destroyApp(boolean unconditional)
                   throws MIDletStateChangeException
Called by the Squawk VM when the reset button is pressed. Can also be called by the shutdown() method when an error occurs or switch 2 is pressed.

Specified by:
destroyApp in class MIDlet
Parameters:
unconditional - unused
Throws:
MIDletStateChangeException

pauseApp

protected void pauseApp()
Deprecated. Never called. Not used by the Squawk VM.

Specified by:
pauseApp in class MIDlet

shutdown

public void shutdown()
Silently catches any exceptions from destroyApp(boolean) and reboots the SPOT.


startApp

protected void startApp()
                 throws MIDletStateChangeException
Squawk VM starts execution here. Sets accelerometers to 6G scale and the timer to the desired sample rate as defined in AccelManager.

Specified by:
startApp in class MIDlet
Throws:
MIDletStateChangeException

switchPressed

public void switchPressed(ISwitch sw2)
Reboots the Sun SPOT.

Specified by:
switchPressed in interface ISwitchListener
Parameters:
sw2 - the SPOT's "Switch 2"

switchReleased

public void switchReleased(ISwitch sw2)
Deprecated. unused

Specified by:
switchReleased in interface ISwitchListener

enableLights

static void enableLights(byte status)
Sets the LEDs on the SPOT to a given status code. The code must be a number between 0 and 8. 0 Turns all lights off. Any other number lights up its corresponding LED.

Parameters:
status - a given status byte such as FINDING_HOST or JOIN_FAILURE