Border Agent#
This module includes functions for the Thread Border Agent role.
Modules#
Enumerations#
Defines the Border Agent state.
Typedefs#
Represents a Border Agent Identifier.
Defines the Border Agent state.
Callback function pointer to signal changes related to the Border Agent's ephemeral key.
Functions#
Gets the counters of the Thread Border Agent.
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.
Disconnects the Border Agent from any active secure sessions.
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. |
89
of file include/openthread/border_agent.h
Typedef Documentation#
otBorderAgentId#
typedef struct otBorderAgentId otBorderAgentId
Represents a Border Agent Identifier.
84
of file include/openthread/border_agent.h
otBorderAgentState#
typedef enum otBorderAgentState otBorderAgentState
Defines the Border Agent state.
94
of file include/openthread/border_agent.h
otBorderAgentCounters#
typedef struct otBorderAgentCounters otBorderAgentCounters
116
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.
268
of file include/openthread/border_agent.h
Function Documentation#
otBorderAgentGetCounters#
const otBorderAgentCounters * otBorderAgentGetCounters (otInstance * aInstance)
Gets the counters of the Thread Border Agent.
[in] | aInstance | A pointer to an OpenThread instance. |
Returns
A pointer to the Border Agent counters.
125
of file include/openthread/border_agent.h
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.
134
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.
143
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
162
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
181
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.
During the timeout interval, the ephemeral key can be used only once by an external commissioner to establish a connection. After the commissioner disconnects, the ephemeral key is cleared, and the Border Agent reverts to using PSKc. If the timeout expires while a commissioner is still connected, the session will be terminated, and the Border Agent will cease using the ephemeral key and revert to PSKc.
218
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, or the ephemeral key timeout expires.
237
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
.
249
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.
281
of file include/openthread/border_agent.h
otBorderAgentDisconnect#
void otBorderAgentDisconnect (otInstance * aInstance)
Disconnects the Border Agent from any active secure sessions.
[in] | aInstance | The OpenThread instance. |
If Border Agent is connected to a commissioner candidate with ephemeral key, calling this API will cause the ephemeral key to be cleared after the session is disconnected.
The Border Agent state may not change immediately upon calling this method. The state will be updated when the connection update is notified with a delay.
296
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.
56
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.
61
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.
66
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.
71
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.
76
of file include/openthread/border_agent.h