esp-rs / esp-idf-svc

Type-Safe Rust Wrappers for various ESP-IDF services (WiFi, Network, Httpd, Logging, etc.)
https://docs.esp-rs.org/esp-idf-svc/
Apache License 2.0
333 stars 183 forks source link

How to use the mdns module? #343

Closed abonshan closed 10 months ago

abonshan commented 10 months ago

I can't get the mdns module to work with the documentation or the stuff I found in some other issues. As in I can't import EspMdns and use it. I'm guessing that I have to enable it as an "remote-component" or "extra-component" but I found no list for which components are which or an explanation on how to enable them. I would be grateful if someone could kindly clear it up for me and others facing the same questions. Thanks in advance

Vollbrecht commented 10 months ago

Since esp-idf version 5 espressif started to move things that were previously directly available into there separate components registry. So in your case you are seeing that the mdns module in our code is behind the following feature gate if you look here . If you see such a feature gate where you see *comp_espressif"component-name" with a double underscore ( ) in between you can use the esp-idf-sys component feature to add it as a remote component. This will automatically make it available.

For more information how you can use this esp-idf-sys feature you can have a look here

To make it short you can add it via your Cargo.toml by adding

[[package.metadata.esp-idf-sys.extra_components]]
remote_component = { name = "espressif/mdns", version = "1.2" }

You might need to add a cargo clean after adding it and then recompile

abonshan commented 10 months ago

Thank you, that did the trick.