Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
e269bf62f3
|
|||
|
3dd8296dbe
|
@@ -27,7 +27,7 @@
|
||||
// ============================================================================
|
||||
// UART Serial Configuration
|
||||
// ============================================================================
|
||||
#define BMC_UART_NUM UART_NUM_0
|
||||
#define BMC_UART_NUM UART_NUM_1
|
||||
#define BMC_UART_TX_GPIO GPIO_NUM_43
|
||||
#define BMC_UART_RX_GPIO GPIO_NUM_44
|
||||
#define BMC_UART_BAUD_RATE 115200
|
||||
|
||||
@@ -241,6 +241,6 @@ esp_err_t gpio_reset(void) {
|
||||
}
|
||||
|
||||
bool gpio_power_status(void) {
|
||||
int level = gpio_get_level(BMC_GPIO_POWER);
|
||||
int level = gpio_read(BMC_GPIO_POWER);
|
||||
return (level == 1);
|
||||
}
|
||||
|
||||
@@ -1023,7 +1023,7 @@
|
||||
const indicator = document.getElementById('power-indicator');
|
||||
const status = document.getElementById('power-status');
|
||||
|
||||
if (result.data.power_good) {
|
||||
if (result.data.power_status === 'on') {
|
||||
indicator.classList.add('on');
|
||||
status.textContent = 'ON';
|
||||
} else {
|
||||
@@ -1087,14 +1087,7 @@
|
||||
|
||||
function connectWebSocket() {
|
||||
const protocol = window.location.protocol === 'https' ? 'wss' : '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)}`;
|
||||
}
|
||||
const wsUrl = `${protocol}://${window.location.host}/api/serial/ws`;
|
||||
|
||||
ws = new WebSocket(wsUrl);
|
||||
|
||||
|
||||
@@ -504,14 +504,9 @@ static void uart_to_ws_callback(const uint8_t *data, size_t len) {
|
||||
}
|
||||
|
||||
static esp_err_t ws_serial_handler(httpd_req_t *req) {
|
||||
#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
|
||||
// Note: WebSocket authentication is disabled because browsers don't support
|
||||
// custom Authorization headers on WebSocket connections.
|
||||
// TODO: Find a way to fix this
|
||||
|
||||
// For WebSocket handlers with is_websocket=true, ESP-IDF handles the handshake
|
||||
// internally. This handler is only called for frame processing.
|
||||
@@ -871,7 +866,6 @@ 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)
|
||||
@@ -949,7 +943,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 = auth_ws_serial_handler,
|
||||
.handler = ws_serial_handler,
|
||||
.is_websocket = true,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user