From 5e79850a745503d6353c84a7a797ebd24203cf19 Mon Sep 17 00:00:00 2001 From: xue <2144439972@qq.com> Date: Fri, 26 Dec 2025 11:19:41 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E9=94=99=E8=AF=AF=E4=BF=A1?= =?utf8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../debug_output_notification.cpp | 23 +++++++++++++++---- .../zhihui/websocket/os_ws/haisi_websocket.c | 20 +++++++++++++++- .../zhihui/websocket/os_ws/haisi_websocket.h | 3 +++ 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/code/sdk/application/wearable/ln/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp b/code/sdk/application/wearable/ln/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp index f27707345..ccff3b5d2 100644 --- a/code/sdk/application/wearable/ln/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp +++ b/code/sdk/application/wearable/ln/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp @@ -26,6 +26,7 @@ extern "C" #include "ln_api.h" #include #include +#include "haisi_websocket.h" char *uapi_ln_get_device_id(void); char *uapi_ln_get_device_iccid(void); @@ -219,13 +220,25 @@ namespace OHOS deviceInfo += " rsrq_quality:" + std::string(cat1_api_runtime_get_cat1_rsrq_quality())+ "\n"; deviceInfo += "cat1 csq_rssi:" + std::to_string(cat1_api_runtime_get_cat1_signal())+ " "+std::to_string(cat1_api_runtime_get_cat1_signal_bars())+"\n"; #endif - // 检查设备业务忙状态 - const char* busyStatus = uapi_ln_get_device_busy_status(); - if (busyStatus != NULL) { - deviceInfo += "业务状态:业务忙 - " + std::string(busyStatus) + "\n"; + // // 检查设备业务忙状态 + // const char* busyStatus = uapi_ln_get_device_busy_status(); + // if (busyStatus != NULL) { + // deviceInfo += "业务状态:业务忙 - " + std::string(busyStatus) + "\n"; + // } else { + // deviceInfo += "业务状态:空闲\n"; + // } + + // 获取WebSocket最后错误信息 + int errorCode = 0; + const char *errorMessage = NULL; + uapi_ws_get_last_error(&errorCode, &errorMessage); + if (errorMessage != NULL) { + deviceInfo += "last_error.errorMessage:" + std::string(errorMessage) + "\n"; } else { - deviceInfo += "业务状态:空闲\n"; + deviceInfo += "last_error.errorMessage:NULL\n"; } + deviceInfo += "last_error.errorCode:" + std::to_string(errorCode) + "\n"; + return deviceInfo; } diff --git a/code/sdk/zhihui/websocket/os_ws/haisi_websocket.c b/code/sdk/zhihui/websocket/os_ws/haisi_websocket.c index 0cdbe5aa7..bf3115359 100644 --- a/code/sdk/zhihui/websocket/os_ws/haisi_websocket.c +++ b/code/sdk/zhihui/websocket/os_ws/haisi_websocket.c @@ -23,7 +23,7 @@ typedef enum { // 当前日志等级(可通过配置修改) static haisi_ws_log_level_t g_haisi_log_level = HAISI_WS_LOG_INFO; - +// // 日志等级字符串数组 static const char *g_log_level_str[] = { "[ERROR]", "[WARN ]", "[INFO]", "[DEBUG]" @@ -707,8 +707,11 @@ int uapi_ws_send_text(const char *text) // 设置发送状态标志 g_ws_is_sending = 1; + HAISI_WS_DEBUG("uapi_ws_send_text: %s\n", text); // 发送数据 int ret = WebSocketClientSendText(g_ws_client_fd, text, strlen(text)); + + HAISI_WS_DEBUG("uapi_ws_send_text ret: %d\n", ret); // 更新最后发送时间 if (ret == 0) { @@ -1345,3 +1348,18 @@ int uapi_ws_wake_keep(int enable) return 0; } +/** + * @brief 获取最后一次WebSocket错误信息 + * @param errorCode 输出参数,错误码 + * @param errorMessage 输出参数,错误消息(可能为NULL) + */ +void uapi_ws_get_last_error(int *errorCode, const char **errorMessage) +{ + if (errorCode != NULL) { + *errorCode = last_error.errorCode; + } + if (errorMessage != NULL) { + *errorMessage = last_error.errorMessage; + } +} + diff --git a/code/sdk/zhihui/websocket/os_ws/haisi_websocket.h b/code/sdk/zhihui/websocket/os_ws/haisi_websocket.h index a9b28e598..bd7bdb5d0 100644 --- a/code/sdk/zhihui/websocket/os_ws/haisi_websocket.h +++ b/code/sdk/zhihui/websocket/os_ws/haisi_websocket.h @@ -78,6 +78,9 @@ int uapi_ws_get_close_status_public(void); void uapi_ws_print_status_info(void); uint32_t uapi_ws_get_main_thread_interval(void); +/* WebSocket错误信息查询接口 */ +void uapi_ws_get_last_error(int *errorCode, const char **errorMessage); + /* WebSocket低功耗管理接口 */ int uapi_ws_suspend(void); int uapi_ws_resume(void); -- 2.17.1