Border Agent#
This module includes functions for the Thread Border Agent role.
Modules#
Enumerations#
Defines the Border Agent state.
Typedefs#
Represents a Border Agent ID.
Defines the Border Agent state.
Callback function pointer to signal changes related to the Border Agent's ephemeral key.
Variables#
Functions#
Gets the otBorderAgentState of the Thread Border Agent role.
Gets the UDP port of the Thread Border Agent service.
Gets the randomly generated Border Agent ID.
Sets the Border Agent ID.
Sets the ephemeral key for a given timeout duration.
Cancels the ephemeral key that is in use.
Indicates whether or not an ephemeral key is currently active.
Sets the callback function used by the Border Agent to notify any changes related to use of ephemeral key.
Macros#
The length of Border Agent/Router ID in bytes.
Minimum length of the ephemeral key string.
Maximum length of the ephemeral key string.
Default ephemeral key timeout interval in milliseconds.
Maximum ephemeral key timeout interval in milliseconds.
Enumeration Documentation#
otBorderAgentState#
otBorderAgentState
Defines the Border Agent state.
Enumerator | |
---|---|
OT_BORDER_AGENT_STATE_STOPPED | Border agent role is disabled. |
OT_BORDER_AGENT_STATE_STARTED | Border agent is started. |
OT_BORDER_AGENT_STATE_ACTIVE | Border agent is connected with external commissioner. |
106
of file include/openthread/border_agent.h
Typedef Documentation#
otBorderAgentId#
typedef struct otBorderAgentId otBorderAgentId
Represents a Border Agent ID.
100
of file include/openthread/border_agent.h
otBorderAgentState#
typedef enum otBorderAgentState otBorderAgentState
Defines the Border Agent state.
111
of file include/openthread/border_agent.h
otBorderAgentEphemeralKeyCallback#
typedef void(* otBorderAgentEphemeralKeyCallback) (void *aContext) )(void *aContext)
Callback function pointer to signal changes related to the Border Agent's ephemeral key.
[in] | aContext | A pointer to an arbitrary context (provided when callback is set). |
This callback is invoked whenever:
The Border Agent starts using an ephemeral key.
Any parameter related to the ephemeral key, such as the port number, changes.
The Border Agent stops using the ephemeral key due to:
A direct call to
otBorderAgentClearEphemeralKey()
.The ephemeral key timing out.
An external commissioner successfully using the key to connect and then disconnecting.
Reaching the maximum number of allowed failed connection attempts.
Any OpenThread API, including otBorderAgent
APIs, can be safely called from this callback.
261
of file include/openthread/border_agent.h
Variable Documentation#
OT_TOOL_PACKED_END#
OT_TOOL_PACKED_BEGIN struct otBorderAgentId OT_TOOL_PACKED_END
94
of file include/openthread/border_agent.h
Function Documentation#
otBorderAgentGetState#
otBorderAgentState otBorderAgentGetState (otInstance * aInstance)
Gets the otBorderAgentState of the Thread Border Agent role.
[in] | aInstance | A pointer to an OpenThread instance. |
Returns
The current otBorderAgentState of the Border Agent.
121
of file include/openthread/border_agent.h
otBorderAgentGetUdpPort#
uint16_t otBorderAgentGetUdpPort (otInstance * aInstance)
Gets the UDP port of the Thread Border Agent service.
[in] | aInstance | A pointer to an OpenThread instance. |
Returns
UDP port of the Border Agent.
131
of file include/openthread/border_agent.h
otBorderAgentGetId#
otError otBorderAgentGetId (otInstance * aInstance, otBorderAgentId * aId)
Gets the randomly generated Border Agent ID.
[in] | aInstance | A pointer to an OpenThread instance. |
[out] | aId | A pointer to buffer to receive the ID. |
Requires OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE
.
The ID is saved in persistent storage and survives reboots. The typical use case of the ID is to be published in the MeshCoP mDNS service as the id
TXT value for the client to identify this Border Router/Agent device.
See Also
151
of file include/openthread/border_agent.h
otBorderAgentSetId#
otError otBorderAgentSetId (otInstance * aInstance, const otBorderAgentId * aId)
Sets the Border Agent ID.
[in] | aInstance | A pointer to an OpenThread instance. |
[out] | aId | A pointer to the Border Agent ID. |
Requires OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE
.
The Border Agent ID will be saved in persistent storage and survive reboots. It's required to set the ID only once after factory reset. If the ID has never been set by calling this function, a random ID will be generated and returned when otBorderAgentGetId
is called.
See Also
171
of file include/openthread/border_agent.h
otBorderAgentSetEphemeralKey#
otError otBorderAgentSetEphemeralKey (otInstance * aInstance, const char * aKeyString, uint32_t aTimeout, uint16_t aUdpPort)
Sets the ephemeral key for a given timeout duration.
[in] | aInstance | The OpenThread instance. |
[in] | aKeyString | The ephemeral key string (used as PSK excluding the trailing null |
[in] | aTimeout | The timeout duration in milliseconds to use the ephemeral key. If zero, the default |
[in] | aUdpPort | The UDP port to use with ephemeral key. If zero, an ephemeral port will be used. |
Requires OPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE
.
The ephemeral key can be set when the Border Agent is already running and is not currently connected to any external commissioner (i.e., it is in OT_BORDER_AGENT_STATE_STARTED
state). Otherwise OT_ERROR_INVALID_STATE
is returned.
The given aKeyString
is directly used as the ephemeral PSK (excluding the trailing null \0
character ). The aKeyString
length must be between OT_BORDER_AGENT_MIN_EPHEMERAL_KEY_LENGTH
and OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_LENGTH
, inclusive.
Setting the ephemeral key again before a previously set key has timed out will replace the previously set key and reset the timeout.
While the timeout interval is in effect, the ephemeral key can be used only once by an external commissioner to connect. Once the commissioner disconnects, the ephemeral key is cleared, and the Border Agent reverts to using PSKc.
208
of file include/openthread/border_agent.h
otBorderAgentClearEphemeralKey#
void otBorderAgentClearEphemeralKey (otInstance * aInstance)
Cancels the ephemeral key that is in use.
[in] | aInstance | The OpenThread instance. |
Requires OPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE
.
Can be used to cancel a previously set ephemeral key before it times out. If the Border Agent is not running or there is no ephemeral key in use, calling this function has no effect.
If a commissioner is connected using the ephemeral key and is currently active, calling this function does not change its state. In this case the otBorderAgentIsEphemeralKeyActive()
will continue to return TRUE
until the commissioner disconnects.
228
of file include/openthread/border_agent.h
otBorderAgentIsEphemeralKeyActive#
bool otBorderAgentIsEphemeralKeyActive (otInstance * aInstance)
Indicates whether or not an ephemeral key is currently active.
[in] | aInstance | The OpenThread instance. |
Requires OPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE
.
241
of file include/openthread/border_agent.h
otBorderAgentSetEphemeralKeyCallback#
void otBorderAgentSetEphemeralKeyCallback (otInstance * aInstance, otBorderAgentEphemeralKeyCallback aCallback, void * aContext)
Sets the callback function used by the Border Agent to notify any changes related to use of ephemeral key.
[in] | aInstance | The OpenThread instance. |
[in] | aCallback | The callback function pointer. |
[in] | aContext | The arbitrary context to use with callback. |
Requires OPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE
.
A subsequent call to this function will replace any previously set callback.
275
of file include/openthread/border_agent.h
Macro Definition Documentation#
OT_BORDER_AGENT_ID_LENGTH#
#define OT_BORDER_AGENT_ID_LENGTHValue:
(16)
The length of Border Agent/Router ID in bytes.
58
of file include/openthread/border_agent.h
OT_BORDER_AGENT_MIN_EPHEMERAL_KEY_LENGTH#
#define OT_BORDER_AGENT_MIN_EPHEMERAL_KEY_LENGTHValue:
(6)
Minimum length of the ephemeral key string.
64
of file include/openthread/border_agent.h
OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_LENGTH#
#define OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_LENGTHValue:
(32)
Maximum length of the ephemeral key string.
70
of file include/openthread/border_agent.h
OT_BORDER_AGENT_DEFAULT_EPHEMERAL_KEY_TIMEOUT#
#define OT_BORDER_AGENT_DEFAULT_EPHEMERAL_KEY_TIMEOUTValue:
(2 * 60 * 1000u)
Default ephemeral key timeout interval in milliseconds.
76
of file include/openthread/border_agent.h
OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_TIMEOUT#
#define OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_TIMEOUTValue:
(10 * 60 * 1000u)
Maximum ephemeral key timeout interval in milliseconds.
82
of file include/openthread/border_agent.h