Skip to content

Commit

Permalink
Added MAC address as identifier for Arduino Due
Browse files Browse the repository at this point in the history
  • Loading branch information
fredlcore committed Feb 9, 2025
1 parent 587a60b commit d6fdee2
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions BSB_LAN/BSB_LAN.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8015,20 +8015,18 @@ active_cmdtbl_size = sizeof(cmdtbl)/sizeof(cmdtbl[0]);
}

if(mDNS_hostname[0]) {
char macStr[18];
snprintf(macStr, sizeof(macStr), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
char macStr[18];
snprintf(macStr, sizeof(macStr), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
#if defined(ESP32)
MDNS.begin(mDNS_hostname);
MDNS.addService("http", "tcp", HTTPPort);
MDNS.addServiceTxt("http", "tcp", "description", "BSB-LAN web service");
MDNS.addServiceTxt("http", "tcp", "mac", (const char*)macStr);
#else
mdns.begin(Ethernet.localIP(), mDNS_hostname);
char service_txt[25];
snprintf(service_txt, sizeof(service_txt), "mac=%s", macStr);
mdns.addServiceRecord("BSB-LAN._http", HTTPPort, MDNSServiceTCP, "description=BSB-LAN web service");
char service_txt[60];
snprintf(service_txt, sizeof(service_txt), "%c%s%c%s%s", 0x1F, "BSB-LAN web service", 0x15, "mac=", macStr);
mdns.addServiceRecord("BSB-LAN._http", HTTPPort, MDNSServiceTCP, service_txt);
// TODO: Add text entry for MAC address to create unique MDNS record also for Arduino Due
#endif
printFmtToDebug("Starting MDNS service with hostname %s\r\n", mDNS_hostname);
}
Expand Down

0 comments on commit d6fdee2

Please sign in to comment.