Instance#
This module includes functions that control the OpenThread Instance.
Enumerations#
This enumeration defines flags that are passed as part of otStateChangedCallback
.
Typedefs#
This structure represents the OpenThread instance structure.
This type represents a bit-field indicating specific state/configuration that has changed.
This function pointer is called to notify certain configuration or state changes within OpenThread.
Functions#
This function initializes the OpenThread library.
This function initializes the static single instance of the OpenThread library.
This function indicates whether or not the instance is valid/initialized.
This function disables the OpenThread library.
This function returns the current instance uptime (in msec).
This function returns the current instance uptime as a human-readable string.
This function registers a callback to indicate when certain configuration or state changes within OpenThread.
This function removes a callback to indicate when certain configuration or state changes within OpenThread.
This method triggers a platform reset.
Deletes all the settings stored on non-volatile memory, and then triggers a platform reset.
This method resets the internal states of the OpenThread radio stack.
This function erases all the OpenThread persistent info (network settings) stored on non-volatile memory.
This function gets the OpenThread version string.
This function gets the OpenThread radio version string.
Macros#
Recommended size for string representation of uptime.
Enumeration Documentation#
@2#
@2
This enumeration defines flags that are passed as part of otStateChangedCallback
.
Enumerator | |
---|---|
OT_CHANGED_IP6_ADDRESS_ADDED | IPv6 address was added. |
OT_CHANGED_IP6_ADDRESS_REMOVED | IPv6 address was removed. |
OT_CHANGED_THREAD_ROLE | Role (disabled, detached, child, router, leader) changed. |
OT_CHANGED_THREAD_LL_ADDR | The link-local address changed. |
OT_CHANGED_THREAD_ML_ADDR | The mesh-local address changed. |
OT_CHANGED_THREAD_RLOC_ADDED | RLOC was added. |
OT_CHANGED_THREAD_RLOC_REMOVED | RLOC was removed. |
OT_CHANGED_THREAD_PARTITION_ID | Partition ID changed. |
OT_CHANGED_THREAD_KEY_SEQUENCE_COUNTER | Thread Key Sequence changed. |
OT_CHANGED_THREAD_NETDATA | Thread Network Data changed. |
OT_CHANGED_THREAD_CHILD_ADDED | Child was added. |
OT_CHANGED_THREAD_CHILD_REMOVED | Child was removed. |
OT_CHANGED_IP6_MULTICAST_SUBSCRIBED | Subscribed to a IPv6 multicast address. |
OT_CHANGED_IP6_MULTICAST_UNSUBSCRIBED | Unsubscribed from a IPv6 multicast address. |
OT_CHANGED_THREAD_CHANNEL | Thread network channel changed. |
OT_CHANGED_THREAD_PANID | Thread network PAN Id changed. |
OT_CHANGED_THREAD_NETWORK_NAME | Thread network name changed. |
OT_CHANGED_THREAD_EXT_PANID | Thread network extended PAN ID changed. |
OT_CHANGED_NETWORK_KEY | Network key changed. |
OT_CHANGED_PSKC | PSKc changed. |
OT_CHANGED_SECURITY_POLICY | Security Policy changed. |
OT_CHANGED_CHANNEL_MANAGER_NEW_CHANNEL | Channel Manager new pending Thread channel changed. |
OT_CHANGED_SUPPORTED_CHANNEL_MASK | Supported channel mask changed. |
OT_CHANGED_COMMISSIONER_STATE | Commissioner state changed. |
OT_CHANGED_THREAD_NETIF_STATE | Thread network interface state changed. |
OT_CHANGED_THREAD_BACKBONE_ROUTER_STATE | Backbone Router state changed. |
OT_CHANGED_THREAD_BACKBONE_ROUTER_LOCAL | Local Backbone Router configuration changed. |
OT_CHANGED_JOINER_STATE | Joiner state changed. |
OT_CHANGED_ACTIVE_DATASET | Active Operational Dataset changed. |
OT_CHANGED_PENDING_DATASET | Pending Operational Dataset changed. |
OT_CHANGED_NAT64_TRANSLATOR_STATE | The state of NAT64 translator changed. |
167
of file include/openthread/instance.h
Typedef Documentation#
otInstance#
typedef struct otInstance otInstance
This structure represents the OpenThread instance structure.
71
of file include/openthread/instance.h
otChangedFlags#
typedef uint32_t otChangedFlags
This type represents a bit-field indicating specific state/configuration that has changed.
See OT_CHANGED_*
definitions.
207
of file include/openthread/instance.h
otStateChangedCallback#
typedef void(* otStateChangedCallback) (otChangedFlags aFlags, void *aContext) )(otChangedFlags aFlags, void *aContext)
This function pointer is called to notify certain configuration or state changes within OpenThread.
[in] | aFlags | A bit-field indicating specific state that has changed. See |
[in] | aContext | A pointer to application-specific context. |
216
of file include/openthread/instance.h
Function Documentation#
otInstanceInit#
otInstance * otInstanceInit (void * aInstanceBuffer, size_t * aInstanceBufferSize)
This function initializes the OpenThread library.
[in] | aInstanceBuffer | The buffer for OpenThread to use for allocating the otInstance structure. |
[inout] | aInstanceBufferSize | On input, the size of aInstanceBuffer. On output, if not enough space for otInstance, the number of bytes required for otInstance. |
This function initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be called before any other calls to OpenThread.
This function is available and can only be used when support for multiple OpenThread instances is enabled.
Returns
A pointer to the new OpenThread instance.
See Also
90
of file include/openthread/instance.h
otInstanceInitSingle#
otInstance * otInstanceInitSingle (void )
This function initializes the static single instance of the OpenThread library.
N/A |
This function initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be called before any other calls to OpenThread.
This function is available and can only be used when support for multiple OpenThread instances is disabled.
Returns
A pointer to the single OpenThread instance.
103
of file include/openthread/instance.h
otInstanceIsInitialized#
bool otInstanceIsInitialized (otInstance * aInstance)
This function indicates whether or not the instance is valid/initialized.
[in] | aInstance | A pointer to an OpenThread instance. |
The instance is considered valid if it is acquired and initialized using either otInstanceInitSingle()
(in single instance case) or otInstanceInit()
(in multi instance case). A subsequent call to otInstanceFinalize()
causes the instance to be considered as uninitialized.
Returns
TRUE if the given instance is valid/initialized, FALSE otherwise.
117
of file include/openthread/instance.h
otInstanceFinalize#
void otInstanceFinalize (otInstance * aInstance)
This function disables the OpenThread library.
[in] | aInstance | A pointer to an OpenThread instance. |
Call this function when OpenThread is no longer in use.
127
of file include/openthread/instance.h
otInstanceGetUptime#
uint64_t otInstanceGetUptime (otInstance * aInstance)
This function returns the current instance uptime (in msec).
[in] | aInstance | A pointer to an OpenThread instance. |
This function requires OPENTHREAD_CONFIG_UPTIME_ENABLE
to be enabled.
The uptime is given as number of milliseconds since OpenThread instance was initialized.
Returns
The uptime (number of milliseconds).
141
of file include/openthread/instance.h
otInstanceGetUptimeAsString#
void otInstanceGetUptimeAsString (otInstance * aInstance, char * aBuffer, uint16_t aSize)
This function returns the current instance uptime as a human-readable string.
[in] | aInstance | A pointer to an OpenThread instance. |
[out] | aBuffer | A pointer to a char array to output the string. |
[in] | aSize | The size of |
This function requires OPENTHREAD_CONFIG_UPTIME_ENABLE
to be enabled.
The string follows the format "<hh>:<mm>:<ss>.<mmmm>" for hours, minutes, seconds and millisecond (if uptime is shorter than one day) or "<dd>d.<hh>:<mm>:<ss>.<mmmm>" (if longer than a day).
If the resulting string does not fit in aBuffer
(within its aSize
characters), the string will be truncated but the outputted string is always null-terminated.
161
of file include/openthread/instance.h
otSetStateChangedCallback#
otError otSetStateChangedCallback (otInstance * aInstance, otStateChangedCallback aCallback, void * aContext)
This function registers a callback to indicate when certain configuration or state changes within OpenThread.
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aCallback | A pointer to a function that is called with certain configuration or state changes. |
[in] | aContext | A pointer to application-specific context. |
230
of file include/openthread/instance.h
otRemoveStateChangeCallback#
void otRemoveStateChangeCallback (otInstance * aInstance, otStateChangedCallback aCallback, void * aContext)
This function removes a callback to indicate when certain configuration or state changes within OpenThread.
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aCallback | A pointer to a function that is called with certain configuration or state changes. |
[in] | aContext | A pointer to application-specific context. |
240
of file include/openthread/instance.h
otInstanceReset#
void otInstanceReset (otInstance * aInstance)
This method triggers a platform reset.
[in] | aInstance | A pointer to an OpenThread instance. |
The reset process ensures that all the OpenThread state/info (stored in volatile memory) is erased. Note that the otPlatformReset
does not erase any persistent state/info saved in non-volatile memory.
251
of file include/openthread/instance.h
otInstanceFactoryReset#
void otInstanceFactoryReset (otInstance * aInstance)
Deletes all the settings stored on non-volatile memory, and then triggers a platform reset.
[in] | aInstance | A pointer to an OpenThread instance. |
259
of file include/openthread/instance.h
otInstanceResetRadioStack#
void otInstanceResetRadioStack (otInstance * aInstance)
This method resets the internal states of the OpenThread radio stack.
[in] | aInstance | A pointer to an OpenThread instance. |
Callbacks and configurations are preserved.
This API is only available under radio builds (OPENTHREAD_RADIO = 1
).
271
of file include/openthread/instance.h
otInstanceErasePersistentInfo#
otError otInstanceErasePersistentInfo (otInstance * aInstance)
This function erases all the OpenThread persistent info (network settings) stored on non-volatile memory.
[in] | aInstance | A pointer to an OpenThread instance. |
Erase is successful only if the device is in disabled
state/role.
283
of file include/openthread/instance.h
otGetVersionString#
const char * otGetVersionString (void )
This function gets the OpenThread version string.
N/A |
Returns
A pointer to the OpenThread version.
291
of file include/openthread/instance.h
otGetRadioVersionString#
const char * otGetRadioVersionString (otInstance * aInstance)
This function gets the OpenThread radio version string.
[in] | aInstance | A pointer to an OpenThread instance. |
Returns
A pointer to the OpenThread radio version.
301
of file include/openthread/instance.h