@@ -55,9 +55,9 @@ extern "C" {
5555
5656
5757
58- #define MDNS_DEBUG_ERR
59- #define MDNS_DEBUG_TX
60- #define MDNS_DEBUG_RX
58+ // #define MDNS_DEBUG_ERR
59+ // #define MDNS_DEBUG_TX
60+ // #define MDNS_DEBUG_RX
6161
6262#define MDNS_NAME_REF 0xC000
6363
@@ -151,49 +151,39 @@ void MDNSResponder::setInstanceName(char * name){
151151bool MDNSResponder::addServiceTxt (char *name, char *proto, char *key, char *value){
152152 MDNSService* servicePtr;
153153
154- // DEBUG Serial.printf("Starting addServiceTxt(name=%s,proto=%s,txt=%s)\n", name,proto,txt);
155- // DEBUG delay(20);
156154 uint8_t txtLen = os_strlen (key) + os_strlen (value) + 1 ; // Add one for equals sign
157155 txtLen+=1 ; // accounts for length byte added when building the txt responce
158156 if ( txtLen > 128 ) return false ;
159157 // Find the service
160158 for (servicePtr = _services; servicePtr; servicePtr = servicePtr->_next ) {
161- // DEBUG Serial.printf("Checking service name=%s,proto=%s\n", servicePtr->_name,servicePtr->_proto);
162- // DEBUG delay(20);
159+ // Checking Service names
163160 if (strcmp (servicePtr->_name , name) == 0 && strcmp (servicePtr->_proto , proto) == 0 ){
164161 if (servicePtr->_txtLen + txtLen > 1300 ) return false ; // max txt record size
165- // DEBUG Serial.printf("found match service name=%s,proto=%s\n", servicePtr->_name,servicePtr->_proto);
166- // DEBUG delay(20);
167- struct MDNSTxt *newtxt = (struct MDNSTxt *)(os_malloc (sizeof (struct MDNSTxt )));
168- os_strcpy (newtxt->_txt , key);
169- os_strcat (newtxt->_txt , " =" );
170- os_strcat (newtxt->_txt , value);
171- newtxt->_next = 0 ;
172- if (servicePtr->_txts == 0 ) { // no services have been added
173- servicePtr->_txts = newtxt;
174- servicePtr->_txtLen += txtLen;
175- // DEBUG Serial.printf("Adding First TXT of %s to service %s and proto %s\n", newtxt->_txt,servicePtr->_name,servicePtr->_proto);
176- // DEBUG Serial.printf("New txt length: %d\n",servicePtr->_txtLen);
177- return true ;
178- }
179- else {
180- MDNSTxt * txtPtr = servicePtr->_txts ;
181- while (txtPtr->_next !=0 ) {
182- txtPtr = txtPtr->_next ;
183- // DEBUG Serial.println("Incramenting txt pointer");
162+ // found a service name match
163+ struct MDNSTxt *newtxt = (struct MDNSTxt *)(os_malloc (sizeof (struct MDNSTxt )));
164+ os_strcpy (newtxt->_txt , key);
165+ os_strcat (newtxt->_txt , " =" );
166+ os_strcat (newtxt->_txt , value);
167+ newtxt->_next = 0 ;
168+ if (servicePtr->_txts == 0 ) { // no services have been added
169+ // Adding First TXT to service
170+ servicePtr->_txts = newtxt;
171+ servicePtr->_txtLen += txtLen;
172+ return true ;
184173 }
174+ else {
175+ MDNSTxt * txtPtr = servicePtr->_txts ;
176+ while (txtPtr->_next !=0 ) {
177+ txtPtr = txtPtr->_next ;
178+ }
179+ // adding another TXT to service
185180 txtPtr->_next = newtxt;
186181 servicePtr->_txtLen += txtLen;
187- // DEBUG Serial.printf("Adding Another TXT of %s to service %s and proto %s\n", newtxt->_txt,servicePtr->_name,servicePtr->_proto);
188- // DEBUG Serial.printf("New txt length: %d\n",servicePtr->_txtLen);
189182 return true ;
190183 }
191- /*
192- */
193184 }
194185 }
195186 return false ;
196- // DEBUG Serial.println("No Service Found When adding a txt");
197187}
198188
199189void MDNSResponder::addService (char *name, char *proto, uint16_t port){
@@ -242,17 +232,6 @@ uint16_t MDNSResponder::_getServiceTxtLen(char *name, char *proto){
242232 return 0 ;
243233}
244234
245-
246-
247-
248-
249-
250-
251-
252-
253-
254-
255-
256235uint16_t MDNSResponder::_getServicePort (char *name, char *proto){
257236 MDNSService* servicePtr;
258237 for (servicePtr = _services; servicePtr; servicePtr = servicePtr->_next ) {
@@ -477,14 +456,6 @@ void MDNSResponder::_parsePacket(){
477456
478457void MDNSResponder::enableArduino (uint16_t port, bool auth){
479458
480- // char boardName[64];
481- // const char *boardExtra = "board=";
482- // os_sprintf(boardName, "%s%s", boardExtra, ARDUINO_BOARD);
483-
484- // char authUpload[16];
485- // const char *authUploadExtra = "auth_upload=";
486- // os_sprintf(authUpload, "%s%s", authUploadExtra, (auth) ? "yes":"no");
487-
488459 addService (" arduino" , " tcp" , port);
489460 addServiceTxt (" arduino" , " tcp" , " tcp_check" , " no" );
490461 addServiceTxt (" arduino" , " tcp" , " ssh_upload" , " no" );
0 commit comments