nRF5 SDK for Thread and Zigbee v4.0.0
Data Structures | Macros | Typedefs | Enumerations | Functions
Router/Leader

This module includes functions for Thread Routers and Leaders. More...

Data Structures

struct  otChildInfo
 
struct  otEidCacheEntry
 
struct  otNeighborTableEntryInfo
 

Macros

#define OT_CHILD_IP6_ADDRESS_ITERATOR_INIT   0
 Initializer for otChildIP6AddressIterator.
 

Typedefs

typedef uint16_t otChildIp6AddressIterator
 Used to iterate through IPv6 addresses of a Thread Child entry.
 
typedef struct otEidCacheEntry otEidCacheEntry
 
typedef void(* otNeighborTableCallback )(otNeighborTableEvent aEvent, const otNeighborTableEntryInfo *aEntryInfo)
 

Enumerations

enum  otNeighborTableEvent { OT_NEIGHBOR_TABLE_EVENT_CHILD_ADDED, OT_NEIGHBOR_TABLE_EVENT_CHILD_REMOVED, OT_NEIGHBOR_TABLE_EVENT_ROUTER_ADDED, OT_NEIGHBOR_TABLE_EVENT_ROUTER_REMOVED }
 

Functions

uint16_t otThreadGetMaxAllowedChildren (otInstance *aInstance)
 
otError otThreadSetMaxAllowedChildren (otInstance *aInstance, uint16_t aMaxChildren)
 
bool otThreadIsRouterEligible (otInstance *aInstance)
 
otError otThreadSetRouterEligible (otInstance *aInstance, bool aEligible)
 
otError otThreadSetPreferredRouterId (otInstance *aInstance, uint8_t aRouterId)
 
uint8_t otThreadGetLocalLeaderWeight (otInstance *aInstance)
 
void otThreadSetLocalLeaderWeight (otInstance *aInstance, uint8_t aWeight)
 
uint32_t otThreadGetLocalLeaderPartitionId (otInstance *aInstance)
 
void otThreadSetLocalLeaderPartitionId (otInstance *aInstance, uint32_t aPartitionId)
 
uint16_t otThreadGetJoinerUdpPort (otInstance *aInstance)
 
otError otThreadSetJoinerUdpPort (otInstance *aInstance, uint16_t aJoinerUdpPort)
 
void otThreadSetSteeringData (otInstance *aInstance, const otExtAddress *aExtAddress)
 
uint32_t otThreadGetContextIdReuseDelay (otInstance *aInstance)
 
void otThreadSetContextIdReuseDelay (otInstance *aInstance, uint32_t aDelay)
 
uint8_t otThreadGetNetworkIdTimeout (otInstance *aInstance)
 
void otThreadSetNetworkIdTimeout (otInstance *aInstance, uint8_t aTimeout)
 
uint8_t otThreadGetRouterUpgradeThreshold (otInstance *aInstance)
 
void otThreadSetRouterUpgradeThreshold (otInstance *aInstance, uint8_t aThreshold)
 
otError otThreadReleaseRouterId (otInstance *aInstance, uint8_t aRouterId)
 
otError otThreadBecomeRouter (otInstance *aInstance)
 
otError otThreadBecomeLeader (otInstance *aInstance)
 
uint8_t otThreadGetRouterDowngradeThreshold (otInstance *aInstance)
 
void otThreadSetRouterDowngradeThreshold (otInstance *aInstance, uint8_t aThreshold)
 
uint8_t otThreadGetRouterSelectionJitter (otInstance *aInstance)
 
void otThreadSetRouterSelectionJitter (otInstance *aInstance, uint8_t aRouterJitter)
 
otError otThreadGetChildInfoById (otInstance *aInstance, uint16_t aChildId, otChildInfo *aChildInfo)
 
otError otThreadGetChildInfoByIndex (otInstance *aInstance, uint16_t aChildIndex, otChildInfo *aChildInfo)
 
otError otThreadGetChildNextIp6Address (otInstance *aInstance, uint16_t aChildIndex, otChildIp6AddressIterator *aIterator, otIp6Address *aAddress)
 
uint8_t otThreadGetRouterIdSequence (otInstance *aInstance)
 
uint8_t otThreadGetMaxRouterId (otInstance *aInstance)
 
otError otThreadGetRouterInfo (otInstance *aInstance, uint16_t aRouterId, otRouterInfo *aRouterInfo)
 
otError otThreadGetEidCacheEntry (otInstance *aInstance, uint8_t aIndex, otEidCacheEntry *aEntry)
 
const otPskcotThreadGetPskc (otInstance *aInstance)
 
otError otThreadSetPskc (otInstance *aInstance, const otPskc *aPskc)
 
int8_t otThreadGetParentPriority (otInstance *aInstance)
 
otError otThreadSetParentPriority (otInstance *aInstance, int8_t aParentPriority)
 
void otThreadRegisterNeighborTableCallback (otInstance *aInstance, otNeighborTableCallback aCallback)
 

Detailed Description

This module includes functions for Thread Routers and Leaders.

Typedef Documentation

This structure represents an EID cache entry.

typedef void(* otNeighborTableCallback)(otNeighborTableEvent aEvent, const otNeighborTableEntryInfo *aEntryInfo)

This function pointer is called to notify that a child or router neighbor is being added to or removed from neighbor table.

Parameters
[in]aEventA event flag.
[in]aEntryInfoA pointer to table entry info.

Enumeration Type Documentation

This enumeration defines the constants used in otNeighborTableCallback to indicate whether a child or router neighbor is being added or removed.

Enumerator
OT_NEIGHBOR_TABLE_EVENT_CHILD_ADDED 

A child is being added.

OT_NEIGHBOR_TABLE_EVENT_CHILD_REMOVED 

A child is being removed.

OT_NEIGHBOR_TABLE_EVENT_ROUTER_ADDED 

A router is being added.

OT_NEIGHBOR_TABLE_EVENT_ROUTER_REMOVED 

A router is being removed.

Function Documentation

otError otThreadBecomeLeader ( otInstance aInstance)

Become a leader and start a new partition.

Note
This API is reserved for testing and demo purposes only. Changing settings with this API will render a production application non-compliant with the Thread Specification.
Parameters
[in]aInstanceA pointer to an OpenThread instance.
Return values
OT_ERROR_NONESuccessfully became a leader and started a new partition.
OT_ERROR_INVALID_STATEThread is disabled.
otError otThreadBecomeRouter ( otInstance aInstance)

Attempt to become a router.

Note
This API is reserved for testing and demo purposes only. Changing settings with this API will render a production application non-compliant with the Thread Specification.
Parameters
[in]aInstanceA pointer to an OpenThread instance.
Return values
OT_ERROR_NONESuccessfully begin attempt to become a router.
OT_ERROR_INVALID_STATEThread is disabled.
otError otThreadGetChildInfoById ( otInstance aInstance,
uint16_t  aChildId,
otChildInfo aChildInfo 
)

The function retains diagnostic information for an attached Child by its Child ID or RLOC16.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aChildIdThe Child ID or RLOC16 for the attached child.
[out]aChildInfoA pointer to where the child information is placed.
Return values
OT_ERROR_NONEaChildInfo was successfully updated with the info for the given ID.
OT_ERROR_NOT_FOUNDNo valid child with this Child ID.
OT_ERROR_INVALID_ARGSIf aChildInfo is NULL.
otError otThreadGetChildInfoByIndex ( otInstance aInstance,
uint16_t  aChildIndex,
otChildInfo aChildInfo 
)

The function retains diagnostic information for an attached Child by the internal table index.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aChildIndexThe table index.
[out]aChildInfoA pointer to where the child information is placed.
Return values
OT_ERROR_NONEaChildInfo was successfully updated with the info for the given index.
OT_ERROR_NOT_FOUNDNo valid child at this index.
OT_ERROR_INVALID_ARGSEither aChildInfo is NULL, or aChildIndex is out of range (higher than max table index).
See also
otGetMaxAllowedChildren
otError otThreadGetChildNextIp6Address ( otInstance aInstance,
uint16_t  aChildIndex,
otChildIp6AddressIterator aIterator,
otIp6Address aAddress 
)

This function gets the next IPv6 address (using an iterator) for a given child.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aChildIndexThe child index.
[in,out]aIteratorA pointer to the iterator. On success the iterator will be updated to point to next entry in the list. To get the first IPv6 address the iterator should be set to OT_CHILD_IP6_ADDRESS_ITERATOR_INIT.
[out]aAddressA pointer to an IPv6 address where the child's next address is placed (on success).
Return values
OT_ERROR_NONESuccessfully found the next IPv6 address (aAddress was successfully updated).
OT_ERROR_NOT_FOUNDThe child has no subsequent IPv6 address entry.
OT_ERROR_INVALID_ARGSaIterator or aAddress are NULL, or child at aChildIndex is not valid.
See also
otThreadGetChildInfoByIndex
uint32_t otThreadGetContextIdReuseDelay ( otInstance aInstance)

Get the CONTEXT_ID_REUSE_DELAY parameter used in the Leader role.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
Returns
The CONTEXT_ID_REUSE_DELAY value.
See also
otThreadSetContextIdReuseDelay
otError otThreadGetEidCacheEntry ( otInstance aInstance,
uint8_t  aIndex,
otEidCacheEntry aEntry 
)

This function gets an EID cache entry.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aIndexAn index into the EID cache table.
[out]aEntryA pointer to where the EID information is placed.
Return values
OT_ERROR_NONESuccessfully retrieved the EID cache entry.
OT_ERROR_INVALID_ARGSaIndex was out of bounds or aEntry was NULL.
uint16_t otThreadGetJoinerUdpPort ( otInstance aInstance)

Get the Joiner UDP Port.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
Returns
The Joiner UDP Port number.
See also
otThreadSetJoinerUdpPort
uint32_t otThreadGetLocalLeaderPartitionId ( otInstance aInstance)

Get the Thread Leader Partition Id used when operating in the Leader role.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
Returns
The Thread Leader Partition Id value.
uint8_t otThreadGetLocalLeaderWeight ( otInstance aInstance)

Get the Thread Leader Weight used when operating in the Leader role.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
Returns
The Thread Leader Weight value.
See also
otThreadSetLeaderWeight
uint16_t otThreadGetMaxAllowedChildren ( otInstance aInstance)

Get the maximum number of children currently allowed.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
Returns
The maximum number of children currently allowed.
See also
otThreadSetMaxAllowedChildren
uint8_t otThreadGetMaxRouterId ( otInstance aInstance)

The function returns the maximum allowed router ID

Parameters
[in]aInstanceA pointer to an OpenThread instance.
Returns
The maximum allowed router ID.
uint8_t otThreadGetNetworkIdTimeout ( otInstance aInstance)

Get the NETWORK_ID_TIMEOUT parameter used in the Router role.

Note
This API is reserved for testing and demo purposes only. Changing settings with this API will render a production application non-compliant with the Thread Specification.
Parameters
[in]aInstanceA pointer to an OpenThread instance.
Returns
The NETWORK_ID_TIMEOUT value.
See also
otThreadSetNetworkIdTimeout
int8_t otThreadGetParentPriority ( otInstance aInstance)

Get the assigned parent priority.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
Returns
The assigned parent priority value, -2 means not assigned.
See also
otThreadSetParentPriority
const otPskc* otThreadGetPskc ( otInstance aInstance)

Get the Thread PSKc

Parameters
[in]aInstanceA pointer to an OpenThread instance.
Returns
A pointer to Thread PSKc
See also
otThreadSetPskc
uint8_t otThreadGetRouterDowngradeThreshold ( otInstance aInstance)

Get the ROUTER_DOWNGRADE_THRESHOLD parameter used in the Router role.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
Returns
The ROUTER_DOWNGRADE_THRESHOLD value.
See also
otThreadSetRouterDowngradeThreshold
uint8_t otThreadGetRouterIdSequence ( otInstance aInstance)

Get the current Router ID Sequence.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
Returns
The Router ID Sequence.
otError otThreadGetRouterInfo ( otInstance aInstance,
uint16_t  aRouterId,
otRouterInfo aRouterInfo 
)

The function retains diagnostic information for a given Thread Router.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aRouterIdThe router ID or RLOC16 for a given router.
[out]aRouterInfoA pointer to where the router information is placed.
Return values
OT_ERROR_NONESuccessfully retrieved the router info for given id.
OT_ERROR_NOT_FOUNDNo router entry with the given id.
OT_ERROR_INVALID_ARGSaRouterInfo is NULL.
uint8_t otThreadGetRouterSelectionJitter ( otInstance aInstance)

Get the ROUTER_SELECTION_JITTER parameter used in the REED/Router role.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
Returns
The ROUTER_SELECTION_JITTER value.
See also
otThreadSetRouterSelectionJitter
uint8_t otThreadGetRouterUpgradeThreshold ( otInstance aInstance)

Get the ROUTER_UPGRADE_THRESHOLD parameter used in the REED role.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
Returns
The ROUTER_UPGRADE_THRESHOLD value.
See also
otThreadSetRouterUpgradeThreshold
bool otThreadIsRouterEligible ( otInstance aInstance)

This method indicates whether or not the device is router-eligible.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
Return values
TRUEIf device is router-eligible.
FALSEIf device is not router-eligible.
void otThreadRegisterNeighborTableCallback ( otInstance aInstance,
otNeighborTableCallback  aCallback 
)

This function registers a neighbor table callback function.

The provided callback (if non-NULL) will be invoked when a child or router neighbor entry is being added/removed to/from the neighbor table. Subsequent calls to this method will overwrite the previous callback. Note that this callback in invoked while the neighbor/child table is being updated and always before the otStateChangedCallback.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aCallbackA pointer to callback handler function.
otError otThreadReleaseRouterId ( otInstance aInstance,
uint8_t  aRouterId 
)

Release a Router ID that has been allocated by the device in the Leader role.

Note
This API is reserved for testing and demo purposes only. Changing settings with this API will render a production application non-compliant with the Thread Specification.
Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aRouterIdThe Router ID to release. Valid range is [0, 62].
Return values
OT_ERROR_NONESuccessfully released the router id.
OT_ERROR_INVALID_ARGSaRouterId is not in the range [0, 62].
OT_ERROR_INVALID_STATEThe device is not currently operating as a leader.
OT_ERROR_NOT_FOUNDThe router id is not currently allocated.
void otThreadSetContextIdReuseDelay ( otInstance aInstance,
uint32_t  aDelay 
)

Set the CONTEXT_ID_REUSE_DELAY parameter used in the Leader role.

Note
This API is reserved for testing and demo purposes only. Changing settings with this API will render a production application non-compliant with the Thread Specification.
Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aDelayThe CONTEXT_ID_REUSE_DELAY value.
See also
otThreadGetContextIdReuseDelay
otError otThreadSetJoinerUdpPort ( otInstance aInstance,
uint16_t  aJoinerUdpPort 
)

Set the Joiner UDP Port.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aJoinerUdpPortThe Joiner UDP Port number.
Return values
OT_ERROR_NONESuccessfully set the Joiner UDP Port.
See also
otThreadGetJoinerUdpPort
void otThreadSetLocalLeaderPartitionId ( otInstance aInstance,
uint32_t  aPartitionId 
)

Set the Thread Leader Partition Id used when operating in the Leader role.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aPartitionIdThe Thread Leader Partition Id value.
void otThreadSetLocalLeaderWeight ( otInstance aInstance,
uint8_t  aWeight 
)

Set the Thread Leader Weight used when operating in the Leader role.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aWeightThe Thread Leader Weight value.
See also
otThreadGetLeaderWeight
otError otThreadSetMaxAllowedChildren ( otInstance aInstance,
uint16_t  aMaxChildren 
)

Set the maximum number of children currently allowed.

This parameter can only be set when Thread protocol operation has been stopped.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aMaxChildrenThe maximum allowed children.
Return values
OT_ERROR_NONESuccessfully set the max.
OT_ERROR_INVALID_ARGSIf aMaxChildren is not in the range [1, OPENTHREAD_CONFIG_MLE_MAX_CHILDREN].
OT_ERROR_INVALID_STATEIf Thread isn't stopped.
See also
otThreadGetMaxAllowedChildren
void otThreadSetNetworkIdTimeout ( otInstance aInstance,
uint8_t  aTimeout 
)

Set the NETWORK_ID_TIMEOUT parameter used in the Leader role.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aTimeoutThe NETWORK_ID_TIMEOUT value.
See also
otThreadGetNetworkIdTimeout
otError otThreadSetParentPriority ( otInstance aInstance,
int8_t  aParentPriority 
)

Set the parent priority.

Note
This API is reserved for testing and demo purposes only. Changing settings with this API will render a production application non-compliant with the Thread Specification.
Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aParentPriorityThe parent priority value.
Return values
OT_ERROR_NONESuccessfully set the parent priority.
OT_ERROR_INVALID_ARGSIf the parent priority value is not among 1, 0, -1 and -2.
See also
otThreadGetParentPriority
otError otThreadSetPreferredRouterId ( otInstance aInstance,
uint8_t  aRouterId 
)

Set the preferred Router Id.

Upon becoming a router/leader the node attempts to use this Router Id. If the preferred Router Id is not set or if it can not be used, a randomly generated router id is picked. This property can be set only when the device role is either detached or disabled.

Note
This API is reserved for testing and demo purposes only. Changing settings with this API will render a production application non-compliant with the Thread Specification.
Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aRouterIdThe preferred Router Id.
Return values
OT_ERROR_NONESuccessfully set the preferred Router Id.
OT_ERROR_INVALID_STATECould not set (role is not detached or disabled)
otError otThreadSetPskc ( otInstance aInstance,
const otPskc aPskc 
)

Set the Thread PSKc

This function will only succeed when Thread protocols are disabled. A successful call to this function will also invalidate the Active and Pending Operational Datasets in non-volatile memory.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aPskcA pointer to the new Thread PSKc.
Return values
OT_ERROR_NONESuccessfully set the Thread PSKc.
OT_ERROR_INVALID_STATEThread protocols are enabled.
See also
otThreadGetPskc
void otThreadSetRouterDowngradeThreshold ( otInstance aInstance,
uint8_t  aThreshold 
)

Set the ROUTER_DOWNGRADE_THRESHOLD parameter used in the Leader role.

Note
This API is reserved for testing and demo purposes only. Changing settings with this API will render a production application non-compliant with the Thread Specification.
Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aThresholdThe ROUTER_DOWNGRADE_THRESHOLD value.
See also
otThreadGetRouterDowngradeThreshold
otError otThreadSetRouterEligible ( otInstance aInstance,
bool  aEligible 
)

This function sets whether or not the device is router-eligible.

If aEligible is false and the device is currently operating as a router, this call will cause the device to detach and attempt to reattach as a child.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aEligibleTRUE to configure the device as router-eligible, FALSE otherwise.
Return values
OT_ERROR_NONESuccessfully set the router-eligible configuration.
OT_ERROR_NOT_CAPABLEThe device is not capable of becoming a router.
void otThreadSetRouterSelectionJitter ( otInstance aInstance,
uint8_t  aRouterJitter 
)

Set the ROUTER_SELECTION_JITTER parameter used in the REED/Router role.

Note
This API is reserved for testing and demo purposes only. Changing settings with this API will render a production application non-compliant with the Thread Specification.
Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aRouterJitterThe ROUTER_SELECTION_JITTER value.
See also
otThreadGetRouterSelectionJitter
void otThreadSetRouterUpgradeThreshold ( otInstance aInstance,
uint8_t  aThreshold 
)

Set the ROUTER_UPGRADE_THRESHOLD parameter used in the Leader role.

Note
This API is reserved for testing and demo purposes only. Changing settings with this API will render a production application non-compliant with the Thread Specification.
Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aThresholdThe ROUTER_UPGRADE_THRESHOLD value.
See also
otThreadGetRouterUpgradeThreshold
void otThreadSetSteeringData ( otInstance aInstance,
const otExtAddress aExtAddress 
)

Set Steering data out of band.

Configuration option OPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE should be set to enable setting of steering data out of band.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aExtAddressAddress used to update the steering data. All zeros to clear the steering data (no steering data). All 0xFFs to set steering data/bloom filter to accept/allow all. A specific EUI64 which is then added to current steering data/bloom filter.

Documentation feedback | Developer Zone | Subscribe | Updated