Compare commits

1 Commits
main ... test

Author SHA1 Message Date
05ff87d0b8 test: temp test 2026-03-13 12:18:18 +01:00
4 changed files with 21 additions and 8 deletions

View File

@@ -27,7 +27,7 @@
// ============================================================================
// UART Serial Configuration
// ============================================================================
#define BMC_UART_NUM UART_NUM_1
#define BMC_UART_NUM UART_NUM_0
#define BMC_UART_TX_GPIO GPIO_NUM_43
#define BMC_UART_RX_GPIO GPIO_NUM_44
#define BMC_UART_BAUD_RATE 115200

View File

@@ -241,6 +241,6 @@ esp_err_t gpio_reset(void) {
}
bool gpio_power_status(void) {
int level = gpio_read(BMC_GPIO_POWER);
int level = gpio_get_level(BMC_GPIO_POWER);
return (level == 1);
}

View File

@@ -1023,7 +1023,7 @@
const indicator = document.getElementById('power-indicator');
const status = document.getElementById('power-status');
if (result.data.power_status === 'on') {
if (result.data.power_good) {
indicator.classList.add('on');
status.textContent = 'ON';
} else {
@@ -1087,7 +1087,14 @@
function connectWebSocket() {
const protocol = window.location.protocol === 'https' ? 'wss' : 'ws';
const wsUrl = `${protocol}://${window.location.host}/api/serial/ws`;
const auth = getStoredCredentials();
let wsUrl = `${protocol}://${window.location.host}/api/serial/ws`;
// Add auth parameter for WebSocket authentication
if (auth) {
const authB64 = btoa(auth.username + ':' + auth.password);
wsUrl += `?auth=${encodeURIComponent(authB64)}`;
}
ws = new WebSocket(wsUrl);

View File

@@ -504,9 +504,14 @@ static void uart_to_ws_callback(const uint8_t *data, size_t len) {
}
static esp_err_t ws_serial_handler(httpd_req_t *req) {
// Note: WebSocket authentication is disabled because browsers don't support
// custom Authorization headers on WebSocket connections.
// TODO: Find a way to fix this
#if BMC_HTTP_AUTH_ENABLED
// Check authentication on WebSocket handshake
// The Authorization header is available during the initial HTTP upgrade request
if (!check_auth(req)) {
// Send 401 response - this will fail the WebSocket handshake
return send_auth_required(req);
}
#endif
// For WebSocket handlers with is_websocket=true, ESP-IDF handles the handshake
// internally. This handler is only called for frame processing.
@@ -866,6 +871,7 @@ AUTH_HANDLER(auth_api_power_reset_handler, api_power_reset_handler)
AUTH_HANDLER(auth_api_serial_config_get_handler, api_serial_config_get_handler)
AUTH_HANDLER(auth_api_serial_config_set_handler, api_serial_config_set_handler)
AUTH_HANDLER(auth_api_serial_send_handler, api_serial_send_handler)
AUTH_HANDLER(auth_ws_serial_handler, ws_serial_handler)
AUTH_HANDLER(auth_api_system_info_handler, api_system_info_handler)
AUTH_HANDLER(auth_api_system_status_handler, api_system_status_handler)
AUTH_HANDLER(auth_api_ota_status_handler, api_ota_status_handler)
@@ -943,7 +949,7 @@ static const httpd_uri_t uri_api_serial_send = {
static const httpd_uri_t uri_ws_serial = {
.uri = "/api/serial/ws",
.method = HTTP_GET,
.handler = ws_serial_handler,
.handler = auth_ws_serial_handler,
.is_websocket = true,
};