mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
ESP8266mDNS: support AP and STA interfaces at once
Bind the UDP connection to IP_ADDR_ANY rather than a specific interface IP, so that it can receive queries from all interfaces at once. When processing a query, detect which interface it was received on, and pass this information to the reply code. Set the IP multicast interface before each transmission, so that we can route each packet to a different interface if required. These changes enable the code to respond correctly on both AP and STA interfaces at once. The original code only worked correctly for the STA interface if both were enabled. When advertizing all services, do it on both AP and STA interfaces if they're both enabled. Provide an API for the application to notify the MDNS code if the AP configuration changes (enabled, disabled, IP changed). Ideally, the WiFi core would provide an event callback for this purpose, as it does for STA changes, but it does not appear to, so the application must provide this information.
This commit is contained in:
committed by
Ivan Grokhotkov
parent
eb1ac103e4
commit
a546d64e07
@ -66,6 +66,8 @@ public:
|
||||
bool begin(const char* hostName, IPAddress ip, uint32_t ttl=120){
|
||||
return begin(hostName);
|
||||
}
|
||||
/* Application should call this whenever AP is configured/disabled */
|
||||
void notifyAPChange();
|
||||
void update();
|
||||
|
||||
void addService(char *service, char *proto, uint16_t port);
|
||||
@ -118,12 +120,11 @@ private:
|
||||
WiFiEventHandler _gotIPHandler;
|
||||
|
||||
|
||||
uint32_t _getOurIp();
|
||||
uint16_t _getServicePort(char *service, char *proto);
|
||||
MDNSTxt * _getServiceTxt(char *name, char *proto);
|
||||
uint16_t _getServiceTxtLen(char *name, char *proto);
|
||||
void _parsePacket();
|
||||
void _reply(uint8_t replyMask, char * service, char *proto, uint16_t port);
|
||||
void _reply(uint8_t replyMask, char * service, char *proto, uint16_t port, uint32_t ip);
|
||||
size_t advertiseServices(); // advertise all hosted services
|
||||
MDNSAnswer* _getAnswerFromIdx(int idx);
|
||||
int _getNumAnswers();
|
||||
|
Reference in New Issue
Block a user