diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 839d4958336..03343c1fb3c 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -2,6 +2,11 @@ #include #include "MyMesh.h" +#if defined(ENABLE_WIFI_INTERFACE) && defined(ENABLE_ESP_MDNS) +#define HAS_ESP_MDNS +#include +#endif + // Believe it or not, this std C function is busted on some platforms! static uint32_t _atoi(const char* sp) { uint32_t n = 0; @@ -266,6 +271,22 @@ void setup() { interface_manager.addInterface(InterfaceType::Ethernet, ðernet_interface); #endif +#ifdef HAS_ESP_MDNS + String mdnsName = "meshcore_"; + mdnsName += the_mesh.getNodeName(); + if (!MDNS.begin(mdnsName.c_str())) { + WIFI_DEBUG_PRINTLN("mDNS failed to start!"); + } else { + MDNS.addService("meshcore", "tcp", TCP_PORT); + MDNS.addServiceTxt("meshcore", "tcp", "node-name", the_mesh.getNodeName()); + MDNS.addServiceTxt("meshcore", "tcp", "firmware-version", FIRMWARE_VERSION); + String protocol; protocol+=FIRMWARE_VER_CODE; + MDNS.addServiceTxt("meshcore", "tcp", "protocol-version", protocol.c_str()); + MDNS.addServiceTxt("meshcore", "tcp", "build-date", __DATE__); + MDNS.addServiceTxt("meshcore", "tcp", "build-time", __TIME__); + } +#endif + // add hardware serial interface #if defined(SERIAL_RX) companion_serial.setPins(SERIAL_RX, SERIAL_TX); diff --git a/variants/heltec_v4/platformio.ini b/variants/heltec_v4/platformio.ini index 76e8e714e68..c6b0a05bb02 100644 --- a/variants/heltec_v4/platformio.ini +++ b/variants/heltec_v4/platformio.ini @@ -212,6 +212,7 @@ build_flags = -D BLE_DEBUG_LOGGING=1 -D OFFLINE_QUEUE_SIZE=256 -D ENABLE_WIFI_INTERFACE + -D ENABLE_ESP_MDNS ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${heltec_v4_oled.build_src_filter} @@ -231,6 +232,7 @@ build_flags = ${heltec_v4_oled.build_flags} -I examples/companion_radio/ui-new -D ENABLE_WIFI_INTERFACE + -D ENABLE_ESP_MDNS -D MAX_CONTACTS=350 -D MAX_GROUP_CHANNELS=40 -D OFFLINE_QUEUE_SIZE=256