1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-27 18:02:17 +03:00

UDP multicast APIs fix

fix #74, fix #7
This commit is contained in:
Ivan Grokhotkov
2015-04-28 00:00:15 +08:00
parent 22f063b913
commit 727c61efe2
7 changed files with 60 additions and 18 deletions

View File

@ -62,6 +62,7 @@ MDNSResponder::~MDNSResponder() {
bool MDNSResponder::begin(const char* domain, IPAddress addr, uint32_t ttlSeconds)
{
_localAddr = addr;
// Construct DNS request/response fully qualified domain name of form:
// <domain length>, <domain characters>, 5, "local"
size_t n = strlen(domain);
@ -190,8 +191,9 @@ void MDNSResponder::update() {
Serial.print("responding, i=");
Serial.println(i);
#endif
_mdnsConn.beginPacketMulticast(IPAddress(224, 0, 0, 251), 5353, _localAddr);
_mdnsConn.write(_response, _responseLen);
_mdnsConn.endPacketMulticast(IPAddress(224, 0, 0, 251), 5353);
_mdnsConn.endPacket();
_index = 0;
}
}

View File

@ -64,6 +64,8 @@ private:
int _responseLen;
// Socket for MDNS communication
WiFiUDP _mdnsConn;
// local IP Address
IPAddress _localAddr;
};
#endif //ESP8266MDNS_H

View File

@ -53,7 +53,6 @@ void setup(void)
// the fully-qualified domain name is "esp8266.local"
// - second argument is the IP address to advertise
// we send our IP address on the WiFi network
// Note: for AP mode we would use WiFi.softAPIP()!
if (!mdns.begin("esp8266", WiFi.localIP())) {
Serial.println("Error setting up MDNS responder!");
while(1) {