com.thingmagic
Class BluetoothTransportAndroid

java.lang.Object
  extended by com.thingmagic.BluetoothTransportAndroid
All Implemented Interfaces:
SerialTransport

public class BluetoothTransportAndroid
extends java.lang.Object
implements SerialTransport


Constructor Summary
BluetoothTransportAndroid(java.lang.String deviceName)
          Creates a new instance of SerialPort through bluetooth
 
Method Summary
 SerialReader createSerialReader(java.lang.String uri)
           
 void flush()
          Take any actions necessary (possibly none) to remove unsent data from the output path.
 int getBaudRate()
          Get the current baud rate of the communication channel.
 void open()
          Causes the communication interface to be opened but does not transmit any serial-layer data.
 byte[] receiveBytes(int length, byte[] messageSpace, int offset, int timeoutMs)
          Receive a number of bytes on the serial transport.
 void sendBytes(int length, byte[] message, int offset, int timeoutMs)
          Send bytes down the serial transport layer.
 void setBaudRate(int rate)
          Set the current baud rate of the communication channel.
 void shutdown()
          Disconnects from the connected Bluetooth device.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BluetoothTransportAndroid

public BluetoothTransportAndroid(java.lang.String deviceName)
Creates a new instance of SerialPort through bluetooth

Method Detail

open

public void open()
          throws ReaderException
Description copied from interface: SerialTransport
Causes the communication interface to be opened but does not transmit any serial-layer data. This should perform actions such as opening a serial port device or establishing a network connection within a wrapper protocol.

Specified by:
open in interface SerialTransport
Throws:
ReaderException

shutdown

public void shutdown()
Disconnects from the connected Bluetooth device.

Specified by:
shutdown in interface SerialTransport

flush

public void flush()
Description copied from interface: SerialTransport
Take any actions necessary (possibly none) to remove unsent data from the output path.

Specified by:
flush in interface SerialTransport

setBaudRate

public void setBaudRate(int rate)
Description copied from interface: SerialTransport
Set the current baud rate of the communication channel.

Specified by:
setBaudRate in interface SerialTransport
Parameters:
rate - the baud rate to set

getBaudRate

public int getBaudRate()
Description copied from interface: SerialTransport
Get the current baud rate of the communication channel.

Specified by:
getBaudRate in interface SerialTransport
Returns:
the baud rate

sendBytes

public void sendBytes(int length,
                      byte[] message,
                      int offset,
                      int timeoutMs)
               throws ReaderException
Description copied from interface: SerialTransport
Send bytes down the serial transport layer. No interpretation or modification occurs.

Specified by:
sendBytes in interface SerialTransport
Parameters:
length - number of bytes to send
message - array containing the bytes to be sent
offset - position in array to send from
timeoutMs - The duration to wait for the operation to complete.
Throws:
ReaderException

receiveBytes

public byte[] receiveBytes(int length,
                           byte[] messageSpace,
                           int offset,
                           int timeoutMs)
                    throws ReaderException
Description copied from interface: SerialTransport
Receive a number of bytes on the serial transport.

Specified by:
receiveBytes in interface SerialTransport
Parameters:
length - number of bytes to receive
messageSpace - byte array to store the message in, or null to have one allocated
offset - location in messageSpace to store bytes
timeoutMs - maximum duration to wait for a message
Returns:
the byte array with the number of bytes added
Throws:
ReaderException

createSerialReader

public SerialReader createSerialReader(java.lang.String uri)
                                throws ReaderException
Throws:
ReaderException