added mDNS
This commit is contained in:
parent
ae341f91b3
commit
92e7399fe4
|
@ -10,9 +10,10 @@
|
||||||
// ------------------------------------------ WiFi ---------------------------------------------------------------------------------
|
// ------------------------------------------ WiFi ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
const char *CONFIG_WIFI_SSID = "WLAN";
|
const char *CONFIG_WIFI_SSID = "WLAN";
|
||||||
//const char *CONFIG_WIFI_SSID = "RepeaterWZ";
|
//const char *CONFIG_WIFI_SSID = "MartinHandy";
|
||||||
const char *CONFIG_WIFI_PASSWORD = "Bau3rWLAN";
|
const char *CONFIG_WIFI_PASSWORD = "Bau3rWLAN";
|
||||||
const char *CONFIG_HOSTNAME = "smartswim";
|
//const char *CONFIG_WIFI_PASSWORD = "35cbbd203afe";
|
||||||
|
const char *CONFIG_HOSTNAME = "swimtracker";
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------- Hardware & Measurement Settings ------------------------------------------------------------
|
// ------------------------------------- Hardware & Measurement Settings ------------------------------------------------------------
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "WebsocketServer.h"
|
#include "WebsocketServer.h"
|
||||||
|
|
||||||
#include "esp_https_ota.h"
|
#include "esp_https_ota.h"
|
||||||
|
#include "ESPmDNS.h"
|
||||||
|
|
||||||
using Session_T = SimpleMeasurementSession<MeasurementT, CONFIG_SESSION_MAX_SIZE>;
|
using Session_T = SimpleMeasurementSession<MeasurementT, CONFIG_SESSION_MAX_SIZE>;
|
||||||
SessionManager<Session_T> sessionManager(CONFIG_SCALE_DOUT_PIN, CONFIG_SCALE_SCK_PIN, CONFIG_TARE_AVG_COUNT);
|
SessionManager<Session_T> sessionManager(CONFIG_SCALE_DOUT_PIN, CONFIG_SCALE_SCK_PIN, CONFIG_TARE_AVG_COUNT);
|
||||||
|
@ -126,7 +127,7 @@ void httpSetup(SessionManager<SessionT> *sessionManager)
|
||||||
const String idfVersion(descr->idf_ver);
|
const String idfVersion(descr->idf_ver);
|
||||||
const String compileDate(descr->date);
|
const String compileDate(descr->date);
|
||||||
const String compileTime(descr->time);
|
const String compileTime(descr->time);
|
||||||
result += "\"firmware\": { \"name\" : \"" +
|
result += "\"firmware\": { \"name\" : \"" +
|
||||||
projectName + "\", \"version\": \"" +
|
projectName + "\", \"version\": \"" +
|
||||||
versionStr + "\", \"idfVersion\": \"" +
|
versionStr + "\", \"idfVersion\": \"" +
|
||||||
idfVersion + "\", \"compile_date\": \"" +
|
idfVersion + "\", \"compile_date\": \"" +
|
||||||
|
@ -207,6 +208,32 @@ String getIdSuffix()
|
||||||
return String(baseMacChr);
|
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()
|
void setup()
|
||||||
{
|
{
|
||||||
// Serial
|
// Serial
|
||||||
|
@ -244,17 +271,13 @@ void setup()
|
||||||
Serial.print("Connected to WiFi. IP:");
|
Serial.print("Connected to WiFi. IP:");
|
||||||
Serial.println(WiFi.localIP());
|
Serial.println(WiFi.localIP());
|
||||||
|
|
||||||
Serial.println("Running version new24!"); // todo
|
mdnsSetup(fullHostname);
|
||||||
|
|
||||||
// Session
|
// Session
|
||||||
sessionManager.begin();
|
sessionManager.begin();
|
||||||
|
|
||||||
// HTTP & Websocket server
|
// HTTP & Websocket server
|
||||||
httpSetup(&sessionManager);
|
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();
|
webSocketServer.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue