|
@@ -564,53 +564,59 @@ esp_err_t img_tmp_handler(httpd_req_t *req)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+static esp_err_t raw_jpg_capture_worker(httpd_req_t *req)
|
|
|
|
|
+{
|
|
|
|
|
+ bool previewCapture = false;
|
|
|
|
|
+ char query[64] = "";
|
|
|
|
|
+ char preview[8] = "";
|
|
|
|
|
+ if (httpd_req_get_url_query_str(req, query, sizeof(query)) == ESP_OK &&
|
|
|
|
|
+ httpd_query_key_value(query, "preview", preview, sizeof(preview)) == ESP_OK)
|
|
|
|
|
+ {
|
|
|
|
|
+ previewCapture = (strcmp(preview, "1") == 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ return GetRawJPG(req, previewCapture);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
esp_err_t img_tmp_virtual_handler(httpd_req_t *req)
|
|
esp_err_t img_tmp_virtual_handler(httpd_req_t *req)
|
|
|
{
|
|
{
|
|
|
- #ifdef DEBUG_DETAIL_ON
|
|
|
|
|
- LogFile.WriteHeapInfo("img_tmp_virtual_handler - Start");
|
|
|
|
|
- #endif
|
|
|
|
|
|
|
+#ifdef DEBUG_DETAIL_ON
|
|
|
|
|
+ LogFile.WriteHeapInfo("img_tmp_virtual_handler - Start");
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
char filepath[50];
|
|
char filepath[50];
|
|
|
-
|
|
|
|
|
ESP_LOGD(TAG, "uri: %s", req->uri);
|
|
ESP_LOGD(TAG, "uri: %s", req->uri);
|
|
|
|
|
|
|
|
char *base_path = (char*) req->user_ctx;
|
|
char *base_path = (char*) req->user_ctx;
|
|
|
- std::string filetosend(base_path);
|
|
|
|
|
-
|
|
|
|
|
const char *filename = get_path_from_uri(filepath, base_path,
|
|
const char *filename = get_path_from_uri(filepath, base_path,
|
|
|
- req->uri + sizeof("/img_tmp/") - 1, sizeof(filepath));
|
|
|
|
|
- ESP_LOGD(TAG, "1 uri: %s, filename: %s, filepath: %s", req->uri, filename, filepath);
|
|
|
|
|
|
|
+ req->uri + sizeof("/img_tmp/") - 1, sizeof(filepath));
|
|
|
|
|
+ if (filename == NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ httpd_resp_send_err(req, HTTPD_414_URI_TOO_LONG, "Filename too long");
|
|
|
|
|
+ return ESP_FAIL;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- filetosend = std::string(filename);
|
|
|
|
|
- ESP_LOGD(TAG, "File to upload: %s", filetosend.c_str());
|
|
|
|
|
|
|
+ const std::string fileName(filename);
|
|
|
|
|
+ ESP_LOGD(TAG, "File to upload: %s", fileName.c_str());
|
|
|
|
|
|
|
|
- // Only the test_take URL opts into temporary preview settings.
|
|
|
|
|
- if (filetosend == "raw.jpg")
|
|
|
|
|
|
|
+ // A raw camera capture can take several seconds. Keep it off the single
|
|
|
|
|
+ // HTTP server task so status, log and static-file requests remain responsive.
|
|
|
|
|
+ if (fileName == "raw.jpg")
|
|
|
{
|
|
{
|
|
|
- bool previewCapture = false;
|
|
|
|
|
- char query[64] = "";
|
|
|
|
|
- char preview[8] = "";
|
|
|
|
|
- if (httpd_req_get_url_query_str(req, query, sizeof(query)) == ESP_OK &&
|
|
|
|
|
- httpd_query_key_value(query, "preview", preview, sizeof(preview)) == ESP_OK)
|
|
|
|
|
- {
|
|
|
|
|
- previewCapture = (strcmp(preview, "1") == 0);
|
|
|
|
|
- }
|
|
|
|
|
- return GetRawJPG(req, previewCapture);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return dispatch_camera_http_request_async(req, raw_jpg_capture_worker, "raw capture");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // Serve alg.jpg, alg_roi.jpg or digit and analog ROIs
|
|
|
|
|
- if (ESP_OK == GetJPG(filetosend, req))
|
|
|
|
|
|
|
+ // Serve alg.jpg, alg_roi.jpg or digit and analog ROIs.
|
|
|
|
|
+ if (ESP_OK == GetJPG(fileName, req))
|
|
|
return ESP_OK;
|
|
return ESP_OK;
|
|
|
|
|
|
|
|
- #ifdef DEBUG_DETAIL_ON
|
|
|
|
|
- LogFile.WriteHeapInfo("img_tmp_virtual_handler - Done");
|
|
|
|
|
- #endif
|
|
|
|
|
|
|
+#ifdef DEBUG_DETAIL_ON
|
|
|
|
|
+ LogFile.WriteHeapInfo("img_tmp_virtual_handler - Done");
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
- // File was not served already --> serve with img_tmp_handler
|
|
|
|
|
|
|
+ // File was not served already --> serve img_tmp file.
|
|
|
return img_tmp_handler(req);
|
|
return img_tmp_handler(req);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
esp_err_t sysinfo_handler(httpd_req_t *req)
|
|
esp_err_t sysinfo_handler(httpd_req_t *req)
|
|
|
{
|
|
{
|
|
|
// Take one snapshot of resource and card information for this response.
|
|
// Take one snapshot of resource and card information for this response.
|