public abstract class BluetoothConnectionBase extends AndroidNonvisibleComponent implements Component, OnDestroyListener, Deleteable
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
logTag |
protected boolean |
secure |
form
ACCELEROMETER_SENSITIVITY_MODERATE, ACCELEROMETER_SENSITIVITY_STRONG, ACCELEROMETER_SENSITIVITY_WEAK, ALIGNMENT_CENTER, ALIGNMENT_NORMAL, ALIGNMENT_OPPOSITE, ASSET_DIRECTORY, BUTTON_SHAPE_DEFAULT, BUTTON_SHAPE_OVAL, BUTTON_SHAPE_RECT, BUTTON_SHAPE_ROUNDED, COLOR_BLACK, COLOR_BLUE, COLOR_CYAN, COLOR_DEFAULT, COLOR_DKGRAY, COLOR_GRAY, COLOR_GREEN, COLOR_LTGRAY, COLOR_MAGENTA, COLOR_NONE, COLOR_ORANGE, COLOR_PINK, COLOR_RED, COLOR_WHITE, COLOR_YELLOW, DEFAULT_VALUE_COLOR_BLACK, DEFAULT_VALUE_COLOR_BLUE, DEFAULT_VALUE_COLOR_CYAN, DEFAULT_VALUE_COLOR_DEFAULT, DEFAULT_VALUE_COLOR_DKGRAY, DEFAULT_VALUE_COLOR_GRAY, DEFAULT_VALUE_COLOR_GREEN, DEFAULT_VALUE_COLOR_LTGRAY, DEFAULT_VALUE_COLOR_MAGENTA, DEFAULT_VALUE_COLOR_NONE, DEFAULT_VALUE_COLOR_ORANGE, DEFAULT_VALUE_COLOR_PINK, DEFAULT_VALUE_COLOR_RED, DEFAULT_VALUE_COLOR_WHITE, DEFAULT_VALUE_COLOR_YELLOW, DIRECTION_EAST, DIRECTION_MAX, DIRECTION_MIN, DIRECTION_NONE, DIRECTION_NORTH, DIRECTION_NORTHEAST, DIRECTION_NORTHWEST, DIRECTION_SOUTH, DIRECTION_SOUTHEAST, DIRECTION_SOUTHWEST, DIRECTION_WEST, FONT_DEFAULT_SIZE, LAYOUT_ORIENTATION_HORIZONTAL, LAYOUT_ORIENTATION_VERTICAL, LENGTH_FILL_PARENT, LENGTH_PREFERRED, LENGTH_UNKNOWN, SLIDER_MAX_VALUE, SLIDER_MIN_VALUE, SLIDER_THUMB_VALUE, TOAST_LENGTH_LONG, TOAST_LENGTH_SHORT, TYPEFACE_DEFAULT, TYPEFACE_MONOSPACE, TYPEFACE_SANSSERIF, TYPEFACE_SERIF
Modifier | Constructor and Description |
---|---|
protected |
BluetoothConnectionBase(ComponentContainer container,
java.lang.String logTag)
Creates a new BluetoothConnectionBase.
|
protected |
BluetoothConnectionBase(java.io.OutputStream outputStream,
java.io.InputStream inputStream)
This constructor is for testing purposes only.
|
Modifier and Type | Method and Description |
---|---|
boolean |
Available()
Returns true if Bluetooth is available on the device, false otherwise.
|
protected void |
bluetoothError(java.lang.String functionName,
int errorNumber,
java.lang.Object... messageArgs) |
void |
BluetoothError(java.lang.String functionName,
java.lang.String message) |
int |
BytesAvailableToReceive()
Returns number of bytes available from the input stream.
|
java.lang.String |
CharacterEncoding()
Returns the character encoding to use when sending and receiving text.
|
void |
CharacterEncoding(java.lang.String encoding)
Sets the character encoding to use when sending and receiving text.
|
int |
DelimiterByte()
Returns the delimiter byte to use when passing a negative number for the
numberOfBytes parameter when calling ReceiveText, ReceiveSignedBytes, or
ReceiveUnsignedBytes.
|
void |
DelimiterByte(int number)
Sets the delimiter byte to use when passing a negative number for the
numberOfBytes parameter when calling ReceiveText, ReceiveSignedBytes, or
ReceiveUnsignedBytes.
|
void |
Disconnect()
Disconnects from the connected Bluetooth device.
|
boolean |
Enabled()
Returns true if Bluetooth is enabled, false otherwise.
|
boolean |
HighByteFirst()
Returns true if numbers are sent and received with the most significant
byte first.
|
void |
HighByteFirst(boolean highByteFirst)
Specifies whether numbers are sent and received with the most significant
byte first.
|
void |
Initialize()
Default Initialize
|
boolean |
IsConnected()
Returns true if a connection to a Bluetooth device has been made.
|
void |
onDelete() |
void |
onDestroy() |
protected byte[] |
read(java.lang.String functionName,
int numberOfBytes)
Reads a number of bytes from the input stream.
|
int |
ReceiveSigned1ByteNumber()
Reads a signed 1-byte number.
|
int |
ReceiveSigned2ByteNumber()
Reads a signed 2-byte number.
|
long |
ReceiveSigned4ByteNumber()
Reads a signed 4-byte number.
|
java.util.List<java.lang.Integer> |
ReceiveSignedBytes(int numberOfBytes)
Reads a number of signed bytes from the input stream and returns them as
a List.
|
java.lang.String |
ReceiveText(int numberOfBytes)
Reads a number of bytes from the input stream and converts them to text.
|
int |
ReceiveUnsigned1ByteNumber()
Reads an unsigned 1-byte number.
|
int |
ReceiveUnsigned2ByteNumber()
Reads an unsigned 2-byte number.
|
long |
ReceiveUnsigned4ByteNumber()
Reads an unsigned 4-byte number.
|
java.util.List<java.lang.Integer> |
ReceiveUnsignedBytes(int numberOfBytes)
Reads a number of unsigned bytes from the input stream and returns them as
a List.
|
boolean |
Secure()
Returns whether a secure connection should be used.
|
void |
Secure(boolean secure)
Specifies whether a secure connection should be used.
|
void |
Send1ByteNumber(java.lang.String number)
Decodes the given number String to an integer and writes it as one byte
to the output stream.
|
void |
Send2ByteNumber(java.lang.String number)
Decodes the given number String to an integer and writes it as two bytes
to the output stream.
|
void |
Send4ByteNumber(java.lang.String number)
Decodes the given number String to an integer and writes it as four bytes
to the output stream.
|
void |
SendBytes(YailList list)
Takes each element from the given list, converts it to a String, decodes
the String to an integer, and writes it as one byte to the output stream.
|
void |
SendText(java.lang.String text)
Converts the given text to bytes and writes them to the output stream.
|
protected void |
setConnection(java.lang.Object bluetoothSocket) |
protected void |
write(java.lang.String functionName,
byte b)
Writes the given byte to the output stream.
|
protected void |
write(java.lang.String functionName,
byte[] bytes)
Writes the given bytes to the output stream.
|
getDispatchDelegate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDispatchDelegate
protected BluetoothConnectionBase(ComponentContainer container, java.lang.String logTag)
protected BluetoothConnectionBase(java.io.OutputStream outputStream, java.io.InputStream inputStream)
public final void Initialize()
public void BluetoothError(java.lang.String functionName, java.lang.String message)
protected void bluetoothError(java.lang.String functionName, int errorNumber, java.lang.Object... messageArgs)
public boolean Available()
public boolean Enabled()
protected final void setConnection(java.lang.Object bluetoothSocket) throws java.io.IOException
java.io.IOException
public final void Disconnect()
public final boolean IsConnected()
public boolean Secure()
public void Secure(boolean secure)
secure
- true
to use a secure connectionpublic boolean HighByteFirst()
true
for high byte first, false
for low byte
firstpublic void HighByteFirst(boolean highByteFirst)
highByteFirst
- true
for high byte first, false
for
low byte firstpublic void CharacterEncoding(java.lang.String encoding)
public java.lang.String CharacterEncoding()
public void DelimiterByte(int number)
public int DelimiterByte()
public void SendText(java.lang.String text)
text
- the text to writepublic void Send1ByteNumber(java.lang.String number)
number
- the number to writepublic void Send2ByteNumber(java.lang.String number)
number
- the number to writepublic void Send4ByteNumber(java.lang.String number)
number
- the number to writepublic void SendBytes(YailList list)
list
- the list of numeric values to writeprotected void write(java.lang.String functionName, byte b)
functionName
- the name of the SimpleFunction calling this methodb
- the byte to writeprotected void write(java.lang.String functionName, byte[] bytes)
functionName
- the name of the SimpleFunction calling this methodbytes
- the bytes to writepublic int BytesAvailableToReceive()
public java.lang.String ReceiveText(int numberOfBytes)
numberOfBytes
- the number of bytes to read; a negative number
indicates to read until a delimiter byte value is readpublic int ReceiveSigned1ByteNumber()
public int ReceiveUnsigned1ByteNumber()
public int ReceiveSigned2ByteNumber()
public int ReceiveUnsigned2ByteNumber()
public long ReceiveSigned4ByteNumber()
public long ReceiveUnsigned4ByteNumber()
public java.util.List<java.lang.Integer> ReceiveSignedBytes(int numberOfBytes)
numberOfBytes
- the number of bytes to read; a negative number
indicates to read until a delimiter byte value is readpublic java.util.List<java.lang.Integer> ReceiveUnsignedBytes(int numberOfBytes)
numberOfBytes
- the number of bytes to read; a negative number
indicates to read until a delimiter byte value is readprotected final byte[] read(java.lang.String functionName, int numberOfBytes)
functionName
- the name of the SimpleFunction calling this methodnumberOfBytes
- the number of bytes to read; a negative number
indicates to read until a delimiter byte value is readpublic void onDestroy()
onDestroy
in interface OnDestroyListener
public void onDelete()
onDelete
in interface Deleteable