EasyManua.ls Logo

Freenove ESP32-S3 - Page 135

Default Icon
142 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Any concerns? support@freenove.com
133
Chapter 8 Camera Tcp Server
www.freenove.com
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
xTaskCreateUniversal(loopTask_Cmd, "loopTask_Cmd", 8192, NULL, 1, &loopTaskHandle,
0);//loopTask_Cmd uses core 0.
xTaskCreateUniversal(loopTask_Blink, "loopTask_Blink", 8192, NULL, 1, &loopTaskHandle,
0);//loopTask_Blink uses core 0.
}
//task loop uses core 1.
void loop() {
WiFiClient client = server_Camera.available(); // listen for incoming clients
if (client) { // if you get a client,
Serial.println("Camera Server connected to a client.");// print a message out the serial
port
String currentLine = ""; // make a String to hold incoming data from the client
while (client.connected()) { // loop while the client's connected
camera_fb_t * fb = NULL;
while (client.connected()) {
fb = esp_camera_fb_get();
if (fb != NULL) {
uint8_t slen[4];
slen[0] = fb->len >> 0;
slen[1] = fb->len >> 8;
slen[2] = fb->len >> 16;
slen[3] = fb->len >> 24;
client.write(slen, 4);
client.write(fb->buf, fb->len);
esp_camera_fb_return(fb);
}
else {
Serial.println("Camera Error");
}
}
}
// close the connection:
client.stop();
Serial.println("Camera Client Disconnected.");
}
}
void loopTask_Cmd(void *pvParameters) {
Serial.println("Task Cmd_Server is starting ... ");
while (1) {
WiFiClient client = server_Cmd.available(); // listen for incoming clients
if (client) { // if you get a client,
Serial.println("Command Server connected to a client.");// print a message out the
serial port