Package ej.bluetooth.util.services.sps
Class SerialPortServer
- java.lang.Object
-
- ej.bluetooth.listeners.impl.DefaultLocalServiceListener
-
- ej.bluetooth.util.services.sps.SerialPortServer
-
- All Implemented Interfaces:
LocalServiceListener
public abstract class SerialPortServer extends DefaultLocalServiceListener
TheSerialPortServerclass represents a serial port server.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSerialPortServer(BluetoothService service)Creates a serial port server, using the serial port service provided by this device.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidonDataReceived(BluetoothConnection connection, byte[] data)Called when data has been received from a client.protected abstract voidonDataSent(BluetoothConnection connection, boolean success)Called when data has been sent to a client.voidonNotificationSent(BluetoothConnection connection, BluetoothCharacteristic characteristic, boolean success)voidonReadRequest(BluetoothConnection connection, BluetoothAttribute attribute)voidonWriteRequest(BluetoothConnection connection, BluetoothAttribute attribute, byte[] value)voidsendData(BluetoothConnection connection, byte[] data)Sends the given data to the given client.voidstart()Starts this serial port server.voidstop()Stops this serial port server.-
Methods inherited from class ej.bluetooth.listeners.impl.DefaultLocalServiceListener
onExecuteWriteRequest, onPrepareWriteRequest, onReadBlobRequest
-
-
-
-
Constructor Detail
-
SerialPortServer
protected SerialPortServer(BluetoothService service)
Creates a serial port server, using the serial port service provided by this device.- Parameters:
service- the serial port service provided by this device.- Throws:
IllegalArgumentException- if one of the mandatory attributes of the service is missing.
-
-
Method Detail
-
start
public void start()
Starts this serial port server.
-
stop
public void stop()
Stops this serial port server.
-
sendData
public void sendData(BluetoothConnection connection, byte[] data)
Sends the given data to the given client. TheonDataSent(BluetoothConnection, boolean)methods is called once the data has been sent to the client.- Parameters:
connection- the connection to the device to which the data should be sent.data- the data to send.
-
onReadRequest
public void onReadRequest(BluetoothConnection connection, BluetoothAttribute attribute)
- Specified by:
onReadRequestin interfaceLocalServiceListener- Overrides:
onReadRequestin classDefaultLocalServiceListener
-
onWriteRequest
public void onWriteRequest(BluetoothConnection connection, BluetoothAttribute attribute, byte[] value)
- Specified by:
onWriteRequestin interfaceLocalServiceListener- Overrides:
onWriteRequestin classDefaultLocalServiceListener
-
onNotificationSent
public void onNotificationSent(BluetoothConnection connection, BluetoothCharacteristic characteristic, boolean success)
- Specified by:
onNotificationSentin interfaceLocalServiceListener- Overrides:
onNotificationSentin classDefaultLocalServiceListener
-
onDataReceived
protected abstract void onDataReceived(BluetoothConnection connection, byte[] data)
Called when data has been received from a client.- Parameters:
connection- the connection to the device from which the data has been received.data- the data received from the client.
-
onDataSent
protected abstract void onDataSent(BluetoothConnection connection, boolean success)
Called when data has been sent to a client.- Parameters:
connection- the connection to the device to which the data has been sent.success- true if the the data was sent successfully, false otherwise.
-
-