|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.gtosoft.libvoyager.session.OBD2Session
public class OBD2Session
- A Session layer which connects ELMBT, with a higher level class, such as PIDDecoder. - We will maintain an open line of OBD2 communication so that bluetooth commands can be sent. - When an OBD2 response is received, we'll leave the decoding up to the PIDDecoder class. - PIDDecoder will probably even request OBD data through us. - Usage: instantiate this class with an alrady -configured ELMBT, and an already-instantiated PIDDecoder. - And make sure to shut down this class by calling its shutdown() - otherwise threads will continue to live beyond our lifetime. - To get data, make a request through PIDDecoder. PIDDecoder will use a callback, which we register, to request us to get data from the bluetooth. We will in turn get that data and pass it back to PIDDecoder for decoding.
Field Summary | |
---|---|
static int |
STATE_BTCONFIGURED
|
static int |
STATE_BTCONNECTED
|
static int |
STATE_OBDCONNECTED
|
static int |
STATE_UNINITIALIZED
|
Constructor Summary | |
---|---|
OBD2Session(ELMBT e,
PIDDecoder p,
java.lang.String NOTUSEDnetwork,
DashDB d)
Constructor. |
Method Summary | |
---|---|
boolean |
_suspend()
Suspend operations by this class/session and return the network to a usable state for others. |
int |
getCurrentState()
|
java.lang.String |
getCurrentStateByName()
|
DashDB |
getDashDB()
Returns a handle to the local DashDB instance... |
java.lang.String |
getOBDProtocol()
Call this AFTER you detect that the session state is in OBDconnected state. |
GeneralStats |
getStats()
|
boolean |
isIODoneTrying()
|
java.lang.String |
obdCommand(java.lang.String obdRequest)
Sends the specified OBD Command and obtains the response. |
void |
registerMessageCallback(EventCallback eventCallback)
A means for a parent class to receive messages generated by this class. |
void |
registerOnStateChangedListener(EventCallback newStateChangeListener)
Convenience method that wraps the setOnStateChangedListener. |
boolean |
resume()
Resume from a suspended state - re-initialize the device in a way that ensures that it is ready for our state. |
java.lang.String |
sendATCommand(java.lang.String ATCommand)
Allow the sending of AT commands... |
java.lang.String |
sendDTCReset()
|
java.util.HashMap<java.lang.String,java.lang.String> |
sendOBDRequestByName(java.lang.String dataPointName)
** Intended to be called by piddecoder, not you... |
void |
setIOReconnectNOW()
Will kick the I/O Layer into trying to connect again. |
void |
setOnStateChangedListener(EventCallback newStateChangeListener)
Define a method that you want to be executed any time the OBD2 state changes. |
void |
shutdown()
Shutdown threads and clean up. |
boolean |
startStateManagementThread()
defines and starts the state management thread. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int STATE_UNINITIALIZED
public static final int STATE_BTCONNECTED
public static final int STATE_BTCONFIGURED
public static final int STATE_OBDCONNECTED
Constructor Detail |
---|
public OBD2Session(ELMBT e, PIDDecoder p, java.lang.String NOTUSEDnetwork, DashDB d)
network
- - defines which network we're on. This is quite important.
Records in the DB are distinguished by this network ID.e
- - An instance of ELMBT which we'll use for I/O.p
- - An instance of PIDDecoder. We register ourself with this
piddecoder so they can pass us requests.Method Detail |
---|
public int getCurrentState()
public java.lang.String getCurrentStateByName()
public boolean startStateManagementThread()
public void setOnStateChangedListener(EventCallback newStateChangeListener)
newStateChangeListener
- - an instance of EventCallback with onStateChange() defined
(overridden).public void registerOnStateChangedListener(EventCallback newStateChangeListener)
newStateChangeListener
- public void registerMessageCallback(EventCallback eventCallback)
eventCallback
- - override the newMessage() method.public void shutdown()
public DashDB getDashDB()
public java.lang.String obdCommand(java.lang.String obdRequest)
obdRequest
- - raw request without the CR/LF.
public java.lang.String sendATCommand(java.lang.String ATCommand)
ATCommand
-
public java.util.HashMap<java.lang.String,java.lang.String> sendOBDRequestByName(java.lang.String dataPointName)
dataPointName
- - the data point name for which we want data.
public boolean isIODoneTrying()
public void setIOReconnectNOW()
public java.lang.String sendDTCReset()
public boolean _suspend()
public boolean resume()
public GeneralStats getStats()
public java.lang.String getOBDProtocol()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |