mirror of
https://github.com/espressif/openthread.git
synced 2026-08-01 16:47:47 +00:00
[mle] add RLOC16 related helper methods in Mle (#10440)
This commit introduces new helper methods in the `Mle` class: - `HasRloc16()`: Checks if the device is using a given RLOC16. - `MatchesRouterId()`: Checks if this device's RLOC16 matches a given Router ID. - `HasMatchingRouterIdWith()`: Checks if this device's RLOC16 shares the same Router ID with a given RLOC16. This implies that the two devices are either directly related as parent and child or are children of the same parent within the Thread network. - `ParentRloc16ForRloc16()` derives the router RLOC16 corresponding to the parent of a given (child) RLOC16. These methods act as syntactic sugar, simplifying code and enhancing readability.
This commit is contained in:
@@ -81,7 +81,7 @@ otError otThreadGetLeaderRloc(otInstance *aInstance, otIp6Address *aLeaderRloc)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
VerifyOrExit(AsCoreType(aInstance).Get<Mle::Mle>().GetRloc16() != Mle::kInvalidRloc16, error = kErrorDetached);
|
||||
VerifyOrExit(!AsCoreType(aInstance).Get<Mle::Mle>().HasRloc16(Mle::kInvalidRloc16), error = kErrorDetached);
|
||||
AsCoreType(aInstance).Get<Mle::Mle>().GetLeaderRloc(AsCoreType(aLeaderRloc));
|
||||
|
||||
exit:
|
||||
@@ -197,7 +197,7 @@ otError otThreadGetServiceAloc(otInstance *aInstance, uint8_t aServiceId, otIp6A
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
VerifyOrExit(AsCoreType(aInstance).Get<Mle::Mle>().GetRloc16() != Mle::kInvalidRloc16, error = kErrorDetached);
|
||||
VerifyOrExit(!AsCoreType(aInstance).Get<Mle::Mle>().HasRloc16(Mle::kInvalidRloc16), error = kErrorDetached);
|
||||
AsCoreType(aInstance).Get<Mle::Mle>().GetServiceAloc(aServiceId, AsCoreType(aServiceAloc));
|
||||
|
||||
exit:
|
||||
|
||||
Reference in New Issue
Block a user