Network Time Synchronization#

This module includes functions that control network time synchronization service.

Enumerations#

enum
OT_NETWORK_TIME_UNSYNCHRONIZED = -1
OT_NETWORK_TIME_RESYNC_NEEDED = 0
OT_NETWORK_TIME_SYNCHRONIZED = 1
}

This enumeration represents OpenThread time synchronization status.

Typedefs#

typedef enum otNetworkTimeStatus

This enumeration represents OpenThread time synchronization status.

typedef void(*
otNetworkTimeSyncCallbackFn)(void *aCallbackContext)

This function pointer is called when a network time sync or status change occurs.

Functions#

otNetworkTimeGet(otInstance *aInstance, uint64_t *aNetworkTime)

Get the Thread network time.

otNetworkTimeSetSyncPeriod(otInstance *aInstance, uint16_t aTimeSyncPeriod)

Set the time synchronization period.

uint16_t
otNetworkTimeGetSyncPeriod(otInstance *aInstance)

Get the time synchronization period.

otNetworkTimeSetXtalThreshold(otInstance *aInstance, uint16_t aXTALThreshold)

Set the time synchronization XTAL accuracy threshold for Router-Capable device.

uint16_t
otNetworkTimeGetXtalThreshold(otInstance *aInstance)

Get the time synchronization XTAL accuracy threshold for Router.

void
otNetworkTimeSyncSetCallback(otInstance *aInstance, otNetworkTimeSyncCallbackFn aCallbackFn, void *aCallbackContext)

Set a callback to be called when a network time sync or status change occurs.

Macros#

#define

zero is considered as invalid time synchronization sequence.

Enumeration Documentation#

otNetworkTimeStatus#

otNetworkTimeStatus

This enumeration represents OpenThread time synchronization status.

Enumerator
OT_NETWORK_TIME_UNSYNCHRONIZED

The device hasn't attached to a network.

OT_NETWORK_TIME_RESYNC_NEEDED

The device hasn’t received time sync for more than two periods time.

OT_NETWORK_TIME_SYNCHRONIZED

The device network time is synchronized.


Definition at line 59 of file include/openthread/network_time.h

Typedef Documentation#

otNetworkTimeStatus#

typedef enum otNetworkTimeStatus otNetworkTimeStatus

This enumeration represents OpenThread time synchronization status.


Definition at line 64 of file include/openthread/network_time.h

otNetworkTimeSyncCallbackFn#

typedef void(* otNetworkTimeSyncCallbackFn) (void *aCallbackContext) )(void *aCallbackContext)

This function pointer is called when a network time sync or status change occurs.


Definition at line 70 of file include/openthread/network_time.h

Function Documentation#

otNetworkTimeGet#

otNetworkTimeStatus otNetworkTimeGet (otInstance * aInstance, uint64_t * aNetworkTime)

Get the Thread network time.

Parameters
[in]aInstance

The OpenThread instance structure.

[inout]aNetworkTime

The Thread network time in microseconds.

Returns

  • The time synchronization status.


Definition at line 87 of file include/openthread/network_time.h

otNetworkTimeSetSyncPeriod#

otError otNetworkTimeSetSyncPeriod (otInstance * aInstance, uint16_t aTimeSyncPeriod)

Set the time synchronization period.

Parameters
[in]aInstance

The OpenThread instance structure.

[in]aTimeSyncPeriod

The time synchronization period, in seconds.

This function can only be called while Thread protocols are disabled.


Definition at line 101 of file include/openthread/network_time.h

otNetworkTimeGetSyncPeriod#

uint16_t otNetworkTimeGetSyncPeriod (otInstance * aInstance)

Get the time synchronization period.

Parameters
[in]aInstance

The OpenThread instance structure.

Returns

  • The time synchronization period.


Definition at line 111 of file include/openthread/network_time.h

otNetworkTimeSetXtalThreshold#

otError otNetworkTimeSetXtalThreshold (otInstance * aInstance, uint16_t aXTALThreshold)

Set the time synchronization XTAL accuracy threshold for Router-Capable device.

Parameters
[in]aInstance

The OpenThread instance structure.

[in]aXTALThreshold

The XTAL accuracy threshold for Router, in PPM.

This function can only be called while Thread protocols are disabled.


Definition at line 125 of file include/openthread/network_time.h

otNetworkTimeGetXtalThreshold#

uint16_t otNetworkTimeGetXtalThreshold (otInstance * aInstance)

Get the time synchronization XTAL accuracy threshold for Router.

Parameters
[in]aInstance

The OpenThread instance structure.

Returns

  • The XTAL accuracy threshold for Router, in PPM.


Definition at line 135 of file include/openthread/network_time.h

otNetworkTimeSyncSetCallback#

void otNetworkTimeSyncSetCallback (otInstance * aInstance, otNetworkTimeSyncCallbackFn aCallbackFn, void * aCallbackContext)

Set a callback to be called when a network time sync or status change occurs.

Parameters
[in]aInstance

The OpenThread instance structure.

[in]aCallbackFn

The callback function to be called

[in]aCallbackContext

The context to be passed to the callback function upon invocation

This callback shall be called only when the network time offset jumps by OPENTHREAD_CONFIG_TIME_SYNC_JUMP_NOTIF_MIN_US or when the status changes.


Definition at line 148 of file include/openthread/network_time.h

Macro Definition Documentation#

OT_TIME_SYNC_INVALID_SEQ#

#define OT_TIME_SYNC_INVALID_SEQ
Value:
0

zero is considered as invalid time synchronization sequence.


Definition at line 76 of file include/openthread/network_time.h