diff --git a/firmware/src/SwimTrackerConfig.h b/firmware/src/SwimTrackerConfig.h index 3799757..d72e525 100644 --- a/firmware/src/SwimTrackerConfig.h +++ b/firmware/src/SwimTrackerConfig.h @@ -10,9 +10,10 @@ // ------------------------------------------ WiFi --------------------------------------------------------------------------------- const char *CONFIG_WIFI_SSID = "WLAN"; -//const char *CONFIG_WIFI_SSID = "RepeaterWZ"; -const char *CONFIG_WIFI_PASSWORD = "Bau3rWLAN"; -const char *CONFIG_HOSTNAME = "smartswim"; +//const char *CONFIG_WIFI_SSID = "MartinHandy"; +const char *CONFIG_WIFI_PASSWORD = "Bau3rWLAN"; +//const char *CONFIG_WIFI_PASSWORD = "35cbbd203afe"; +const char *CONFIG_HOSTNAME = "swimtracker"; // ------------------------------------- Hardware & Measurement Settings ------------------------------------------------------------ diff --git a/firmware/src/firmware_main.cpp b/firmware/src/firmware_main.cpp index eabe6ea..738ea82 100644 --- a/firmware/src/firmware_main.cpp +++ b/firmware/src/firmware_main.cpp @@ -18,6 +18,7 @@ #include "WebsocketServer.h" #include "esp_https_ota.h" +#include "ESPmDNS.h" using Session_T = SimpleMeasurementSession; SessionManager sessionManager(CONFIG_SCALE_DOUT_PIN, CONFIG_SCALE_SCK_PIN, CONFIG_TARE_AVG_COUNT); @@ -126,7 +127,7 @@ void httpSetup(SessionManager *sessionManager) const String idfVersion(descr->idf_ver); const String compileDate(descr->date); const String compileTime(descr->time); - result += "\"firmware\": { \"name\" : \"" + + result += "\"firmware\": { \"name\" : \"" + projectName + "\", \"version\": \"" + versionStr + "\", \"idfVersion\": \"" + idfVersion + "\", \"compile_date\": \"" + @@ -207,6 +208,32 @@ String getIdSuffix() return String(baseMacChr); } +void mdnsSetup(const String &fullHostname) +{ + if (!MDNS.begin(fullHostname.c_str())) + { + Serial.println("Error setting up MDNS responder!"); + while (1) + { + delay(1000); + } + } + Serial.printf("mDNS started %s\n", fullHostname.c_str()); + MDNS.addService("_swimtracker", "tcp", 80); + /* + // mDNS + esp_err_t err = mdns_init(); + if (err) + Serial.printf("MDNS Init failed: %d\n", err); + else { + Serial.printf("Setting up zeroconf hostname %s\n", fullHostname.c_str()); + mdns_hostname_set(fullHostname.c_str()); + mdns_service_add(NULL, "_swimtracker", "_tcp", 81, NULL, 0); + mdns_instance_name_set("SwimTracker by bauer.tech"); + } + */ +} + void setup() { // Serial @@ -244,17 +271,13 @@ void setup() Serial.print("Connected to WiFi. IP:"); Serial.println(WiFi.localIP()); - Serial.println("Running version new24!"); // todo + mdnsSetup(fullHostname); + // Session sessionManager.begin(); // HTTP & Websocket server httpSetup(&sessionManager); - - Serial.printf("Offset %d\n", sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t)); - Serial.printf("Size %d\n", sizeof(esp_app_desc_t)); - - webSocketServer.begin(); }