public abstract class SerialPortServer extends DefaultLocalServiceListener
SerialPortServer class represents a serial port server.| Constructor and Description |
|---|
SerialPortServer(BluetoothService service)
Creates a serial port server, using the serial port service provided by this device.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
onDataReceived(BluetoothConnection connection,
byte[] data)
Called when data has been received from a client.
|
protected abstract void |
onDataSent(BluetoothConnection connection,
boolean success)
Called when data has been sent to a client.
|
void |
onNotificationSent(BluetoothConnection connection,
BluetoothCharacteristic characteristic,
boolean success) |
void |
onReadRequest(BluetoothConnection connection,
BluetoothAttribute attribute) |
void |
onWriteRequest(BluetoothConnection connection,
BluetoothAttribute attribute,
byte[] value) |
void |
sendData(BluetoothConnection connection,
byte[] data)
Sends the given data to the given client.
|
void |
start()
Starts this serial port server.
|
void |
stop()
Stops this serial port server.
|
onExecuteWriteRequest, onPrepareWriteRequest, onReadBlobRequestpublic SerialPortServer(BluetoothService service)
service - the serial port service provided by this device.IllegalArgumentException - if one of the mandatory attributes of the service is missing.protected abstract void onDataReceived(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(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.public void onNotificationSent(BluetoothConnection connection, BluetoothCharacteristic characteristic, boolean success)
onNotificationSent in interface LocalServiceListeneronNotificationSent in class DefaultLocalServiceListenerpublic void onReadRequest(BluetoothConnection connection, BluetoothAttribute attribute)
onReadRequest in interface LocalServiceListeneronReadRequest in class DefaultLocalServiceListenerpublic void onWriteRequest(BluetoothConnection connection, BluetoothAttribute attribute, byte[] value)
onWriteRequest in interface LocalServiceListeneronWriteRequest in class DefaultLocalServiceListenerpublic void sendData(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 start()
public void stop()