public abstract class SerialPortServer
extends ej.bluetooth.listeners.impl.DefaultLocalServiceListener
SerialPortServer class represents a serial port server.| Constructor and Description |
|---|
SerialPortServer(ej.bluetooth.BluetoothService service)
Creates a serial port server, using the serial port service provided by this device.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this serial port server.
|
protected abstract void |
onDataReceived(ej.bluetooth.BluetoothConnection connection,
byte[] data)
Called when data has been received from a client.
|
protected abstract void |
onDataSent(ej.bluetooth.BluetoothConnection connection,
boolean success)
Called when data has been sent to a client.
|
void |
onNotificationSent(ej.bluetooth.BluetoothConnection connection,
ej.bluetooth.BluetoothCharacteristic characteristic,
boolean success) |
void |
onReadRequest(ej.bluetooth.BluetoothConnection connection,
ej.bluetooth.BluetoothAttribute attribute) |
void |
onWriteRequest(ej.bluetooth.BluetoothConnection connection,
ej.bluetooth.BluetoothAttribute attribute,
byte[] value) |
void |
sendData(ej.bluetooth.BluetoothConnection connection,
byte[] data)
Sends the given data to the given client.
|
public SerialPortServer(ej.bluetooth.BluetoothService service)
throws AttributeNotFoundException
service - the serial port service provided by this device.AttributeNotFoundException - if one of the mandatory attributes of the service is missing.public void close()
public void sendData(ej.bluetooth.BluetoothConnection connection,
byte[] data)
onDataSent(BluetoothConnection, boolean) methods is called
once the data has been sent to the client.connection - the connection to the device to which the data should be sent.data - the data to send.public void onReadRequest(ej.bluetooth.BluetoothConnection connection,
ej.bluetooth.BluetoothAttribute attribute)
onReadRequest in interface ej.bluetooth.listeners.LocalServiceListeneronReadRequest in class ej.bluetooth.listeners.impl.DefaultLocalServiceListenerpublic void onWriteRequest(ej.bluetooth.BluetoothConnection connection,
ej.bluetooth.BluetoothAttribute attribute,
byte[] value)
onWriteRequest in interface ej.bluetooth.listeners.LocalServiceListeneronWriteRequest in class ej.bluetooth.listeners.impl.DefaultLocalServiceListenerpublic void onNotificationSent(ej.bluetooth.BluetoothConnection connection,
ej.bluetooth.BluetoothCharacteristic characteristic,
boolean success)
onNotificationSent in interface ej.bluetooth.listeners.LocalServiceListeneronNotificationSent in class ej.bluetooth.listeners.impl.DefaultLocalServiceListenerprotected abstract void onDataReceived(ej.bluetooth.BluetoothConnection connection,
byte[] data)
connection - the connection to the device from which the data has been received.data - the data received from the client.protected abstract void onDataSent(ej.bluetooth.BluetoothConnection connection,
boolean success)
connection - the connection to the device to which the data has been sent.success - true if the the data was sent successfully, false otherwise.