public abstract class SerialPortClient
extends ej.bluetooth.listeners.impl.DefaultRemoteServiceListener
SerialPortClient class represents a serial port client.| Constructor and Description |
|---|
SerialPortClient(ej.bluetooth.BluetoothConnection connection,
ej.bluetooth.BluetoothService service)
Creates a serial port client, using the serial port service provided by a remote device and the connection to
this device.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this serial port client.
|
protected abstract void |
onDataReceived(byte[] data)
Called when data has been received from the server.
|
protected abstract void |
onDataSent(boolean success)
Called when data has been sent to the server.
|
void |
onNotificationReceived(ej.bluetooth.BluetoothConnection connection,
ej.bluetooth.BluetoothCharacteristic characteristic,
byte[] value) |
void |
onWriteCompleted(ej.bluetooth.BluetoothConnection connection,
ej.bluetooth.BluetoothAttribute attribute,
byte status) |
void |
sendData(byte[] data)
Sends the given data to the server.
|
public SerialPortClient(ej.bluetooth.BluetoothConnection connection,
ej.bluetooth.BluetoothService service)
throws AttributeNotFoundException
connection - the connection to the device.service - the serial port service provided by the device.AttributeNotFoundException - if one of the mandatory attributes of the service is missing.public void close()
public void sendData(byte[] data)
onDataSent(boolean) methods is called once the data has been
sent to the server.data - the data to send.public void onWriteCompleted(ej.bluetooth.BluetoothConnection connection,
ej.bluetooth.BluetoothAttribute attribute,
byte status)
onWriteCompleted in interface ej.bluetooth.listeners.RemoteServiceListeneronWriteCompleted in class ej.bluetooth.listeners.impl.DefaultRemoteServiceListenerpublic void onNotificationReceived(ej.bluetooth.BluetoothConnection connection,
ej.bluetooth.BluetoothCharacteristic characteristic,
byte[] value)
onNotificationReceived in interface ej.bluetooth.listeners.RemoteServiceListeneronNotificationReceived in class ej.bluetooth.listeners.impl.DefaultRemoteServiceListenerprotected abstract void onDataReceived(byte[] data)
data - the data received from the server.protected abstract void onDataSent(boolean success)
success - true if the the data was sent successfully, false otherwise.