#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);
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;
}
// 当前日志等级(可通过配置修改)
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]"
// 设置发送状态标志
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) {
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;
+ }
+}
+
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);