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

Add TXT support

This commit is contained in:
Eric Wilkison
2015-12-15 05:39:49 -08:00
parent f34f84be74
commit 758107f35d
2 changed files with 159 additions and 31 deletions

View File

@ -57,6 +57,13 @@ struct MDNSService {
char _name[32];
char _proto[3];
uint16_t _port;
struct MDNSTxt * _txts;
uint16_t _txtLen; // length of all txts
};
struct MDNSTxt{
MDNSTxt * _next;
char _txt[128];
};
class MDNSResponder {
@ -78,16 +85,25 @@ public:
addService(service.c_str(), proto.c_str(), port);
}
void enableArduino(uint16_t port, bool auth=false);
bool addServiceTxt(char *name, char *proto, char *txt);
void addServiceTxt(const char *name, const char *proto, const char *txt){
addServiceTxt((char *)name, (char *)proto, (char *)txt);
}
void addServiceTxt(String name, String proto, String txt){
addServiceTxt(name.c_str(), proto.c_str(), txt.c_str());
}
void enableArduino(uint16_t port, bool auth=false);
private:
struct MDNSService * _services;
UdpContext* _conn;
char _hostName[128];
bool _arduinoAuth;
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);
};