|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.gtosoft.libvoyager.android.ELMBT
public class ELMBT
This class connects to, and remains connected to, the given bluetooth device. This class DOES NOT send any data to the device on its own accord. Instead, data must be sent by a parent class. - This ensures that the calling class can be in any state such as ATMA monitor-all, and we won't disrupt that. Exception 1: Upon connecting, we may go out and query the connected device with a few AT commands for statistical purposes.
Constructor Summary | |
---|---|
ELMBT(BluetoothAdapter defaultAdapter,
java.lang.String peerMACAddress)
Constructor... |
Method Summary | |
---|---|
void |
cancelCurrentSleeps()
May be called by outsiders to tell us to bust out of any sleeps we might be in. |
void |
cancelSniff()
We cancel a sniff (ATMA/ATMT/ATMR) session by sending a single space character. |
boolean |
checkBluetoothSettings()
- Check the system bluetooth settings and make sure bluetooth is enabled and ready for use! - This method may kick off a dialog to the user to request that bluetooth be enabled. |
java.lang.String |
clearInputBuffer()
Clears the input buffer such as before we send an AT command... |
java.lang.String |
getAdapterMAC()
Rerturns the MAC address of the device's bluetooth device. |
long |
getATLoopCount(java.lang.String atCommand,
int testDuration)
See how many AT commands we can send in the given time interval. |
long |
getBytesIn()
Passes the value of the input byte counter. |
java.lang.String |
getCANErrorCounts()
Convenience method to get the response from the ELM ATCS command. |
int |
getNumFailedConnects()
|
int |
getNumInputBytesBuffered()
Shall return the number of bytes currently queued within the inputStream buffer. |
int |
getNumMaxRetries()
|
java.lang.String |
getPeerMAC()
|
java.lang.String |
getPeerName()
|
int |
getProtocolNumber()
Returns the ELM327 ATDPN protocol number. |
java.lang.String |
getProtocolString()
Performs a query against the ELM device and returns the protocol description (ATDP) |
long |
getReadRate()
Returns the read rate in bytes per second. |
GeneralStats |
getStats()
|
long |
getTimeInCurrentState()
|
long |
getTimeSinceLastConnect()
|
int |
inputBytesAvailable()
Wrapper method for getting number of bytes in the input buffer. |
boolean |
isCANErrorFree()
Check the CAN error counters. |
boolean |
isConnected()
Note: After a successful connect() we won't know a disconnect happened until the I/O failcount goes up high enough to suggest that the connection is dead. |
boolean |
isIODoneTrying()
|
boolean |
isValidATResponse(java.lang.String request,
java.lang.String response)
|
void |
notifyBluetoothDisconnected(java.lang.String address)
Call this method with the MAC of a bluetooth device which we just disconnected from. |
java.lang.String |
readInputBuffer_string(char UpToThisCharacter)
Reads all bytes from the input buffer UP TO 4K. |
java.lang.String |
readInputBuffer(char UpToThisCharacter)
|
java.lang.String |
readUpToCharacter(char stopAtThisCharacter,
int maxWaitSeconds)
Loop if necessary (limited by a timeout value) to read data from input buffer up to and including the prompt character. |
java.lang.String |
readUpToPrompt()
Convenience method to read up to the prompt character. |
void |
reconnectIfDisconnected(boolean truetoReconnect)
This method lets you specify whether or not the bluetooth connection should be re-established in the event that it dies. |
void |
registerMessageCallback(EventCallback eventCallback)
A means for a parent class to receive messages generated by this class. |
void |
registerStateChangeCallback(EventCallback eventCallback)
A away for calling class to register a method to get fired off when our state changes (when we disconnect or connect). |
java.lang.String |
sendATCommand(java.lang.String ATCommand)
Send a single AT command and return the response. |
java.lang.String |
sendATCommand2(java.lang.String cmd)
Send AT command, return only the response data. |
java.lang.String |
sendATCommandWithRetry(java.lang.String ATCommand)
Like sendATCommand except: 1. |
boolean |
sendATInitialization(java.lang.String[] atCommands)
Send a series of AT commands, one after another, only proceeding if the last succeeded. |
java.lang.String |
sendOBDCommand(java.lang.String Command)
Send a command to the device, it can be an OBD command... |
boolean |
sendRaw(java.lang.String sendThis)
// * Send the exact string provided. |
void |
setConnectRetryPeriod(int retryPeriodInSeconds)
sets the number of seconds to wait in between connect re-tries. |
void |
setIOReconnectNOW()
Will kick the I/O Layer into trying to connect again. |
void |
setIOStopTryingToConnect()
|
void |
setMaxRetries(int maxRetries)
|
void |
shutdown()
Shut down this class. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ELMBT(BluetoothAdapter defaultAdapter, java.lang.String peerMACAddress)
numHeaderBits
- - 11 or 29defaultAdapter
- - just pass us an adapter. You can do it since you have the context. We're just a java class without the context to grab the default adapter.peerMACAddress
- - MAC address, all uppercase, of the Bluetooth peer for which we are to connect.Method Detail |
---|
public long getTimeInCurrentState()
public void registerMessageCallback(EventCallback eventCallback)
eventCallback
- - override the newMessage() method.public long getTimeSinceLastConnect()
public boolean isConnected()
public void shutdown()
public boolean checkBluetoothSettings()
public void registerStateChangeCallback(EventCallback eventCallback)
eventCallback
- - override onStateChange().public java.lang.String getCANErrorCounts()
public java.lang.String clearInputBuffer()
public java.lang.String sendOBDCommand(java.lang.String Command)
Command
- - for example "01 00"
public java.lang.String sendATCommand(java.lang.String ATCommand)
ATCommand
- - the AT command without \r.
public java.lang.String sendATCommand2(java.lang.String cmd)
ATCommand
-
public java.lang.String sendATCommandWithRetry(java.lang.String ATCommand)
ATCommand
- - the AT command to send, which should result in an OK or ELM response.
public boolean isValidATResponse(java.lang.String request, java.lang.String response)
public boolean sendATInitialization(java.lang.String[] atCommands)
atCommands
- - a String array containing the list of initialization commands.
public boolean sendRaw(java.lang.String sendThis)
sendThis
- - exact string to send to the device.
public int inputBytesAvailable()
public java.lang.String readUpToPrompt()
public int getNumInputBytesBuffered()
public java.lang.String readUpToCharacter(char stopAtThisCharacter, int maxWaitSeconds)
public java.lang.String readInputBuffer(char UpToThisCharacter)
public java.lang.String readInputBuffer_string(char UpToThisCharacter)
UpToThisCharacter
-
public void reconnectIfDisconnected(boolean truetoReconnect)
truetoReconnect
- - set to true if you want ELMBT to reconnect if disconnected. false means we stay disconnected if the connection dies.public long getATLoopCount(java.lang.String atCommand, int testDuration)
atCommand
- testDuration
-
public long getBytesIn()
public long getReadRate()
public void setConnectRetryPeriod(int retryPeriodInSeconds)
retryPeriodInSeconds
- - number of seconds.public void setMaxRetries(int maxRetries)
public int getNumFailedConnects()
public int getNumMaxRetries()
public java.lang.String getAdapterMAC()
public java.lang.String getPeerName()
public java.lang.String getPeerMAC()
public boolean isIODoneTrying()
public void setIOReconnectNOW()
public void setIOStopTryingToConnect()
public void cancelSniff()
public void notifyBluetoothDisconnected(java.lang.String address)
address
- - Bluetooth address, all caps.public GeneralStats getStats()
public void cancelCurrentSleeps()
public boolean isCANErrorFree()
public java.lang.String getProtocolString()
public int getProtocolNumber()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |