Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
thk_EspCamServer
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
thk_libs
microcontrollers
thk_EspCamServer
Commits
5999496e
Commit
5999496e
authored
3 years ago
by
Vladislav Vlasuk
Browse files
Options
Downloads
Patches
Plain Diff
hello world without camera
parent
849391b3
Branches
Branches containing commit
No related tags found
1 merge request
!3
hello world without camera
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/helloworld_handler/helloworld_handler.ino
+43
-0
43 additions, 0 deletions
examples/helloworld_handler/helloworld_handler.ino
with
43 additions
and
0 deletions
examples/
cameraserver/cameraserv
er.ino
→
examples/
helloworld_handler/helloworld_handl
er.ino
+
43
−
0
View file @
5999496e
...
@@ -2,14 +2,13 @@
...
@@ -2,14 +2,13 @@
// Beispiel Sketch für das Auslesen der ESP32One Waveshare Kamera
// Beispiel Sketch für das Auslesen der ESP32One Waveshare Kamera
// und lokales Streamen des Kamerabildes per HTTP
// und lokales Streamen des Kamerabildes per HTTP
// Abhängigkeiten:
// Abhängigkeiten:
//
thk_EspCamDriver.h,
thk_EspCamServer.h
// thk_EspCamServer.h
// Autor:
// Autor:
// Vladislav Vlasuk (TH Köln, Labor für Assistenzsysteme)
// Vladislav Vlasuk (TH Köln, Labor für Assistenzsysteme)
// Datum:
// Datum:
// 05.07.2022
// 05.07.2022
// Bitte ESP32 Kameramodell auskommentieren
// Bitte ESP32 Kameramodell auskommentieren
#include
<thk_EspCamDriver.h>
// ESP32 Kamera
#include
<thk_EspCamServer.h>
// WIFI und HTTP-Server
#include
<thk_EspCamServer.h>
// WIFI und HTTP-Server
// Wlan-Netzwerk und Internetressource (URI) festlegen
// Wlan-Netzwerk und Internetressource (URI) festlegen
...
@@ -17,26 +16,15 @@ const char *ssid = "iPhone von Vladislav";
...
@@ -17,26 +16,15 @@ const char *ssid = "iPhone von Vladislav";
const
char
*
password
=
"qqqqqqqq"
;
const
char
*
password
=
"qqqqqqqq"
;
const
char
*
uri
=
"/stream"
;
const
char
*
uri
=
"/stream"
;
// ESP32 Kameraspezifisch
esp_image_t
image
;
camera_config_t
cameraconfig
;
// Konfig
esp_err_t
cameraerror
;
// Fehler
camera_fb_t
*
fb
=
NULL
;
// Framebuffer
// Objekte erzeugen
// Objekte erzeugen
thk_EspCamDriver
camera
(
&
cameraconfig
,
&
cameraerror
,
fb
,
&
image
);
thk_EspCamServer
server
(
ssid
,
password
,
uri
);
thk_EspCamServer
server
(
ssid
,
password
,
uri
);
void
setup
()
void
setup
()
{
{
Serial
.
begin
(
115200
);
Serial
.
begin
(
115200
);
camera
.
set_hmirror
(
1
);
camera
.
set_vflip
(
1
);
camera
.
set_grayscale
(
1
);
camera
.
init
();
// Kamera starten
server
.
connect
();
// Wifi verbinden
server
.
connect
();
// Wifi verbinden
server
.
start_webserver
(
&
get_
stream
_handler
);
// Server starten
server
.
start_webserver
(
&
get_
helloworld
_handler
);
// Server starten
};
};
void
loop
()
void
loop
()
...
@@ -45,60 +33,6 @@ void loop()
...
@@ -45,60 +33,6 @@ void loop()
delay
(
1e4
);
delay
(
1e4
);
}
}
// Handler für das Auslesen des Kameramoduls am ESP32One Waveshare
esp_err_t
get_stream_handler
(
httpd_req_t
*
req
)
{
Serial
.
println
(
"Starte Kamera Handler"
);
esp_err_t
res
=
ESP_OK
;
size_t
_jpg_buf_len
=
0
;
uint8_t
*
_jpg_buf
=
NULL
;
char
*
part_buf
[
128
];
res
=
httpd_resp_set_type
(
req
,
_STREAM_CONTENT_TYPE
);
if
(
res
!=
ESP_OK
)
return
res
;
while
(
true
)
{
// Schieße Bild
camera
.
take_picture
();
_jpg_buf_len
=
camera
.
get_fb
()
->
len
;
_jpg_buf
=
camera
.
get_fb
()
->
buf
;
// This API will send the data as an HTTP response to the request in the form of chunks with chunked-encoding
if
(
res
==
ESP_OK
)
{
res
=
httpd_resp_send_chunk
(
req
,
_STREAM_BOUNDARY
,
strlen
(
_STREAM_BOUNDARY
));
}
if
(
res
==
ESP_OK
)
{
size_t
hlen
=
snprintf
((
char
*
)
part_buf
,
128
,
_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
);
}
// close stream
if
(
camera
.
get_fb
())
{
camera
.
close_stream
();
_jpg_buf
=
NULL
;
}
else
if
(
_jpg_buf
)
{
free
(
_jpg_buf
);
_jpg_buf
=
NULL
;
}
if
(
res
!=
ESP_OK
)
{
Serial
.
println
(
"send frame failed failed"
);
break
;
}
}
return
res
;
}
// Bare Minimum Handler
// Bare Minimum Handler
static
esp_err_t
get_helloworld_handler
(
httpd_req_t
*
req
)
static
esp_err_t
get_helloworld_handler
(
httpd_req_t
*
req
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment