增加错误信息 2974/2 2974/head 2975/target/1
authorxue <2144439972@qq.com>
Fri, 26 Dec 2025 03:19:41 +0000 (11:19 +0800)
committerxue <2144439972@qq.com>
Fri, 26 Dec 2025 03:19:41 +0000 (11:19 +0800)
code/sdk/application/wearable/ln/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp
code/sdk/zhihui/websocket/os_ws/haisi_websocket.c
code/sdk/zhihui/websocket/os_ws/haisi_websocket.h

index f277073..ccff3b5 100644 (file)
@@ -26,6 +26,7 @@ extern "C"
 #include "ln_api.h"
 #include <ConfigModelC.h>
 #include <cat1_runtime.h>
+#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;
     }
 
index 0cdbe5a..bf31153 100644 (file)
@@ -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;
+    }
+}
+
index a9b28e5..bd7bdb5 100644 (file)
@@ -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);