Google 致力于为黑人社区推动种族平等。查看具体行动

路由器/领导者

此模块包含线程路由器和主要副本的函数。

总结

枚举

otCacheEntryState 枚举
定义 EID 缓存条目状态。
otNeighborTableEvent{
  OT_NEIGHBOR_TABLE_EVENT_CHILD_ADDED,
  OT_NEIGHBOR_TABLE_EVENT_CHILD_REMOVED,
  OT_NEIGHBOR_TABLE_EVENT_CHILD_MODE_CHANGED,
  OT_NEIGHBOR_TABLE_EVENT_ROUTER_ADDED,
  OT_NEIGHBOR_TABLE_EVENT_ROUTER_REMOVED
}
枚举
定义 otNeighborTableCallback 中用于指示邻域表发生更改的常量。
otPowerSupply{
  OT_POWER_SUPPLY_BATTERY = 0,
  OT_POWER_SUPPLY_EXTERNAL = 1,
  OT_POWER_SUPPLY_EXTERNAL_STABLE = 2,
  OT_POWER_SUPPLY_EXTERNAL_UNSTABLE = 3
}
枚举
表示设备上的电源属性。

类型定义符

otCacheEntryInfo typedef
表示 EID 缓存条目。
otCacheEntryIterator typedef
表示用于迭代 EID 缓存表条目的迭代器。
otCacheEntryState typedef
定义 EID 缓存条目状态。
otChildIp6AddressIterator typedef
uint16_t
用于遍历 Thread Child 条目的 IPv6 地址。
otDeviceProperties typedef
表示用于计算设备上的本地前导权重的设备属性。
otNeighborTableCallback)(otNeighborTableEvent aEvent, const otNeighborTableEntryInfo *aEntryInfo) typedef
void(*
系统会调用指针来通知邻表发生了更改。

函数

otThreadBecomeLeader(otInstance *aInstance)
成为领先变体并启动新的分区。
otThreadBecomeRouter(otInstance *aInstance)
尝试成为路由器。
otThreadGetChildInfoById(otInstance *aInstance, uint16_t aChildId, otChildInfo *aChildInfo)
根据所关联子项的子 ID 或 RLOC16 获取诊断信息。
otThreadGetChildInfoByIndex(otInstance *aInstance, uint16_t aChildIndex, otChildInfo *aChildInfo)
函数通过内部表索引保留附加的子元素的诊断信息。
otThreadGetChildNextIp6Address(otInstance *aInstance, uint16_t aChildIndex, otChildIp6AddressIterator *aIterator, otIp6Address *aAddress)
获取给定子项的下一个 IPv6 地址(使用迭代器)。
otThreadGetChildRouterLinks(otInstance *aInstance)
uint8_t
获取 REED 角色中使用的 MLE_CHILD_ROUTER_LINKS 参数。
otThreadGetContextIdReuseDelay(otInstance *aInstance)
uint32_t
获取 Leader 角色中使用的 CONTEXT_ID_REUSE_DELAY 参数。
otThreadGetDeviceProperties(otInstance *aInstance)
获取当前的设备属性。
otThreadGetJoinerUdpPort(otInstance *aInstance)
uint16_t
获取 Joiner UDP 端口。
otThreadGetLocalLeaderWeight(otInstance *aInstance)
uint8_t
获取以 Leader 角色运行时使用的 Thread Leader Weight。
otThreadGetMaxAllowedChildren(otInstance *aInstance)
uint16_t
获取当前允许的子项数上限。
otThreadGetMaxChildIpAddresses(otInstance *aInstance)
uint8_t
获取每个 MTD 子级可在此设备上注册为父级的 IP 地址数量上限。
otThreadGetMaxRouterId(otInstance *aInstance)
uint8_t
函数会返回允许的路由器 ID 数上限。
otThreadGetNetworkIdTimeout(otInstance *aInstance)
uint8_t
获取路由器角色中使用的 NETWORK_ID_TIMEOUT 参数。
otThreadGetNextCacheEntry(otInstance *aInstance, otCacheEntryInfo *aEntryInfo, otCacheEntryIterator *aIterator)
获取下一个 EID 缓存条目(使用迭代器)。
otThreadGetNextHopAndPathCost(otInstance *aInstance, uint16_t aDestRloc16, uint16_t *aNextHopRloc16, uint8_t *aPathCost)
void
获取指向指定 RLOC16 目的地的下一个跃点和路径费用。
otThreadGetParentPriority(otInstance *aInstance)
int8_t
获取分配的父级优先级。
otThreadGetPreferredLeaderPartitionId(otInstance *aInstance)
uint32_t
获取以 Leader 角色运行时使用的首选 Thread Leader Partition ID。
otThreadGetPskc(otInstance *aInstance, otPskc *aPskc)
void
获取 PSKc。
otThreadGetPskcRef(otInstance *aInstance)
获取对 Thread PSKc 存储的密钥引用。
otThreadGetRouterDowngradeThreshold(otInstance *aInstance)
uint8_t
获取路由器角色中使用的 ROUTER_DOWNGrade_THRESHOLD 参数。
otThreadGetRouterIdRange(otInstance *aInstance, uint8_t *aMinRouterId, uint8_t *aMaxRouterId)
void
获取允许分配给线程网络中的节点的路由器 ID 范围。
otThreadGetRouterIdSequence(otInstance *aInstance)
uint8_t
获取当前的路由器 ID 序列。
otThreadGetRouterInfo(otInstance *aInstance, uint16_t aRouterId, otRouterInfo *aRouterInfo)
该函数会保留给定线程路由器的诊断信息。
otThreadGetRouterSelectionJitter(otInstance *aInstance)
uint8_t
获取 REED/Router 角色中使用的 ROUTER_SELECTION_JITTER 参数。
otThreadGetRouterUpgradeThreshold(otInstance *aInstance)
uint8_t
获取 REED 角色中使用的 ROUTER_UPGrade_THRESHOLD 参数。
otThreadIsRouterEligible(otInstance *aInstance)
bool
指明设备是否符合路由器条件。
otThreadIsRouterIdAllocated(otInstance *aInstance, uint8_t aRouterId)
bool
指明当前是否分配了路由器 ID。
otThreadRegisterNeighborTableCallback(otInstance *aInstance, otNeighborTableCallback aCallback)
void
注册邻域表回调函数。
otThreadReleaseRouterId(otInstance *aInstance, uint8_t aRouterId)
释放设备在“主管”角色中分配的路由器 ID。
otThreadSetCcmEnabled(otInstance *aInstance, bool aEnabled)
void
设置设备是否通过使用 CCM 调试的。
otThreadSetChildRouterLinks(otInstance *aInstance, uint8_t aChildRouterLinks)
设置 REED 角色中使用的 MLE_CHILD_ROUTER_LINKS 参数。
otThreadSetContextIdReuseDelay(otInstance *aInstance, uint32_t aDelay)
void
设置“Leader”角色中使用的 CONTEXT_ID_REUSE_DELAY 参数。
otThreadSetDeviceProperties(otInstance *aInstance, const otDeviceProperties *aDeviceProperties)
void
设置设备属性,然后这些属性将用来确定和设置前导权重。
otThreadSetJoinerUdpPort(otInstance *aInstance, uint16_t aJoinerUdpPort)
设置 Joiner UDP 端口。
otThreadSetLocalLeaderWeight(otInstance *aInstance, uint8_t aWeight)
void
设置以 Leader 角色运行时使用的 Thread Leader Weight。
otThreadSetMaxAllowedChildren(otInstance *aInstance, uint16_t aMaxChildren)
设置当前允许的子级数量上限。
otThreadSetMaxChildIpAddresses(otInstance *aInstance, uint8_t aMaxIpAddresses)
设置或恢复每个 MTD 子设备可在此设备注册为父 IP 地址的 IP 地址数上限。
otThreadSetNetworkIdTimeout(otInstance *aInstance, uint8_t aTimeout)
void
设置 Leader 角色中使用的 NETWORK_ID_TIMEOUT 参数。
otThreadSetParentPriority(otInstance *aInstance, int8_t aParentPriority)
设置父级优先级。
otThreadSetPreferredLeaderPartitionId(otInstance *aInstance, uint32_t aPartitionId)
void
设置以 Leader 角色运行时使用的首选 Thread Leader Partition ID。
otThreadSetPreferredRouterId(otInstance *aInstance, uint8_t aRouterId)
设置首选路由器 ID。
otThreadSetPskc(otInstance *aInstance, const otPskc *aPskc)
设置 Thread PSK。
otThreadSetPskcRef(otInstance *aInstance, otPskcRef aKeyRef)
设置 Thread PSK。
otThreadSetRouterDowngradeThreshold(otInstance *aInstance, uint8_t aThreshold)
void
设置 Leader 角色中使用的 ROUTER_DOWNGrade_THRESHOLD 参数。
otThreadSetRouterEligible(otInstance *aInstance, bool aEligible)
设置设备是否符合路由器条件。
otThreadSetRouterIdRange(otInstance *aInstance, uint8_t aMinRouterId, uint8_t aMaxRouterId)
设置允许分配给线程网络中的节点的路由器 ID 范围。
otThreadSetRouterSelectionJitter(otInstance *aInstance, uint8_t aRouterJitter)
void
设置 REED/Router 角色中使用的 ROUTER_SELECTION_JITTER 参数。
otThreadSetRouterUpgradeThreshold(otInstance *aInstance, uint8_t aThreshold)
void
设置“主要角色”角色中使用的 ROUTER_UPGrade_THRESHOLD 参数。
otThreadSetSteeringData(otInstance *aInstance, const otExtAddress *aExtAddress)
void
将带外数据设置为带外数据。
otThreadSetThreadVersionCheckEnabled(otInstance *aInstance, bool aEnabled)
void
设置是否已启用安全政策的 TLV 版本阈值(VR 字段)。

结构体

otCacheEntryInfo

表示 EID 缓存条目。

otCacheEntryIterator

表示用于迭代 EID 缓存表条目的迭代器。

otChildInfo

保留线程子级的诊断信息。

otDeviceProperties

表示用于计算设备上的本地前导权重的设备属性。

otNeighborTableEntryInfo

表示邻域表条目信息(子节点或路由器),并用作邻域表回调 otNeighborTableCallback 中的参数。

枚举

otCacheEntryState

 otCacheEntryState

定义 EID 缓存条目状态。

otNeighborTableEvent

 otNeighborTableEvent

定义 otNeighborTableCallback 中用于指示邻域表发生更改的常量。

属性
OT_NEIGHBOR_TABLE_EVENT_CHILD_ADDED

正在添加儿童。

OT_NEIGHBOR_TABLE_EVENT_CHILD_MODE_CHANGED

已有孩子的模式会发生变化。

OT_NEIGHBOR_TABLE_EVENT_CHILD_REMOVED

正在移除儿童。

OT_NEIGHBOR_TABLE_EVENT_ROUTER_ADDED

正在添加路由器。

OT_NEIGHBOR_TABLE_EVENT_ROUTER_REMOVED

正在移除某个路由器。

超级电源

 otPowerSupply

表示设备上的电源属性。

此属性用作 otDeviceProperties 中的属性,用于计算前导权重。

属性
OT_POWER_SUPPLY_BATTERY

电池供电。

OT_POWER_SUPPLY_EXTERNAL

由外部电源(由电源供电)

OT_POWER_SUPPLY_EXTERNAL_STABLE

稳定的外部电源(备用电池或 UPS)。

OT_POWER_SUPPLY_EXTERNAL_UNSTABLE

外部电源可能不稳定(例如灯泡通过开关供电)。

类型定义符

otCacheEntryInfo

struct otCacheEntryInfo otCacheEntryInfo

表示 EID 缓存条目。

otCacheEntryIterator

struct otCacheEntryIterator otCacheEntryIterator

表示用于迭代 EID 缓存表条目的迭代器。

要初始化迭代器并从缓存表中的第一个条目开始,请将结构中的所有字段设置为零(例如,memset 迭代器到零)。

otCacheEntryState

enum otCacheEntryState otCacheEntryState

定义 EID 缓存条目状态。

otChildIp6AddressIterator

uint16_t otChildIp6AddressIterator

用于遍历 Thread Child 条目的 IPv6 地址。

otDeviceProperties

struct otDeviceProperties otDeviceProperties

表示用于计算设备上的本地前导权重的设备属性。

这些参数是根据设备的功能(无论是充当边界路由器、电源配置等)设置的。

mIsUnstable 表示设备的稳定性,通过供应商特定的机制来确定。该权限可以包括:

  • 设备内部检测到外部电源丢失的频率高于平时。通常由供应商决定。
  • 设备内部检测到它重新启动的频率比平时高。通常由供应商决定。

otNeighborTableCallback

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

系统会调用指针来通知邻表发生了更改。

详情
参数
[in] aEvent
一个事件标志。
[in] aEntryInfo
指向表格条目信息的指针。

函数

otThread 成为领先变体

otError otThreadBecomeLeader(
  otInstance *aInstance
)

成为领先变体并启动新的分区。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
返回值
OT_ERROR_NONE
已成功成为领先变体并启动了新的分区。
OT_ERROR_INVALID_STATE
话题已停用。

otThread 成为 Router

otError otThreadBecomeRouter(
  otInstance *aInstance
)

尝试成为路由器。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
返回值
OT_ERROR_NONE
成功开始尝试成为路由器。
OT_ERROR_INVALID_STATE
话题已停用。

otThreadGetChildInfoById

otError otThreadGetChildInfoById(
  otInstance *aInstance,
  uint16_t aChildId,
  otChildInfo *aChildInfo
)

根据所关联子项的子 ID 或 RLOC16 获取诊断信息。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aChildId
附加的子项的子 ID 或 RLOC16。
[out] aChildInfo
指向子信息放置位置的指针。
返回值
OT_ERROR_NONE
已成功将“aChildInfo”更新为指定 ID 的相关信息。
OT_ERROR_NOT_FOUND
没有使用此子 ID 的有效子级。
OT_ERROR_INVALID_ARGS
如果 aChildInfo 为 NULL,

otThreadGetChildInfoByIndex

otError otThreadGetChildInfoByIndex(
  otInstance *aInstance,
  uint16_t aChildIndex,
  otChildInfo *aChildInfo
)

函数通过内部表索引保留附加的子元素的诊断信息。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aChildIndex
表索引。
[out] aChildInfo
指向子信息放置位置的指针。
返回值
OT_ERROR_NONE
已成功将“aChildInfo”更新为指定索引的相关信息。
OT_ERROR_NOT_FOUND
此索引没有有效的子项。
OT_ERROR_INVALID_ARGS
aChildInfo 为 NULL,或者 aChildIndex 超出范围(高于表数上限)。
另请参阅
otGetMaxAllowedChildren

otThreadGetChildNextIp6Address

otError otThreadGetChildNextIp6Address(
  otInstance *aInstance,
  uint16_t aChildIndex,
  otChildIp6AddressIterator *aIterator,
  otIp6Address *aAddress
)

获取给定子项的下一个 IPv6 地址(使用迭代器)。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aChildIndex
子索引。
[in,out] aIterator
指向迭代器的指针。成功执行后,迭代器将更新为指向列表中的下一个条目。如需获取第一个 IPv6 地址,迭代器应设置为 OT_CHILD_IP6_ADDRESS_ITERATOR_INIT。
[out] aAddress
指向 IPv6 地址的指针,该地址会被放置子节点的下一个地址(成功后)。
返回值
OT_ERROR_NONE
已成功找到下一个 IPv6 地址(aAddress 已成功更新)。
OT_ERROR_NOT_FOUND
子节点没有后续 IPv6 地址条目。
OT_ERROR_INVALID_ARGS
aIteratoraAddress 为 NULL,或者 aChildIndex 的子级无效。
另请参阅
otThreadGetChildInfoByIndex

uint8_t otThreadGetChildRouterLinks(
  otInstance *aInstance
)

获取 REED 角色中使用的 MLE_CHILD_ROUTER_LINKS 参数。

此参数用于指定设备(作为 FED)将尝试建立连接的相邻路由器的最大数量。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
返回
MLE_CHILD_ROUTER_LINKS 值。
另请参阅
otThreadSetChildRouterLinks

otThreadGetContextIdReuseDelay

uint32_t otThreadGetContextIdReuseDelay(
  otInstance *aInstance
)

获取 Leader 角色中使用的 CONTEXT_ID_REUSE_DELAY 参数。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
返回
CONTEXT_ID_REUSE_DELAY 值。
另请参阅
otThreadSetContextIdReuseDelay

otThreadGetDeviceProperties

const otDeviceProperties * otThreadGetDeviceProperties(
  otInstance *aInstance
)

获取当前的设备属性。

详情
返回
设备属性 otDeviceProperties

otThreadGetJoinerUdpPort

uint16_t otThreadGetJoinerUdpPort(
  otInstance *aInstance
)

获取 Joiner UDP 端口。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
返回
Joiner UDP 端口号。
另请参阅
otThreadSetJoinerUdpPort

otThreadGetLocalLeaderWeight

uint8_t otThreadGetLocalLeaderWeight(
  otInstance *aInstance
)

获取以 Leader 角色运行时使用的 Thread Leader Weight。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
返回
线程前导权重值。
另请参阅
otThreadSetLeaderWeight
otThreadSetDeviceProperties

otThreadGetMaxAllowedChildren

uint16_t otThreadGetMaxAllowedChildren(
  otInstance *aInstance
)

获取当前允许的子项数上限。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
返回
当前允许的子级数量上限。
另请参阅
otThreadSetMaxAllowedChildren

otThreadGetMaxChildIpAddress

uint8_t otThreadGetMaxChildIpAddresses(
  otInstance *aInstance
)

获取每个 MTD 子级可在此设备上注册为父级的 IP 地址数量上限。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
返回
每个 MTD 子节点可在这个设备上作为父节点注册的 IP 地址的数量上限。
另请参阅
otThreadSetMaxChildIpAddress

otThreadGetMaxRouterId

uint8_t otThreadGetMaxRouterId(
  otInstance *aInstance
)

函数会返回允许的路由器 ID 数上限。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
返回
允许的路由器 ID 上限。

otThreadGetNetworkIdTimeout

uint8_t otThreadGetNetworkIdTimeout(
  otInstance *aInstance
)

获取路由器角色中使用的 NETWORK_ID_TIMEOUT 参数。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
返回
NETWORK_ID_TIMEOUT 值。
另请参阅
otThreadSetNetworkIdTimeout

otThreadGetNextCacheEntry

otError otThreadGetNextCacheEntry(
  otInstance *aInstance,
  otCacheEntryInfo *aEntryInfo,
  otCacheEntryIterator *aIterator
)

获取下一个 EID 缓存条目(使用迭代器)。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[out] aEntryInfo
指向 EID 缓存条目信息的放置位置。
[in,out] aIterator
指向迭代器的指针。成功更新后,系统会指向下一个条目。如需获取第一个条目,请将迭代器的所有字段设为零(例如,memset 迭代器结构为零)。
返回值
OT_ERROR_NONE
已成功为下一个 EID 缓存条目填充 aEntryInfo
OT_ERROR_NOT_FOUND
地址缓存表中没有其他条目。

otThreadGetNextHopAndPathCost

void otThreadGetNextHopAndPathCost(
  otInstance *aInstance,
  uint16_t aDestRloc16,
  uint16_t *aNextHopRloc16,
  uint8_t *aPathCost
)

获取指向指定 RLOC16 目的地的下一个跃点和路径费用。

可以与 aNextHopRloc16aPathCost 为 NULL 时配合使用,表示调用方不想获取该值。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aDesRloct16
目的地的 RLOC16。
[out] aNextHopRloc16
用于返回下一个跃点的 RLOC16 的指针,如果没有下一个跃点,则返回 0xfffe。
[out] aPathCost
用于返回前往目的地的路径费用的指针。

otThreadGetParentPriority

int8_t otThreadGetParentPriority(
  otInstance *aInstance
)

获取分配的父级优先级。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
返回
为父级指定的优先级值“-2”表示未分配。
另请参阅
otThreadSetParentPriority

otThreadGetPreferredLeaderPartitionId

uint32_t otThreadGetPreferredLeaderPartitionId(
  otInstance *aInstance
)

获取以 Leader 角色运行时使用的首选 Thread Leader Partition ID。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
返回
Thread Leader Partition ID 值。

otThreadGetPskc

void otThreadGetPskc(
  otInstance *aInstance,
  otPskc *aPskc
)

获取 PSKc。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[out] aPskc
指向 otPskc 的指针,用于返回检索到的 Thread PSKc。
另请参阅
otThreadSetPskc

otThreadGetPskcRef

otPskcRef otThreadGetPskcRef(
  otInstance *aInstance
)

获取对 Thread PSKc 存储的密钥引用。

需要启用构建时功能 OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
返回
提及 PSKc 的重要参考
另请参阅
otThreadSetPskcRef

otThreadGetRouterDowngradeThreshold

uint8_t otThreadGetRouterDowngradeThreshold(
  otInstance *aInstance
)

获取路由器角色中使用的 ROUTER_DOWNGrade_THRESHOLD 参数。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
返回
ROUTER_DOWNGrade_THRESHOLD 值。
另请参阅
otThreadSetRouterDowngradeThreshold

otThreadGetRouterIdRange

void otThreadGetRouterIdRange(
  otInstance *aInstance,
  uint8_t *aMinRouterId,
  uint8_t *aMaxRouterId
)

获取允许分配给线程网络中的节点的路由器 ID 范围。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[out] aMinRouterId
最低路由器 ID。
[out] aMaxRouterId
路由器 ID 上限。
另请参阅
otThreadSetRouterIdRange

otThreadGetRouterIdSequence

uint8_t otThreadGetRouterIdSequence(
  otInstance *aInstance
)

获取当前的路由器 ID 序列。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
返回
路由器 ID 序列。

otThreadGetRouterInfo

otError otThreadGetRouterInfo(
  otInstance *aInstance,
  uint16_t aRouterId,
  otRouterInfo *aRouterInfo
)

该函数会保留给定线程路由器的诊断信息。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aRouterId
给定路由器的路由器 ID 或 RLOC16。
[out] aRouterInfo
指向路由器信息的放置位置的指针。
返回值
OT_ERROR_NONE
已成功检索到指定 ID 的路由器信息。
OT_ERROR_NOT_FOUND
没有具有指定 ID 的路由器条目。
OT_ERROR_INVALID_ARGS
aRouterInfo 为 NULL。

otThreadGetRouterSelectionJitter

uint8_t otThreadGetRouterSelectionJitter(
  otInstance *aInstance
)

获取 REED/Router 角色中使用的 ROUTER_SELECTION_JITTER 参数。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
返回
ROUTER_SELECTION_JITTER 值。
另请参阅
otThreadSetRouterSelectionJitter

otThreadGetRouterUpgradeThreshold

uint8_t otThreadGetRouterUpgradeThreshold(
  otInstance *aInstance
)

获取 REED 角色中使用的 ROUTER_UPGrade_THRESHOLD 参数。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
返回
ROUTER_UPGrade_THRESHOLD 值。
另请参阅
otThreadSetRouterUpgradeThreshold

otThreadIsRouter 符合条件

bool otThreadIsRouterEligible(
  otInstance *aInstance
)

指明设备是否符合路由器条件。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
返回值
TRUE
设备是否可使用路由器。
FALSE
如果设备不符合使用路由器的条件,

otThreadIsRouterIdAlassigned

bool otThreadIsRouterIdAllocated(
  otInstance *aInstance,
  uint8_t aRouterId
)

指明当前是否分配了路由器 ID。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aRouterId
要检查的路由器 ID。
返回值
TRUE
分配了 aRouterId
FALSE
未分配 aRouterId

otThreadRegisterNeighborTableCallback

void otThreadRegisterNeighborTableCallback(
  otInstance *aInstance,
  otNeighborTableCallback aCallback
)

注册邻域表回调函数。

当邻居表发生更改(例如,添加/移除子项或路由器邻居项或更改现有子项的模式)时,系统会调用提供的回调(如果为非 NULL)。

对此方法的后续调用将覆盖之前的回调。请注意,在更新邻表/子表且始终在 otStateChangedCallback 之前调用此回调。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aCallback
指向回调处理程序函数的指针。

otThreadReleaseRouterId

otError otThreadReleaseRouterId(
  otInstance *aInstance,
  uint8_t aRouterId
)

释放设备在“主管”角色中分配的路由器 ID。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aRouterId
要释放的路由器 ID。有效范围为 [0, 62]。
返回值
OT_ERROR_NONE
已成功释放路由器 ID。
OT_ERROR_INVALID_ARGS
aRouterId 不在 [0, 62] 的范围内。
OT_ERROR_INVALID_STATE
此设备目前未作为主要副本。
OT_ERROR_NOT_FOUND
路由器 ID 目前尚未分配。

otThreadSetCcmEnabled

void otThreadSetCcmEnabled(
  otInstance *aInstance,
  bool aEnabled
)

设置设备是否通过使用 CCM 调试的。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aEnabled
如果设备是使用 CCM 调试的,则为 TRUE;否则为 FALSE。
otError otThreadSetChildRouterLinks(
  otInstance *aInstance,
  uint8_t aChildRouterLinks
)

设置 REED 角色中使用的 MLE_CHILD_ROUTER_LINKS 参数。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aChildRouterLinks
MLE_CHILD_ROUTER_LINKS 值。
返回值
OT_ERROR_NONE
已成功设置该值。
OT_ERROR_INVALID_STATE
线程协议已启用。
另请参阅
otThreadGetChildRouterLinks

otThreadSetContextIdReuseDelay

void otThreadSetContextIdReuseDelay(
  otInstance *aInstance,
  uint32_t aDelay
)

设置“Leader”角色中使用的 CONTEXT_ID_REUSE_DELAY 参数。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aDelay
CONTEXT_ID_REUSE_DELAY 值。
另请参阅
otThreadGetContextIdReuseDelay

otThreadSetDeviceProperties

void otThreadSetDeviceProperties(
  otInstance *aInstance,
  const otDeviceProperties *aDeviceProperties
)

设置设备属性,然后这些属性将用来确定和设置前导权重。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aDeviceProperties
设备属性。

otThreadSetJoinerUdpPort

otError otThreadSetJoinerUdpPort(
  otInstance *aInstance,
  uint16_t aJoinerUdpPort
)

设置 Joiner UDP 端口。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aJoinerUdpPort
Joiner UDP 端口号。
返回值
OT_ERROR_NONE
已成功设置 Joiner UDP 端口。
另请参阅
otThreadGetJoinerUdpPort

otThreadSetLocalLeaderWeight

void otThreadSetLocalLeaderWeight(
  otInstance *aInstance,
  uint8_t aWeight
)

设置以 Leader 角色运行时使用的 Thread Leader Weight。

直接将前导权重设置为新值,替换其前一个值(该值可能由当前的 otDeviceProperties 确定)。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aWeight
线程前导权重值。
另请参阅
otThreadGetLeaderWeight

otThreadSetMaxAllowedChildren

otError otThreadSetMaxAllowedChildren(
  otInstance *aInstance,
  uint16_t aMaxChildren
)

设置当前允许的子级数量上限。

只有在已停止 Thread 协议操作时才能设置此参数。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aMaxChildren
子项数量上限。
返回值
OT_ERROR_NONE
已成功设置上限。
OT_ERROR_INVALID_ARGS
如果 aMaxChildren 不在 [1, OPENTHREAD_CONFIG_MLE_MAX_CHILDREN] 范围内。
OT_ERROR_INVALID_STATE
如果 Thread 未停止,则线程不会停止。
另请参阅
otThreadGetMaxAllowedChildren

otThreadSetMaxChildIpAddress

otError otThreadSetMaxChildIpAddresses(
  otInstance *aInstance,
  uint8_t aMaxIpAddresses
)

设置或恢复每个 MTD 子设备可在此设备注册为父 IP 地址的 IP 地址数上限。

传递 0 可清除该设置并恢复默认设置。

启用 OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE 后可用。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aMaxIpAddresses
每个 MTD 子节点可在这个设备上作为父节点注册的 IP 地址的数量上限。0 可清除设置并恢复默认设置。
返回值
OT_ERROR_NONE
已成功设置/清除号码。
OT_ERROR_INVALID_ARGS
如果超过允许的数量上限,
另请参阅
otThreadGetMaxChildIpAddress

otThreadSetNetworkIdTimeout

void otThreadSetNetworkIdTimeout(
  otInstance *aInstance,
  uint8_t aTimeout
)

设置 Leader 角色中使用的 NETWORK_ID_TIMEOUT 参数。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aTimeout
NETWORK_ID_TIMEOUT 值。
另请参阅
otThreadGetNetworkIdTimeout

otThreadSetParentPriority

otError otThreadSetParentPriority(
  otInstance *aInstance,
  int8_t aParentPriority
)

设置父级优先级。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aParentPriority
父级优先级值。
返回值
OT_ERROR_NONE
已成功设置父级优先级。
OT_ERROR_INVALID_ARGS
如果父级优先级值不在 1、0、-1 和 -2 之间。
另请参阅
otThreadGetParentPriority

otThreadSetPreferredLeaderPartitionId

void otThreadSetPreferredLeaderPartitionId(
  otInstance *aInstance,
  uint32_t aPartitionId
)

设置以 Leader 角色运行时使用的首选 Thread Leader Partition ID。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aPartitionId
Thread Leader Partition ID 值。

otThreadSetPreferredRouterId

otError otThreadSetPreferredRouterId(
  otInstance *aInstance,
  uint8_t aRouterId
)

设置首选路由器 ID。

成为路由器/领导者后,节点会尝试使用此路由器 ID。如果未设置首选路由器 ID 或无法使用首选路由器 ID,系统会选择随机生成的路由器 ID。只有在设备角色分离或停用时才能设置此属性。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aRouterId
首选路由器 ID。
返回值
OT_ERROR_NONE
已成功设置首选路由器 ID。
OT_ERROR_INVALID_STATE
无法设置(角色未分离或已停用)

otThreadSetPskc

otError otThreadSetPskc(
  otInstance *aInstance,
  const otPskc *aPskc
)

设置 Thread PSK。

仅在 Thread 协议停用时成功。成功调用此函数还会使非易失性内存中的活跃和待处理操作数据集无效。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aPskc
指向新的 Thread PSKc 的指针。
返回值
OT_ERROR_NONE
已成功设置 PSKc。
OT_ERROR_INVALID_STATE
线程协议已启用。
另请参阅
otThreadGetPskc

otThreadSetPskcRef

otError otThreadSetPskcRef(
  otInstance *aInstance,
  otPskcRef aKeyRef
)

设置 Thread PSK。

需要启用构建时功能 OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE

仅在 Thread 协议停用时成功。成功调用此函数还会使非易失性内存中的活跃和待处理操作数据集无效。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aKeyRef
对新 Thread PSKc 的密钥引用。
返回值
OT_ERROR_NONE
已成功设置 PSKc。
OT_ERROR_INVALID_STATE
线程协议已启用。
另请参阅
otThreadGetPskcRef

otThreadSetRouterDowngradeThreshold

void otThreadSetRouterDowngradeThreshold(
  otInstance *aInstance,
  uint8_t aThreshold
)

设置 Leader 角色中使用的 ROUTER_DOWNGrade_THRESHOLD 参数。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aThreshold
ROUTER_DOWNGrade_THRESHOLD 值。
另请参阅
otThreadGetRouterDowngradeThreshold

otThreadSetRoutereligible

otError otThreadSetRouterEligible(
  otInstance *aInstance,
  bool aEligible
)

设置设备是否符合路由器条件。

如果 aEligible 为 false 且设备当前作为路由器运行,则此调用会导致设备分离并尝试重新连接为子级。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aEligible
如果为 TRUE,则将设备配置为支持路由器,否则为 FALSE。
返回值
OT_ERROR_NONE
已成功设置路由器配置。
OT_ERROR_NOT_CAPABLE
该设备无法成为路由器。

otThreadSetRouterIdRange

otError otThreadSetRouterIdRange(
  otInstance *aInstance,
  uint8_t aMinRouterId,
  uint8_t aMaxRouterId
)

设置允许分配给线程网络中的节点的路由器 ID 范围。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aMinRouterId
最低路由器 ID。
[in] aMaxRouterId
路由器 ID 上限。
返回值
OT_ERROR_NONE
已成功设置范围。
OT_ERROR_INVALID_ARGS
aMinRouterId > aMaxRouterId,或者范围未包含在 [0, 62] 中。
另请参阅
otThreadGetRouterIdRange

otThreadSetRouterSelectionJitter

void otThreadSetRouterSelectionJitter(
  otInstance *aInstance,
  uint8_t aRouterJitter
)

设置 REED/Router 角色中使用的 ROUTER_SELECTION_JITTER 参数。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aRouterJitter
ROUTER_SELECTION_JITTER 值。
另请参阅
otThreadGetRouterSelectionJitter

otThreadSetRouterUpgradeThreshold

void otThreadSetRouterUpgradeThreshold(
  otInstance *aInstance,
  uint8_t aThreshold
)

设置“主要角色”角色中使用的 ROUTER_UPGrade_THRESHOLD 参数。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aThreshold
ROUTER_UPGrade_THRESHOLD 值。
另请参阅
otThreadGetRouterUpgradeThreshold

otThreadSetSteeringData

void otThreadSetSteeringData(
  otInstance *aInstance,
  const otExtAddress *aExtAddress
)

将带外数据设置为带外数据。

应设置配置选项 OPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE,以支持对带外数据的设置。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aExtAddress
用于更新方向盘数据的地址。所有零都会清除方向盘数据(无方向盘数据)。所有 0xFF 均用于设置转向数据/开花过滤器,以接受/允许所有方向。特定的 EUI64,随后添加到当前的转向数据/Bloom 过滤器。

otThreadSetThreadVersionCheckEnabled

void otThreadSetThreadVersionCheckEnabled(
  otInstance *aInstance,
  bool aEnabled
)

设置是否已启用安全政策的 TLV 版本阈值(VR 字段)。

详情
参数
[in] aInstance
指向 OpenThread 实例的指针。
[in] aEnabled
如果为 TRUE,则启用针对路由的安全政策 TLV 版本的阈值,否则为 FALSE。

OT_CHILD_IP6_ADDRESS_ITERATOR_INIT

 OT_CHILD_IP6_ADDRESS_ITERATOR_INIT 0

otChildIP6AddressIterator 的初始化程序。

资源

OpenThread API 参考主题源自源代码,可在 GitHub 上获取。 如需了解详情或为我们的文档贡献内容,请参阅资源