forked from external-repos/esp32cam-rtsp
- Added basic auth to restart and LED
- GUI: show IP address instead of hostname.local
This commit is contained in:
20
README.md
20
README.md
@@ -172,26 +172,32 @@ This link can be opened with for example [VLC](https://www.videolan.org/vlc/).
|
|||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
There is a minimum API present to perform some tasks using HTTP requests.
|
There is a minimum API present to perform some tasks using HTTP requests. For some requests authentication is required.
|
||||||
|
The authentication used is basic authentication. The user is always admin and the password the access point key.\
|
||||||
|
If using a browser, remember that the authentication is stored in the browser session so needs to be entered only once.
|
||||||
|
|
||||||
The URLs are below:
|
The URLs are below:
|
||||||
|
|
||||||
### GET: /restart
|
### GET: /restart
|
||||||
|
|
||||||
Calling this URL will restart the device.
|
Calling this URL will restart the device. Authentication is required.
|
||||||
|
|
||||||
### GET: /config
|
### GET: /config
|
||||||
|
|
||||||
Calling this URL will start the form for configuring the device in the browser.
|
Calling this URL will start the form for configuring the device in the browser. Authentication is required.
|
||||||
|
|
||||||
### GET: /snapshot
|
### GET: /snapshot
|
||||||
|
|
||||||
Calling this URL will return a JPEG snapshot of the camera in the browser.
|
Calling this URL will return a JPEG snapshot of the camera in the browser.
|
||||||
|
|
||||||
### GET: /flash?v={value}
|
This request can also be used (for example using cURL) to save the snapshot to a file.
|
||||||
|
|
||||||
Calling this URL will set the intensity of the flash LED.
|
### GET: /flash?v={intensity}
|
||||||
The values must for {value} must be between 0 and 255.
|
|
||||||
If no v parameter is present, it will be set to the value of the configuration.
|
Calling this URL will set the intensity of the flash LED. Authentication is required.
|
||||||
|
|
||||||
|
The parameter v for the intensity must be between 0 (off) and 255 (max).
|
||||||
|
If no v parameter is present, it will be set to the value of the flash LED intensity from configuration.
|
||||||
|
|
||||||
## Issues / Nice to know
|
## Issues / Nice to know
|
||||||
|
|
||||||
|
|||||||
@@ -182,26 +182,27 @@
|
|||||||
<span>
|
<span>
|
||||||
The camera RTSP stream can be found at:
|
The camera RTSP stream can be found at:
|
||||||
<a
|
<a
|
||||||
href="rtsp://{{IpV4}}:{{RtspPort}}/mjpeg/1">rtsp://{{HostName}}:{{RtspPort}}/mjpeg/1</a>
|
href="rtsp://{{IpV4}}:{{RtspPort}}/mjpeg/1">rtsp://{{IpV4}}:{{RtspPort}}/mjpeg/1</a>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<span>
|
<span>
|
||||||
A snapshot of the camera can be found at:
|
A snapshot of the camera can be found at:
|
||||||
<a href="http://{{IpV4}}/snapshot">http://{{HostName}}/snapshot</a>
|
<a href="http://{{IpV4}}/snapshot">http://{{IpV4}}/snapshot</a>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<span>
|
<span>
|
||||||
The intensity of the flash led (0-255) can be controlled using:
|
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>.
|
<a href="http://{{IpV4}}/flash?v=0">http://{{IpV4}}/flash?v=value</a>.
|
||||||
If no value is present, the configuration value is used.
|
Authentication is required and if no value is present, the configuration value is used.
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<span>
|
<span>
|
||||||
Restarting the camera can be done using:
|
Restarting the camera can be done using:
|
||||||
<a href="http://{{IpV4}}/restart">http://{{HostName}}/restart</a>
|
<a href="http://{{IpV4}}/restart">http://{{IpV4}}/restart</a>.
|
||||||
|
Authentication is required.
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
13
src/main.cpp
13
src/main.cpp
@@ -122,6 +122,12 @@ void handle_restart()
|
|||||||
{
|
{
|
||||||
log_v("Handle restart");
|
log_v("Handle restart");
|
||||||
|
|
||||||
|
if (!web_server.authenticate("admin", iotWebConf.getApPasswordParameter()->valueBuffer))
|
||||||
|
{
|
||||||
|
web_server.requestAuthentication();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const moustache_variable_t substitutions[] = {
|
const moustache_variable_t substitutions[] = {
|
||||||
{"AppTitle", APP_TITLE},
|
{"AppTitle", APP_TITLE},
|
||||||
{"AppVersion", APP_VERSION},
|
{"AppVersion", APP_VERSION},
|
||||||
@@ -161,6 +167,13 @@ void handle_snapshot()
|
|||||||
void handle_flash()
|
void handle_flash()
|
||||||
{
|
{
|
||||||
log_v("handle_flash");
|
log_v("handle_flash");
|
||||||
|
|
||||||
|
if (!web_server.authenticate("admin", iotWebConf.getApPasswordParameter()->valueBuffer))
|
||||||
|
{
|
||||||
|
web_server.requestAuthentication();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If no value present, use value from config
|
// If no value present, use value from config
|
||||||
auto value = web_server.hasArg("v") ? web_server.arg("v") : flash_led_intensity_val;
|
auto value = web_server.hasArg("v") ? web_server.arg("v") : flash_led_intensity_val;
|
||||||
// If conversion fails, v = 0
|
// If conversion fails, v = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user