mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-06-06 02:36:49 +08:00
Add Camera streaming server
add ESP command 170/171/172 apply astyle add flag to distinguish websocket terminal vs data
This commit is contained in:
parent
ccb441892a
commit
cb726b51d5
@ -61,7 +61,7 @@
|
||||
#define DISPLAY_UI_COLOR UI_COLORED
|
||||
|
||||
//BUZZER_DEVICE: allow to connect passive buzzer
|
||||
#define BUZZER_DEVICE
|
||||
//#define BUZZER_DEVICE
|
||||
|
||||
|
||||
#if defined (DISPLAY_DEVICE)
|
||||
@ -115,7 +115,7 @@
|
||||
#define DIRECT_PIN_FEATURE
|
||||
|
||||
//TIMESTAMP_FEATURE: set time system
|
||||
#define TIMESTAMP_FEATURE
|
||||
//#define TIMESTAMP_FEATURE
|
||||
|
||||
//FILESYSTEM_TIMESTAMP_FEATURE: allow to get last write time from FILESYSTEM files
|
||||
//#define FILESYSTEM_TIMESTAMP_FEATURE
|
||||
@ -132,7 +132,7 @@
|
||||
#define CAPTIVE_PORTAL_FEATURE
|
||||
|
||||
//OTA_FEATURE: this feature is arduino update over the air
|
||||
#define OTA_FEATURE
|
||||
//#define OTA_FEATURE
|
||||
|
||||
//WEB_UPDATE_FEATURE: allow to flash fw using web UI
|
||||
#define WEB_UPDATE_FEATURE
|
||||
@ -140,6 +140,18 @@
|
||||
//NOTIFICATION_FEATURE : allow to push notifications
|
||||
#define NOTIFICATION_FEATURE
|
||||
|
||||
//CAMERA_DEVICE: Enable the support of connected camera
|
||||
//CAMERA_MODEL_CUSTOM 0 //Edit the pins in include/pins.h
|
||||
//CAMERA_MODEL_ESP_EYE 1
|
||||
//CAMERA_MODEL_M5STACK_PSRAM 2
|
||||
//CAMERA_MODEL_M5STACK_WIDE 3
|
||||
//CAMERA_MODEL_AI_THINKER 4 e.g. used by ESP32-CAM
|
||||
//CAMERA_MODEL_WROVER_KIT 5
|
||||
#define CAMERA_DEVICE CAMERA_MODEL_AI_THINKER
|
||||
//#define CAMERA_DEVICE_FLIP_VERTICALY //comment to disable
|
||||
//#define CAMERA_DEVICE_FLIP_HORIZONTALY//comment to disable
|
||||
#define CUSTOM_CAMERA_NAME "ESP32-CAM"
|
||||
|
||||
//Extra features /////////////////////////////////////////////////////////////////////////
|
||||
/************************************
|
||||
*
|
||||
|
@ -113,6 +113,50 @@ int Commands::get_space_pos(const char * string, uint from)
|
||||
return -1;
|
||||
}
|
||||
|
||||
//return first label but pwd using labelseparator (usualy =) like mylabel=myvalue will return mylabel
|
||||
const char* Commands::get_label (const char * cmd_params, const char * labelseparator, uint8_t startindex)
|
||||
{
|
||||
static String res;
|
||||
String tmp = "";
|
||||
res = "";
|
||||
int start = 1;
|
||||
int end = -1;
|
||||
res = cmd_params;
|
||||
res.replace("\r ", "");
|
||||
res.replace("\n ", "");
|
||||
res.trim();
|
||||
if ((res.length() == 0) || (startindex >=res.length())) {
|
||||
return res.c_str();
|
||||
}
|
||||
|
||||
if (strlen(labelseparator) > 0) {
|
||||
end = res.indexOf(labelseparator, startindex);
|
||||
if (end == -1) {
|
||||
return "";
|
||||
}
|
||||
start = end;
|
||||
for (int8_t p = end; p >= startindex ; p--, start--) {
|
||||
if (res[p]==' ') {
|
||||
p = -1;
|
||||
start+=2;
|
||||
}
|
||||
}
|
||||
if(start==-1) {
|
||||
start=0;
|
||||
}
|
||||
if (start > end) {
|
||||
return "";
|
||||
}
|
||||
tmp = res.substring(start,end);
|
||||
if (tmp == "pwd") {
|
||||
res = get_label (cmd_params, labelseparator,end+1);
|
||||
} else {
|
||||
res = tmp;
|
||||
}
|
||||
}
|
||||
return res.c_str();
|
||||
}
|
||||
|
||||
//extract parameter with corresponding label
|
||||
//if label is empty give whole line without authentication label/parameter
|
||||
const char * Commands::get_param (const char * cmd_params, const char * label)
|
||||
@ -126,10 +170,11 @@ const char * Commands::get_param (const char * cmd_params, const char * label)
|
||||
res = cmd_params;
|
||||
res.replace("\r ", "");
|
||||
res.replace("\n ", "");
|
||||
res.trim();
|
||||
if (res.length() == 0) {
|
||||
return res.c_str();
|
||||
}
|
||||
res.trim();
|
||||
|
||||
tmp = " " + res;
|
||||
slabel += label;
|
||||
if (strlen(label) > 0) {
|
||||
@ -339,6 +384,19 @@ bool Commands::execute_internal_command (int cmd, const char* cmd_params, level_
|
||||
response = ESP161(cmd_params, auth_type, output);
|
||||
break;
|
||||
#endif //WS_DATA_FEATURE
|
||||
#ifdef CAMERA_DEVICE
|
||||
//Set carmera server state which can be ON, OFF
|
||||
//[ESP170]<state>pwd=<admin password>
|
||||
case 170:
|
||||
response = ESP170(cmd_params, auth_type, output);
|
||||
break;
|
||||
case 171:
|
||||
response = ESP171(cmd_params, auth_type, output);
|
||||
break;
|
||||
case 172:
|
||||
response = ESP172(cmd_params, auth_type, output);
|
||||
break;
|
||||
#endif //CAMERA_DEVICE
|
||||
#ifdef DIRECT_PIN_FEATURE
|
||||
//Get/Set pin value
|
||||
//[ESP201]P<pin> V<value> [PULLUP=YES RAW=YES]pwd=<admin password>
|
||||
@ -456,7 +514,7 @@ bool Commands::execute_internal_command (int cmd, const char* cmd_params, level_
|
||||
//Action on ESP Filesystem
|
||||
//rmdir / remove / mkdir / exists
|
||||
//[ESP730]<Action>=<path> pwd=<admin password>
|
||||
case 730:
|
||||
case 730:
|
||||
response = ESP730(cmd_params, auth_type, output);
|
||||
break;
|
||||
#endif //FILESYSTEM_FEATURE
|
||||
|
@ -34,6 +34,7 @@ public:
|
||||
bool execute_internal_command(int cmd, const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
int get_space_pos(const char * string, uint from = 0);
|
||||
const char* get_param (const char * cmd_params, const char * label);
|
||||
const char* get_label (const char * cmd_params, const char * labelseparator, uint8_t startindex = 0);
|
||||
bool hastag (const char * cmd_params, const char * tag);
|
||||
#if defined (WIFI_FEATURE)
|
||||
bool ESP100(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
@ -75,6 +76,11 @@ public:
|
||||
bool ESP160(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP161(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //WS_DATA_FEATURE
|
||||
#if defined(CAMERA_DEVICE)
|
||||
bool ESP170(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP171(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
bool ESP172(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //CAMERA_DEVICE
|
||||
#ifdef DIRECT_PIN_FEATURE
|
||||
bool ESP201(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||
#endif //DIRECT_PIN_FEATURE
|
||||
|
@ -171,6 +171,6 @@ void Esp3D::restart_now()
|
||||
ESP.restart();
|
||||
while (1) {
|
||||
delay (1);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
69
esp3d/src/core/espcmd/ESP170.cpp
Normal file
69
esp3d/src/core/espcmd/ESP170.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
ESP170.cpp - ESP3D command class
|
||||
|
||||
Copyright (c) 2014 Luc Lebosse. All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#include "../../include/esp3d_config.h"
|
||||
#if defined (CAMERA_DEVICE)
|
||||
#include "../commands.h"
|
||||
#include "../esp3doutput.h"
|
||||
#include "../settings_esp3d.h"
|
||||
#include "../../modules/authentication/authentication_service.h"
|
||||
#include "../../modules/network/netservices.h"
|
||||
#include "../../modules/camera/camera.h"
|
||||
//Set carmera server state which can be ON, OFF
|
||||
//[ESP170]<state>pwd=<admin password>
|
||||
bool Commands::ESP170(const char* cmd_params, level_authenticate_type auth_type, ESP3DOutput * output)
|
||||
{
|
||||
bool response = true;
|
||||
String parameter;
|
||||
#ifdef AUTHENTICATION_FEATURE
|
||||
if (auth_type == LEVEL_GUEST) {
|
||||
output->printERROR("Wrong authentication!", 401);
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
(void)auth_type;
|
||||
#endif //AUTHENTICATION_FEATURE
|
||||
parameter = get_param (cmd_params, "");
|
||||
//get
|
||||
if (parameter.length() == 0) {
|
||||
output->printMSG(!esp3d_camera.started()?"Camera OFF":"Camera ON");
|
||||
} else { //set
|
||||
#ifdef AUTHENTICATION_FEATURE
|
||||
if (auth_type != LEVEL_ADMIN) {
|
||||
output->printERROR("Wrong authentication!", 401);
|
||||
return false;
|
||||
}
|
||||
#endif //AUTHENTICATION_FEATURE
|
||||
parameter.toUpperCase();
|
||||
if (!((parameter == "ON") || (parameter == "OFF"))) {
|
||||
output->printERROR("Only ON or OFF mode supported!");
|
||||
return false;
|
||||
} else {
|
||||
if (parameter == "ON") {
|
||||
esp3d_camera.begin();
|
||||
} else {
|
||||
esp3d_camera.end();
|
||||
}
|
||||
output->printMSG ("ok");
|
||||
}
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
#endif //HTTP_FEATURE && CAMERA_DEVICE
|
66
esp3d/src/core/espcmd/ESP171.cpp
Normal file
66
esp3d/src/core/espcmd/ESP171.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
ESP171.cpp - ESP3D command class
|
||||
|
||||
Copyright (c) 2014 Luc Lebosse. All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#include "../../include/esp3d_config.h"
|
||||
#if defined (CAMERA_DEVICE)
|
||||
#include "../commands.h"
|
||||
#include "../esp3doutput.h"
|
||||
#include "../settings_esp3d.h"
|
||||
#include "../../modules/authentication/authentication_service.h"
|
||||
//Set Camera port
|
||||
//[ESP171]<port>pwd=<admin password>
|
||||
bool Commands::ESP171(const char* cmd_params, level_authenticate_type auth_type, ESP3DOutput * output)
|
||||
{
|
||||
bool response = true;
|
||||
String parameter;
|
||||
#ifdef AUTHENTICATION_FEATURE
|
||||
if (auth_type == LEVEL_GUEST) {
|
||||
output->printERROR("Wrong authentication!", 401);
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
(void)auth_type;
|
||||
#endif //AUTHENTICATION_FEATURE
|
||||
parameter = get_param (cmd_params, "");
|
||||
//get
|
||||
if (parameter.length() == 0) {
|
||||
output->printMSG(String(Settings_ESP3D::read_uint32(ESP_CAMERA_PORT)).c_str());
|
||||
} else { //set
|
||||
#ifdef AUTHENTICATION_FEATURE
|
||||
if (auth_type != LEVEL_ADMIN) {
|
||||
output->printERROR("Wrong authentication!", 401);
|
||||
return false;
|
||||
}
|
||||
#endif //AUTHENTICATION_FEATURE
|
||||
uint ibuf = parameter.toInt();
|
||||
if ((ibuf > Settings_ESP3D::get_max_int32_value(ESP_CAMERA_PORT)) || (ibuf < Settings_ESP3D::get_min_int32_value(ESP_CAMERA_PORT))) {
|
||||
output->printERROR ("Incorrect port!");
|
||||
return false;
|
||||
}
|
||||
if (!Settings_ESP3D::write_uint32 (ESP_CAMERA_PORT, ibuf)) {
|
||||
output->printERROR ("Set failed!");
|
||||
response = false;
|
||||
} else {
|
||||
output->printMSG ("ok");
|
||||
}
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
#endif //CAMERA_DEVICE
|
503
esp3d/src/core/espcmd/ESP172.cpp
Normal file
503
esp3d/src/core/espcmd/ESP172.cpp
Normal file
@ -0,0 +1,503 @@
|
||||
/*
|
||||
ESP122.cpp - ESP3D command class
|
||||
|
||||
Copyright (c) 2014 Luc Lebosse. All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#include "../../include/esp3d_config.h"
|
||||
#if defined (CAMERA_DEVICE)
|
||||
#include "../commands.h"
|
||||
#include "../esp3doutput.h"
|
||||
#include "esp_camera.h"
|
||||
#include "../settings_esp3d.h"
|
||||
#include "../../modules/authentication/authentication_service.h"
|
||||
#include "../../modules/camera/camera.h"
|
||||
//Set Camera command value / list all values in JSON/plain
|
||||
//[ESP172]<plain><label=value> pwd=<admin password>
|
||||
bool Commands::ESP172(const char* cmd_params, level_authenticate_type auth_type, ESP3DOutput * output)
|
||||
{
|
||||
bool response = true;
|
||||
String parameter;
|
||||
#ifdef AUTHENTICATION_FEATURE
|
||||
if (auth_type == LEVEL_GUEST) {
|
||||
output->printERROR("Wrong authentication!", 401);
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
(void)auth_type;
|
||||
#endif //AUTHENTICATION_FEATURE
|
||||
parameter = get_param (cmd_params, "");
|
||||
//get
|
||||
bool plain = hastag (cmd_params, "plain");
|
||||
if ((parameter.length() == 0) || plain) {
|
||||
sensor_t * s = esp_camera_sensor_get();
|
||||
if (!plain) {
|
||||
output->print ("{");
|
||||
}
|
||||
//framesize
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("framesize");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.framesize);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//quality
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("quality");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.quality);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//brightness
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("brightness");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.brightness);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//contrast
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("contrast");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.contrast);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//saturation
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("saturation");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.saturation);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//sharpness
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("sharpness");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.sharpness);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//special_effect
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("special_effect");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.special_effect);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//wb_mode
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("wb_mode");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.wb_mode);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//awb
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("awb");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.awb);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//awb_gain
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("awb_gain");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.awb_gain);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//aec
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("aec");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.aec);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//aec2
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("aec2");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.aec2);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//ae_level
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("ae_level");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.ae_level);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//aec_value
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("aec_value");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.aec_value);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//agc
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("agc");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.agc);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//agc_gain
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("agc_gain");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.agc_gain);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//gainceiling
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("gainceiling");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.gainceiling);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//bpc
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("bpc");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.bpc);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//wpc
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("wpc");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.wpc);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//raw_gma
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("raw_gma");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.raw_gma);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//lenc
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("lenc");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.lenc);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//vflip
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("vflip");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.vflip);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//hmirror
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("hmirror");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.hmirror);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//dcw
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("dcw");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.dcw);
|
||||
if (!plain) {
|
||||
output->print ("\",");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//colorbar
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
}
|
||||
output->print ("colorbar");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (s->status.colorbar);
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
#if CAM_LED_PIN != -1
|
||||
//light
|
||||
if (!plain) {
|
||||
output->print (",\"");
|
||||
}
|
||||
output->print ("light");
|
||||
if (!plain) {
|
||||
output->print ("\":\"");
|
||||
} else {
|
||||
output->print (" : ");
|
||||
}
|
||||
output->print (digitalRead(CAM_LED_PIN)==HIGH?1:0);
|
||||
if (!plain) {
|
||||
output->print ("\"");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
#endif //CAM_LED_PIN
|
||||
if (!plain) {
|
||||
output->print ("}");
|
||||
}
|
||||
} else { //set
|
||||
#ifdef AUTHENTICATION_FEATURE
|
||||
if (auth_type != LEVEL_ADMIN) {
|
||||
output->printERROR("Wrong authentication!", 401);
|
||||
return false;
|
||||
}
|
||||
#endif //AUTHENTICATION_FEATURE
|
||||
String label = get_label (cmd_params, "=");
|
||||
if (label.length()==0) {
|
||||
output->printERROR("Missing command!");
|
||||
return false;
|
||||
}
|
||||
String labels = label+"=";
|
||||
String value = get_param (cmd_params,labels.c_str());
|
||||
if (value.length()==0) {
|
||||
output->printERROR("Invalid value!");
|
||||
return false;
|
||||
}
|
||||
int r = esp3d_camera.command(label.c_str(), value.c_str());
|
||||
if (r == -1) {
|
||||
output->printERROR("Unknow command!");
|
||||
response = false;
|
||||
} else if (r == 1) {
|
||||
output->printERROR("Invalid value!");
|
||||
response = false;
|
||||
} else {
|
||||
output->printMSG ("ok");
|
||||
}
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
#endif //CAMERA_DEVICE
|
@ -232,6 +232,19 @@ bool Commands::ESP400(const char* cmd_params, level_authenticate_type auth_type,
|
||||
output->printLN ("\"}");
|
||||
#endif //TELNET
|
||||
|
||||
#ifdef CAMERA_DEVICE
|
||||
//Camera Port
|
||||
output->print (",{\"F\":\"network\",\"P\":\"");
|
||||
output->print (ESP_CAMERA_PORT);
|
||||
output->print ("\",\"T\":\"I\",\"V\":\"");
|
||||
output->print (Settings_ESP3D::read_uint32(ESP_CAMERA_PORT));
|
||||
output->print ("\",\"H\":\"Camera Port\",\"S\":\"");
|
||||
output->print (Settings_ESP3D::get_max_int32_value(ESP_CAMERA_PORT));
|
||||
output->print ("\",\"M\":\"");
|
||||
output->print (Settings_ESP3D::get_min_int32_value(ESP_CAMERA_PORT));
|
||||
output->printLN ("\"}");
|
||||
#endif //CAMERA_DEVICE
|
||||
|
||||
#ifdef AUTHENTICATION_FEATURE
|
||||
//22-Admin password
|
||||
output->print (",{\"F\":\"network\",\"P\":\"");
|
||||
|
@ -22,6 +22,9 @@
|
||||
#include "../esp3doutput.h"
|
||||
#include "../settings_esp3d.h"
|
||||
#include "../../modules/authentication/authentication_service.h"
|
||||
#ifdef CAMERA_DEVICE
|
||||
#include "../../modules/camera/camera.h"
|
||||
#endif //CAMERA_DEVICE
|
||||
#ifdef DHT_DEVICE
|
||||
#include "../../modules/dht/dht.h"
|
||||
#endif //DHT_DEVICE
|
||||
@ -111,6 +114,11 @@ bool Commands::ESP401(const char* cmd_params, level_authenticate_type auth_type,
|
||||
esp3d_DHT.setInterval(sval.toInt());
|
||||
break;
|
||||
#endif //DHT_DEVICE
|
||||
#ifdef CAMERA_DEVICE
|
||||
case ESP_CAMERA_PORT:
|
||||
//esp3d_camera.begin();
|
||||
break;
|
||||
#endif //CAMERA_DEVICE
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -59,6 +59,9 @@
|
||||
#ifdef BUZZER_DEVICE
|
||||
#include "../../modules/buzzer/buzzer.h"
|
||||
#endif //BUZZER_DEVICE
|
||||
#ifdef CAMERA_DEVICE
|
||||
#include "../../modules/camera/camera.h"
|
||||
#endif //CAMERA_DEVICE
|
||||
|
||||
//Get ESP current status
|
||||
//output is JSON or plain text according parameter
|
||||
@ -415,6 +418,43 @@ bool Commands::ESP420(const char* cmd_params, level_authenticate_type auth_type,
|
||||
}
|
||||
}
|
||||
#endif //WS_DATA_FEATURE
|
||||
#if defined (CAMERA_DEVICE)
|
||||
if (esp3d_camera.started()) {
|
||||
//camera name
|
||||
if (!plain) {
|
||||
output->print (",{\"id\":\"");
|
||||
}
|
||||
output->print ("camera name");
|
||||
if (!plain) {
|
||||
output->print ("\",\"value\":\"");
|
||||
} else {
|
||||
output->print (": ");
|
||||
}
|
||||
output->printf ("%s(%d)",esp3d_camera.GetModelString(),esp3d_camera.GetModel());
|
||||
if (!plain) {
|
||||
output->print ("\"}");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
//camera port
|
||||
if (!plain) {
|
||||
output->print (",{\"id\":\"");
|
||||
}
|
||||
output->print ("camera ports");
|
||||
if (!plain) {
|
||||
output->print ("\",\"value\":\"");
|
||||
} else {
|
||||
output->print (": ");
|
||||
}
|
||||
output->printf ("%d - %d",esp3d_camera.port(), esp3d_camera.port()+1);
|
||||
if (!plain) {
|
||||
output->print ("\"}");
|
||||
} else {
|
||||
output->printLN("");
|
||||
}
|
||||
}
|
||||
#endif //CAMERA_DEVICE
|
||||
|
||||
#if defined (BLUETOOTH_FEATURE)
|
||||
if (bt_service.started()) {
|
||||
//BT mode
|
||||
|
@ -42,42 +42,42 @@ bool Commands::ESP730(const char* cmd_params, level_authenticate_type auth_type,
|
||||
#endif //AUTHENTICATION_FEATURE
|
||||
parameter = get_param (cmd_params, "mkdir=");
|
||||
if (parameter.length() != 0) {
|
||||
if (ESP_FileSystem::mkdir(parameter.c_str())) {
|
||||
output->printMSG ("ok");
|
||||
} else {
|
||||
output->printERROR ("failed!");
|
||||
response = false;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
if (ESP_FileSystem::mkdir(parameter.c_str())) {
|
||||
output->printMSG ("ok");
|
||||
} else {
|
||||
output->printERROR ("failed!");
|
||||
response = false;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
parameter = get_param (cmd_params, "rmdir=");
|
||||
if (parameter.length() != 0) {
|
||||
if (ESP_FileSystem::rmdir(parameter.c_str())) {
|
||||
output->printMSG ("ok");
|
||||
} else {
|
||||
output->printERROR ("failed!");
|
||||
response = false;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
parameter = get_param (cmd_params, "remove=");
|
||||
if (ESP_FileSystem::rmdir(parameter.c_str())) {
|
||||
output->printMSG ("ok");
|
||||
} else {
|
||||
output->printERROR ("failed!");
|
||||
response = false;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
parameter = get_param (cmd_params, "remove=");
|
||||
if (parameter.length() != 0) {
|
||||
if (ESP_FileSystem::remove(parameter.c_str())) {
|
||||
output->printMSG ("ok");
|
||||
} else {
|
||||
output->printERROR ("failed!");
|
||||
response = false;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
if (ESP_FileSystem::remove(parameter.c_str())) {
|
||||
output->printMSG ("ok");
|
||||
} else {
|
||||
output->printERROR ("failed!");
|
||||
response = false;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
parameter = get_param (cmd_params, "exists=");
|
||||
if (parameter.length() != 0) {
|
||||
if (ESP_FileSystem::exists(parameter.c_str())) {
|
||||
output->printMSG ("yes");
|
||||
} else {
|
||||
output->printMSG ("no");
|
||||
}
|
||||
return response;
|
||||
if (ESP_FileSystem::exists(parameter.c_str())) {
|
||||
output->printMSG ("yes");
|
||||
} else {
|
||||
output->printMSG ("no");
|
||||
}
|
||||
return response;
|
||||
}
|
||||
output->printERROR ("Incorrect command!");
|
||||
return false;
|
||||
|
@ -38,6 +38,9 @@
|
||||
#ifdef TIMESTAMP_FEATURE
|
||||
#include "../../modules/time/time_server.h"
|
||||
#endif //TIMESTAMP_FEATURE
|
||||
#ifdef CAMERA_DEVICE
|
||||
#include "../../modules/camera/camera.h"
|
||||
#endif //CAMERA_DEVICE
|
||||
//get fw version firmare target and fw version
|
||||
//eventually set time with pc time
|
||||
//output is JSON or plain text according parameter
|
||||
@ -256,7 +259,44 @@ bool Commands::ESP800(const char* cmd_params, level_authenticate_type auth_type,
|
||||
} else {
|
||||
output->print("\"");
|
||||
}
|
||||
|
||||
#ifdef CAMERA_DEVICE
|
||||
//camera port
|
||||
if (plain) {
|
||||
output->print("Camera port:");
|
||||
} else {
|
||||
output->print(",\"Cam_port\":\"");
|
||||
}
|
||||
output->print(esp3d_camera.port());
|
||||
if(plain) {
|
||||
output->printLN("");
|
||||
} else {
|
||||
output->print("\"");
|
||||
}
|
||||
//camera ID
|
||||
if (plain) {
|
||||
output->print("Camera ID:");
|
||||
} else {
|
||||
output->print(",\"Cam_ID\":\"");
|
||||
}
|
||||
output->print(esp3d_camera.GetModel());
|
||||
if(plain) {
|
||||
output->printLN("");
|
||||
} else {
|
||||
output->print("\"");
|
||||
}
|
||||
//camera Name
|
||||
if (plain) {
|
||||
output->print("Camera Name:");
|
||||
} else {
|
||||
output->print(",\"Cam_name\":\"");
|
||||
}
|
||||
output->print(esp3d_camera.GetModelString());
|
||||
if(plain) {
|
||||
output->printLN("");
|
||||
} else {
|
||||
output->print("\"");
|
||||
}
|
||||
#endif //CAMERA_DEVICE
|
||||
//final
|
||||
if(!plain) {
|
||||
output->printLN("}");
|
||||
|
@ -18,6 +18,7 @@
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#include "../../include/esp3d_config.h"
|
||||
#if defined (BUZZER_DEVICE)
|
||||
#include "../commands.h"
|
||||
#include "../esp3doutput.h"
|
||||
#include "../settings_esp3d.h"
|
||||
@ -68,3 +69,4 @@ bool Commands::ESP910(const char* cmd_params, level_authenticate_type auth_type,
|
||||
}
|
||||
return response;
|
||||
}
|
||||
#endif //BUZZER_DEVICE
|
||||
|
@ -118,6 +118,7 @@
|
||||
#define DEFAULT_BAUD_RATE 115200L
|
||||
#define DEFAULT_HTTP_PORT 80L
|
||||
#define DEFAULT_WEBSOCKET_PORT 8282L
|
||||
#define DEFAULT_CAMERA_PORT 9600L
|
||||
#define DEFAULT_TELNET_PORT 23L
|
||||
#define DEFAULT_DHT_INTERVAL 30000L
|
||||
#define DEFAULT_BOOT_DELAY 10000L
|
||||
@ -265,7 +266,7 @@ uint8_t Settings_ESP3D::get_default_byte_value(int pos)
|
||||
//case ESP_SSID_VISIBLE:
|
||||
// res = DEFAULT_SSID_VISIBLE;
|
||||
// break;
|
||||
#endif //WIFI_FEATURE
|
||||
#endif //WIFI_FEATURE
|
||||
case ESP_OUTPUT_FLAG:
|
||||
res = DEFAULT_OUTPUT_FLAG;
|
||||
break;
|
||||
@ -379,11 +380,16 @@ uint32_t Settings_ESP3D::get_default_int32_value(int pos)
|
||||
res = DEFAULT_WEBSOCKET_PORT;
|
||||
break;
|
||||
#endif //WS_DATA_FEATURE
|
||||
#ifdef CAMERA_DEVICE
|
||||
case ESP_CAMERA_PORT:
|
||||
res = DEFAULT_CAMERA_PORT;
|
||||
break;
|
||||
#endif //CAMERA_DEVICE
|
||||
#if defined(DHT_DEVICE)
|
||||
case ESP_DHT_INTERVAL:
|
||||
res = DEFAULT_DHT_INTERVAL;
|
||||
break;
|
||||
#endif //DHT_DEVICE
|
||||
#endif //DHT_DEVICE
|
||||
default:
|
||||
res = DEFAULT_ESP_INT;
|
||||
}
|
||||
@ -398,6 +404,11 @@ uint32_t Settings_ESP3D::get_max_int32_value(int pos)
|
||||
case ESP_BOOT_DELAY:
|
||||
res = MAX_BOOT_DELAY;
|
||||
break;
|
||||
#ifdef CAMERA_DEVICE
|
||||
case ESP_CAMERA_PORT:
|
||||
res = MAX_HTTP_PORT;
|
||||
break;
|
||||
#endif //CAMERA_DEVICE
|
||||
#ifdef HTTP_FEATURE
|
||||
case ESP_HTTP_PORT:
|
||||
res = MAX_HTTP_PORT;
|
||||
@ -432,6 +443,11 @@ uint32_t Settings_ESP3D::get_min_int32_value(int pos)
|
||||
case ESP_BOOT_DELAY:
|
||||
res = MIN_BOOT_DELAY;
|
||||
break;
|
||||
#ifdef CAMERA_DEVICE
|
||||
case ESP_CAMERA_PORT:
|
||||
res =MIN_HTTP_PORT;
|
||||
break;
|
||||
#endif //CAMERA_DEVICE
|
||||
#ifdef HTTP_FEATURE
|
||||
case ESP_HTTP_PORT:
|
||||
res = MIN_HTTP_PORT;
|
||||
@ -451,7 +467,7 @@ uint32_t Settings_ESP3D::get_min_int32_value(int pos)
|
||||
case ESP_DHT_INTERVAL:
|
||||
res = MIN_DHT_INTERVAL;
|
||||
break;
|
||||
#endif //DHT_DEVICE
|
||||
#endif //DHT_DEVICE
|
||||
default:
|
||||
res = DEFAULT_ESP_INT;
|
||||
}
|
||||
@ -486,7 +502,7 @@ uint8_t Settings_ESP3D::get_min_byte(int pos)
|
||||
case ESP_AP_CHANNEL:
|
||||
res = MIN_CHANNEL;
|
||||
break;
|
||||
#endif //WIFI_FEATURE
|
||||
#endif //WIFI_FEATURE
|
||||
#ifdef TIMESTAMP_FEATURE
|
||||
case ESP_TIMEZONE:
|
||||
res= -12;
|
||||
@ -549,7 +565,7 @@ const String & Settings_ESP3D::get_default_string_value(int pos)
|
||||
case ESP_AP_PASSWORD:
|
||||
res = DEFAULT_AP_PASSWORD;
|
||||
break;
|
||||
#endif //WIFI_FEATURE
|
||||
#endif //WIFI_FEATURE
|
||||
#ifdef AUTHENTICATION_FEATURE
|
||||
case ESP_ADMIN_PWD:
|
||||
res = DEFAULT_ADMIN_PWD;
|
||||
@ -602,7 +618,7 @@ uint8_t Settings_ESP3D::get_max_string_size(int pos)
|
||||
case ESP_AP_PASSWORD:
|
||||
res = MAX_PASSWORD_LENGTH;
|
||||
break;
|
||||
#endif //WIFI_FEATURE
|
||||
#endif //WIFI_FEATURE
|
||||
#ifdef AUTHENTICATION_FEATURE
|
||||
case ESP_ADMIN_PWD:
|
||||
case ESP_USER_PWD:
|
||||
@ -729,7 +745,7 @@ bool Settings_ESP3D::write_byte (int pos, const uint8_t value)
|
||||
log_esp3d("Error commit %s", p.c_str());
|
||||
return false;
|
||||
}
|
||||
#endif //SETTINGS_IN_PREFERENCES
|
||||
#endif //SETTINGS_IN_PREFERENCES
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -978,7 +994,7 @@ bool Settings_ESP3D::reset()
|
||||
}
|
||||
res = prefs.clear();
|
||||
prefs.end();
|
||||
#endif //SETTINGS_IN_PREFERENCES
|
||||
#endif //SETTINGS_IN_PREFERENCES
|
||||
|
||||
//for EEPROM need to overwrite all settings
|
||||
#if ESP_SAVE_SETTINGS == SETTINGS_IN_EEPROM
|
||||
@ -1063,6 +1079,11 @@ bool Settings_ESP3D::reset()
|
||||
Settings_ESP3D::write_uint32 (ESP_TELNET_PORT, Settings_ESP3D::get_default_int32_value(ESP_TELNET_PORT));
|
||||
#endif //TELNET
|
||||
|
||||
#ifdef CAMERA_DEVICE
|
||||
//Camera Port
|
||||
Settings_ESP3D::write_uint32 (ESP_CAMERA_PORT, Settings_ESP3D::get_default_int32_value(ESP_CAMERA_PORT));
|
||||
#endif //CAMERA_DEVICE
|
||||
|
||||
#ifdef WS_DATA_FEATURE
|
||||
//Websocket On
|
||||
Settings_ESP3D::write_byte(ESP_WEBSOCKET_ON,Settings_ESP3D::get_default_byte_value(ESP_WEBSOCKET_ON));
|
||||
@ -1103,7 +1124,7 @@ bool Settings_ESP3D::reset()
|
||||
Settings_ESP3D::write_byte(ESP_DHT_TYPE,Settings_ESP3D::get_default_byte_value(ESP_DHT_TYPE));
|
||||
//DHT query interval
|
||||
Settings_ESP3D::write_uint32 (ESP_DHT_INTERVAL, Settings_ESP3D::get_default_int32_value(ESP_DHT_INTERVAL));
|
||||
#endif //DHT_DEVICE
|
||||
#endif //DHT_DEVICE
|
||||
//Start Delay
|
||||
Settings_ESP3D::write_uint32 (ESP_BOOT_DELAY, Settings_ESP3D::get_default_int32_value(ESP_BOOT_DELAY));
|
||||
#endif //SETTINGS_IN_EEPROM
|
||||
|
@ -66,27 +66,28 @@
|
||||
#define ESP_TELNET_ON 329 //1 byte = flag
|
||||
#define ESP_WEBSOCKET_ON 330 //1 byte = flag
|
||||
#define ESP_SD_SPEED_DIV 331 //1 byte = flag
|
||||
#define ESP_NOTIFICATION_TOKEN1 332 //64 bytes 63+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_NOTIFICATION_TOKEN2 396 //64 bytes 63+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_DHT_TYPE 460//1 bytes = flag
|
||||
#define ESP_TARGET_FW 461 //1 bytes = flag
|
||||
#define ESP_TIMEZONE 462//1 bytes = flag
|
||||
#define ESP_TIME_IS_DST 463//1 bytes = flag
|
||||
#define ESP_TIME_SERVER1 464//129 bytes 128+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_TIME_SERVER2 593 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_TIME_SERVER3 722 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_IS_DIRECT_SD 850//1 bytes = flag
|
||||
#define ESP_PRIMARY_SD 851//1 bytes = flag
|
||||
#define ESP_SECONDARY_SD 852//1 bytes = flag
|
||||
#define ESP_DIRECT_SD_CHECK 853//1 bytes = flag
|
||||
#define ESP_NOTIFICATION_TOKEN1 332 //64 bytes 63+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_NOTIFICATION_TOKEN2 396 //64 bytes 63+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_DHT_TYPE 460 //1 bytes = flag
|
||||
#define ESP_TARGET_FW 461 //1 bytes = flag
|
||||
#define ESP_TIMEZONE 462 //1 bytes = flag
|
||||
#define ESP_TIME_IS_DST 463 //1 bytes = flag
|
||||
#define ESP_TIME_SERVER1 464 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_TIME_SERVER2 593 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_TIME_SERVER3 722 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_IS_DIRECT_SD 850 //1 bytes = flag
|
||||
#define ESP_PRIMARY_SD 851 //1 bytes = flag
|
||||
#define ESP_SECONDARY_SD 852 //1 bytes = flag
|
||||
#define ESP_DIRECT_SD_CHECK 853 //1 bytes = flag
|
||||
#define ESP_SD_CHECK_UPDATE_AT_BOOT 854//1 bytes = flag
|
||||
#define ESP_NOTIFICATION_SETTINGS 855//128 bytes 127+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_CALIBRATION_1 983 //4 bytes = int
|
||||
#define ESP_CALIBRATION_2 987 //4 bytes = int
|
||||
#define ESP_CALIBRATION_3 991 //4 bytes = int
|
||||
#define ESP_CALIBRATION_4 995 //4 bytes = int
|
||||
#define ESP_CALIBRATION_5 999 //4 bytes = int
|
||||
#define ESP_AUTO_NOTIFICATION 1004 //1 byte = flag
|
||||
#define ESP_NOTIFICATION_SETTINGS 855 //128 bytes 127+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_CALIBRATION_1 983 //4 bytes = int
|
||||
#define ESP_CALIBRATION_2 987 //4 bytes = int
|
||||
#define ESP_CALIBRATION_3 991 //4 bytes = int
|
||||
#define ESP_CALIBRATION_4 995 //4 bytes = int
|
||||
#define ESP_CALIBRATION_5 999 //4 bytes = int
|
||||
#define ESP_AUTO_NOTIFICATION 1004 //1 byte = flag
|
||||
#define ESP_CAMERA_PORT 1005 //4 bytes = int
|
||||
|
||||
//Hidden password
|
||||
#define HIDDEN_PASSWORD "********"
|
||||
|
@ -26,10 +26,10 @@
|
||||
#define SETTINGS_IN_PREFERENCES 2
|
||||
|
||||
//Debug
|
||||
#define DEBUG_OUTPUT_SERIAL0 1
|
||||
#define DEBUG_OUTPUT_SERIAL1 2
|
||||
#define DEBUG_OUTPUT_SERIAL2 3
|
||||
#define DEBUG_OUTPUT_TELNET 4
|
||||
#define DEBUG_OUTPUT_SERIAL0 1
|
||||
#define DEBUG_OUTPUT_SERIAL1 2
|
||||
#define DEBUG_OUTPUT_SERIAL2 3
|
||||
#define DEBUG_OUTPUT_TELNET 4
|
||||
#define DEBUG_OUTPUT_WEBSOCKET 5
|
||||
|
||||
|
||||
@ -39,8 +39,8 @@
|
||||
#define USE_SERIAL_2 3
|
||||
|
||||
//Display
|
||||
#define OLED_I2C_SSD1306 1
|
||||
#define OLED_I2C_SSDSH1106 2
|
||||
#define OLED_I2C_SSD1306 1
|
||||
#define OLED_I2C_SSDSH1106 2
|
||||
#define TFT_SPI_ILI9341_320X240 3
|
||||
#define TFT_SPI_ILI9488_480X320 4
|
||||
|
||||
@ -52,10 +52,10 @@
|
||||
|
||||
|
||||
//Touch
|
||||
#define XPT2046_SPI 1
|
||||
#define XPT2046_SPI 1
|
||||
|
||||
//Input
|
||||
#define ROTARY_ENCODER 1
|
||||
#define ROTARY_ENCODER 1
|
||||
|
||||
//File systems
|
||||
#define ESP_SPIFFS_FILESYSTEM 1
|
||||
@ -63,15 +63,23 @@
|
||||
#define ESP_LITTLEFS_FILESYSTEM 3
|
||||
|
||||
//Notifications
|
||||
#define ESP_PUSHOVER_NOTIFICATION 1
|
||||
#define ESP_EMAIL_NOTIFICATION 2
|
||||
#define ESP_LINE_NOTIFICATION 3
|
||||
#define ESP_PUSHOVER_NOTIFICATION 1
|
||||
#define ESP_EMAIL_NOTIFICATION 2
|
||||
#define ESP_LINE_NOTIFICATION 3
|
||||
|
||||
//DHT
|
||||
#define DHT11_DEVICE 1
|
||||
#define DHT22_DEVICE 2
|
||||
#define USE_CELSIUS 1
|
||||
#define USE_FAHRENHEIT 2
|
||||
#define DHT11_DEVICE 1
|
||||
#define DHT22_DEVICE 2
|
||||
#define USE_CELSIUS 1
|
||||
#define USE_FAHRENHEIT 2
|
||||
|
||||
//Camera
|
||||
#define CAMERA_MODEL_CUSTOM 0
|
||||
#define CAMERA_MODEL_ESP_EYE 1
|
||||
#define CAMERA_MODEL_M5STACK_PSRAM 2
|
||||
#define CAMERA_MODEL_M5STACK_WIDE 3
|
||||
#define CAMERA_MODEL_AI_THINKER 4
|
||||
#define CAMERA_MODEL_WROVER_KIT 5
|
||||
|
||||
//Errors code
|
||||
#define ESP_ERROR_AUTHENTICATION 1
|
||||
|
@ -22,6 +22,7 @@
|
||||
#define _ESP3D_CONFIG_H
|
||||
#include <Arduino.h>
|
||||
#include "../include/defines.h"
|
||||
#include "../include/pins.h"
|
||||
#include "../../configuration.h"
|
||||
#include "../include/sanity_esp3d.h"
|
||||
#include "../core/hal.h"
|
||||
@ -39,7 +40,7 @@
|
||||
#define RECOVERY_FEATURE
|
||||
#endif //PIN_RESET_FEATURE || SD_RECOVERY_FEATURE
|
||||
|
||||
#if defined(DISPLAY_DEVICE) || defined(DHT_DEVICE) || defined(RECOVERY_FEATURE) || defined(BUZZER_DEVICE)
|
||||
#if defined(DISPLAY_DEVICE) || defined(DHT_DEVICE) || defined(RECOVERY_FEATURE) || defined(BUZZER_DEVICE) || defined(CAMERA_DEVICE)
|
||||
#define CONNECTED_DEVICES_FEATURE
|
||||
#endif //DISPLAY_DEVICE || DHT_DEVICE
|
||||
|
||||
|
159
esp3d/src/include/pins.h
Normal file
159
esp3d/src/include/pins.h
Normal file
@ -0,0 +1,159 @@
|
||||
/*
|
||||
pins.h - pins definition file
|
||||
|
||||
Copyright (c) 2014 Luc Lebosse. All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
//Pins for the support of connected camera
|
||||
|
||||
#if CAMERA_DEVICE == CAMERA_MODEL_CUSTOM
|
||||
#define CAM_LED_PIN 4
|
||||
#define CAM_PULLUP1 -1
|
||||
#define CAM_PULLUP2 -1
|
||||
#define PWDN_GPIO_NUM 32
|
||||
#define RESET_GPIO_NUM -1
|
||||
#define XCLK_GPIO_NUM 0
|
||||
#define SIOD_GPIO_NUM 26
|
||||
#define SIOC_GPIO_NUM 27
|
||||
|
||||
#define Y9_GPIO_NUM 35
|
||||
#define Y8_GPIO_NUM 34
|
||||
#define Y7_GPIO_NUM 39
|
||||
#define Y6_GPIO_NUM 36
|
||||
#define Y5_GPIO_NUM 21
|
||||
#define Y4_GPIO_NUM 19
|
||||
#define Y3_GPIO_NUM 18
|
||||
#define Y2_GPIO_NUM 5
|
||||
#define VSYNC_GPIO_NUM 25
|
||||
#define HREF_GPIO_NUM 23
|
||||
#define PCLK_GPIO_NUM 22
|
||||
#endif //CAMERA_MODEL_AI_THINKER
|
||||
|
||||
#if CAMERA_DEVICE == CAMERA_MODEL_WROVER_KIT
|
||||
#define CAM_LED_PIN -1
|
||||
#define CAM_PULLUP1 -1
|
||||
#define CAM_PULLUP2 -1
|
||||
#define PWDN_GPIO_NUM -1
|
||||
#define RESET_GPIO_NUM -1
|
||||
#define XCLK_GPIO_NUM 21
|
||||
#define SIOD_GPIO_NUM 26
|
||||
#define SIOC_GPIO_NUM 27
|
||||
|
||||
#define Y9_GPIO_NUM 35
|
||||
#define Y8_GPIO_NUM 34
|
||||
#define Y7_GPIO_NUM 39
|
||||
#define Y6_GPIO_NUM 36
|
||||
#define Y5_GPIO_NUM 19
|
||||
#define Y4_GPIO_NUM 18
|
||||
#define Y3_GPIO_NUM 5
|
||||
#define Y2_GPIO_NUM 4
|
||||
#define VSYNC_GPIO_NUM 25
|
||||
#define HREF_GPIO_NUM 23
|
||||
#define PCLK_GPIO_NUM 22
|
||||
#endif //CAMERA_MODEL_WROVER_KIT
|
||||
|
||||
#if CAMERA_DEVICE == CAMERA_MODEL_ESP_EYE
|
||||
#define CAM_LED_PIN -1
|
||||
#define CAM_PULLUP1 13
|
||||
#define CAM_PULLUP2 14
|
||||
#define PWDN_GPIO_NUM -1
|
||||
#define RESET_GPIO_NUM -1
|
||||
#define XCLK_GPIO_NUM 4
|
||||
#define SIOD_GPIO_NUM 18
|
||||
#define SIOC_GPIO_NUM 23
|
||||
|
||||
#define Y9_GPIO_NUM 36
|
||||
#define Y8_GPIO_NUM 37
|
||||
#define Y7_GPIO_NUM 38
|
||||
#define Y6_GPIO_NUM 39
|
||||
#define Y5_GPIO_NUM 35
|
||||
#define Y4_GPIO_NUM 14
|
||||
#define Y3_GPIO_NUM 13
|
||||
#define Y2_GPIO_NUM 34
|
||||
#define VSYNC_GPIO_NUM 5
|
||||
#define HREF_GPIO_NUM 27
|
||||
#define PCLK_GPIO_NUM 25
|
||||
#endif //CAMERA_MODEL_ESP_EYE
|
||||
|
||||
#if CAMERA_DEVICE == CAMERA_MODEL_M5STACK_PSRAM
|
||||
#define CAM_LED_PIN -1
|
||||
#define CAM_PULLUP1 -1
|
||||
#define CAM_PULLUP2 -1
|
||||
#define PWDN_GPIO_NUM -1
|
||||
#define RESET_GPIO_NUM 15
|
||||
#define XCLK_GPIO_NUM 27
|
||||
#define SIOD_GPIO_NUM 25
|
||||
#define SIOC_GPIO_NUM 23
|
||||
|
||||
#define Y9_GPIO_NUM 19
|
||||
#define Y8_GPIO_NUM 36
|
||||
#define Y7_GPIO_NUM 18
|
||||
#define Y6_GPIO_NUM 39
|
||||
#define Y5_GPIO_NUM 5
|
||||
#define Y4_GPIO_NUM 34
|
||||
#define Y3_GPIO_NUM 35
|
||||
#define Y2_GPIO_NUM 32
|
||||
#define VSYNC_GPIO_NUM 22
|
||||
#define HREF_GPIO_NUM 26
|
||||
#define PCLK_GPIO_NUM 21
|
||||
#endif //CAMERA_MODEL_M5STACK_PSRAM
|
||||
|
||||
#if CAMERA_DEVICE == CAMERA_MODEL_M5STACK_WIDE
|
||||
#define CAM_LED_PIN -1
|
||||
#define CAM_PULLUP1 -1
|
||||
#define CAM_PULLUP2 -1
|
||||
#define PWDN_GPIO_NUM -1
|
||||
#define RESET_GPIO_NUM 15
|
||||
#define XCLK_GPIO_NUM 27
|
||||
#define SIOD_GPIO_NUM 22
|
||||
#define SIOC_GPIO_NUM 23
|
||||
|
||||
#define Y9_GPIO_NUM 19
|
||||
#define Y8_GPIO_NUM 36
|
||||
#define Y7_GPIO_NUM 18
|
||||
#define Y6_GPIO_NUM 39
|
||||
#define Y5_GPIO_NUM 5
|
||||
#define Y4_GPIO_NUM 34
|
||||
#define Y3_GPIO_NUM 35
|
||||
#define Y2_GPIO_NUM 32
|
||||
#define VSYNC_GPIO_NUM 25
|
||||
#define HREF_GPIO_NUM 26
|
||||
#define PCLK_GPIO_NUM 21
|
||||
#endif //CAMERA_MODEL_M5STACK_WIDE
|
||||
|
||||
#if CAMERA_DEVICE == CAMERA_MODEL_AI_THINKER
|
||||
#define CAM_LED_PIN 4
|
||||
#define CAM_PULLUP1 -1
|
||||
#define CAM_PULLUP2 -1
|
||||
#define PWDN_GPIO_NUM 32
|
||||
#define RESET_GPIO_NUM -1
|
||||
#define XCLK_GPIO_NUM 0
|
||||
#define SIOD_GPIO_NUM 26
|
||||
#define SIOC_GPIO_NUM 27
|
||||
|
||||
#define Y9_GPIO_NUM 35
|
||||
#define Y8_GPIO_NUM 34
|
||||
#define Y7_GPIO_NUM 39
|
||||
#define Y6_GPIO_NUM 36
|
||||
#define Y5_GPIO_NUM 21
|
||||
#define Y4_GPIO_NUM 19
|
||||
#define Y3_GPIO_NUM 18
|
||||
#define Y2_GPIO_NUM 5
|
||||
#define VSYNC_GPIO_NUM 25
|
||||
#define HREF_GPIO_NUM 23
|
||||
#define PCLK_GPIO_NUM 22
|
||||
#endif //CAMERA_MODEL_AI_THINKER
|
@ -79,7 +79,7 @@
|
||||
* Time
|
||||
* ***********************/
|
||||
#if defined(FILESYSTEM_TIMESTAMP_FEATURE) && defined( ARDUINO_ARCH_ESP8266)
|
||||
#error SPIFFS time is not available in ESP8266
|
||||
#error Filesystem time is not available in ESP8266 yet
|
||||
#endif
|
||||
|
||||
/**************************
|
||||
@ -92,4 +92,11 @@
|
||||
#error LittleFS is not available in ESP32
|
||||
#endif
|
||||
|
||||
/**************************
|
||||
* Camera
|
||||
* ***********************/
|
||||
#if defined(CAMERA_DEVICE) && defined( ARDUINO_ARCH_ESP8266)
|
||||
#error Camera is not available in ESP8266
|
||||
#endif
|
||||
|
||||
#endif //SANITY_ESP3D_H
|
||||
|
@ -22,7 +22,7 @@
|
||||
#define _VERSION_ESP3D_H
|
||||
|
||||
//version and sources location
|
||||
#define FW_VERSION "3.0.0.a16"
|
||||
#define FW_VERSION "3.0.0.a17"
|
||||
#define REPOSITORY "https://github.com/luc-github/ESP3D"
|
||||
|
||||
#endif //_VERSION_ESP3D_H
|
||||
|
391
esp3d/src/modules/camera/camera.cpp
Normal file
391
esp3d/src/modules/camera/camera.cpp
Normal file
@ -0,0 +1,391 @@
|
||||
/*
|
||||
camera.cpp - camera functions class
|
||||
|
||||
Copyright (c) 2014 Luc Lebosse. All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "../../include/esp3d_config.h"
|
||||
#ifdef CAMERA_DEVICE
|
||||
#include "camera.h"
|
||||
#include "../../core/settings_esp3d.h"
|
||||
#include "../network/netservices.h"
|
||||
#include "../../core/esp3doutput.h"
|
||||
#include "../network/netconfig.h"
|
||||
#include "esp_http_server.h"
|
||||
#include <esp_camera.h>
|
||||
#include "fd_forward.h"
|
||||
#include <soc/rtc_cntl_reg.h>
|
||||
|
||||
#define DEFAULT_FRAME_SIZE FRAMESIZE_SVGA
|
||||
#define PART_BUFFER_SIZE 64
|
||||
#define JPEG_COMPRESSION 80
|
||||
#define MIN_WIDTH_COMPRESSION 400
|
||||
#define PART_BOUNDARY "123456789000000000000987654321"
|
||||
static const char* _STREAM_CONTENT_TYPE = "multipart/x-mixed-replace;boundary=" PART_BOUNDARY;
|
||||
static const char* _STREAM_BOUNDARY = "\r\n--" PART_BOUNDARY "\r\n";
|
||||
static const char* _STREAM_PART = "Content-Type: image/jpeg\r\nContent-Length: %u\r\n\r\n";
|
||||
|
||||
httpd_handle_t stream_httpd = NULL;
|
||||
Camera esp3d_camera;
|
||||
|
||||
//to break the loop
|
||||
static void disconnected_uri(httpd_handle_t hd, int sockfd)
|
||||
{
|
||||
esp3d_camera.connect(false);
|
||||
}
|
||||
|
||||
static esp_err_t stream_handler(httpd_req_t *req)
|
||||
{
|
||||
if (!esp3d_camera.started()) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
esp3d_camera.connect(true);
|
||||
camera_fb_t * fb = NULL;
|
||||
esp_err_t res = ESP_OK;
|
||||
size_t _jpg_buf_len = 0;
|
||||
uint8_t * _jpg_buf = NULL;
|
||||
char * part_buf[PART_BUFFER_SIZE];
|
||||
dl_matrix3du_t *image_matrix = NULL;
|
||||
log_esp3d("Camera stream reached");
|
||||
res = httpd_resp_set_type(req, _STREAM_CONTENT_TYPE);
|
||||
if(res != ESP_OK) {
|
||||
esp3d_camera.connect(false);
|
||||
return res;
|
||||
}
|
||||
while(true) {
|
||||
if (!esp3d_camera.isconnected()) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
log_esp3d("Camera capture ongoing");
|
||||
fb = esp_camera_fb_get();
|
||||
if (!fb) {
|
||||
log_esp3d("Camera capture failed");
|
||||
res = ESP_FAIL;
|
||||
} else {
|
||||
if(fb->width > MIN_WIDTH_COMPRESSION) {
|
||||
if(fb->format != PIXFORMAT_JPEG) {
|
||||
bool jpeg_converted = frame2jpg(fb, JPEG_COMPRESSION, &_jpg_buf, &_jpg_buf_len);
|
||||
esp_camera_fb_return(fb);
|
||||
fb = NULL;
|
||||
if(!jpeg_converted) {
|
||||
log_esp3d("JPEG compression failed");
|
||||
res = ESP_FAIL;
|
||||
}
|
||||
} else {
|
||||
_jpg_buf_len = fb->len;
|
||||
_jpg_buf = fb->buf;
|
||||
}
|
||||
} else {
|
||||
image_matrix = dl_matrix3du_alloc(1, fb->width, fb->height, 3);
|
||||
|
||||
if (!image_matrix) {
|
||||
log_esp3d("dl_matrix3du_alloc failed");
|
||||
res = ESP_FAIL;
|
||||
} else {
|
||||
if(!fmt2rgb888(fb->buf, fb->len, fb->format, image_matrix->item)) {
|
||||
log_esp3d("fmt2rgb888 failed");
|
||||
res = ESP_FAIL;
|
||||
} else {
|
||||
if (fb->format != PIXFORMAT_JPEG) {
|
||||
if(!fmt2jpg(image_matrix->item, fb->width*fb->height*3, fb->width, fb->height, PIXFORMAT_RGB888, 90, &_jpg_buf, &_jpg_buf_len)) {
|
||||
log_esp3d("fmt2jpg failed");
|
||||
res = ESP_FAIL;
|
||||
}
|
||||
esp_camera_fb_return(fb);
|
||||
fb = NULL;
|
||||
} else {
|
||||
_jpg_buf = fb->buf;
|
||||
_jpg_buf_len = fb->len;
|
||||
}
|
||||
}
|
||||
dl_matrix3du_free(image_matrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(res == ESP_OK) {
|
||||
size_t hlen = snprintf((char *)part_buf, PART_BUFFER_SIZE, _STREAM_PART, _jpg_buf_len);
|
||||
res = httpd_resp_send_chunk(req, (const char *)part_buf, hlen);
|
||||
}
|
||||
if(res == ESP_OK) {
|
||||
res = httpd_resp_send_chunk(req, (const char *)_jpg_buf, _jpg_buf_len);
|
||||
}
|
||||
if(res == ESP_OK) {
|
||||
res = httpd_resp_send_chunk(req, _STREAM_BOUNDARY, strlen(_STREAM_BOUNDARY));
|
||||
}
|
||||
if(fb) {
|
||||
esp_camera_fb_return(fb);
|
||||
fb = NULL;
|
||||
_jpg_buf = NULL;
|
||||
} else if(_jpg_buf) {
|
||||
free(_jpg_buf);
|
||||
_jpg_buf = NULL;
|
||||
}
|
||||
if(res != ESP_OK) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
esp3d_camera.connect(false);
|
||||
return res;
|
||||
}
|
||||
|
||||
Camera::Camera()
|
||||
{
|
||||
_started = false;
|
||||
_initialised = false;
|
||||
_connected = false;
|
||||
}
|
||||
|
||||
Camera::~Camera()
|
||||
{
|
||||
end();
|
||||
}
|
||||
|
||||
|
||||
int Camera::command(const char * param, const char * value)
|
||||
{
|
||||
int res = 0;
|
||||
int val = atoi(value);
|
||||
sensor_t * s = esp_camera_sensor_get();
|
||||
#if CAM_LED_PIN != -1
|
||||
if (!strcmp(param, "light")) {
|
||||
digitalWrite(CAM_LED_PIN, val==1?HIGH:LOW);
|
||||
} else
|
||||
#endif //CAM_LED_PIN
|
||||
if(!strcmp(param, "framesize")) {
|
||||
if(s->pixformat == PIXFORMAT_JPEG) {
|
||||
res = s->set_framesize(s, (framesize_t)val);
|
||||
}
|
||||
} else if(!strcmp(param, "quality")) {
|
||||
res = s->set_quality(s, val);
|
||||
} else if(!strcmp(param, "contrast")) {
|
||||
res = s->set_contrast(s, val);
|
||||
} else if(!strcmp(param, "brightness")) {
|
||||
res = s->set_brightness(s, val);
|
||||
} else if(!strcmp(param, "saturation")) {
|
||||
res = s->set_saturation(s, val);
|
||||
} else if(!strcmp(param, "gainceiling")) {
|
||||
res = s->set_gainceiling(s, (gainceiling_t)val);
|
||||
} else if(!strcmp(param, "colorbar")) {
|
||||
res = s->set_colorbar(s, val);
|
||||
} else if(!strcmp(param, "awb")) {
|
||||
res = s->set_whitebal(s, val);
|
||||
} else if(!strcmp(param, "agc")) {
|
||||
res = s->set_gain_ctrl(s, val);
|
||||
} else if(!strcmp(param, "aec")) {
|
||||
res = s->set_exposure_ctrl(s, val);
|
||||
} else if(!strcmp(param, "hmirror")) {
|
||||
res = s->set_hmirror(s, val);
|
||||
} else if(!strcmp(param, "vflip")) {
|
||||
res = s->set_vflip(s, val);
|
||||
} else if(!strcmp(param, "awb_gain")) {
|
||||
res = s->set_awb_gain(s, val);
|
||||
} else if(!strcmp(param, "agc_gain")) {
|
||||
res = s->set_agc_gain(s, val);
|
||||
} else if(!strcmp(param, "aec_value")) {
|
||||
res = s->set_aec_value(s, val);
|
||||
} else if(!strcmp(param, "aec2")) {
|
||||
res = s->set_aec2(s, val);
|
||||
} else if(!strcmp(param, "dcw")) {
|
||||
res = s->set_dcw(s, val);
|
||||
} else if(!strcmp(param, "bpc")) {
|
||||
res = s->set_bpc(s, val);
|
||||
} else if(!strcmp(param, "wpc")) {
|
||||
res = s->set_wpc(s, val);
|
||||
} else if(!strcmp(param, "raw_gma")) {
|
||||
res = s->set_raw_gma(s, val);
|
||||
} else if(!strcmp(param, "lenc")) {
|
||||
res = s->set_lenc(s, val);
|
||||
} else if(!strcmp(param, "special_effect")) {
|
||||
res = s->set_special_effect(s, val);
|
||||
} else if(!strcmp(param, "wb_mode")) {
|
||||
res = s->set_wb_mode(s, val);
|
||||
} else if(!strcmp(param, "ae_level")) {
|
||||
res = s->set_ae_level(s, val);
|
||||
} else {
|
||||
res = -1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
bool Camera::initHardware(bool forceinit)
|
||||
{
|
||||
if (forceinit) {
|
||||
_initialised = false;
|
||||
}
|
||||
if (_initialised) {
|
||||
return _initialised;
|
||||
}
|
||||
stopHardware();
|
||||
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
|
||||
camera_config_t config;
|
||||
config.ledc_channel = LEDC_CHANNEL_0;
|
||||
config.ledc_timer = LEDC_TIMER_0;
|
||||
config.pin_d0 = Y2_GPIO_NUM;
|
||||
config.pin_d1 = Y3_GPIO_NUM;
|
||||
config.pin_d2 = Y4_GPIO_NUM;
|
||||
config.pin_d3 = Y5_GPIO_NUM;
|
||||
config.pin_d4 = Y6_GPIO_NUM;
|
||||
config.pin_d5 = Y7_GPIO_NUM;
|
||||
config.pin_d6 = Y8_GPIO_NUM;
|
||||
config.pin_d7 = Y9_GPIO_NUM;
|
||||
config.pin_xclk = XCLK_GPIO_NUM;
|
||||
config.pin_pclk = PCLK_GPIO_NUM;
|
||||
config.pin_vsync = VSYNC_GPIO_NUM;
|
||||
config.pin_href = HREF_GPIO_NUM;
|
||||
config.pin_sscb_sda = SIOD_GPIO_NUM;
|
||||
config.pin_sscb_scl = SIOC_GPIO_NUM;
|
||||
config.pin_pwdn = PWDN_GPIO_NUM;
|
||||
config.pin_reset = RESET_GPIO_NUM;
|
||||
config.xclk_freq_hz = 20000000;
|
||||
config.pixel_format = PIXFORMAT_JPEG;
|
||||
//init with high specs to pre-allocate larger buffers
|
||||
if(psramFound()) {
|
||||
config.frame_size = DEFAULT_FRAME_SIZE;
|
||||
config.jpeg_quality = 10;
|
||||
config.fb_count = 2;
|
||||
} else {
|
||||
config.frame_size = DEFAULT_FRAME_SIZE;
|
||||
config.jpeg_quality = 12;
|
||||
config.fb_count = 1;
|
||||
}
|
||||
|
||||
#if CAM_PULLUP1 != -1
|
||||
pinMode(CAM_PULLUP1, INPUT_PULLUP);
|
||||
#endif //CAM_PULLUP1
|
||||
#if CAM_PULLUP2 != -1
|
||||
pinMode(CAM_PULLUP2, INPUT_PULLUP);
|
||||
#endif //CAM_PULLUP2
|
||||
#if CAM_LED_PIN != -1
|
||||
pinMode(CAM_LED_PIN, OUTPUT);
|
||||
digitalWrite(CAM_LED_PIN, LOW);
|
||||
#endif //CAM_LED_PIN
|
||||
// camera init
|
||||
esp_err_t err = esp_camera_init(&config);
|
||||
if (err != ESP_OK) {
|
||||
log_esp3d("Camera init failed with error 0x%x", err);
|
||||
return false;
|
||||
}
|
||||
sensor_t * s = esp_camera_sensor_get();
|
||||
//initial sensors are flipped vertically and colors are a bit saturated
|
||||
if (s->id.PID == OV3660_PID) {
|
||||
s->set_brightness(s, 1);//up the blightness just a bit
|
||||
s->set_saturation(s, -2);//lower the saturation
|
||||
}
|
||||
|
||||
s->set_framesize(s, DEFAULT_FRAME_SIZE);
|
||||
|
||||
#if defined(CAMERA_DEVICE_FLIP_HORIZONTALY)
|
||||
s->set_hmirror(s, 1);
|
||||
#endif //CAMERA_DEVICE_FLIP_HORIZONTALY
|
||||
#if defined(CAMERA_DEVICE_FLIP_VERTICALY)
|
||||
s->set_vflip(s, 1);
|
||||
#endif //CAMERA_DEVICE_FLIP_VERTICALY
|
||||
_initialised = true;
|
||||
return _initialised;
|
||||
}
|
||||
|
||||
bool Camera::stopHardware()
|
||||
{
|
||||
end();
|
||||
_initialised = false;
|
||||
log_esp3d("Stop cam");
|
||||
return (esp_camera_deinit() == ESP_OK);
|
||||
}
|
||||
|
||||
//need to be call by device and by network
|
||||
bool Camera::begin(bool forceinit)
|
||||
{
|
||||
end();
|
||||
if (!initHardware(forceinit) ) {
|
||||
return false;
|
||||
}
|
||||
if (NetConfig::started() && (NetConfig::getMode()!= ESP_BT)) {
|
||||
ESP3DOutput output(ESP_ALL_CLIENTS);
|
||||
httpd_config_t httpdconfig = HTTPD_DEFAULT_CONFIG();
|
||||
httpdconfig.close_fn =&disconnected_uri;
|
||||
httpd_uri_t stream_uri = {
|
||||
.uri = "/stream",
|
||||
.method = HTTP_GET,
|
||||
.handler = stream_handler,
|
||||
.user_ctx = NULL
|
||||
};
|
||||
_port = Settings_ESP3D::read_uint32(ESP_CAMERA_PORT);
|
||||
httpdconfig.server_port = _port;
|
||||
httpdconfig.ctrl_port = httpdconfig.server_port +1;
|
||||
httpdconfig.task_priority = 1;
|
||||
if (httpd_start(&stream_httpd, &httpdconfig) == ESP_OK) {
|
||||
httpd_register_uri_handler(stream_httpd, &stream_uri);
|
||||
String stmp = "Camera server started port " + String(httpdconfig.server_port);
|
||||
output.printMSG(stmp.c_str());
|
||||
} else {
|
||||
output.printERROR("Starting camera server failed");
|
||||
return false;
|
||||
}
|
||||
_started = true;
|
||||
}
|
||||
return _started;
|
||||
}
|
||||
|
||||
void Camera::end()
|
||||
{
|
||||
if (_started) {
|
||||
_started = false;
|
||||
_connected = false;
|
||||
if (ESP_OK != httpd_unregister_uri(stream_httpd, "/stream")) {
|
||||
log_esp3d("Error unregistering /stream");
|
||||
}
|
||||
if (ESP_OK != httpd_stop(stream_httpd)) {
|
||||
log_esp3d("Error stopping stream server");
|
||||
}
|
||||
}
|
||||
}
|
||||
void Camera::handle()
|
||||
{
|
||||
//so far nothing to do
|
||||
}
|
||||
uint8_t Camera::GetModel()
|
||||
{
|
||||
return CAMERA_DEVICE;
|
||||
}
|
||||
const char *Camera::GetModelString()
|
||||
{
|
||||
#if defined(CUSTOM_CAMERA_NAME)
|
||||
return CUSTOM_CAMERA_NAME;
|
||||
#else
|
||||
switch(CAMERA_DEVICE) {
|
||||
case CAMERA_MODEL_WROVER_KIT:
|
||||
return "WROVER Kit";
|
||||
break;
|
||||
case CAMERA_MODEL_ESP_EYE:
|
||||
return "ESP Eye";
|
||||
break;
|
||||
case CAMERA_MODEL_M5STACK_PSRAM:
|
||||
return "M5Stack with PSRam";
|
||||
break;
|
||||
case CAMERA_MODEL_M5STACK_WIDE:
|
||||
return "M5Stack wide";
|
||||
break;
|
||||
case CAMERA_MODEL_AI_THINKER:
|
||||
return "ESP32 Cam";
|
||||
break;
|
||||
default:
|
||||
return "Unknow Camera";
|
||||
}
|
||||
#endif //CUSTOM_CAMERA_NAME
|
||||
}
|
||||
#endif //CAMERA_DEVICE
|
69
esp3d/src/modules/camera/camera.h
Normal file
69
esp3d/src/modules/camera/camera.h
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
camera.h - camera functions class
|
||||
|
||||
Copyright (c) 2014 Luc Lebosse. All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _CAMERA_H
|
||||
#define _CAMERA_H
|
||||
|
||||
class Camera
|
||||
{
|
||||
public:
|
||||
Camera();
|
||||
~Camera();
|
||||
bool initHardware(bool forceinit = false);
|
||||
bool begin(bool forceinit = false);
|
||||
void end();
|
||||
void handle();
|
||||
int command(const char * param, const char * value);
|
||||
uint8_t GetModel();
|
||||
const char *GetModelString();
|
||||
bool started()
|
||||
{
|
||||
return _started;
|
||||
}
|
||||
bool initialised()
|
||||
{
|
||||
return _initialised;
|
||||
}
|
||||
bool stopHardware();
|
||||
void connect(bool status)
|
||||
{
|
||||
_connected = status;
|
||||
}
|
||||
bool isconnected()
|
||||
{
|
||||
return _connected;
|
||||
}
|
||||
uint16_t port()
|
||||
{
|
||||
return _port;
|
||||
}
|
||||
private:
|
||||
bool _initialised;
|
||||
bool _started;
|
||||
bool _connected;
|
||||
uint16_t _port;
|
||||
};
|
||||
|
||||
extern Camera esp3d_camera;
|
||||
|
||||
#endif //_CAMERA_H
|
||||
|
@ -36,6 +36,9 @@
|
||||
#ifdef RECOVERY_FEATURE
|
||||
#include "../recovery/recovery_service.h"
|
||||
#endif //RECOVERY_FEATURE
|
||||
#ifdef CAMERA_DEVICE
|
||||
#include "../camera/camera.h"
|
||||
#endif //CAMERA_DEVICE
|
||||
|
||||
bool DevicesServices::_started = false;
|
||||
|
||||
@ -71,10 +74,16 @@ bool DevicesServices::begin()
|
||||
#endif //BUZZER_DEVICE
|
||||
#ifdef RECOVERY_FEATURE
|
||||
if (!recovery_service.begin()) {
|
||||
log_esp3d("Error starting recorery service");
|
||||
log_esp3d("Error starting recovery service");
|
||||
res = false;
|
||||
}
|
||||
#endif //RECOVERY_FEATURE
|
||||
#ifdef CAMERA_DEVICE
|
||||
if (!esp3d_camera.initHardware()) {
|
||||
log_esp3d("Error camera intialization failed");
|
||||
res = false;
|
||||
}
|
||||
#endif //CAMERA_DEVICE
|
||||
if (!res) {
|
||||
end();
|
||||
}
|
||||
@ -87,6 +96,9 @@ void DevicesServices::end()
|
||||
return;
|
||||
}
|
||||
_started = false;
|
||||
#ifdef CAMERA_DEVICE
|
||||
esp3d_camera.stopHardware();
|
||||
#endif //CAMERA_DEVICE
|
||||
#ifdef RECOVERY_FEATURE
|
||||
recovery_service.end();
|
||||
#endif //RECOVERY_FEATURE
|
||||
|
@ -115,7 +115,7 @@ void esp_lv_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *c
|
||||
if(bSnapshot) {
|
||||
uint32_t data = lv_color_to32(*color_p);
|
||||
//to handle any write issue
|
||||
if (fsSnapFile.write((const uint8_t *)(&data), sizeof(uint32_t)) != sizeof(uint32_t)){
|
||||
if (fsSnapFile.write((const uint8_t *)(&data), sizeof(uint32_t)) != sizeof(uint32_t)) {
|
||||
//if error we stop to dump
|
||||
bSnapshot = false;
|
||||
//raise error
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -72,7 +72,7 @@ size_t ESP_FileSystem::max_update_size()
|
||||
//max OTA partition is 1019Kb
|
||||
if (flashsize > 1024 * 1024) {
|
||||
flashsize = (1024 * 1024) - 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif //ARDUINO_ARCH_ESP8266
|
||||
#if defined (ARDUINO_ARCH_ESP32)
|
||||
|
@ -78,7 +78,10 @@ public:
|
||||
static void end();
|
||||
static size_t totalBytes();
|
||||
static size_t usedBytes();
|
||||
static size_t freeBytes(){return totalBytes()-usedBytes();};
|
||||
static size_t freeBytes()
|
||||
{
|
||||
return totalBytes()-usedBytes();
|
||||
};
|
||||
static size_t max_update_size();
|
||||
static const char * FilesystemName();
|
||||
static bool format();
|
||||
|
@ -76,12 +76,12 @@ ESP_File ESP_FileSystem::open(const char* path, uint8_t mode)
|
||||
File ftmp = LittleFS.open(path, (mode == ESP_FILE_READ)?"r":(mode == ESP_FILE_WRITE)?"w":"a");
|
||||
if(ftmp) {
|
||||
log_esp3d("Success openening: %s", path);
|
||||
if (ftmp.isFile()){
|
||||
if (ftmp.isFile()) {
|
||||
log_esp3d("It is a file");
|
||||
ESP_File esptmp(&ftmp, false,(mode == ESP_FILE_READ)?false:true, path);
|
||||
return esptmp;
|
||||
}
|
||||
if (ftmp.isDirectory()){
|
||||
if (ftmp.isDirectory()) {
|
||||
log_esp3d("It is a Directory");
|
||||
}
|
||||
ftmp.close();
|
||||
@ -128,7 +128,7 @@ bool ESP_FileSystem::mkdir(const char *path)
|
||||
|
||||
bool ESP_FileSystem::rmdir(const char *path)
|
||||
{
|
||||
if (!exists(path)) {
|
||||
if (!exists(path)) {
|
||||
return false;
|
||||
}
|
||||
bool res = true;
|
||||
@ -137,7 +137,8 @@ bool ESP_FileSystem::rmdir(const char *path)
|
||||
spath.trim();
|
||||
if (spath[spath.length()-1] != '/') {
|
||||
spath+="/";
|
||||
}if (spath[0] != '/') {
|
||||
}
|
||||
if (spath[0] != '/') {
|
||||
spath ="/" + spath;
|
||||
}
|
||||
pathlist.push(spath);
|
||||
@ -162,7 +163,7 @@ bool ESP_FileSystem::rmdir(const char *path)
|
||||
if (spath !="/") {
|
||||
if (spath[spath.length()-1] == '/') {
|
||||
spath.remove(spath.length()-1);
|
||||
}
|
||||
}
|
||||
if (LittleFS.exists(spath.c_str())) {
|
||||
res = LittleFS.rmdir(spath.c_str());
|
||||
}
|
||||
@ -234,8 +235,8 @@ ESP_File::ESP_File(void* handle, bool isdir, bool iswritemode, const char * path
|
||||
_filename = tFile_handle[i].name();
|
||||
if (_isdir) {
|
||||
if (!((_filename[_filename.length()-1] == '/') || (_filename == "/"))) {
|
||||
_filename+="/";
|
||||
}
|
||||
_filename+="/";
|
||||
}
|
||||
}
|
||||
//name
|
||||
if (_filename == "/") {
|
||||
@ -302,17 +303,19 @@ ESP_File ESP_File::openNextFile()
|
||||
log_esp3d("Getting next file from %s", _filename.c_str());
|
||||
log_esp3d("name :%s %s", name.c_str(), (tDir_handle[_index].isDirectory())?"isDir":"isFile");
|
||||
String s = _filename;
|
||||
if(s[s.length()-1]!='/')s+="/";
|
||||
if(s[s.length()-1]!='/') {
|
||||
s+="/";
|
||||
}
|
||||
s+=name.c_str();
|
||||
if (tDir_handle[_index].isFile()) {
|
||||
ESP_File esptmp(name.c_str(), s.c_str(), false, tDir_handle[_index].fileSize()) ;
|
||||
return esptmp;
|
||||
} else {
|
||||
log_esp3d("Found dir name: %s filename:%s",name.c_str(), s.c_str());
|
||||
ESP_File esptmp = ESP_File(name.c_str(), s.c_str());
|
||||
return esptmp;
|
||||
}
|
||||
|
||||
log_esp3d("Found dir name: %s filename:%s",name.c_str(), s.c_str());
|
||||
ESP_File esptmp = ESP_File(name.c_str(), s.c_str());
|
||||
return esptmp;
|
||||
}
|
||||
|
||||
}
|
||||
return ESP_File();
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ void HTTP_Server::FSFileupload ()
|
||||
HTTPUpload& upload = _webserver->upload();
|
||||
String upload_filename = upload.filename;
|
||||
if ((_upload_status != UPLOAD_STATUS_FAILED) || (upload.status == UPLOAD_FILE_START)) {
|
||||
|
||||
|
||||
//Upload start
|
||||
if (upload.status == UPLOAD_FILE_START) {
|
||||
_upload_status = UPLOAD_STATUS_ONGOING;
|
||||
|
@ -219,7 +219,9 @@ bool NetConfig::begin()
|
||||
end();
|
||||
int8_t espMode =Settings_ESP3D::read_byte(ESP_RADIO_MODE);
|
||||
ESP3DOutput output(ESP_ALL_CLIENTS);
|
||||
if (espMode != NO_NETWORK)output.printMSG("Starting Network");
|
||||
if (espMode != NO_NETWORK) {
|
||||
output.printMSG("Starting Network");
|
||||
}
|
||||
//setup events
|
||||
if(!_events_registered) {
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
|
@ -66,9 +66,11 @@ DNSServer dnsServer;
|
||||
#ifdef NOTIFICATION_FEATURE
|
||||
#include "../notifications/notifications_service.h"
|
||||
#endif //NOTIFICATION_FEATURE
|
||||
|
||||
#ifdef CAMERA_DEVICE
|
||||
#include "../camera/camera.h"
|
||||
#endif //CAMERA_DEVICE
|
||||
bool NetServices::_started = false;
|
||||
|
||||
bool NetServices::_restart = false;
|
||||
NetServices::NetServices()
|
||||
{
|
||||
}
|
||||
@ -211,8 +213,10 @@ bool NetServices::begin()
|
||||
if (!websocket_data_server.begin(Settings_ESP3D::read_uint32(ESP_WEBSOCKET_PORT))) {
|
||||
output.printMSG("Failed start Terminal Web Socket");
|
||||
} else {
|
||||
String stmp = "Websocket server started port " + String(websocket_data_server.port());
|
||||
output.printMSG(stmp.c_str());
|
||||
if (websocket_data_server.started()) {
|
||||
String stmp = "Websocket server started port " + String(websocket_data_server.port());
|
||||
output.printMSG(stmp.c_str());
|
||||
}
|
||||
}
|
||||
#endif //WS_DATA_FEATURE
|
||||
#if defined(HTTP_FEATURE)
|
||||
@ -252,6 +256,11 @@ bool NetServices::begin()
|
||||
notificationsservice.begin();
|
||||
notificationsservice.sendAutoNotification(NOTIFICATION_ESP_ONLINE);
|
||||
#endif //NOTIFICATION_FEATURE
|
||||
#ifdef CAMERA_DEVICE
|
||||
if (!esp3d_camera.begin()) {
|
||||
output.printMSG("Failed start camera streaming server");
|
||||
}
|
||||
#endif //CAMERA_DEVICE
|
||||
if (!res) {
|
||||
end();
|
||||
}
|
||||
@ -260,10 +269,14 @@ bool NetServices::begin()
|
||||
}
|
||||
void NetServices::end()
|
||||
{
|
||||
_restart = false;
|
||||
if(!_started) {
|
||||
return;
|
||||
}
|
||||
_started = false;
|
||||
#ifdef CAMERA_DEVICE
|
||||
esp3d_camera.end();
|
||||
#endif //CAMERA_DEVICE
|
||||
#ifdef NOTIFICATION_FEATURE
|
||||
notificationsservice.end();
|
||||
#endif //NOTIFICATION_FEATURE
|
||||
@ -340,5 +353,8 @@ void NetServices::handle()
|
||||
notificationsservice.handle();
|
||||
#endif //NOTIFICATION_FEATURE
|
||||
}
|
||||
if (_restart) {
|
||||
begin();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,18 @@ public:
|
||||
static bool begin();
|
||||
static void end();
|
||||
static void handle();
|
||||
static bool started()
|
||||
{
|
||||
return _started;
|
||||
}
|
||||
static void start()
|
||||
{
|
||||
_restart=true;
|
||||
Serial.println("Restarting netservices");
|
||||
}
|
||||
private:
|
||||
static bool _started;
|
||||
static bool _restart;
|
||||
};
|
||||
|
||||
#endif //_NET_SERVICES_H
|
||||
|
@ -144,6 +144,9 @@ bool WebSocket_Server::begin(uint16_t port, bool debug)
|
||||
_port = Settings_ESP3D::read_uint32(ESP_HTTP_PORT) +1;
|
||||
} else {
|
||||
_port = port;
|
||||
if (Settings_ESP3D::read_byte(ESP_WEBSOCKET_ON) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
_isdebug = debug;
|
||||
_websocket_server = new WebSocketsServer(_port);
|
||||
|
@ -80,6 +80,7 @@ private:
|
||||
bool _started;
|
||||
uint16_t _port;
|
||||
bool _isdebug;
|
||||
bool _isdata;
|
||||
uint32_t _lastTXflush;
|
||||
uint32_t _lastRXflush;
|
||||
WebSocketsServer * _websocket_server;
|
||||
|
Loading…
x
Reference in New Issue
Block a user