@@ -145,12 +145,13 @@ void MDNSResponder::update() {
145
145
146
146
147
147
148
- bool MDNSResponder::addServiceTxt (char *name, char *proto, char *txt ){
148
+ bool MDNSResponder::addServiceTxt (char *name, char *proto, char *key, char *value ){
149
149
MDNSService* servicePtr;
150
150
151
151
// DEBUG Serial.printf("Starting addServiceTxt(name=%s,proto=%s,txt=%s)\n", name,proto,txt);
152
152
// DEBUG delay(20);
153
- uint8_t txtLen = os_strlen (txt) + 1 ; // One accounts for length byte added when building the txt responce
153
+ uint8_t txtLen = os_strlen (key) + os_strlen (value) + 1 ; // Add one for equals sign
154
+ txtLen+=1 ; // accounts for length byte added when building the txt responce
154
155
if ( txtLen > 128 ) return false ;
155
156
// Find the service
156
157
for (servicePtr = _services; servicePtr; servicePtr = servicePtr->_next ) {
@@ -161,7 +162,9 @@ bool MDNSResponder::addServiceTxt(char *name, char *proto, char *txt){
161
162
// DEBUG Serial.printf("found match service name=%s,proto=%s\n", servicePtr->_name,servicePtr->_proto);
162
163
// DEBUG delay(20);
163
164
struct MDNSTxt *newtxt = (struct MDNSTxt *)(os_malloc (sizeof (struct MDNSTxt )));
164
- os_strcpy (newtxt->_txt , txt);
165
+ os_strcpy (newtxt->_txt , key);
166
+ os_strcat (newtxt->_txt , " =" );
167
+ os_strcat (newtxt->_txt , value);
165
168
newtxt->_next = 0 ;
166
169
if (servicePtr->_txts == 0 ) { // no services have been added
167
170
servicePtr->_txts = newtxt;
@@ -469,19 +472,19 @@ void MDNSResponder::_parsePacket(){
469
472
470
473
void MDNSResponder::enableArduino (uint16_t port, bool auth){
471
474
472
- char boardName[64 ];
473
- const char *boardExtra = " board=" ;
474
- os_sprintf (boardName, " %s%s" , boardExtra, ARDUINO_BOARD);
475
+ // char boardName[64];
476
+ // const char *boardExtra = "board=";
477
+ // os_sprintf(boardName, "%s%s", boardExtra, ARDUINO_BOARD);
475
478
476
- char authUpload[16 ];
477
- const char *authUploadExtra = " auth_upload=" ;
478
- os_sprintf (authUpload, " %s%s" , authUploadExtra, (auth) ? " yes" :" no" );
479
+ // char authUpload[16];
480
+ // const char *authUploadExtra = "auth_upload=";
481
+ // os_sprintf(authUpload, "%s%s", authUploadExtra, (auth) ? "yes":"no");
479
482
480
483
addService (" arduino" , " tcp" , port);
481
- addServiceTxt (" arduino" , " tcp" , " tcp_check= no" );
482
- addServiceTxt (" arduino" , " tcp" , " ssh_upload= no" );
483
- addServiceTxt (" arduino" , " tcp" , ( const char *)boardName );
484
- addServiceTxt (" arduino" , " tcp" , ( const char *)authUpload );
484
+ addServiceTxt (" arduino" , " tcp" , " tcp_check" , " no" );
485
+ addServiceTxt (" arduino" , " tcp" , " ssh_upload" , " no" );
486
+ addServiceTxt (" arduino" , " tcp" , " board " , ARDUINO_BOARD );
487
+ addServiceTxt (" arduino" , " tcp" , " auth_upload " , (auth) ? " yes " : " no " );
485
488
}
486
489
487
490
void MDNSResponder::_reply (uint8_t replyMask, char * service, char *proto, uint16_t port){
0 commit comments