nl::Weave::Profiles::Time::SingleSourceTimeSyncClient

Summary

Public types

ClientState{
  kClientState_Idle,
  kClientState_Sync_1,
  kClientState_Sync_2
}
enum
current state of this Time Sync Client
SyncCompletionHandler)(void *const aApp, const WEAVE_ERROR aErrorCode, const timesync_t aCorrectedSystemTime) typedef
void(*
Callback after both time sync attempts have been completed.
TimeChangeNotificationHandler)(void *const aApp, ExchangeContext *aEC) typedef
void(*
Callback to indicate we just received a Time Change Notification.

Protected types

@324 enum

Public attributes

OnTimeChangeNotificationReceived

Protected attributes

mApp
void *
mBinding
mClientState
mExchangeContext
mExchangeMgr
mFlightTime_usec
int32_t
used to store one way flight time.
mIsInCallback
bool
mOnSyncCompleted
mRegisterSyncResult_usec
timesync_t
used to store Timestamp when a result is registered
mRemoteTimestamp_usec
timesync_t
used to store the system time of remote node, when the response message was about to be sent
mUnadjTimestampLastSent_usec
timesync_t

Public functions

Abort(void)
void
Abort current time sync operation.
GetClientState(void) const
Retrieve current state of this client.
Init(void *const aApp, WeaveExchangeManager *const aExchangeMgr)
Initialize this client.
Sync(Binding *const aBinding, SyncCompletionHandler OnSyncCompleted)
Sync using the given Binding and makes a callback using the pointer provided.

Protected functions

EnterSync2(void)
void
FinalProcessing(void)
void
GetClientStateName(void) const
const char *
InvalidateRegisteredResult(void)
void
Invalidate the registered information for time correction.
IsRegisteredResultValid(void)
bool
Check if the registered information for time correction is valid.
OnResponseTimeout(void)
void
OnSyncResponse(uint32_t aProfileId, uint8_t aMsgType, PacketBuffer *aPayload)
void
ProceedToNextState(void)
void
RegisterSyncResultIfNewOrBetter(const timesync_t aNow_usec, const timesync_t aRemoteTimestamp_usec, const int32_t aFlightTime_usec)
void
SendSyncRequest(void)
SetClientState(const ClientState state)
void
_AbortWithCallback(const WEAVE_ERROR aErrorCode)
void

Protected static functions

HandleResponseTimeout(ExchangeContext *aEC)
void
HandleSyncResponse(ExchangeContext *aEC, const IPPacketInfo *aPktInfo, const WeaveMessageInfo *aMsgInfo, uint32_t aProfileId, uint8_t aMsgType, PacketBuffer *aPayload)
void
HandleTimeChangeNotification(ExchangeContext *aEC, const IPPacketInfo *aPktInfo, const WeaveMessageInfo *aMsgInfo, uint32_t aProfileId, uint8_t aMsgType, PacketBuffer *aPayload)
void

Public types

ClientState

 ClientState

current state of this Time Sync Client

Properties
kClientState_Idle

Initialized, waiting for Time Change Notification, but no actual time sync operation is happening.

kClientState_Sync_1

Working on the first time sync attempt.

kClientState_Sync_2

Working on the second time sync attempt.

SyncCompletionHandler

void(* SyncCompletionHandler)(void *const aApp, const WEAVE_ERROR aErrorCode, const timesync_t aCorrectedSystemTime)

Callback after both time sync attempts have been completed.

If aErrorCode is WEAVE_NO_ERROR, at least one attempt has succeeded. Otherwise both failed at aErrorCode indicates the latest failure.

Details
Parameters
[in] aApp
A pointer to app layer data, set in Init.
[in] aErrorCode
WEAVE_NO_ERROR if at least one time sync operation is successful
[in] aCorrectedSystemTime
Only valid if aErrorCode is WEAVE_NO_ERROR

TimeChangeNotificationHandler

void(* TimeChangeNotificationHandler)(void *const aApp, ExchangeContext *aEC)

Callback to indicate we just received a Time Change Notification.

Set to NULL at Init. If not set, Time Change Notification would be ignored. App layer is allowed to call Abort and Sync in this callback.

Details
Parameters
[in] aApp
A pointer to app layer data, set in Init.
[in] aEC
Exchange context used for this incoming message, which can be used to validate its authenticity

Protected types

@324

 @324

Public attributes

OnTimeChangeNotificationReceived

TimeChangeNotificationHandler OnTimeChangeNotificationReceived

Protected attributes

mApp

void * mApp

mBinding

Binding * mBinding

mClientState

ClientState mClientState

mExchangeContext

ExchangeContext * mExchangeContext

mExchangeMgr

WeaveExchangeManager * mExchangeMgr

mFlightTime_usec

int32_t mFlightTime_usec

used to store one way flight time.

mIsInCallback

bool mIsInCallback

mOnSyncCompleted

SyncCompletionHandler mOnSyncCompleted

mRegisterSyncResult_usec

timesync_t mRegisterSyncResult_usec

used to store Timestamp when a result is registered

mRemoteTimestamp_usec

timesync_t mRemoteTimestamp_usec

used to store the system time of remote node, when the response message was about to be sent

mUnadjTimestampLastSent_usec

timesync_t mUnadjTimestampLastSent_usec

Public functions

Abort

void Abort(
  void
)

Abort current time sync operation.

Release Binding. Abort active exchange. Move back to idle state.

GetClientState

ClientState GetClientState(
  void
) const 

Retrieve current state of this client.

Details
Returns
current state

Init

WEAVE_ERROR Init(
  void *const aApp,
  WeaveExchangeManager *const aExchangeMgr
)

Initialize this client.

Must be called before other functions can be used. Zero/NULL initialize all internal data and register with Time Change Notification.

Details
Parameters
[in] aApp
A pointer to higher layer data, used in callbacks to higher layer.
[in] aExchangeMgr
A pointer to Exchange Manager, which would be used in registering for Time Change Notification message handler
Returns
WEAVE_NO_ERROR on success

Sync

WEAVE_ERROR Sync(
  Binding *const aBinding,
  SyncCompletionHandler OnSyncCompleted
)

Sync using the given Binding and makes a callback using the pointer provided.

If there is a time sync operation going on, it would be aborted implicitly without callback being made. Not available in callback OnSyncCompleted, but allowed in OnTimeChangeNotificationReceived . On error, Abort would be called implicitly before returning from this function.

Details
Parameters
[in] aBinding
Binding to be used in contacting the time server
[in] OnSyncCompleted
Callback function to be used after the time sync operations are completed
Returns
WEAVE_NO_ERROR on success

Protected functions

EnterSync2

void EnterSync2(
  void
)

FinalProcessing

void FinalProcessing(
  void
)

GetClientStateName

const char * GetClientStateName(
  void
) const 

InvalidateRegisteredResult

void InvalidateRegisteredResult(
  void
)

Invalidate the registered information for time correction.

IsRegisteredResultValid

bool IsRegisteredResultValid(
  void
)

Check if the registered information for time correction is valid.

OnResponseTimeout

void OnResponseTimeout(
  void
)

OnSyncResponse

void OnSyncResponse(
  uint32_t aProfileId,
  uint8_t aMsgType,
  PacketBuffer *aPayload
)

ProceedToNextState

void ProceedToNextState(
  void
)

RegisterSyncResultIfNewOrBetter

void RegisterSyncResultIfNewOrBetter(
  const timesync_t aNow_usec,
  const timesync_t aRemoteTimestamp_usec,
  const int32_t aFlightTime_usec
)

SendSyncRequest

WEAVE_ERROR SendSyncRequest(
  void
)

SetClientState

void SetClientState(
  const ClientState state
)

_AbortWithCallback

void _AbortWithCallback(
  const WEAVE_ERROR aErrorCode
)

Protected static functions

HandleResponseTimeout

void HandleResponseTimeout(
  ExchangeContext *aEC
)

HandleSyncResponse

void HandleSyncResponse(
  ExchangeContext *aEC,
  const IPPacketInfo *aPktInfo,
  const WeaveMessageInfo *aMsgInfo,
  uint32_t aProfileId,
  uint8_t aMsgType,
  PacketBuffer *aPayload
)

HandleTimeChangeNotification

void HandleTimeChangeNotification(
  ExchangeContext *aEC,
  const IPPacketInfo *aPktInfo,
  const WeaveMessageInfo *aMsgInfo,
  uint32_t aProfileId,
  uint8_t aMsgType,
  PacketBuffer *aPayload
)