1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-22 15:46:14 +01:00

ESP32 mDNS registration for throttle autodiscovery

This commit is contained in:
pmantoine 2023-06-23 18:08:05 +08:00
parent 196a27a27a
commit ec6e730559
3 changed files with 14 additions and 1 deletions

View File

@ -20,6 +20,7 @@
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
#include <vector> #include <vector>
#include "defines.h" #include "defines.h"
#include "ESPmDNS.h"
#include <WiFi.h> #include <WiFi.h>
#include "esp_wifi.h" #include "esp_wifi.h"
#include "WifiESP32.h" #include "WifiESP32.h"
@ -209,6 +210,15 @@ bool WifiESP::setup(const char *SSid,
// no idea to go on // no idea to go on
return false; return false;
} }
// Now Wifi is up, register the mDNS service
if(!MDNS.begin(hostname)) {
DIAG(F("Wifi setup failed to start mDNS"));
}
if(!MDNS.addService("withrottle", "tcp", 2560)) {
DIAG(F("Wifi setup failed to add withrottle service to mDNS"));
}
server = new WiFiServer(port); // start listening on tcp port server = new WiFiServer(port); // start listening on tcp port
server->begin(); server->begin();
// server started here // server started here

View File

@ -173,6 +173,8 @@ board = esp32dev
framework = arduino framework = arduino
lib_deps = ${env.lib_deps} lib_deps = ${env.lib_deps}
build_flags = -std=c++17 build_flags = -std=c++17
monitor_speed = 115200
monitor_echo = yes
[env:Nucleo-F411RE] [env:Nucleo-F411RE]
platform = ststm32 platform = ststm32

View File

@ -4,7 +4,8 @@
#include "StringFormatter.h" #include "StringFormatter.h"
#define VERSION "4.2.59" #define VERSION "4.2.60"
// 4.2.60 - Add mDNS capability to ESP32 for autodiscovery
// 4.2.59 - Fix: AP SSID was DCC_ instead of DCCEX_ // 4.2.59 - Fix: AP SSID was DCC_ instead of DCCEX_
// 4.2.58 - Start motordriver as soon as possible but without waveform // 4.2.58 - Start motordriver as soon as possible but without waveform
// 4.2.57 - New overload handling (faster and handles commonFaultPin again) // 4.2.57 - New overload handling (faster and handles commonFaultPin again)