-
-
Notifications
You must be signed in to change notification settings - Fork 6
Query for every available interface #32
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mcspr, thank you for the patch!
I've added just two remarks but the patch looks good overall.
what happens when multiple interfaces return the same thing (e.g. lan wifi & ethernet)
If the "ports" are the same, for cleanness I'd like to send just one event upstream.
BTW the pluggable discovery specification explicitly allows sending more "add" events for the same port to update port metadata, so even if we do not ignore the second event it should be fine anyway.
what errorCB supposed to do when one interface fails, but the rest don't
ErrorCallback
is a callback function to signal unrecoverable errors to the client while the discovery is in "event" mode after a START_SYNC. Once the discovery signals an error it means that no more port events will be delivered until the client performs a STOP+START_SYNC cycle.
In our case, IMHO the best thing to do is to just ignore the error and continue to deliver events from the other interfaces.
But, thinking a bit more, there is also another case: if an interface came back online after the discovery has been started then this new interface will be completely ignored requiring a restart of the IDE. Probably the best solution is to poll the available interfaces (every minute?) and possibly start a listener on any new interface that appears.
Do you want to make it a try at implementing this logic?
I see that the main function is getting very complicated, it would be better to move some of the anonymous goroutines go func(...)
into a real function or method to make it more readable.
queries are re-created each loop. in case netif disappears, we won't use it next time (and caching will handle removal) clean-up timeouts, additional interval for queries clean-up control flow, split up main loop func a bit
re. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've added some nitpicks about code readability, but besides that the patch LGTM. Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Now I need to test the patch on all OS, it may take a while...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it on Windows and Linux with MKR 1000, ESP8266, ESP32:
Board discovered by mdns-discovery before/after
OS | MKR 1000 | ESP8266 | ESP32 |
---|---|---|---|
Windows | ❌/❌ | ❌/✔️ | ❌/✔️ |
Linux | ✔️/✔️ | ✔️/✔️ | ✔️/✔️ |
The boards are all discovered by Arduino IDE 1.8.19 even on Windows.
Even if it is still not working perfectly, this is undoubtedly a huge improvement. Thanks @mcspr!
resolving #25 (comment) issue on Windows,
list
finally returns available boards instead of nothingreceiving end stays the same, sendQuery uses specific
Interface
to send thingsnot really sure about