server now responds to get requests to root rather than post
parent
41b2eeb04c
commit
c5ed9c26e0
|
@ -2,7 +2,7 @@
|
||||||
//
|
//
|
||||||
// server.h
|
// server.h
|
||||||
// Call server_init() to start up an http webserver.
|
// Call server_init() to start up an http webserver.
|
||||||
// listens on '/' for POST queries with a url query format like
|
// listens on '/' for GET queries with a url query format like
|
||||||
// ?l=*&r0=*&g0=*&b0=*&a0=*&t0=* ... &rl=*&gl=*&bl=*&al=*&tl=*
|
// ?l=*&r0=*&g0=*&b0=*&a0=*&t0=* ... &rl=*&gl=*&bl=*&al=*&tl=*
|
||||||
// Where l is the number of points on a gradient. And each point of the gradient has a r* g* b* a* and t* where * is the index.
|
// Where l is the number of points on a gradient. And each point of the gradient has a r* g* b* a* and t* where * is the index.
|
||||||
// r g and b are the red green and blue 8-bit colour components of a point on the gradient. A is the 5-bit global component of the led at that point.
|
// r g and b are the red green and blue 8-bit colour components of a point on the gradient. A is the 5-bit global component of the led at that point.
|
||||||
|
@ -76,9 +76,9 @@ void parse_leds_query(char* query_string, size_t query_size) {
|
||||||
leds_set_gradient(points, gradient_point_count, 1);
|
leds_set_gradient(points, gradient_point_count, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// receives HTTP POST requests on root
|
// receives HTTP GET requests on root
|
||||||
static
|
static
|
||||||
esp_err_t on_http_post(httpd_req_t* request) {
|
esp_err_t on_http_get_root(httpd_req_t* request) {
|
||||||
LOGLN("POST received on '/'.");
|
LOGLN("POST received on '/'.");
|
||||||
|
|
||||||
char* buffer;
|
char* buffer;
|
||||||
|
@ -99,10 +99,10 @@ esp_err_t on_http_post(httpd_req_t* request) {
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
httpd_uri_t post = {
|
httpd_uri_t get_root_uri = {
|
||||||
.uri="/",
|
.uri="/",
|
||||||
.method=HTTP_POST,
|
.method=HTTP_GET,
|
||||||
.handler=&on_http_post,
|
.handler=&on_http_get_root,
|
||||||
.user_ctx = NULL
|
.user_ctx = NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -113,8 +113,9 @@ httpd_handle_t start_webserver(void) {
|
||||||
httpd_config_t server_config = HTTPD_DEFAULT_CONFIG();
|
httpd_config_t server_config = HTTPD_DEFAULT_CONFIG();
|
||||||
|
|
||||||
LOGLN("Starting HTTPd server ':%d'.", server_config.server_port);
|
LOGLN("Starting HTTPd server ':%d'.", server_config.server_port);
|
||||||
|
|
||||||
if(httpd_start(&server, &server_config) == ESP_OK) {
|
if(httpd_start(&server, &server_config) == ESP_OK) {
|
||||||
httpd_register_uri_handler(server, &post);
|
httpd_register_uri_handler(server, &get_root_uri);
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue