Over the last few months I've been updating the Arduino EthernetBonjour library still available online at http://gkaindl.com/software/arduino-ethernet. The original library was written for Arduino 0017 and required separate libraries for DNS and DHCP. With Arduino 1.x these are not required anymore as they are part of the Arduino Ethernet library.
The main reason for the overhaul is that the original library made 50+ calls directly to the W5100 Ethernet chip and as such was very hardware dependent. I had already upgraded it to work with Arduino 1.x and also to work with the W5200 Ethernet Chip found for example on the WIZ820io Ethernet Module.
The new library is more or less hardware independent. Bonjour and its underlying mechanisms mDNS and DNS-SD use UDP as its base protocol. As such the overhauled library only works with calls to the read/write methods from the EthernetUDP. This should greatly help to adapt it to other hardware and I am hoping for support from the community. The CC3000 from Texas Instruments would be a good candidate.
The changes to the Bonjour library also necessitated the addition of a routine to the EthernetUDP library in order to allow sending UDP multicast messages, required to implement mDNS and DNS-SD. This has been very similarly discussed on the Arduino forum over a year ago UDP Multicast Sending from Arduino via Ethernet Shield - Networking, Protocols, and Devices - Arduino Forum.
EthernetUDP.h needs these lines aded in the sensible places:
virtual uint8_t beginMulti(IPAddress, uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use Sending UDP packets
.
.
.
friend class EthernetBonjourClass;
EthernetUDP.cpp need this added routine:
/* Start EthernetUDP socket, listening at local port PORT */
uint8_t EthernetUDP::beginMulti(IPAddress ip, uint16_t port) {
for (int i = 0; i < MAX_SOCK_NUM; i++) {
uint8_t s = W5100.readSnSR(i);
if (s == SnSR::CLOSED || s == SnSR::FIN_WAIT) {
_sock = i;
break;
}
}
if (_sock == MAX_SOCK_NUM)
return 0;
byte mac[] = { 0x01, 0x00, 0x5E, 0x00, 0x00, 0x00 };
mac[3] = ip[1] & 0x7F;
mac[4] = ip[2];
mac[5] = ip[3];
// byte mac[] = { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb };
W5100.writeSnDIPR(_sock, rawIPAddress(ip));
W5100.writeSnDPORT(_sock, port);
W5100.writeSnDHAR(_sock,mac);
_remaining = 0;
socket(_sock, SnMR::UDP, port, SnMR::MULTI);
return 1;
}
As noted in the documentation on the original web site, the library compiles to a relatively large chunk of code and is aimed at bigger boards with more flash and ram memory. I don't own an Arduino Mega and in recent projects only have used Paul Stoffregen's Teensy boards Teensy USB Development Board .
The Examples provided in the library compile and work out of the box with a Teensy++2 <-> WIZ812MJ and with a Teensy 3 <-> WIZ820io.
The new library is available here: