References: Android-Arduino Bridge

based on version 0.2

Arduino_Bluetooth

Main class of the API, this manages the connection to the Arduino, sending / receiving data and closing sockets.

Example of use:

Arduino_Bluetooth arduino;

//onCreate()
arduino = new ArduinoBluetooth();

//When click in a button
arduino.Begin("name of Bluetooth device");

//in a Thread dedicated to read data
if(arduino.Available()>0){
  leitura = arduino.Read();
}

//When click in a button to send data
arduino.Write("Hello World");

//onDestroy()
arduino.CloseConnetion();

Public Methods
Type Name Funcionality
DeviceState getDeviceState() Returns the current Device Android state
boolean isDeviceConnected() Returns true if there is an android device connected
String getDeviceAddress() Returns the Address of remote device.
int Available() Returns -1 if the socket bluetooth is not connected or is null.
Returns 0 if the bluetooth socket is connected but it is not receiving data.
Returns 1 if it is connected and receiving data.
ConnectionState connection_state Returns the atual state of connection
void Begin(String name) Begin a bluetooth connection with a device.
String Read() Returns the last received string
void CheckBluetoothAdapter() Sets the state of bluetooth adapter, ie, if it exists and is enabled.
boolean CanConnectWith(String deviceName) Returns true if there are any paired with the name "deviceName" device, false otherwise.
String FindDevice(String deviceName) Returns the device address with the name "deviceName" if it is paired with the handset android. Otherwise returns Null.
void BindTextView(TextView tv) For easy viewing of incoming data. This method need only be invoked once, passing reference to a TextView, this will change your xom String Ultia received each time text that is received new data.
void Write(String data) Sends a String to the remote device.
void CloseConnection() Closes the connection to the remote device.

Soon