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:
ej.bluetooth.listeners.LocalServiceListener
public abstract class SerialPortServer extends ej.bluetooth.listeners.impl.DefaultLocalServiceListenerTheSerialPortServerclass represents a serial port server.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSerialPortServer(ej.bluetooth.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(ej.bluetooth.BluetoothConnection connection, byte[] data)Called when data has been received from a client.protected abstract voidonDataSent(ej.bluetooth.BluetoothConnection connection, boolean success)Called when data has been sent to a client.voidonNotificationSent(ej.bluetooth.BluetoothConnection connection, ej.bluetooth.BluetoothCharacteristic characteristic, boolean success)voidonReadRequest(ej.bluetooth.BluetoothConnection connection, ej.bluetooth.BluetoothAttribute attribute)voidonWriteRequest(ej.bluetooth.BluetoothConnection connection, ej.bluetooth.BluetoothAttribute attribute, byte[] value)voidsendData(ej.bluetooth.BluetoothConnection connection, byte[] data)Sends the given data to the given client.voidstart()Starts this serial port server.voidstop()Stops this serial port server.
-
-
-
Constructor Detail
-
SerialPortServer
protected SerialPortServer(ej.bluetooth.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:
java.lang.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(ej.bluetooth.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(ej.bluetooth.BluetoothConnection connection, ej.bluetooth.BluetoothAttribute attribute)- Specified by:
onReadRequestin interfaceej.bluetooth.listeners.LocalServiceListener- Overrides:
onReadRequestin classej.bluetooth.listeners.impl.DefaultLocalServiceListener
-
onWriteRequest
public void onWriteRequest(ej.bluetooth.BluetoothConnection connection, ej.bluetooth.BluetoothAttribute attribute, byte[] value)- Specified by:
onWriteRequestin interfaceej.bluetooth.listeners.LocalServiceListener- Overrides:
onWriteRequestin classej.bluetooth.listeners.impl.DefaultLocalServiceListener
-
onNotificationSent
public void onNotificationSent(ej.bluetooth.BluetoothConnection connection, ej.bluetooth.BluetoothCharacteristic characteristic, boolean success)- Specified by:
onNotificationSentin interfaceej.bluetooth.listeners.LocalServiceListener- Overrides:
onNotificationSentin classej.bluetooth.listeners.impl.DefaultLocalServiceListener
-
onDataReceived
protected abstract void onDataReceived(ej.bluetooth.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(ej.bluetooth.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.
-
-