@@ -173,6 +173,8 @@ otbrError DBusThreadObjectRcp::Init(void)
173173 RegisterMethod (OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_DEACTIVATE_EPHEMERAL_KEY_MODE_METHOD,
174174 std::bind (&DBusThreadObjectRcp::DeactivateEphemeralKeyModeHandler, this , _1));
175175#endif
176+ RegisterMethod (OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_TAKEOVER_LEADER_METHOD,
177+ std::bind (&DBusThreadObjectRcp::TakeoverLeaderHandler, this , _1));
176178 RegisterMethod (DBUS_INTERFACE_INTROSPECTABLE, DBUS_INTROSPECT_METHOD,
177179 std::bind (&DBusThreadObjectRcp::IntrospectHandler, this , _1));
178180
@@ -194,6 +196,8 @@ otbrError DBusThreadObjectRcp::Init(void)
194196 RegisterSetPropertyHandler (OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_EPHEMERAL_KEY_ENABLED,
195197 std::bind (&DBusThreadObjectRcp::SetEphemeralKeyEnabled, this , _1));
196198#endif
199+ RegisterSetPropertyHandler (OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_LOCAL_LEADER_WEIGHT,
200+ std::bind (&DBusThreadObjectRcp::SetLocalLeaderWeightHandler, this , _1));
197201
198202 RegisterGetPropertyHandler (OTBR_DBUS_THREAD_INTERFACE, OTBR_DBUS_PROPERTY_LINK_MODE,
199203 std::bind (&DBusThreadObjectRcp::GetLinkModeHandler, this , _1));
@@ -987,6 +991,19 @@ otError DBusThreadObjectRcp::GetLocalLeaderWeightHandler(DBusMessageIter &aIter)
987991 return error;
988992}
989993
994+ otError DBusThreadObjectRcp::SetLocalLeaderWeightHandler (DBusMessageIter &aIter)
995+ {
996+ auto threadHelper = mHost .GetThreadHelper ();
997+ otError error = OT_ERROR_NONE;
998+ uint8_t weight;
999+
1000+ VerifyOrExit (DBusMessageExtractFromVariant (&aIter, weight) == OTBR_ERROR_NONE, error = OT_ERROR_INVALID_ARGS);
1001+ otThreadSetLocalLeaderWeight (threadHelper->GetInstance (), weight);
1002+
1003+ exit:
1004+ return error;
1005+ }
1006+
9901007otError DBusThreadObjectRcp::GetChannelMonitorSampleCountHandler (DBusMessageIter &aIter)
9911008{
9921009#if OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE
@@ -1906,6 +1923,19 @@ void DBusThreadObjectRcp::LeaveNetworkHandler(DBusRequest &aRequest)
19061923 });
19071924}
19081925
1926+ void DBusThreadObjectRcp::TakeoverLeaderHandler (DBusRequest &aRequest)
1927+ {
1928+ auto threadHelper = mHost .GetThreadHelper ();
1929+ otError error = OT_ERROR_NONE;
1930+ otDeviceRole role = otThreadGetDeviceRole (threadHelper->GetInstance ());
1931+
1932+ VerifyOrExit (role != OT_DEVICE_ROLE_DISABLED && role != OT_DEVICE_ROLE_DETACHED, error = OT_ERROR_INVALID_STATE);
1933+ SuccessOrExit (error = otThreadBecomeLeader (threadHelper->GetInstance ()));
1934+
1935+ exit:
1936+ aRequest.ReplyOtResult (error);
1937+ }
1938+
19091939#if OTBR_ENABLE_NAT64
19101940void DBusThreadObjectRcp::SetNat64Enabled (DBusRequest &aRequest)
19111941{
0 commit comments