added WEB api
parent
a82fa2e48c
commit
7ff7fb06f5
|
|
@ -428,6 +428,52 @@ void Server_InitWebServer_Actions() {
|
||||||
request->send_P(200, "text/plain", "Change LED status");
|
request->send_P(200, "text/plain", "Change LED status");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* route for change LED status */
|
||||||
|
server.on("/light", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||||
|
SystemLog.AddEvent(LogLevel_Verbose, F("WEB server: /light set LED status"));
|
||||||
|
if (Server_CheckBasicAuth(request) == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (request->hasArg("on")) {
|
||||||
|
SystemLog.AddEvent(LogLevel_Verbose, F("Turning light ON"));
|
||||||
|
SystemCamera.SetFlashStatus(true);
|
||||||
|
SystemCamera.SetCameraFlashEnable(false);
|
||||||
|
request->send_P(200, "text/plain", "Light ON");
|
||||||
|
|
||||||
|
} else if (request->hasArg("off")) {
|
||||||
|
SystemLog.AddEvent(LogLevel_Verbose, F("Turning light OFF"));
|
||||||
|
SystemCamera.SetFlashStatus(false);
|
||||||
|
SystemCamera.SetCameraFlashEnable(false);
|
||||||
|
request->send_P(200, "text/plain", "Light OFF");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
request->send_P(400, "text/plain", "Invalid request");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/* route for change FLASH status */
|
||||||
|
server.on("/flash", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||||
|
SystemLog.AddEvent(LogLevel_Verbose, F("WEB server: /flash set flash status"));
|
||||||
|
if (Server_CheckBasicAuth(request) == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (request->hasArg("on")) {
|
||||||
|
SystemLog.AddEvent(LogLevel_Verbose, F("Turning flash ON"));
|
||||||
|
SystemCamera.SetCameraFlashEnable(true);
|
||||||
|
SystemCamera.SetFlashStatus(false);
|
||||||
|
request->send_P(200, "text/plain", "Flash ON");
|
||||||
|
|
||||||
|
} else if (request->hasArg("off")) {
|
||||||
|
SystemLog.AddEvent(LogLevel_Verbose, F("Turning flash OFF"));
|
||||||
|
SystemCamera.SetCameraFlashEnable(false);
|
||||||
|
SystemCamera.SetFlashStatus(false);
|
||||||
|
request->send_P(200, "text/plain", "Flash OFF");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
request->send_P(400, "text/plain", "Invalid request");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/* reboot MCU */
|
/* reboot MCU */
|
||||||
server.on("/action_reboot", HTTP_GET, [](AsyncWebServerRequest* request) {
|
server.on("/action_reboot", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||||
SystemLog.AddEvent(LogLevel_Verbose, F("WEB server: /action_reboo reboot MCU!"));
|
SystemLog.AddEvent(LogLevel_Verbose, F("WEB server: /action_reboo reboot MCU!"));
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ void Camera::Init() {
|
||||||
|
|
||||||
log->AddEvent(LogLevel_Info, F("Init GPIO"));
|
log->AddEvent(LogLevel_Info, F("Init GPIO"));
|
||||||
ledcAttach(FLASH_GPIO_NUM, FLASH_PWM_FREQ, FLASH_PWM_RESOLUTION);
|
ledcAttach(FLASH_GPIO_NUM, FLASH_PWM_FREQ, FLASH_PWM_RESOLUTION);
|
||||||
ledcWrite(FLASH_GPIO_NUM, FLASH_OFF_STATUS);
|
SetFlashStatus(false);
|
||||||
|
|
||||||
InitCameraModule();
|
InitCameraModule();
|
||||||
ApplyCameraCfg();
|
ApplyCameraCfg();
|
||||||
|
|
@ -117,7 +117,6 @@ void Camera::InitCameraModule() {
|
||||||
|
|
||||||
/* Camera init */
|
/* Camera init */
|
||||||
err = esp_camera_init(&CameraConfig);
|
err = esp_camera_init(&CameraConfig);
|
||||||
|
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
log->AddEvent(LogLevel_Warning, F("Camera init failed. Error: "), String(err, HEX));
|
log->AddEvent(LogLevel_Warning, F("Camera init failed. Error: "), String(err, HEX));
|
||||||
log->AddEvent(LogLevel_Warning, F("Reset ESP32-cam!"));
|
log->AddEvent(LogLevel_Warning, F("Reset ESP32-cam!"));
|
||||||
|
|
@ -333,7 +332,7 @@ void Camera::CapturePhoto() {
|
||||||
CameraCaptureSuccess = false;
|
CameraCaptureSuccess = false;
|
||||||
/* check flash, and enable FLASH LED */
|
/* check flash, and enable FLASH LED */
|
||||||
if (true == CameraFlashEnable) {
|
if (true == CameraFlashEnable) {
|
||||||
ledcWrite(FLASH_GPIO_NUM, FLASH_ON_STATUS);
|
SetFlashStatus(true);
|
||||||
delay(CameraFlashTime);
|
delay(CameraFlashTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -401,8 +400,7 @@ void Camera::CapturePhoto() {
|
||||||
|
|
||||||
/* Disable flash */
|
/* Disable flash */
|
||||||
if (true == CameraFlashEnable) {
|
if (true == CameraFlashEnable) {
|
||||||
//delay(CameraFlashTime);
|
SetFlashStatus(false);
|
||||||
ledcWrite(FLASH_GPIO_NUM, FLASH_OFF_STATUS);
|
|
||||||
}
|
}
|
||||||
xSemaphoreGive(frameBufferSemaphore);
|
xSemaphoreGive(frameBufferSemaphore);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,14 @@
|
||||||
|
/**
|
||||||
|
@file connect_types.h
|
||||||
|
|
||||||
|
@brief Here are defined types for communication with prusa connect backend
|
||||||
|
|
||||||
|
@author Miroslav Pivovarsky
|
||||||
|
Contact: miroslav.pivovarsky@gmail.com
|
||||||
|
|
||||||
|
@bug: no know bug
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
//#define ESP32_WROVER_DEV
|
//#define ESP32_WROVER_DEV
|
||||||
|
|
||||||
/* ---------------- BASIC MCU CFG --------------*/
|
/* ---------------- BASIC MCU CFG --------------*/
|
||||||
#define SW_VERSION "1.0.3" ///< SW version
|
#define SW_VERSION "1.1.0-rc1" ///< SW version
|
||||||
#define SW_BUILD __DATE__ " " __TIME__ ///< build number
|
#define SW_BUILD __DATE__ " " __TIME__ ///< build number
|
||||||
#define CONSOLE_VERBOSE_DEBUG false ///< enable/disable verbose debug log level for console
|
#define CONSOLE_VERBOSE_DEBUG false ///< enable/disable verbose debug log level for console
|
||||||
#define DEVICE_HOSTNAME "Prusa-ESP32cam" ///< device hostname
|
#define DEVICE_HOSTNAME "Prusa-ESP32cam" ///< device hostname
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue