Added MDNS

This commit is contained in:
Rene Zeldenthuis
2022-07-04 19:55:44 +02:00
parent a2f427f4f7
commit d9462f3a2f
2 changed files with 11 additions and 11 deletions

View File

@@ -1,6 +1,5 @@
#include "rtsp_server.h"
#include <esp32-hal-log.h>
#include <ESPmDNS.h>
#include <OV2640Streamer.h>
// URI: e.g. rtsp://192.168.178.27:554/mjpeg/1
@@ -9,9 +8,6 @@ rtsp_server::rtsp_server(OV2640 &cam, unsigned long interval, int port /*= 554*/
{
log_i("Starting RTSP server");
WiFiServer::begin();
// Add service to mDNS - rtsp
MDNS.addService("rtsp", "tcp", 554);
timer_.every(interval, client_handler, this);
}

View File

@@ -1,16 +1,11 @@
#include <Arduino.h>
#include <soc/rtc_cntl_reg.h>
#include <IotWebConf.h>
#include <IotWebConfTParameter.h>
#include <OV2640.h>
#include <ESPmDNS.h>
#include <rtsp_server.h>
#include <frame_size.h>
#include <esp32cam.h>
char frame_rate_val[6];
@@ -54,7 +49,7 @@ void handleRoot()
html += "<h3>Settings</h3>";
html += "<ul>";
html += "<li>Frame size: " + String(frame_size_val) + "</li>";
html += "<li>Frame rate: " + String(frame_rate_val) + "</li>";
html += "<li>Frame rate: " + String(frame_rate_val) + " ms</li>";
html += "</ul>";
html += "<br/>Go to <a href=\"config\">configure page</a> to change settings.";
html += "</body></html>";
@@ -149,6 +144,15 @@ void setup()
{ iotWebConf.handleConfig(); });
web_server.onNotFound([]()
{ iotWebConf.handleNotFound(); });
// Set DNS to thingname
if (!MDNS.begin(iotWebConf.getThingName()))
log_e("Error setting up MDNS responder!");
// Add service to mDNS - http
MDNS.addService("http", "tcp", 80);
// Add service to mDNS - rtsp
MDNS.addService("rtsp", "tcp", 554);
}
void loop()