com.gtosoft.libvoyager.session
Class CommandSession

java.lang.Object
  extended by com.gtosoft.libvoyager.session.CommandSession

public class CommandSession
extends java.lang.Object

This class defines methods and procedures for sending commands on the SWCAN Network.

Author:
brad

Field Summary
static int STATE_READY
           
static int STATE_UNINITIALIZED
           
 
Constructor Summary
CommandSession(ELMBT bt, DashDB dashDB)
          Default Constructor.
 
Method Summary
 void doVoyagerVMorseCode()
          This method sends a command to the network which invokes the audio system and plays a "V" in Morse code, representative of Voyager command session having successfully connected.
 int getCurrentState()
          Lets others know our internal state!
 GeneralStats getStats()
           
 boolean isIODoneTrying()
           
 void registerMsgCallback(EventCallback eCallback)
          Call this method to register your very own callback to receive messages from this class!
 void registerStateChangeCallback(EventCallback newStateChangeCallback)
           
 boolean resume()
          Perform any actions necessary to resume from a suspend.
 boolean sendCommand_SYNC(java.lang.String commandName)
          synchronously (not in a separate thread thread) send the specified command.
 void sendCommand(java.lang.String commandName)
          Send a command over the network asynchronously.
 boolean setHeaders(java.lang.String fourByteHeader)
           
 void setIOReconnectNOW()
          Will kick the I/O Layer into trying to connect again.
 void setKeepalives(boolean onOrOff)
          With this method you can set whether or not we shall send keepalive messages to the bluetooth peer.
 void shutdown()
           
 boolean suspend()
          Suspend operations by this class/session and return the network to a usable state for others.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE_UNINITIALIZED

public static final int STATE_UNINITIALIZED
See Also:
Constant Field Values

STATE_READY

public static final int STATE_READY
See Also:
Constant Field Values
Constructor Detail

CommandSession

public CommandSession(ELMBT bt,
                      DashDB dashDB)
Default Constructor.

Parameters:
bt - - a reference to the ElmBT object which we should use to connect to the command network. Please initialize bt before passint it to us.
Method Detail

doVoyagerVMorseCode

public void doVoyagerVMorseCode()
This method sends a command to the network which invokes the audio system and plays a "V" in Morse code, representative of Voyager command session having successfully connected.


registerStateChangeCallback

public void registerStateChangeCallback(EventCallback newStateChangeCallback)

getCurrentState

public int getCurrentState()
Lets others know our internal state!

Returns:

setKeepalives

public void setKeepalives(boolean onOrOff)
With this method you can set whether or not we shall send keepalive messages to the bluetooth peer. This has two purposes: 1. Enhanced responsiveness, since the connection never goes to sleep 2. Quickly detect dead connections, since I/O must be flowing in order to know the connection has died.

Parameters:
onOrOff - - true to turn them on, false turns them off.

shutdown

public void shutdown()

registerMsgCallback

public void registerMsgCallback(EventCallback eCallback)
Call this method to register your very own callback to receive messages from this class!

Parameters:
eCallback - - this is an instance of com.gtosoft.dash.EventCallback with the newMsg method overridden with your own code.

sendCommand

public void sendCommand(java.lang.String commandName)
Send a command over the network asynchronously.

Parameters:
commandName -

sendCommand_SYNC

public boolean sendCommand_SYNC(java.lang.String commandName)
synchronously (not in a separate thread thread) send the specified command.

Parameters:
commandName -
Returns:

setHeaders

public boolean setHeaders(java.lang.String fourByteHeader)

isIODoneTrying

public boolean isIODoneTrying()
Returns:
- returns true if the IO layer is done trying to reconnect.

setIOReconnectNOW

public void setIOReconnectNOW()
Will kick the I/O Layer into trying to connect again.


getStats

public GeneralStats getStats()

suspend

public boolean suspend()
Suspend operations by this class/session and return the network to a usable state for others. We will go to sleep as long as we're suspended.

Returns:

resume

public boolean resume()
Perform any actions necessary to resume from a suspend. This method may also be used during initial startup.

Returns: