public abstract class CurrentTimeClient
extends ej.bluetooth.listeners.impl.DefaultRemoteServiceListener
CurrentTimeClient
class represents a current time client.Constructor and Description |
---|
CurrentTimeClient(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.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this current time client.
|
protected abstract void |
onCurrentTimeUpdate(long currentTime)
Called when the current time is received.
|
protected abstract void |
onLocalTimeUpdate(long localTimeOffset)
Called when the local time is received.
|
void |
onReadCompleted(ej.bluetooth.BluetoothConnection connection,
ej.bluetooth.BluetoothAttribute attribute,
byte status,
byte[] value) |
void |
requestTime()
Requests the current time and local time to the server.
|
public CurrentTimeClient(ej.bluetooth.BluetoothConnection connection, ej.bluetooth.BluetoothService service) throws AttributeNotFoundException
connection
- the connection to the device.service
- the current time service provided by the device.AttributeNotFoundException
- if one of the mandatory attributes of the service is missing.public void close()
public void requestTime()
onCurrentTimeUpdate(long)
and
onLocalTimeUpdate(long)
methods are called once the time information is received from the server.public void onReadCompleted(ej.bluetooth.BluetoothConnection connection, ej.bluetooth.BluetoothAttribute attribute, byte status, byte[] value)
onReadCompleted
in interface ej.bluetooth.listeners.RemoteServiceListener
onReadCompleted
in class ej.bluetooth.listeners.impl.DefaultRemoteServiceListener
protected abstract void onCurrentTimeUpdate(long currentTime)
currentTime
- the current time (in milliseconds).protected abstract void onLocalTimeUpdate(long localTimeOffset)
localTimeOffset
- the local time offset (in milliseconds).