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:
ej.bluetooth.listeners.RemoteServiceListener
public abstract class SerialPortClient extends ej.bluetooth.listeners.impl.DefaultRemoteServiceListenerTheSerialPortClientclass represents a serial port client.
-
-
Constructor Summary
Constructors Constructor Description SerialPortClient(ej.bluetooth.BluetoothConnection connection, ej.bluetooth.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(ej.bluetooth.BluetoothConnection connection, ej.bluetooth.BluetoothCharacteristic characteristic, byte[] value)voidonWriteCompleted(ej.bluetooth.BluetoothConnection connection, ej.bluetooth.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.
-
-
-
Constructor Detail
-
SerialPortClient
public SerialPortClient(ej.bluetooth.BluetoothConnection connection, ej.bluetooth.BluetoothService service) throws AttributeNotFoundExceptionCreates 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(ej.bluetooth.BluetoothConnection connection, ej.bluetooth.BluetoothAttribute attribute, byte status)- Specified by:
onWriteCompletedin interfaceej.bluetooth.listeners.RemoteServiceListener- Overrides:
onWriteCompletedin classej.bluetooth.listeners.impl.DefaultRemoteServiceListener
-
onNotificationReceived
public void onNotificationReceived(ej.bluetooth.BluetoothConnection connection, ej.bluetooth.BluetoothCharacteristic characteristic, byte[] value)- Specified by:
onNotificationReceivedin interfaceej.bluetooth.listeners.RemoteServiceListener- Overrides:
onNotificationReceivedin classej.bluetooth.listeners.impl.DefaultRemoteServiceListener
-
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.
-
-