A library for resolving mDNS (Bonjour) host names
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
fixtures Building out parse answer. Need to run some tests Nov 1, 2016
mocks
src
test
.gitignore
.travis.yml
LICENSE.txt
Makefile
README.md
library.json
library.properties

README.md

mDNS Resolver Build Status

An Arduino library that resolves mDNS (bonjour) names. It doesn't do any discovery, it just resolves names.

Compatibility

  • Hardware: ESP8266. I don't believe the stock Arduino UDP library supports multicast (Please correct me if I'm wrong), so only the ESP8266 is supported at the moment
  • Software: Tested against avahi and avahi-alias which adds CNAMEs. Post a bug report if it doesn't work with a server that you are using.

Why?

My home automation projects don't need discovery - I just wanted to be able to enter the name of my MQTT server when configuring my devices. There are other libraries out there that do discovery of services, but they didn't do name resolution easily - And they introduced more code than I needed.

Installation

Clone this code in to your Arduino directory.

cd ~/Arduino
git clone git@github.com:madpilot/mDNSResolver.git

Restart your IDE. You can now include

#include <mDNSResolver.h>

in your sketch.

Usage

IPAddress ip = resolver.search("test.local");

Returns INADDR_NONE if the name can't be found.

See the examples folder for the full setup details

Advanced Customisation

You can change a few settings by defining some constants before including the mDNSResolver header file, but only if you really know what you are doing

#define MDNS_RETRY    1000      # Number of milliseconds between rebroadcasting a name query
#define MDNS_ATTEMPTS 5         # Number of times to try a resolving before giving up
#define UDP_TIMEOUT   255       # Amount of time (in milliseconds) before giving up on the UDP packet
#define MDNS_TLD      ".local"  # Top-level domain to search for. This can technically be anything, but pretty much everyone says leave it as .local

#include <mDNSResolver.h>

Testing

The library has a suite of specs, which you can run on any machine that supports g++ (requires c++11 support).

The specs are written using Catch, written in BDD style.

make test

Contributing

Issues and bugs can be raised on the Issue tracker on GitHub

For code and documentation fixes, clone the code, make the fix, write and run the tests, and submit a pull request.

Feature branches with lots of small commits (especially titled "oops", "fix typo", "forgot to add file", etc.) should be squashed before opening a pull request. At the same time, please refrain from putting multiple unrelated changes into a single pull request.

License

See LICENSE.txt

Credits

Much inspiration, and some parts of the code have been taken (or modified from) https://github.com/mrdunk/esp8266_mdns