Border Agent#

This module includes functions for the Thread Border Agent role.

Modules#

otBorderAgentId

Enumerations#

enum
OT_BORDER_AGENT_STATE_STOPPED = 0
OT_BORDER_AGENT_STATE_STARTED = 1
OT_BORDER_AGENT_STATE_ACTIVE = 2
}

Defines the Border Agent state.

Typedefs#

typedef struct otBorderAgentId

Represents a Border Agent ID.

typedef enum otBorderAgentState

Defines the Border Agent state.

typedef void(*

Callback function pointer to signal changes related to the Border Agent's ephemeral key.

Functions#

otBorderAgentGetState(otInstance *aInstance)

Gets the otBorderAgentState of the Thread Border Agent role.

uint16_t
otBorderAgentGetUdpPort(otInstance *aInstance)

Gets the UDP port of the Thread Border Agent service.

otBorderAgentGetId(otInstance *aInstance, otBorderAgentId *aId)

Gets the randomly generated Border Agent ID.

otBorderAgentSetId(otInstance *aInstance, const otBorderAgentId *aId)

Sets the Border Agent ID.

otBorderAgentSetEphemeralKey(otInstance *aInstance, const char *aKeyString, uint32_t aTimeout, uint16_t aUdpPort)

Sets the ephemeral key for a given timeout duration.

void
otBorderAgentClearEphemeralKey(otInstance *aInstance)

Cancels the ephemeral key that is in use.

bool
otBorderAgentIsEphemeralKeyActive(otInstance *aInstance)

Indicates whether or not an ephemeral key is currently active.

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.

Macros#

#define

The length of Border Agent/Router ID in bytes.

#define

Minimum length of the ephemeral key string.

#define

Maximum length of the ephemeral key string.

#define

Default ephemeral key timeout interval in milliseconds.

#define

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.


Definition at line 106 of file include/openthread/border_agent.h

Typedef Documentation#

otBorderAgentId#

typedef struct otBorderAgentId otBorderAgentId

Represents a Border Agent ID.


Definition at line 100 of file include/openthread/border_agent.h

otBorderAgentState#

typedef enum otBorderAgentState otBorderAgentState

Defines the Border Agent state.


Definition at line 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.

Parameters
[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.


Definition at line 261 of file include/openthread/border_agent.h

Variable Documentation#

OT_TOOL_PACKED_END#

OT_TOOL_PACKED_BEGIN struct otBorderAgentId OT_TOOL_PACKED_END

Definition at line 94 of file include/openthread/border_agent.h

Function Documentation#

otBorderAgentGetState#

otBorderAgentState otBorderAgentGetState (otInstance * aInstance)

Gets the otBorderAgentState of the Thread Border Agent role.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

Returns


Definition at line 121 of file include/openthread/border_agent.h

otBorderAgentGetUdpPort#

uint16_t otBorderAgentGetUdpPort (otInstance * aInstance)

Gets the UDP port of the Thread Border Agent service.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

Returns

  • UDP port of the Border Agent.


Definition at line 131 of file include/openthread/border_agent.h

otBorderAgentGetId#

otError otBorderAgentGetId (otInstance * aInstance, otBorderAgentId * aId)

Gets the randomly generated Border Agent ID.

Parameters
[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


Definition at line 151 of file include/openthread/border_agent.h

otBorderAgentSetId#

otError otBorderAgentSetId (otInstance * aInstance, const otBorderAgentId * aId)

Sets the Border Agent ID.

Parameters
[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


Definition at line 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.

Parameters
[in]aInstance

The OpenThread instance.

[in]aKeyString

The ephemeral key string (used as PSK excluding the trailing null \0 character).

[in]aTimeout

The timeout duration in milliseconds to use the ephemeral key. If zero, the default OT_BORDER_AGENT_DEFAULT_EPHEMERAL_KEY_TIMEOUT value will be used. If the given timeout value is larger than OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_TIMEOUT, the max value OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_TIMEOUT will be used instead.

[in]aUdpPort

The UDP port to use with ephemeral key. If zero, an ephemeral port will be used. otBorderAgentGetUdpPort() will return the current UDP port being 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.


Definition at line 208 of file include/openthread/border_agent.h

otBorderAgentClearEphemeralKey#

void otBorderAgentClearEphemeralKey (otInstance * aInstance)

Cancels the ephemeral key that is in use.

Parameters
[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.


Definition at line 228 of file include/openthread/border_agent.h

otBorderAgentIsEphemeralKeyActive#

bool otBorderAgentIsEphemeralKeyActive (otInstance * aInstance)

Indicates whether or not an ephemeral key is currently active.

Parameters
[in]aInstance

The OpenThread instance.

Requires OPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE.


Definition at line 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.

Parameters
[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.


Definition at line 275 of file include/openthread/border_agent.h

Macro Definition Documentation#

OT_BORDER_AGENT_ID_LENGTH#

#define OT_BORDER_AGENT_ID_LENGTH
Value:
(16)

The length of Border Agent/Router ID in bytes.


Definition at line 58 of file include/openthread/border_agent.h

OT_BORDER_AGENT_MIN_EPHEMERAL_KEY_LENGTH#

#define OT_BORDER_AGENT_MIN_EPHEMERAL_KEY_LENGTH
Value:
(6)

Minimum length of the ephemeral key string.


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

OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_LENGTH#

#define OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_LENGTH
Value:
(32)

Maximum length of the ephemeral key string.


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

OT_BORDER_AGENT_DEFAULT_EPHEMERAL_KEY_TIMEOUT#

#define OT_BORDER_AGENT_DEFAULT_EPHEMERAL_KEY_TIMEOUT
Value:
(2 * 60 * 1000u)

Default ephemeral key timeout interval in milliseconds.


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

OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_TIMEOUT#

#define OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_TIMEOUT
Value:
(10 * 60 * 1000u)

Maximum ephemeral key timeout interval in milliseconds.


Definition at line 82 of file include/openthread/border_agent.h