Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pd] daemon service: reconnect to dbus on dbus reset #2605

Merged
merged 8 commits into from
Nov 21, 2024
12 changes: 5 additions & 7 deletions script/reference-device/dhcp6_pd_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,13 @@ def connect_to_signal():
properties_changed_handler,
dbus_interface=properties_dbus_iface.dbus_interface)
logging.info("Connected to D-Bus signal.")
return dbus_obj
except dbus.DBusException as e:
logging.error(f"Error connecting to D-Bus: {e}")
return None


def check_and_reconnect(dbus_obj):
if dbus_obj is None:
def handle_name_owner_changed(new_owner):
if new_owner:
logging.info(f"New D-Bus owner({new_owner}) assigned, connecting...")
connect_to_signal()


Expand All @@ -130,9 +129,8 @@ def main():

loop = GLib.MainLoop()

thread_dbus_obj = connect_to_signal()

GLib.timeout_add_seconds(5, check_and_reconnect, thread_dbus_obj)
bus.watch_name_owner(bus_name='io.openthread.BorderRouter.wpan0',
callback=handle_name_owner_changed)

loop.run()

Expand Down
Loading