forked from external-repos/esp32cam-rtsp
- Removed check for reset URL
- Light configurable through API - Fixed HTML if initialization of camera failed
This commit is contained in:
@@ -163,7 +163,7 @@
|
||||
{{^CameraInitialized}}
|
||||
<div class="mt-4 alert alert-danger" role="alert">
|
||||
<p>Failed to initialize the camera!</p>
|
||||
<p>Result: {{CameraInitResultText}} ({{CameraInitResult}})</p>
|
||||
<p>Result: {{CameraInitResultText}}</p>
|
||||
<p>Please check hardware or correct the camera settings and restart.</p>
|
||||
<button type="button" class="btn btn-danger"
|
||||
onclick="location.href='restart'">Restart</button>
|
||||
@@ -176,20 +176,41 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="card bg-light mb-3">
|
||||
<h5 class="card-header">Camera stream</h5>
|
||||
<h5 class="card-header">Special URLs / API</h5>
|
||||
<div class="card-body">
|
||||
</p>The camera stream can be found at the following location:
|
||||
<a href="rtsp://{{HostName}}:{{RtspPort}}/mjpeg/1">rtsp://{{HostName}}:{{RtspPort}}/mjpeg/1</a>
|
||||
</p>
|
||||
<!-- <img class="rounded mx-auto d-block" src="snapshot" alt="Camera image" width="25%">-->
|
||||
<div class="row">
|
||||
<span>
|
||||
The camera RTSP stream can be found at:
|
||||
<a
|
||||
href="rtsp://{{IpV4}}:{{RtspPort}}/mjpeg/1">rtsp://{{HostName}}:{{RtspPort}}/mjpeg/1</a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span>
|
||||
A snapshot of the camera can be found at:
|
||||
<a href="http://{{IpV4}}/snapshot">http://{{HostName}}/snapshot</a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span>
|
||||
The intensity of the flash led (0-255) can be controlled using:
|
||||
<a href="http://{{IpV4}}/flash?v=0">http://{{HostName}}/flash?v=value</a>.
|
||||
If no value is present, the configuration value is used.
|
||||
</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span>
|
||||
Restarting the camera can be done using:
|
||||
<a href="http://{{IpV4}}/restart">http://{{HostName}}/restart</a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-grid gap-2 col-6 mx-auto">
|
||||
<button type="button" class="btn btn-lg btn-warning" onclick="location.href='config'">Settings</button>
|
||||
</div>
|
||||
<div class="d-grid gap-2 col-6 mx-auto">
|
||||
<button type="button" class="btn btn-lg btn-warning" onclick="location.href='config'">Settings</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<link rel="stylesheet" href="bootstrap.min.css">
|
||||
<meta http-equiv="refresh" content="30;url=/index.html">
|
||||
<meta http-equiv="refresh" content="1;url=/index.html">
|
||||
<title>{{AppTitle}} v{{AppVersion}}</title>
|
||||
</head>
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -15,4 +15,4 @@
|
||||
#define DEFAULT_FRAME_BUFFERS "2"
|
||||
#define DEFAULT_FRAME_SIZE "SVGA (800x600)"
|
||||
#define DEFAULT_JPEG_QUALITY "12"
|
||||
#define DEFAULT_LIGHT_INTENSITY "5"
|
||||
#define DEFAULT_LIGHT_INTENSITY "1"
|
||||
23
src/main.cpp
23
src/main.cpp
@@ -108,7 +108,6 @@ void handle_root()
|
||||
{"FrameBuffers", frame_buffers_val},
|
||||
{"JpegQuality", jpeg_quality_val},
|
||||
{"CameraInitialized", String(camera_init_result == ESP_OK)},
|
||||
{"CameraInitResult", "0x" + String(camera_init_result, 16)},
|
||||
{"CameraInitResultText", esp_err_to_name(camera_init_result)},
|
||||
{"FlashLedIntensity", flash_led_intensity_val},
|
||||
// RTSP
|
||||
@@ -122,14 +121,6 @@ void handle_root()
|
||||
void handle_restart()
|
||||
{
|
||||
log_v("Handle restart");
|
||||
// If configuration is not changed and camera working, do not allow a restart
|
||||
if (!config_changed && camera_init_result == ESP_OK)
|
||||
{
|
||||
// Redirect to root page
|
||||
web_server.sendHeader("Location", "/", true);
|
||||
web_server.send(302, "text/plain", "Restart not possible.");
|
||||
return;
|
||||
}
|
||||
|
||||
const moustache_variable_t substitutions[] = {
|
||||
{"AppTitle", APP_TITLE},
|
||||
@@ -167,6 +158,18 @@ void handle_snapshot()
|
||||
delete[] fb;
|
||||
}
|
||||
|
||||
void handle_flash()
|
||||
{
|
||||
log_v("handle_flash");
|
||||
// If no value present, use value from config
|
||||
auto value = web_server.hasArg("v") ? web_server.arg("v") : flash_led_intensity_val;
|
||||
// If conversion fails, v = 0
|
||||
auto v = (uint8_t)min(value.toInt(), 255l);
|
||||
analogWrite(LED_FLASH, v);
|
||||
web_server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||
web_server.send(200);
|
||||
}
|
||||
|
||||
void on_config_saved()
|
||||
{
|
||||
log_v("on_config_saved");
|
||||
@@ -268,6 +271,8 @@ void setup()
|
||||
web_server.on("/restart", HTTP_GET, handle_restart);
|
||||
// Camera snapshot
|
||||
web_server.on("/snapshot", handle_snapshot);
|
||||
// Camera flash light
|
||||
web_server.on("/flash", HTTP_GET, handle_flash);
|
||||
|
||||
// bootstrap
|
||||
web_server.on("/bootstrap.min.css", HTTP_GET, []()
|
||||
|
||||
Reference in New Issue
Block a user