AI2 Component  (Version nb184)
com.google.appinventor.components.runtime.BluetoothConnectionBase Class Referenceabstract
Inheritance diagram for com.google.appinventor.components.runtime.BluetoothConnectionBase:
com.google.appinventor.components.runtime.AndroidNonvisibleComponent com.google.appinventor.components.runtime.Component com.google.appinventor.components.runtime.OnDestroyListener com.google.appinventor.components.runtime.Deleteable com.google.appinventor.components.runtime.Component com.google.appinventor.components.runtime.BluetoothClient com.google.appinventor.components.runtime.BluetoothServer

Public Member Functions

final void Initialize ()
 
void BluetoothError (String functionName, String message)
 
boolean Available ()
 
boolean Enabled ()
 
final void Disconnect ()
 
final boolean IsConnected ()
 
boolean Secure ()
 
void Secure (boolean secure)
 
boolean HighByteFirst ()
 
void HighByteFirst (boolean highByteFirst)
 
void CharacterEncoding (String encoding)
 
String CharacterEncoding ()
 
void DelimiterByte (int number)
 
int DelimiterByte ()
 
void SendText (String text)
 
void Send1ByteNumber (String number)
 
void Send2ByteNumber (String number)
 
void Send4ByteNumber (String number)
 
void SendBytes (YailList list)
 
int BytesAvailableToReceive ()
 
String ReceiveText (int numberOfBytes)
 
int ReceiveSigned1ByteNumber ()
 
int ReceiveUnsigned1ByteNumber ()
 
int ReceiveSigned2ByteNumber ()
 
int ReceiveUnsigned2ByteNumber ()
 
long ReceiveSigned4ByteNumber ()
 
long ReceiveUnsigned4ByteNumber ()
 
List< Integer > ReceiveSignedBytes (int numberOfBytes)
 
List< Integer > ReceiveUnsignedBytes (int numberOfBytes)
 
void onDestroy ()
 
void onDelete ()
 
- Public Member Functions inherited from com.google.appinventor.components.runtime.AndroidNonvisibleComponent
HandlesEventDispatching getDispatchDelegate ()
 

Protected Member Functions

 BluetoothConnectionBase (ComponentContainer container, String logTag)
 
 BluetoothConnectionBase (OutputStream outputStream, InputStream inputStream)
 
void bluetoothError (String functionName, int errorNumber, Object... messageArgs)
 
final void setConnection (Object bluetoothSocket) throws IOException
 
boolean DisconnectOnError ()
 
void write (String functionName, byte b)
 
void write (String functionName, byte[] bytes)
 
final byte[] read (String functionName, int numberOfBytes)
 
- Protected Member Functions inherited from com.google.appinventor.components.runtime.AndroidNonvisibleComponent
 AndroidNonvisibleComponent (Form form)
 

Protected Attributes

final String logTag
 
boolean disconnectOnError
 
boolean secure
 
- Protected Attributes inherited from com.google.appinventor.components.runtime.AndroidNonvisibleComponent
final Form form
 

Additional Inherited Members

- Static Public Attributes inherited from com.google.appinventor.components.runtime.Component
static final String ASSET_DIRECTORY = "component"
 
static final int ALIGNMENT_NORMAL = 0
 
static final int ALIGNMENT_CENTER = 1
 
static final int ALIGNMENT_OPPOSITE = 2
 
static final int ACCELEROMETER_SENSITIVITY_WEAK = 1
 
static final int ACCELEROMETER_SENSITIVITY_MODERATE = 2
 
static final int ACCELEROMETER_SENSITIVITY_STRONG = 3
 
static final int BUTTON_SHAPE_DEFAULT = 0
 
static final int BUTTON_SHAPE_ROUNDED = 1
 
static final int BUTTON_SHAPE_RECT = 2
 
static final int BUTTON_SHAPE_OVAL = 3
 
static final int COLOR_NONE = 0x00FFFFFF
 
static final int COLOR_BLACK = 0xFF000000
 
static final int COLOR_BLUE = 0xFF0000FF
 
static final int COLOR_CYAN = 0xFF00FFFF
 
static final int COLOR_DKGRAY = 0xFF444444
 
static final int COLOR_GRAY = 0xFF888888
 
static final int COLOR_GREEN = 0xFF00FF00
 
static final int COLOR_LTGRAY = 0xFFCCCCCC
 
static final int COLOR_MAGENTA = 0xFFFF00FF
 
static final int COLOR_ORANGE = 0xFFFFC800
 
static final int COLOR_PINK = 0xFFFFAFAF
 
static final int COLOR_RED = 0xFFFF0000
 
static final int COLOR_WHITE = 0xFFFFFFFF
 
static final int COLOR_YELLOW = 0xFFFFFF00
 
static final int COLOR_DEFAULT = 0x00000000
 
static final String DEFAULT_VALUE_COLOR_NONE = "&H00FFFFFF"
 
static final String DEFAULT_VALUE_COLOR_BLACK = "&HFF000000"
 
static final String DEFAULT_VALUE_COLOR_BLUE = "&HFF0000FF"
 
static final String DEFAULT_VALUE_COLOR_CYAN = "&HFF00FFFF"
 
static final String DEFAULT_VALUE_COLOR_DKGRAY = "&HFF444444"
 
static final String DEFAULT_VALUE_COLOR_GRAY = "&HFF888888"
 
static final String DEFAULT_VALUE_COLOR_GREEN = "&HFF00FF00"
 
static final String DEFAULT_VALUE_COLOR_LTGRAY = "&HFFCCCCCC"
 
static final String DEFAULT_VALUE_COLOR_MAGENTA = "&HFFFF00FF"
 
static final String DEFAULT_VALUE_COLOR_ORANGE = "&HFFFFC800"
 
static final String DEFAULT_VALUE_COLOR_PINK = "&HFFFFAFAF"
 
static final String DEFAULT_VALUE_COLOR_RED = "&HFFFF0000"
 
static final String DEFAULT_VALUE_COLOR_WHITE = "&HFFFFFFFF"
 
static final String DEFAULT_VALUE_COLOR_YELLOW = "&HFFFFFF00"
 
static final String DEFAULT_VALUE_COLOR_DEFAULT = "&H00000000"
 
static final float FONT_DEFAULT_SIZE = 14
 
static final int LAYOUT_ORIENTATION_HORIZONTAL = ComponentConstants.LAYOUT_ORIENTATION_HORIZONTAL
 
static final int LAYOUT_ORIENTATION_VERTICAL = ComponentConstants.LAYOUT_ORIENTATION_VERTICAL
 
static final int SCALING_SCALE_PROPORTIONALLY = 0
 
static final int SCALING_SCALE_TO_FIT = 1
 
static final int TYPEFACE_DEFAULT = 0
 
static final int TYPEFACE_SANSSERIF = 1
 
static final int TYPEFACE_SERIF = 2
 
static final int TYPEFACE_MONOSPACE = 3
 
static final int LENGTH_PREFERRED = -1
 
static final int LENGTH_FILL_PARENT = -2
 
static final int LENGTH_UNKNOWN = -3
 
static final int LENGTH_PERCENT_TAG = -1000
 
static final int TOAST_LENGTH_SHORT = 0
 
static final int TOAST_LENGTH_LONG = 1
 
static final int DIRECTION_NORTH = 1
 
static final int DIRECTION_NORTHEAST = 2
 
static final int DIRECTION_EAST = 3
 
static final int DIRECTION_SOUTHEAST = 4
 
static final int DIRECTION_SOUTH = -1
 
static final int DIRECTION_SOUTHWEST = -2
 
static final int DIRECTION_WEST = -3
 
static final int DIRECTION_NORTHWEST = -4
 
static final int DIRECTION_NONE = 0
 
static final int DIRECTION_MIN = -4
 
static final int DIRECTION_MAX = 4
 
static float SLIDER_MIN_VALUE = 10
 
static float SLIDER_MAX_VALUE = 50
 
static float SLIDER_THUMB_VALUE = (SLIDER_MIN_VALUE + SLIDER_MAX_VALUE) / 2.0f
 
static final String DEFAULT_VALUE_TEXT_TO_SPEECH_COUNTRY = ""
 
static final String DEFAULT_VALUE_TEXT_TO_SPEECH_LANGUAGE = ""
 

Detailed Description

An abstract base class for the BluetoothClient and BluetoothServer component.

Author
lizlo.nosp@m.oney.nosp@m.@goog.nosp@m.le.c.nosp@m.om (Liz Looney)

Definition at line 41 of file BluetoothConnectionBase.java.

Constructor & Destructor Documentation

◆ BluetoothConnectionBase() [1/2]

com.google.appinventor.components.runtime.BluetoothConnectionBase.BluetoothConnectionBase ( ComponentContainer  container,
String  logTag 
)
protected

Creates a new BluetoothConnectionBase.

Definition at line 62 of file BluetoothConnectionBase.java.

◆ BluetoothConnectionBase() [2/2]

com.google.appinventor.components.runtime.BluetoothConnectionBase.BluetoothConnectionBase ( OutputStream  outputStream,
InputStream  inputStream 
)
protected

This constructor is for testing purposes only.

Definition at line 82 of file BluetoothConnectionBase.java.

Member Function Documentation

◆ Available()

boolean com.google.appinventor.components.runtime.BluetoothConnectionBase.Available ( )

Returns true{:.logic.block} if Bluetooth is available on the device, false{:.logic.block} otherwise.

Returns
true if Bluetooth is available on the device, false otherwise

Definition at line 143 of file BluetoothConnectionBase.java.

◆ bluetoothError()

void com.google.appinventor.components.runtime.BluetoothConnectionBase.bluetoothError ( String  functionName,
int  errorNumber,
Object...  messageArgs 
)
protected

Definition at line 131 of file BluetoothConnectionBase.java.

◆ BluetoothError()

void com.google.appinventor.components.runtime.BluetoothConnectionBase.BluetoothError ( String  functionName,
String  message 
)

Definition at line 128 of file BluetoothConnectionBase.java.

◆ BytesAvailableToReceive()

int com.google.appinventor.components.runtime.BluetoothConnectionBase.BytesAvailableToReceive ( )

Returns number of bytes available from the input stream.

Definition at line 564 of file BluetoothConnectionBase.java.

◆ CharacterEncoding() [1/2]

String com.google.appinventor.components.runtime.BluetoothConnectionBase.CharacterEncoding ( )

Returns the character encoding to use when sending and receiving text.

Definition at line 291 of file BluetoothConnectionBase.java.

◆ CharacterEncoding() [2/2]

void com.google.appinventor.components.runtime.BluetoothConnectionBase.CharacterEncoding ( String  encoding)

Sets the character encoding to use when sending and receiving text. The default value is "UTF-8"{:.text.block}.

Definition at line 276 of file BluetoothConnectionBase.java.

◆ DelimiterByte() [1/2]

int com.google.appinventor.components.runtime.BluetoothConnectionBase.DelimiterByte ( )

Returns the delimiter byte to use when passing a negative number for the numberOfBytes parameter when calling ReceiveText, ReceiveSignedBytes, or ReceiveUnsignedBytes.

Definition at line 324 of file BluetoothConnectionBase.java.

◆ DelimiterByte() [2/2]

void com.google.appinventor.components.runtime.BluetoothConnectionBase.DelimiterByte ( int  number)

Sets the delimiter byte to use when passing a negative number for the numberOfBytes parameter when calling ReceiveText, ReceiveSignedBytes, or ReceiveUnsignedBytes. Those functions will continue to read bytes until they encounter the value specified here. The default delimiter is 0, the null byte.

Definition at line 305 of file BluetoothConnectionBase.java.

◆ Disconnect()

final void com.google.appinventor.components.runtime.BluetoothConnectionBase.Disconnect ( )

Disconnects from the connected Bluetooth device.

Definition at line 181 of file BluetoothConnectionBase.java.

◆ DisconnectOnError()

boolean com.google.appinventor.components.runtime.BluetoothConnectionBase.DisconnectOnError ( )
protected

◆ Enabled()

boolean com.google.appinventor.components.runtime.BluetoothConnectionBase.Enabled ( )

Returns true{:.logic.block} if Bluetooth is enabled, false{:.logic.block} otherwise.

Returns
true if Bluetooth is enabled, false otherwise

Definition at line 158 of file BluetoothConnectionBase.java.

◆ HighByteFirst() [1/2]

boolean com.google.appinventor.components.runtime.BluetoothConnectionBase.HighByteFirst ( )

Returns true{:.logic.block} if numbers are sent and received with the most significant byte first (big endian). If false{:.logic.block}, the least significant byte in a multibyte value is sent or received first (little endian).

Returns
true
for high byte first,
false
for low byte first

Definition at line 252 of file BluetoothConnectionBase.java.

◆ HighByteFirst() [2/2]

void com.google.appinventor.components.runtime.BluetoothConnectionBase.HighByteFirst ( boolean  highByteFirst)

Specifies whether numbers are sent and received with the most significant byte first.

Parameters
highByteFirst

Definition at line 266 of file BluetoothConnectionBase.java.

◆ Initialize()

final void com.google.appinventor.components.runtime.BluetoothConnectionBase.Initialize ( )

Default Initialize

Definition at line 122 of file BluetoothConnectionBase.java.

◆ IsConnected()

final boolean com.google.appinventor.components.runtime.BluetoothConnectionBase.IsConnected ( )

Returns frue{:.logic.block} if a connection to a Bluetooth device has been made.

Definition at line 204 of file BluetoothConnectionBase.java.

◆ onDelete()

void com.google.appinventor.components.runtime.BluetoothConnectionBase.onDelete ( )

◆ onDestroy()

void com.google.appinventor.components.runtime.BluetoothConnectionBase.onDestroy ( )

◆ read()

final byte [] com.google.appinventor.components.runtime.BluetoothConnectionBase.read ( String  functionName,
int  numberOfBytes 
)
protected

Reads a number of bytes from the input stream.

If numberOfBytes is negative, this method reads until a delimiter byte value is read. The delimiter byte is included in the returned array.

Parameters
functionNamethe name of the SimpleFunction calling this method
numberOfBytesthe number of bytes to read; a negative number indicates to read until a delimiter byte value is read

Definition at line 778 of file BluetoothConnectionBase.java.

◆ ReceiveSigned1ByteNumber()

int com.google.appinventor.components.runtime.BluetoothConnectionBase.ReceiveSigned1ByteNumber ( )

Reads a signed 1-byte number.

Definition at line 615 of file BluetoothConnectionBase.java.

◆ ReceiveSigned2ByteNumber()

int com.google.appinventor.components.runtime.BluetoothConnectionBase.ReceiveSigned2ByteNumber ( )

Reads a signed 2-byte number.

Definition at line 643 of file BluetoothConnectionBase.java.

◆ ReceiveSigned4ByteNumber()

long com.google.appinventor.components.runtime.BluetoothConnectionBase.ReceiveSigned4ByteNumber ( )

Reads a signed 4-byte number.

Definition at line 679 of file BluetoothConnectionBase.java.

◆ ReceiveSignedBytes()

List<Integer> com.google.appinventor.components.runtime.BluetoothConnectionBase.ReceiveSignedBytes ( int  numberOfBytes)

Reads a number of signed bytes from the input stream and returns them as a List.

If numberOfBytes is negative, this method reads until a delimiter byte value is read. The delimiter byte value is included in the returned list.

Parameters
numberOfBytesthe number of bytes to read; a negative number indicates to read until a delimiter byte value is read

Definition at line 735 of file BluetoothConnectionBase.java.

◆ ReceiveText()

String com.google.appinventor.components.runtime.BluetoothConnectionBase.ReceiveText ( int  numberOfBytes)

Reads a number of bytes from the input stream and converts them to text.

If numberOfBytes is negative, read until a delimiter byte value is read.

Parameters
numberOfBytesthe number of bytes to read; a negative number indicates to read until a delimiter byte value is read

Definition at line 595 of file BluetoothConnectionBase.java.

◆ ReceiveUnsigned1ByteNumber()

int com.google.appinventor.components.runtime.BluetoothConnectionBase.ReceiveUnsigned1ByteNumber ( )

Reads an unsigned 1-byte number.

Definition at line 629 of file BluetoothConnectionBase.java.

◆ ReceiveUnsigned2ByteNumber()

int com.google.appinventor.components.runtime.BluetoothConnectionBase.ReceiveUnsigned2ByteNumber ( )

Reads an unsigned 2-byte number.

Definition at line 661 of file BluetoothConnectionBase.java.

◆ ReceiveUnsigned4ByteNumber()

long com.google.appinventor.components.runtime.BluetoothConnectionBase.ReceiveUnsigned4ByteNumber ( )

Reads an unsigned 4-byte number.

Definition at line 703 of file BluetoothConnectionBase.java.

◆ ReceiveUnsignedBytes()

List<Integer> com.google.appinventor.components.runtime.BluetoothConnectionBase.ReceiveUnsignedBytes ( int  numberOfBytes)

Reads a number of unsigned bytes from the input stream and returns them as a List.

If numberOfBytes is negative, this method reads until a delimiter byte value is read. The delimiter byte value is included in the returned list.

Parameters
numberOfBytesthe number of bytes to read; a negative number indicates to read until a delimiter byte value is read

Definition at line 758 of file BluetoothConnectionBase.java.

◆ Secure() [1/2]

boolean com.google.appinventor.components.runtime.BluetoothConnectionBase.Secure ( )

Whether to invoke SSP (Simple Secure Pairing), which is supported on devices with Bluetooth v2.1 or higher. When working with embedded Bluetooth devices, this property may need to be set to False. For Android 2.0-2.2, this property setting will be ignored.

Returns
whether a secure connection should be used.

Definition at line 227 of file BluetoothConnectionBase.java.

◆ Secure() [2/2]

void com.google.appinventor.components.runtime.BluetoothConnectionBase.Secure ( boolean  secure)

Specifies whether a secure connection should be used.

Parameters
secure

Definition at line 239 of file BluetoothConnectionBase.java.

◆ Send1ByteNumber()

void com.google.appinventor.components.runtime.BluetoothConnectionBase.Send1ByteNumber ( String  number)

Decodes the given number String to an integer and writes it as one byte to the output stream.

If the number could not be decoded to an integer, or the integer would not fit in one byte, then the Form's ErrorOccurred event is triggered and this method returns without writing any bytes to the output stream.

Parameters
numberthe number to write

Definition at line 360 of file BluetoothConnectionBase.java.

◆ Send2ByteNumber()

void com.google.appinventor.components.runtime.BluetoothConnectionBase.Send2ByteNumber ( String  number)

Decodes the given number String to an integer and writes it as two bytes to the output stream.

If the number could not be decoded to an integer, or the integer would not fit in two bytes, then the Form's ErrorOccurred event is triggered and this method returns without writing any bytes to the output stream.

Parameters
numberthe number to write

Definition at line 391 of file BluetoothConnectionBase.java.

◆ Send4ByteNumber()

void com.google.appinventor.components.runtime.BluetoothConnectionBase.Send4ByteNumber ( String  number)

Decodes the given number String to an integer and writes it as four bytes to the output stream.

If the number could not be decoded to an integer, or the integer would not fit in four bytes, then the Form's ErrorOccurred event is triggered and this method returns without writing any bytes to the output stream.

Parameters
numberthe number to write

Definition at line 431 of file BluetoothConnectionBase.java.

◆ SendBytes()

void com.google.appinventor.components.runtime.BluetoothConnectionBase.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.

If an element could not be decoded to an integer, or the integer would not fit in one byte, then the Form's ErrorOccurred event is triggered and this method returns without writing any bytes to the output stream.

Parameters
listthe list of numeric values to write

Definition at line 479 of file BluetoothConnectionBase.java.

◆ SendText()

void com.google.appinventor.components.runtime.BluetoothConnectionBase.SendText ( String  text)

Converts the given text to bytes and writes them to the output stream.

Parameters
textthe text to write

Definition at line 334 of file BluetoothConnectionBase.java.

◆ setConnection()

final void com.google.appinventor.components.runtime.BluetoothConnectionBase.setConnection ( Object  bluetoothSocket) throws IOException
protected

Definition at line 168 of file BluetoothConnectionBase.java.

◆ write() [1/2]

void com.google.appinventor.components.runtime.BluetoothConnectionBase.write ( String  functionName,
byte  b 
)
protected

Writes the given byte to the output stream.

Parameters
functionNamethe name of the SimpleFunction calling this method
bthe byte to write

Definition at line 513 of file BluetoothConnectionBase.java.

◆ write() [2/2]

void com.google.appinventor.components.runtime.BluetoothConnectionBase.write ( String  functionName,
byte[]  bytes 
)
protected

Writes the given bytes to the output stream.

Parameters
functionNamethe name of the SimpleFunction calling this method
bytesthe bytes to write

Definition at line 539 of file BluetoothConnectionBase.java.

Member Data Documentation

◆ disconnectOnError

boolean com.google.appinventor.components.runtime.BluetoothConnectionBase.disconnectOnError
protected

Definition at line 51 of file BluetoothConnectionBase.java.

◆ logTag

final String com.google.appinventor.components.runtime.BluetoothConnectionBase.logTag
protected

Definition at line 44 of file BluetoothConnectionBase.java.

◆ secure

boolean com.google.appinventor.components.runtime.BluetoothConnectionBase.secure
protected

Definition at line 52 of file BluetoothConnectionBase.java.


The documentation for this class was generated from the following file: