}// 发送HTTP响应httpd_resp_set_type(req, HTTPD_TYPE_TEXT);httpd_resp_send(req,"Received data: ",-1);httpd_resp_send_chunk(req, buf, req->content_len);httpd_resp_send_chunk(req,NULL,0);returnESP_OK; } 5. 处理web socket连接 除了支持HTTP请求外,ESP-IDF的Web服务器还支持WebSocket连接。
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 (fb) { esp_camera_fb_return(fb); fb = NULL; _jpg_buf = NULL; } else if (_jpg_buf) { free(_...
httpd_resp_set_hdr(req, "Custom-Header-11", "Custom-Value-1"); httpd_resp_set_hdr(req, "Custom-Header-22", "Custom-Value-2"); /* Send response with custom headers and body set as the * string passed in user context*/ const char* resp_str = (const char*) req->user_ctx; htt...
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_f...
}//End responsehttpd_resp_send_chunk(req, NULL,0);returnESP_OK; }staticconsthttpd_uri_t echo ={ .uri="/echo", .method=HTTP_POST, .handler=echo_post_handler, .user_ctx=NULL };/** 自定义错误处理*/esp_err_t http_404_error_handler(httpd_req_t*req, httpd_err_code_t err) ...
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; ...
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){ ...
res=httpd_resp_send_chunk(req,(constchar*)_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; ...
if (ret == HTTPD_SOCK_ERR_TIMEOUT) { /* Retry receiving if timeout occurred */ continue; } return ESP_FAIL; } /* Send back the same data */ httpd_resp_send_chunk(req, buf, ret); remaining -= ret; /* Log data received */ ESP_LOGI(TAG, ...
index){ j->len =0; }if(httpd_resp_send_chunk(j->req, (constchar*)data, len) != ESP_OK){return0; } j->len += len;returnlen; }esp_err_tjpg_httpd_handler(httpd_req_t*req){camera_fb_t* fb =NULL;esp_err_tres = ESP_OK;size_tfb_len =0;int64_tfr_start = esp_timer_get...