frog.plugin.spot
Class SpotConnection

java.lang.Object
  extended by frog.plugin.spot.SpotConnection
All Implemented Interfaces:
Frog_Spot_Constants

public class SpotConnection
extends Object
implements Frog_Spot_Constants

SpotConnection is a peer-to-peer connection with a single SPOT. It is responsible for listening for incoming gestures and passing them up to the higher portions of FROG and for sending any messages back to the SPOT.

Author:
Team Better Recognize

Field Summary
(package private)  Vector<String> activeFilters
           
 
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
 
Constructor Summary
SpotConnection(String address, short txPort, short rxPort, Device device)
          Creates a new SpotConnection to a SPOT at the given address and port
 
Method Summary
 void close()
          Attempt to kill this connection nicely.
 int getSampleRate()
          Returns the current sample rate of this SPOT.
 void send(Message msg)
          Send a Message to the device.
 void setSampleRate(int rate)
          Sets the rate at which the SPOT will sample its accelerometers.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

activeFilters

final Vector<String> activeFilters
Constructor Detail

SpotConnection

public SpotConnection(String address,
                      short txPort,
                      short rxPort,
                      Device device)
               throws IOException
Creates a new SpotConnection to a SPOT at the given address and port

Parameters:
address - the IEEE address of the SPOT to connect to
rxPort - the port number assigned to the receiving connection
txPort - the port number assigned to the sending connection
device - the Device object representing this connection
Throws:
IOException - if any errors arise out of creating this connection
Method Detail

close

public void close()
           throws IOException
Attempt to kill this connection nicely. Usually called by Device.disconnect(). Does not notify of unexpected disconnect.

Throws:
IOException

getSampleRate

public int getSampleRate()
Returns the current sample rate of this SPOT. Will be a valid sample rate in the range of 1 to 1000Hz.

Returns:
the sample rate in hertz

send

public void send(Message msg)
Send a Message to the device.

Parameters:
msg - the Message to be sent

setSampleRate

public void setSampleRate(int rate)
                   throws IOException
Sets the rate at which the SPOT will sample its accelerometers. The given number must be an integer in the range of 1 to 1000Hz.

Parameters:
rate - the new sampling rate in hertz for the SPOT
Throws:
IOException - if the sample rate is invalid

toString

public String toString()
Overrides:
toString in class Object