public class ATransportBluetooth extends ATransport
ATransport.IBufferControlEventListener, ATransport.IConnectStateEventListener
DUMP, INFO, IO, mAddress, mConnType, mDevName, mDevType, mIsAutoConnect, mIsDeviceAttached, mMacAddress, mQueue, mState, TAG
Constructor and Description |
---|
ATransportBluetooth()
Create an instance of the ATransportBluetooth class
|
ATransportBluetooth(DeviceType type,
java.lang.String name,
java.lang.String address)
Create an instance of the ATransportBluetooth class
|
Modifier and Type | Method and Description |
---|---|
int |
available()
Returns the length of data that can be read with the read method.
|
boolean |
connect()
Attempts to connect to the appliance using an instance of the Transport class.
|
void |
destroy()
ATransportBluetooth Destroys the instance and returns the resource.
|
void |
disconnect()
An instance of the Transport class closes the connection to the device to which the device is connected.
|
boolean |
getAutoConnect()
Returns whether automatically connect to the appliance using an instance of the Transport class.
|
boolean |
getDeviceAttached()
Returns whether attached to the appliance using an instance of the Transport class.
|
void |
listen()
An instance of the ATransport class waits for the device to connect.
|
int |
read(byte[] data,
int offset,
int length)
Read data received from the device.
|
int |
read(byte[] data,
int offset,
int length,
int timeout)
Read data received from the device.
|
void |
setAutoConnect(boolean enabled)
Sets whether automatically connect to the appliance using an instance of the Transport class.
|
int |
write(byte[] data,
int offset,
int length)
Transfer data to the device.
|
int |
write(byte[] data,
int offset,
int length,
int timeout)
Transfer data to the device.
|
checkBufferSize, getAddress, getConnectType, getDeviceName, getDeviceType, getMacAddress, getState, read, read, setAddress, setBufferControlListener, setBufferControlListener, setDeviceName, setDeviceType, setMacAddress, setState, setStateListener, toString, write, write
public ATransportBluetooth()
public ATransportBluetooth(DeviceType type, java.lang.String name, java.lang.String address)
type
- A DeviceType enumeration that specifies the type of connected device using an instance of the ATransportBluetooth class.name
- A string that specifies the name of the connected device using an instance of the ATransportBluetooth class.address
- A string that specifies the address of the connected device by using an instance of the ATransportBluetooth class.public void destroy()
destroy
in class ATransport
public void setAutoConnect(boolean enabled)
ATransport
setAutoConnect
in class ATransport
enabled
- A boolean specifying whether the device automatically connect.public boolean getAutoConnect()
ATransport
getAutoConnect
in class ATransport
public boolean getDeviceAttached()
ATransport
getDeviceAttached
in class ATransport
public boolean connect()
ATransport
connect
in class ATransport
public void listen()
ATransport
listen
in class ATransport
public void disconnect()
ATransport
disconnect
in class ATransport
public int write(byte[] data, int offset, int length)
ATransport
write
in class ATransport
data
- A byte array that specifies the data to transfer to the Device.offset
- An integer indicating the start address of the data to be transferred to the Device.length
- An integer indicating the length of the data to be transferred to the Device.public int write(byte[] data, int offset, int length, int timeout)
ATransport
write
in class ATransport
data
- A byte array that specifies the data to transfer to the Device.offset
- An integer indicating the start address of the data to be transferred to the Device.length
- An integer indicating the length of the data to be transferred to the Device.timeout
- An integer specifying the timeout of data transmission to the device.public int available()
ATransport
available
in class ATransport
public int read(byte[] data, int offset, int length)
ATransport
read
in class ATransport
data
- A byte array to store the data received from the device.offset
- Integer specifying the start address at which data received from device will begin to be stored in a byte array.length
- An integer specifying the maximum length at which data received from the device can be stored in a byte array.public int read(byte[] data, int offset, int length, int timeout)
ATransport
read
in class ATransport
data
- A byte array to store the data received from the device.offset
- Integer specifying the start address at which data received from device will begin to be stored in a byte array.length
- An integer specifying the maximum length at which data received from the device can be stored in a byte array.timeout
- An integer that specifies the timeout for reading data received from the device.