I've posted in THIS thread a few days ago that I finished an overhaul of the EthernetBonjour library, removing all direct hardware calls to the W5100/W5200 Ethernet chip with calls from the EthernetUDP library.
These changes 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 in THIS thread.
EthernetUDP.h needs these lines aded in the sensible places:
EthernetUDP.cpp need this added routine:
I am proposing to add this permanently added to the Ethernet library in the Teensyduino distribution.
Crits and comments are welcome!
These changes 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 in THIS thread.
EthernetUDP.h needs these lines aded in the sensible places:
Code:
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:
Code:
/* 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;
}
I am proposing to add this permanently added to the Ethernet library in the Teensyduino distribution.
Crits and comments are welcome!