diff --git a/aseba/thymio-device-manager/aseba_node_registery.cpp b/aseba/thymio-device-manager/aseba_node_registery.cpp index 6922de81f..ce158bf81 100644 --- a/aseba/thymio-device-manager/aseba_node_registery.cpp +++ b/aseba/thymio-device-manager/aseba_node_registery.cpp @@ -108,11 +108,13 @@ aseba_node_registery::node_map aseba_node_registery::nodes() const { void aseba_node_registery::set_tcp_endpoint(const boost::asio::ip::tcp::endpoint& endpoint) { m_nodes_service_desc.endpoint(endpoint); - update_discovery(); } void aseba_node_registery::set_ws_endpoint(const boost::asio::ip::tcp::endpoint& endpoint) { m_ws_endpoint = endpoint; +} + +void aseba_node_registery::set_discovery() { update_discovery(); } @@ -134,10 +136,12 @@ void aseba_node_registery::update_discovery() { void aseba_node_registery::on_update_discovery_complete(const boost::system::error_code& ec) { if(ec) { mLogError("Discovery : {}", ec.message()); + m_discovery_needs_update = true; } else { mLogTrace("Discovery : update complete"); + m_updating_discovery = false; } - m_updating_discovery = false; + if(m_discovery_needs_update) { boost::asio::post(boost::asio::get_associated_executor(this), boost::bind(&aseba_node_registery::update_discovery, this)); diff --git a/aseba/thymio-device-manager/aseba_node_registery.h b/aseba/thymio-device-manager/aseba_node_registery.h index 0a3a00bdd..64d72a22b 100644 --- a/aseba/thymio-device-manager/aseba_node_registery.h +++ b/aseba/thymio-device-manager/aseba_node_registery.h @@ -30,6 +30,7 @@ class aseba_node_registery : public boost::asio::detail::service_base node_from_id(const node_id&) const; diff --git a/aseba/thymio-device-manager/main.cpp b/aseba/thymio-device-manager/main.cpp index 299dd549a..fdc777516 100644 --- a/aseba/thymio-device-manager/main.cpp +++ b/aseba/thymio-device-manager/main.cpp @@ -62,8 +62,12 @@ void run_service(boost::asio::io_context& ctx) { // Create a server for websocket mobsya::application_server websocket_server(ctx, 8597); + node_registery.set_ws_endpoint(websocket_server.endpoint()); websocket_server.accept(); - node_registery.set_ws_endpoint(websocket_server.endpoint()); + + // Enable Bonjour, Zeroconf + node_registery.set_discovery(); + #ifdef MOBSYA_TDM_ENABLE_USB mobsya::usb_server usb_server(ctx, {mobsya::THYMIO2_DEVICE_ID, mobsya::THYMIO_WIRELESS_DEVICE_ID});