Example #1
0
void ChildSupervisor::HandleTimer(void)
{
    Child * child;
    uint8_t numChildren;

    VerifyOrExit(mSupervisionInterval != 0);

    child = GetNetif().GetMle().GetChildren(&numChildren);

    for (uint8_t i = 0; i < numChildren; i++, child++)
    {
        if (!child->IsStateValidOrRestoring())
        {
            continue;
        }

        child->IncrementSecondsSinceLastSupervision();

        if ((child->GetSecondsSinceLastSupervision() >= mSupervisionInterval) && (child->IsRxOnWhenIdle() == false))
        {
            SendMessage(*child);
        }
    }

    mTimer.Start(kOneSecond);

exit:
    return;
}
Example #2
0
// Checks whether a `Child::State` matches a `ChildTable::StateFilter`.
static bool StateMatchesFilter(Child::State aState, ChildTable::StateFilter aFilter)
{
    bool  rval = false;
    Child child;

    child.SetState(aState);

    switch (aFilter)
    {
    case ChildTable::kInStateAnyExceptInvalid:
        rval = (aState != Child::kStateInvalid);
        break;

    case ChildTable::kInStateValid:
        rval = (aState == Child::kStateValid);
        break;

    case ChildTable::kInStateValidOrRestoring:
        rval = child.IsStateValidOrRestoring();
        break;

    case ChildTable::kInStateChildIdRequest:
        rval = (aState == Child::kStateChildIdRequest);
        break;

    case ChildTable::kInStateValidOrAttaching:
        rval = child.IsStateValidOrAttaching();
        break;

    case ChildTable::kInStateAnyExceptValidOrRestoring:
        rval = !child.IsStateValidOrRestoring();
        break;
    }

    return rval;
}