Package ej.bluetooth.util.services.sps
Class SerialPortClient
- java.lang.Object
-
- ej.bluetooth.listeners.impl.DefaultRemoteServiceListener
-
- ej.bluetooth.util.services.sps.SerialPortClient
-
- All Implemented Interfaces:
RemoteServiceListener
public abstract class SerialPortClient extends DefaultRemoteServiceListener
TheSerialPortClientclass represents a serial port client.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSerialPortClient(BluetoothConnection connection, BluetoothService service)Creates a serial port client, using the serial port service provided by a remote device and the connection to this device.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidonDataReceived(byte[] data)Called when data has been received from the server.protected abstract voidonDataSent(boolean success)Called when data has been sent to the server.voidonNotificationReceived(BluetoothConnection connection, BluetoothCharacteristic characteristic, byte[] value)voidonWriteCompleted(BluetoothConnection connection, BluetoothAttribute attribute, byte status)voidsendData(byte[] data)Sends the given data to the server.voidstart()Starts this serial port client.voidstop()Stops this serial port client.-
Methods inherited from class ej.bluetooth.listeners.impl.DefaultRemoteServiceListener
onReadCompleted
-
-
-
-
Constructor Detail
-
SerialPortClient
protected SerialPortClient(BluetoothConnection connection, BluetoothService service) throws AttributeNotFoundException
Creates a serial port client, using the serial port service provided by a remote device and the connection to this device.- Parameters:
connection- the connection to the device.service- the serial port service provided by the device.- Throws:
AttributeNotFoundException- if one of the mandatory attributes of the service is missing.
-
-
Method Detail
-
start
public void start()
Starts this serial port client.
-
stop
public void stop()
Stops this serial port client.
-
sendData
public void sendData(byte[] data)
Sends the given data to the server. TheonDataSent(boolean)methods is called once the data has been sent to the server.- Parameters:
data- the data to send.
-
onWriteCompleted
public void onWriteCompleted(BluetoothConnection connection, BluetoothAttribute attribute, byte status)
- Specified by:
onWriteCompletedin interfaceRemoteServiceListener- Overrides:
onWriteCompletedin classDefaultRemoteServiceListener
-
onNotificationReceived
public void onNotificationReceived(BluetoothConnection connection, BluetoothCharacteristic characteristic, byte[] value)
- Specified by:
onNotificationReceivedin interfaceRemoteServiceListener- Overrides:
onNotificationReceivedin classDefaultRemoteServiceListener
-
onDataReceived
protected abstract void onDataReceived(byte[] data)
Called when data has been received from the server.- Parameters:
data- the data received from the server.
-
onDataSent
protected abstract void onDataSent(boolean success)
Called when data has been sent to the server.- Parameters:
success- true if the the data was sent successfully, false otherwise.
-
-