Package ej.bluetooth.util.services.cts
Class CurrentTimeClient
- java.lang.Object
-
- ej.bluetooth.listeners.impl.DefaultRemoteServiceListener
-
- ej.bluetooth.util.services.cts.CurrentTimeClient
-
- All Implemented Interfaces:
ej.bluetooth.listeners.RemoteServiceListener
public abstract class CurrentTimeClient extends ej.bluetooth.listeners.impl.DefaultRemoteServiceListenerTheCurrentTimeClientclass represents a current time client.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCurrentTimeClient(ej.bluetooth.BluetoothConnection connection, ej.bluetooth.BluetoothService service)Creates a current time client, using the current time 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 voidonCurrentTimeUpdate(long currentTime)Called when the current time is received.protected abstract voidonLocalTimeUpdate(long localTimeOffset)Called when the local time is received.voidonReadCompleted(ej.bluetooth.BluetoothConnection connection, ej.bluetooth.BluetoothAttribute attribute, byte status, byte[] value)voidrequestTime()Requests the current time and local time to the server.voidstart()Starts this current time client.voidstop()Stops this current time client.
-
-
-
Constructor Detail
-
CurrentTimeClient
protected CurrentTimeClient(ej.bluetooth.BluetoothConnection connection, ej.bluetooth.BluetoothService service) throws AttributeNotFoundExceptionCreates a current time client, using the current time service provided by a remote device and the connection to this device.- Parameters:
connection- the connection to the device.service- the current time 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 current time client.
-
stop
public void stop()
Stops this current time client.
-
requestTime
public void requestTime()
Requests the current time and local time to the server. TheonCurrentTimeUpdate(long)andonLocalTimeUpdate(long)methods are called once the time information is received from the server.
-
onReadCompleted
public void onReadCompleted(ej.bluetooth.BluetoothConnection connection, ej.bluetooth.BluetoothAttribute attribute, byte status, byte[] value)- Specified by:
onReadCompletedin interfaceej.bluetooth.listeners.RemoteServiceListener- Overrides:
onReadCompletedin classej.bluetooth.listeners.impl.DefaultRemoteServiceListener
-
onCurrentTimeUpdate
protected abstract void onCurrentTimeUpdate(long currentTime)
Called when the current time is received.- Parameters:
currentTime- the current time (in milliseconds).
-
onLocalTimeUpdate
protected abstract void onLocalTimeUpdate(long localTimeOffset)
Called when the local time is received.- Parameters:
localTimeOffset- the local time offset (in milliseconds).
-
-