With this, you have a dependeny free way to find all your Nerves and MikroTik devices on your network.
To start add it to your nerves project dependencies (no hex.pm for now until version 0.1.0 is ready). The application will be automatically started.
def deps do
[
{:mndp, github: "kevinschweikert/mndp"}
]
end
There is a Mix task included to scan for devices for 15s. This will be improved when i implement subscribing so that we can scan for as long as we want and get the results back in realtime.
> mix discover
Searching for devices...
IDENTITY MAC IPV4 INTERFACE UPTIME
nerves-2a0c BE:FE:21:C8:80:A1 172.31.199.73 usb0 1605
Thanks to the mdns_lite library for many inspirations and a part of the code was adapted for this library.
I would be happy, if you could try this with your devices, give feedback, open an issue or a PR. Have a look at the todo/idea list in the README to get a feeling for the current state.
I just tried it out. That’s really cool, and I’ll have to look into this more.
I usually use Elixir scripts rather than Mix tasks, so I converted the task to one. It’s a copy/paste of your code, but it lets me run discovery from any directory. MNDP Discovery Script · GitHub
I like the ideas of having a script/escript. I will add a CLI module so it will be easier to start it in a script and can be updated by the library itself. I will also look into escrips and how they can be installed from Hex. This sounds like a nice way for people to have the discover functionality globally available!
Thanks for your input!
Added MNDP.CLI Module to make it easier to use in scripts. Thanks to @fhunleth for providing the Mix.install script. I’ve added a new one to the root of the repo.
The two things missing for me, for a first versioned release is the cleanup of the config management and a feature, that per spec you should answer a discovery request packet, so that you can find devices faster. Because i seperated sender and listener i have to find out, which sender is responsible for the response of the received discovery request.
[edit] after reading the code this is LLDP so not MDNS, please ignore my question
My understanding, is that this is fully mdns compliant, right? So it would be possible to wire it into other beam systems like libcluster or khepri or is this solely nerves?