Porting arduino-esp32 CameraWebServer to https
Describe Your Goal Running the standard ESP32 CameraWebServer example on an https webserver.
What Does Your Project Look Like The same as the official example except including esp_https_server instead of esp_http_server and changes in startCameraServer(), see below.
ESP32 Module TTGO Camera Plus
Software (please complete the following information if applicable)
- Visual Studio Code with latest Arduino Core and PlatformIO
Additional context
To run the CameraWebServer on https, I have changed the startCameraServer() function as follows:
void startCameraServer(){
#ifndef _ESP_HTTPS_SERVER_H_
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
#else
httpd_ssl_config config = HTTPD_SSL_CONFIG_DEFAULT();
config.cacert_len = cert->getCertLength();
config.cacert_pem = cert->getCertData();
config.prvtkey_len = cert->getPKLength();
config.prvtkey_pem = cert->getPKData();
#endif
httpd_uri_t index_uri = { .uri = "/", .method = HTTP_GET, .handler = index_handler, .user_ctx = NULL };
httpd_uri_t status_uri = { .uri = "/status", .method = HTTP_GET, .handler = status_handler, .user_ctx = NULL };
httpd_uri_t cmd_uri = { .uri = "/control", .method = HTTP_GET, .handler = cmd_handler, .user_ctx = NULL };
httpd_uri_t capture_uri = { .uri = "/capture", .method = HTTP_GET, .handler = capture_handler, .user_ctx = NULL };
httpd_uri_t stream_uri = { .uri = "/stream", .method = HTTP_GET, .handler = stream_handler, .user_ctx = NULL };
ra_filter_init(&ra_filter, 20);
mtmn_config.type = FAST;
mtmn_config.min_face = 80;
mtmn_config.pyramid = 0.707;
mtmn_config.pyramid_times = 4;
mtmn_config.p_threshold.score = 0.6;
mtmn_config.p_threshold.nms = 0.7;
mtmn_config.p_threshold.candidate_number = 20;
mtmn_config.r_threshold.score = 0.7;
mtmn_config.r_threshold.nms = 0.7;
mtmn_config.r_threshold.candidate_number = 10;
mtmn_config.o_threshold.score = 0.7;
mtmn_config.o_threshold.nms = 0.7;
mtmn_config.o_threshold.candidate_number = 1;
face_id_init(&id_list, FACE_ID_SAVE_NUMBER, ENROLL_CONFIRM_TIMES);
#ifndef _ESP_HTTPS_SERVER_H_
Serial.printf("Starting web server on port: '%d'\n", config.server_port);
if (httpd_start(&camera_httpd, &config) == ESP_OK) {
#else
Serial.printf("Starting web server on port: '%d'\n", config.port_secure);
if (httpd_ssl_start(&camera_httpd, &config) == ESP_OK) {
#endif
httpd_register_uri_handler(camera_httpd, &index_uri);
httpd_register_uri_handler(camera_httpd, &cmd_uri);
httpd_register_uri_handler(camera_httpd, &status_uri);
httpd_register_uri_handler(camera_httpd, &capture_uri);
}
#ifndef _ESP_HTTPS_SERVER_H_
config.server_port += 1;
config.ctrl_port += 1;
Serial.printf("Starting stream server on port: '%d'\n", config.server_port);
if (httpd_start(&stream_httpd, &config) == ESP_OK) {
#else
config.port_secure += 1;
config.httpd.ctrl_port += 1;
Serial.printf("Starting stream server on port: '%d'\n", config.port_secure);
if (httpd_ssl_start(&stream_httpd, &config) == ESP_OK) {
#endif
httpd_register_uri_handler(stream_httpd, &stream_uri);
}
}
If I include esp_http_server.h the original code will compile and everything runs fine. If I include esp_https_server.h my changes will compile and the webserver nicely comes up at port 443. The menu shows and I can get a still from the camera. The only thing that doesn't work is what it's all about: the live stream. The window shows but only with a broken image icon. I see no messages in the terminal window in PlatformIO or anything in the browser.
Any ideas how to get this working?
@jov58: This is probably not the correct forum to ask about this, as you are using the web server library from Espressif. This repository is for a completely different HTTP server with a totally different API.
My current project is to port that camera example to this web server (issue #138), but I haven't quite gotten it to work yet.
@jov58: I think this is where you would want to ask your question: https://github.com/espressif/arduino-esp32/tree/master/libraries/WebServer