本文整理汇总了C++中Child::SetExtAddress方法的典型用法代码示例。如果您正苦于以下问题:C++ Child::SetExtAddress方法的具体用法?C++ Child::SetExtAddress怎么用?C++ Child::SetExtAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Child
的用法示例。
在下文中一共展示了Child::SetExtAddress方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestChildTable
//.........这里部分代码省略.........
ChildTable *table;
otError error;
sInstance = testInitInstance();
VerifyOrQuit(sInstance != NULL, "Null instance");
table = &sInstance->Get<ChildTable>();
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
printf("Checking initial state after child table is constructed");
VerifyOrQuit(table->GetMaxChildrenAllowed() == table->GetMaxChildren(),
"GetMaxChildrenAllowed() initial value is incorrect ");
for (uint8_t i = 0; i < OT_ARRAY_LENGTH(kAllFilters); i++)
{
ChildTable::StateFilter filter = kAllFilters[i];
VerifyOrQuit(table->HasChildren(filter) == false, "HasChildren() failed after init");
VerifyOrQuit(table->GetNumChildren(filter) == 0, "GetNumChildren() failed after init");
}
printf(" -- PASS\n");
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
VerifyChildTableContent(*table, 0, testChildList);
VerifyOrQuit(table->GetMaxChildrenAllowed() >= testListLength,
"Default child table size is too small for the unit test");
// Add the child entries from test list one by one and verify the table content
for (uint8_t i = 0; i < testListLength; i++)
{
Child *child;
child = table->GetNewChild();
VerifyOrQuit(child != NULL, "GetNewChild() failed");
child->SetState(testChildList[i].mState);
child->SetRloc16(testChildList[i].mRloc16);
child->SetExtAddress((static_cast<const Mac::ExtAddress &>(testChildList[i].mExtAddress)));
VerifyChildTableContent(*table, i + 1, testChildList);
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Verify Child Table clear
table->Clear();
VerifyChildTableContent(*table, 0, testChildList);
// Add the child entries from test list in reverse order and verify the table content
for (uint8_t i = testListLength; i > 0; i--)
{
Child *child;
child = table->GetNewChild();
VerifyOrQuit(child != NULL, "GetNewChild() failed");
child->SetState(testChildList[i - 1].mState);
child->SetRloc16(testChildList[i - 1].mRloc16);
child->SetExtAddress((static_cast<const Mac::ExtAddress &>(testChildList[i - 1].mExtAddress)));
VerifyChildTableContent(*table, testListLength - i + 1, &testChildList[i - 1]);
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
printf("Test Get/SetMaxChildrenAllowed");
error = table->SetMaxChildrenAllowed(kMaxChildren - 1);
VerifyOrQuit(error == OT_ERROR_INVALID_STATE, "SetMaxChildrenAllowed() should fail when table is not empty");
table->Clear();
error = table->SetMaxChildrenAllowed(kMaxChildren + 1);
VerifyOrQuit(error == OT_ERROR_INVALID_ARGS, "SetMaxChildrenAllowed() did not fail with an invalid arg");
error = table->SetMaxChildrenAllowed(0);
VerifyOrQuit(error == OT_ERROR_INVALID_ARGS, "SetMaxChildrenAllowed() did not fail with an invalid arg");
error = table->SetMaxChildrenAllowed(testNumAllowedChildren);
VerifyOrQuit(error == OT_ERROR_NONE, "SetMaxChildrenAllowed() failed");
VerifyOrQuit(table->GetMaxChildrenAllowed() == testNumAllowedChildren, "GetMaxChildrenAllowed() failed");
for (uint8_t num = 0; num < testNumAllowedChildren; num++)
{
Child *child = table->GetNewChild();
VerifyOrQuit(child != NULL, "GetNewChild() failed");
child->SetState(Child::kStateValid);
}
VerifyOrQuit(table->GetNewChild() == NULL, "GetNewChild() did not fail when table was full");
printf(" -- PASS\n");
testFreeInstance(sInstance);
}