EthernetBonjour
EthernetBonjour copied to clipboard
Multiple key/value pairs in txt record
Hello,
Does this library support multiple key/value pairs in the txt record and how to achieve this?
(1) A txt record as seen in this example won't work, no client can detect the service.
(2) When using the '\001' ascii like here some clients will parse the record correctly, but some will not. (Might be because some implementations use the raw txt record buffer, which might only work with the first way to format the record)
Regards, Andreas
@andreaspfurtscheller to be honest, I have no idea. The original source code to this library is about 10 years old by now and was originally published here
After the re-write I have not looked at it in a good while myself as it worked for my purposes. What problems would the ability to save multiple key/value pairs solve ?
Also, thank you for your interest. I find it very odd that this library is not more popular as it really saves a number of problems.
Hi! Yes, I can confirm that there is an error in the library with multiple key/value pairs.
The current code is only calculating the length of the full textContent field and sending it as unique key/value pair. In MDNS.cpp (from line 395):
int slen = strlen((char*)this->_serviceRecords[serviceRecord]->textContent);
*((uint16_t*)buf) = ethutil_htons(slen);
this->_udp->write((uint8_t*)buf,2);
ptr += 2;
this->_udp->write((uint8_t*)this->_serviceRecords[serviceRecord]->textContent,slen);
ptr += slen;
Will be necessary to define an special character por split key/value pairs or modify the structures to send an array of char* instead only one textContent field.