Add version info

Signed-off-by: YoungSoo Shin <shinys000114@gmail.com>
This commit is contained in:
2025-09-24 11:22:49 +09:00
parent 4bbf1339f1
commit 39ca2d205a
8 changed files with 64 additions and 3 deletions

View File

@@ -87,5 +87,7 @@ void start_webserver(void)
register_ws_endpoint(server);
register_control_endpoint(server);
register_reboot_endpoint(server);
register_version_endpoint(server);
init_status_monitor();
}

View File

@@ -15,5 +15,6 @@ void register_control_endpoint(httpd_handle_t server);
void push_data_to_ws(const uint8_t* data, size_t len);
void register_reboot_endpoint(httpd_handle_t server);
esp_err_t change_baud_rate(int baud_rate);
void register_version_endpoint(httpd_handle_t server);
#endif // ODROID_REMOTE_HTTP_WEBSERVER_H

View File

@@ -77,3 +77,19 @@ void register_reboot_endpoint(httpd_handle_t server)
.uri = "/api/reboot", .method = HTTP_POST, .handler = reboot_post_handler, .user_ctx = NULL};
httpd_register_uri_handler(server, &post_uri);
}
static esp_err_t version_get_handler(httpd_req_t* req)
{
httpd_resp_set_type(req, "application/json");
char buf[100];
sprintf(buf, "{\"version\": \"%s\"}", VERSION_HASH);
httpd_resp_send(req, buf, strlen(buf));
return ESP_OK;
}
void register_version_endpoint(httpd_handle_t server)
{
httpd_uri_t post_uri = {
.uri = "/api/version", .method = HTTP_GET, .handler = version_get_handler, .user_ctx = NULL};
httpd_register_uri_handler(server, &post_uri);
}