com.gtosoft.libvoyager.session
Class HybridSession

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

public class HybridSession
extends java.lang.Object

Presently, the PIDDecoder is tightly woven with just one device. So if instantiating multiple devices, it's necessary to instantiate new PIDDecoder instances. For example, the new passive network detection, it locks in the GLOBAL NetworkID variable in PIDDecoder, so other device types won't work in that instance.

Author:
brad

Nested Class Summary
static class HybridSession.OOBMessageTypes
           
 
Field Summary
static int SESSION_TYPE_COMMAND
           
static int SESSION_TYPE_MONITOR
           
static int SESSION_TYPE_OBD2
           
static int SESSION_TYPE_UNDEFINED
           
 
Constructor Summary
HybridSession(BluetoothAdapter btAdapter, java.lang.String btAddr, DashDB dashDB, EventCallback OOBEventCallback)
          Constructor.
 
Method Summary
 boolean collectChildStats()
          Possibly not a fast method...
 java.lang.String getAllStatsAsString()
           
 ELMBT getEBT()
           
 MonitorSession getMonitorSession()
           
 OBD2Session getOBDSession()
           
 PIDDecoder getPIDDecoder()
           
 RoutineScan getRoutineScan()
           
 GeneralStats getStats()
          Collect child stats and our own and return it all rolled up into a single genstats instance.
 java.util.HashMap<java.lang.String,java.lang.String> getStatsAsHashMap()
           
 boolean isHardwareSniffable()
          returns true if the hardware supports sniffing.
 boolean isHardwareSWCAN()
           
 boolean isReady()
          Returns true if we're ready for use.
 boolean registerDPArrivedCallback(EventCallback DPArrivedCallback)
          Just for testing - registers a dp handler which just sends new DPNs through the msg() system for display.
 boolean registerMsgCallback(EventCallback ecbMsg)
           
 void registerOOBHandler(EventCallback newOOBHandler)
          Allow upper layers to register an event listener to be notified of out of band information.
 void runAsynchronousSessionDetection()
          this kicks off an asynchronous thread which starts a LOOP of session detection, ending when session is detected.
 boolean runSessionDetection()
          given an open I/O layer, this method should sequence through each session type, and try and get it spun up on the connection.
 boolean setActiveSession(int newSession)
          Use this method to switch from one session to another.
 void shutdown()
          Call this method to tell us you want to get rid of this instance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SESSION_TYPE_UNDEFINED

public static final int SESSION_TYPE_UNDEFINED
See Also:
Constant Field Values

SESSION_TYPE_COMMAND

public static final int SESSION_TYPE_COMMAND
See Also:
Constant Field Values

SESSION_TYPE_OBD2

public static final int SESSION_TYPE_OBD2
See Also:
Constant Field Values

SESSION_TYPE_MONITOR

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

HybridSession

public HybridSession(BluetoothAdapter btAdapter,
                     java.lang.String btAddr,
                     DashDB dashDB,
                     EventCallback OOBEventCallback)
Constructor.

Parameters:
btAdapter - - a reference to the bluetooth adapter.
btAddr - - Bluetooth address of the peer we want to connect to.
dashDB - - an instance of DashDB.
Method Detail

collectChildStats

public boolean collectChildStats()
Possibly not a fast method... combines stats from all children and returns everything in a thread-safe hashmap.

Returns:
- true on success, false otherwise.

getStats

public GeneralStats getStats()
Collect child stats and our own and return it all rolled up into a single genstats instance.

Returns:
- returns a genstats instance of us and everything beneath us.

getStatsAsHashMap

public java.util.HashMap<java.lang.String,java.lang.String> getStatsAsHashMap()

shutdown

public void shutdown()
Call this method to tell us you want to get rid of this instance. After you run this method, don't access this class.


registerDPArrivedCallback

public boolean registerDPArrivedCallback(EventCallback DPArrivedCallback)
Just for testing - registers a dp handler which just sends new DPNs through the msg() system for display.

Returns:

runAsynchronousSessionDetection

public void runAsynchronousSessionDetection()
this kicks off an asynchronous thread which starts a LOOP of session detection, ending when session is detected. If all the hardware is connected properly then this should tell us exactly what kind of capabilities the hardware has.


isReady

public boolean isReady()
Returns true if we're ready for use. false otherwise.

Returns:

isHardwareSWCAN

public boolean isHardwareSWCAN()

runSessionDetection

public boolean runSessionDetection()
given an open I/O layer, this method should sequence through each session type, and try and get it spun up on the connection. This method is responsible for instantiating the session layers, whichever ones are appropriate.

Returns:
- true on success, false means TRY AGAIN. .

getRoutineScan

public RoutineScan getRoutineScan()

setActiveSession

public boolean setActiveSession(int newSession)
Use this method to switch from one session to another. It will block until the transition has been successfully made.

Returns:

registerMsgCallback

public boolean registerMsgCallback(EventCallback ecbMsg)

registerOOBHandler

public void registerOOBHandler(EventCallback newOOBHandler)
Allow upper layers to register an event listener to be notified of out of band information. We pass information to the upper layers via this callback, using our local method sendOOB....

Parameters:
newOOBHandler -

getAllStatsAsString

public java.lang.String getAllStatsAsString()

getEBT

public ELMBT getEBT()

getOBDSession

public OBD2Session getOBDSession()

getPIDDecoder

public PIDDecoder getPIDDecoder()

getMonitorSession

public MonitorSession getMonitorSession()

isHardwareSniffable

public boolean isHardwareSniffable()
returns true if the hardware supports sniffing.

Returns: