ESP32 WebCam Server 5.0
Fully customizable WebCam server based on Espressif ESP32-based board with a camera.
app_httpd.h
Go to the documentation of this file.
1#ifndef app_httpd_h
2#define app_httpd_h
3
4#include <esp_int_wdt.h>
5#include <esp_task_wdt.h>
6#include <freertos/timers.h>
7
8#include "ESPAsyncWebServer.h"
9#include "storage.h"
10#include "app_conn.h"
11#include "app_cam.h"
12
13#define MAX_URI_MAPPINGS 32
14
15#ifdef __cplusplus
16extern "C" {
17#endif
19#ifdef __cplusplus
20}
21#endif
22
24
25String processor(const String& var);
26void onSystemStatus(AsyncWebServerRequest *request);
27void onStatus(AsyncWebServerRequest *request);
28void onInfo(AsyncWebServerRequest *request);
29void onControl(AsyncWebServerRequest *request);
30void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len);
31void onSnapTimer(TimerHandle_t pxTimer);
32
33void dumpSystemStatusToJson(char * buf, size_t size);
34
35
40struct UriMapping { char uri[32]; char path[32];};
41
42
48class CLAppHttpd : public CLAppComponent {
49 public:
50 CLAppHttpd();
51
52 int start();
53 int loadPrefs();
54
55 uint32_t getClientId() {return client_id;};
56
57 int8_t getStreamCount() {return streamCount;};
58 long getStreamsServed() {return streamsServed;};
59 unsigned long getImagesServed() {return imagesServed;};
60 void incImagesServed(){imagesServed++;};
61
62 void setStreamMode(capture_mode mode) {streammode = mode;};
63 capture_mode getStreamMode() {return streammode;};
64
65 int snapToStream(bool debug = false);
66 int startStream(uint32_t id);
67 int stopStream(uint32_t id);
68
69 void updateSnapTimer(int frameRate);
70
71 void serialSendCommand(const char * cmd);
72
73 int getSketchSize(){ return sketchSize;};
74 int getSketchSpace() {return sketchSpace;};
75 String getSketchMD5() {return sketchMD5;};
76
77 String getVersion() {return version;};
78
79 char * getName() {return myName;};
80
81 char * getSerialBuffer() {return serialBuffer;};
82
83
84 private:
85
86 UriMapping *mappingList[MAX_URI_MAPPINGS];
87 int mappingCount=0;
88
89 // Name of the application used in web interface
90 // Can be re-defined in the httpd.json file
91 char myName[20] = CAM_NAME;
92
93 char serialBuffer[64];
94
95 AsyncWebServer *server;
96 AsyncWebSocket *ws;
97 uint32_t client_id = 0;
98 TimerHandle_t snap_timer = NULL;
99
100 int8_t streamCount=0;
101 long streamsServed=0;
102 unsigned long imagesServed;
103
104 // mode of the image capture
105 capture_mode streammode = CAPTURE_STILL;
106
107 // Sketch Info
108 int sketchSize ;
109 int sketchSpace ;
110 String sketchMD5;
111
112 const String version = __DATE__ " @ " __TIME__;
113
114};
115
116
117
118extern CLAppHttpd AppHttpd;
119
120#endif
#define CAM_NAME
Definition: app_config.h:6
CLAppHttpd AppHttpd
Definition: app_httpd.cpp:507
String processor(const String &var)
Definition: app_httpd.cpp:128
void onSnapTimer(TimerHandle_t pxTimer)
Definition: app_httpd.cpp:11
uint8_t temprature_sens_read()
capture_mode
Definition: app_httpd.h:23
@ CAPTURE_STILL
Definition: app_httpd.h:23
@ CAPTURE_STREAM
Definition: app_httpd.h:23
#define MAX_URI_MAPPINGS
Definition: app_httpd.h:13
void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len)
Definition: app_httpd.cpp:93
void dumpSystemStatusToJson(char *buf, size_t size)
Definition: app_httpd.cpp:411
void onSystemStatus(AsyncWebServerRequest *request)
Definition: app_httpd.cpp:393
void onStatus(AsyncWebServerRequest *request)
Definition: app_httpd.cpp:349
void onControl(AsyncWebServerRequest *request)
Definition: app_httpd.cpp:223
void onInfo(AsyncWebServerRequest *request)
Definition: app_httpd.cpp:339
Abstract root class for the appication components.
Definition: app_component.h:14
WebServer Manager Class for handling web server requests. The web pages are assumed to be stored in t...
Definition: app_httpd.h:48
unsigned long getImagesServed()
Definition: app_httpd.h:59
long getStreamsServed()
Definition: app_httpd.h:58
void incImagesServed()
Definition: app_httpd.h:60
void serialSendCommand(const char *cmd)
Definition: app_httpd.cpp:469
String getVersion()
Definition: app_httpd.h:77
void setStreamMode(capture_mode mode)
Definition: app_httpd.h:62
int stopStream(uint32_t id)
Definition: app_httpd.cpp:207
int getSketchSpace()
Definition: app_httpd.h:74
int snapToStream(bool debug=false)
Definition: app_httpd.cpp:141
char * getName()
Definition: app_httpd.h:79
void updateSnapTimer(int frameRate)
Definition: app_httpd.cpp:334
int8_t getStreamCount()
Definition: app_httpd.h:57
int getSketchSize()
Definition: app_httpd.h:73
char * getSerialBuffer()
Definition: app_httpd.h:81
uint32_t getClientId()
Definition: app_httpd.h:55
int start()
Definition: app_httpd.cpp:15
CLAppHttpd()
Definition: app_httpd.cpp:3
String getSketchMD5()
Definition: app_httpd.h:75
capture_mode getStreamMode()
Definition: app_httpd.h:63
int loadPrefs()
Definition: app_httpd.cpp:474
int startStream(uint32_t id)
Definition: app_httpd.cpp:164
Static URI to path mapping.
Definition: app_httpd.h:40
char path[32]
Definition: app_httpd.h:40
char uri[32]
Definition: app_httpd.h:40