1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

Multicast in SoftAP mode (#96)

SDK 1.3 fixed a bug which caused multicast UDP to fail on SoftAP interface. Update MDNSResponder and documentation appropriately.
This commit is contained in:
Ivan Grokhotkov 2015-08-10 16:14:26 +03:00
parent 208ae95979
commit 6cf18ed1a2
3 changed files with 58 additions and 55 deletions

View File

@ -290,7 +290,6 @@ When listening to multicast packets, replace `udp.begin(port)` with
`udp.beginMulticast(WiFi.localIP(), multicast_ip_addr, port)`. `udp.beginMulticast(WiFi.localIP(), multicast_ip_addr, port)`.
You can use `udp.destinationIP()` to tell whether the packet received was You can use `udp.destinationIP()` to tell whether the packet received was
sent to the multicast or unicast address. sent to the multicast or unicast address.
Also note that multicast doesn't work on softAP interface.
`WiFiServer`, `WiFiClient`, and `WiFiUDP` behave mostly the same way as with WiFi shield library. `WiFiServer`, `WiFiClient`, and `WiFiUDP` behave mostly the same way as with WiFi shield library.
Four samples are provided for this library. Four samples are provided for this library.
@ -373,7 +372,6 @@ instead of the one that comes with this package.
## mDNS and DNS-SD responder (ESP8266mDNS library) ## mDNS and DNS-SD responder (ESP8266mDNS library)
Allows the sketch to respond to multicast DNS queries for domain names like "foo.local", and DNS-SD (service dicovery) queries. Allows the sketch to respond to multicast DNS queries for domain names like "foo.local", and DNS-SD (service dicovery) queries.
Currently the library only works on STA interface, AP interface is not supported.
See attached example for details. See attached example for details.
## SSDP responder (ESP8266SSDP) ## SSDP responder (ESP8266SSDP)

View File

@ -163,16 +163,22 @@ uint16_t MDNSResponder::_getServicePort(char *name, char *proto){
} }
uint32_t MDNSResponder::_getOurIp(){ uint32_t MDNSResponder::_getOurIp(){
if(wifi_get_opmode() & STATION_MODE){ int mode = wifi_get_opmode();
if(mode & STATION_MODE){
struct ip_info staIpInfo; struct ip_info staIpInfo;
wifi_get_ip_info(STATION_IF, &staIpInfo); wifi_get_ip_info(STATION_IF, &staIpInfo);
return staIpInfo.ip.addr; return staIpInfo.ip.addr;
} } else if (mode & SOFTAP_MODE) {
struct ip_info staIpInfo;
wifi_get_ip_info(SOFTAP_IF, &staIpInfo);
return staIpInfo.ip.addr;
} else {
#ifdef MDNS_DEBUG_ERR #ifdef MDNS_DEBUG_ERR
os_printf("ERR_NO_LOCAL_IP\n"); os_printf("ERR_NO_LOCAL_IP\n");
#endif #endif
return 0; return 0;
} }
}
void MDNSResponder::_parsePacket(){ void MDNSResponder::_parsePacket(){
int i; int i;

View File

@ -13,7 +13,6 @@ Requirements:
Usage: Usage:
- Include the ESP8266 Multicast DNS library in the sketch. - Include the ESP8266 Multicast DNS library in the sketch.
- Create an instance of the MDNSResponder class.
- Call the begin method in the sketch's setup and provide a domain name (without - Call the begin method in the sketch's setup and provide a domain name (without
the '.local' suffix, i.e. just provide 'foo' to resolve 'foo.local'), and the the '.local' suffix, i.e. just provide 'foo' to resolve 'foo.local'), and the
Adafruit CC3000 class instance. Optionally provide a time to live (in seconds) Adafruit CC3000 class instance. Optionally provide a time to live (in seconds)