From: 孙春阳 Date: Mon, 8 Dec 2025 03:53:05 +0000 (+0800) Subject: 优化雷鸟主窗口信号显示,取消cesq信号获取。防止两种信号一起赋值,造成的异常。 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=8963efd0178614d5dc137b80947f7d2522dac0d9;p=mirrors%2FFD230.git 优化雷鸟主窗口信号显示,取消cesq信号获取。防止两种信号一起赋值,造成的异常。 调试窗口增加信号显示。 --- diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaModel.cpp index a58d35539..00d94c60a 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaModel.cpp @@ -462,7 +462,7 @@ namespace OHOS // 从底层API获取最新的网络状态信息 #if defined(SUPPORT_CAT1_SERVICE) || defined(SUPPORT_PPP_SERVICE) m_cat1PowerStatus = uapi_dev_runtime_get_cat1_powerstat(); // CAT1电源状态 - m_signalStrength = cat1_api_runtime_get_cat1_signal(); // 信号强度 + m_signalStrength = cat1_api_runtime_get_cat1_signal_bars(); // 信号强度 #endif // 记录网络状态更新日志 diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp index d5a6c6b06..6d8369c97 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp @@ -1994,7 +1994,7 @@ extern "C" { #if defined(SUPPORT_CAT1_SERVICE) || defined(SUPPORT_PPP_SERVICE) // m_simStatus = uapi_dev_runtime_get_cat1_simstat(); // SIM卡状态 m_cat1PowerStatus = uapi_dev_runtime_get_cat1_powerstat(); // CAT1电源状态 - m_signalStrength = cat1_api_runtime_get_cat1_signal(); // 信号强度 (旧接口,保留兼容性) + m_signalStrength = cat1_api_runtime_get_cat1_signal_bars(); // 信号强度 (旧接口,保留兼容性) m_networkStatus = uapi_dev_runtime_get_cat1_networkstat(); // 网络连接状态 // m_networkType = uapi_dev_runtime_get_cat1_networtype(); // 网络类型 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 8228b99db..70aac00fb 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 @@ -9,6 +9,7 @@ #include "graphic_service.h" #include "custom_utils.h" #include +#include "cmsis_os.h" #include "events/key_event.h" #include "common/key_code.h" #include "dock/input_device.h" @@ -46,6 +47,7 @@ namespace OHOS UIViewGroup *DebugGroupView{nullptr}; UILabel *debugOutputtitleLabel{nullptr}; UILabel *debugOutputLabel{nullptr}; + osTimerId_t g_debugOutputUpdateTimer{nullptr}; // 2秒定时器,用于更新视图 /* -------------------------------------------------------------------------- */ DebugOutputViewEventListener::DebugOutputViewEventListener() {} @@ -99,6 +101,7 @@ namespace OHOS break; } } + return false; } bool DebugOutputViewEventListener::ClickFunc(int16_t interface) @@ -169,31 +172,37 @@ namespace OHOS // deviceInfo += "设备model:" + std::string(uapi_ln_get_device_model()) + "\n"; deviceInfo += "cat1 model:" + std::string(cat1_api_runtime_get_cat1_modemver()) + "\n"; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "设备连接状态:%d", ln_ws_get_connection_state()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "设备连接状态:%d\n", ln_ws_get_connection_state()); switch ((int)ln_ws_get_connection_state()) { case 0: - deviceInfo += "设备连接状态:未连接 " +std::to_string(ln_ws_get_connection_state()); + deviceInfo += "设备连接状态:未连接 " +std::to_string(ln_ws_get_connection_state())+ "\n"; break; case 1: - deviceInfo += "设备连接状态:连接中 " +std::to_string(ln_ws_get_connection_state()); + deviceInfo += "设备连接状态:连接中 " +std::to_string(ln_ws_get_connection_state())+ "\n"; break; case 2: - deviceInfo += "设备连接状态:连接成功 " +std::to_string(ln_ws_get_connection_state()); + deviceInfo += "设备连接状态:连接成功 " +std::to_string(ln_ws_get_connection_state())+ "\n"; break; case 3: - deviceInfo += "设备连接状态:休眠状态 " +std::to_string(ln_ws_get_connection_state()); + deviceInfo += "设备连接状态:休眠状态 " +std::to_string(ln_ws_get_connection_state())+ "\n"; break; case 4: - deviceInfo += "设备连接状态:重连执行中 " +std::to_string(ln_ws_get_connection_state()); + deviceInfo += "设备连接状态:重连执行中 " +std::to_string(ln_ws_get_connection_state())+ "\n"; break; default: - deviceInfo += "设备连接状态:未知状态 " +std::to_string(ln_ws_get_connection_state()); + deviceInfo += "设备连接状态:未知状态 " +std::to_string(ln_ws_get_connection_state())+ "\n"; break; } - +#ifdef SUPPORT_PPP_SERVICE //ppp波特率 + deviceInfo += "cat1 cesq:" + std::string(cat1_api_runtime_get_cat1_cesq())+ "\n"; + deviceInfo += "cat1 csq_rssi:" + std::to_string(cat1_api_runtime_get_cat1_signal())+ "\n"; uint32_t ppp_baudrate = get_ppp_baudrate_from_config_model(); deviceInfo += "ppp波特率:" + std::to_string(ppp_baudrate) + "\n"; +#else + deviceInfo += "cat1 cesq:" + std::string(cat1_api_runtime_get_cat1_cesq())+ "\n"; + deviceInfo += "cat1 csq_rssi:" + std::to_string(cat1_api_runtime_get_cat1_signal())+ "\n"; +#endif return deviceInfo; } @@ -225,6 +234,16 @@ namespace OHOS return; } + /*定时器回调函数:每2秒更新一次视图*/ + static void DebugOutputUpdateTimerCallback(void *arg) + { + (void)arg; + if (DebugGroupView != nullptr) + { + DebugOutputViewEventListener::GetInstance().UpdateView(); + } + } + /*创建调试专用主窗口视图*/ UIViewGroup *CreateDebugOutputMainView(void) { @@ -250,11 +269,11 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " new debugOutputtitleLabel fail"); return nullptr; } - debugOutputtitleLabel->SetPosition(80, 40, 200, 35); - debugOutputtitleLabel->SetStyle(STYLE_TEXT_FONT, 30); - debugOutputtitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + debugOutputtitleLabel->SetPosition(80, 40, 200, 25); + debugOutputtitleLabel->SetStyle(STYLE_TEXT_FONT, 20); + debugOutputtitleLabel->SetStyle(STYLE_LINE_HEIGHT, 25); debugOutputtitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); - debugOutputtitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + debugOutputtitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); DebugGroupView->Add(debugOutputtitleLabel); } /* -------------------------------------------------------------------------- */ @@ -266,12 +285,12 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new debugOutputLabel fail"); return nullptr; } - debugOutputLabel->SetPosition(30, 70, 300, 70); + debugOutputLabel->SetPosition(30, 65, 300, 70); debugOutputLabel->SetText(DebugOutputViewEventListener::GetInstance().GetLeiNiaoDeviceInfo().c_str()); - debugOutputLabel->SetStyle(STYLE_TEXT_FONT, 24); - debugOutputLabel->SetStyle(STYLE_LINE_HEIGHT, 24); + debugOutputLabel->SetStyle(STYLE_TEXT_FONT, 20); + debugOutputLabel->SetStyle(STYLE_LINE_HEIGHT, 20); debugOutputLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - debugOutputLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); + debugOutputLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); DebugGroupView->Add(debugOutputLabel); } RootView::GetInstance()->SetOnKeyActListener((OHOS::RootView::OnKeyActListener *)&DebugOutputViewEventListener::GetInstance()); @@ -280,6 +299,31 @@ namespace OHOS /* -------------------------------------------------------------------------- */ NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeDebugOutputMainView); /* -------------------------------------------------------------------------- */ + + /* 启动2秒定时器,定期更新视图 */ + if (g_debugOutputUpdateTimer == nullptr) + { + g_debugOutputUpdateTimer = osTimerNew((osTimerFunc_t)DebugOutputUpdateTimerCallback, osTimerPeriodic, nullptr, nullptr); + if (g_debugOutputUpdateTimer != nullptr) + { + uint32_t tick = osMs2Tick(2000); // 2秒 = 2000毫秒 + osStatus_t ret = osTimerStart(g_debugOutputUpdateTimer, tick); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to start debug output update timer, ret=%d", ret); + osTimerDelete(g_debugOutputUpdateTimer); + g_debugOutputUpdateTimer = nullptr; + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Debug output update timer started (2 seconds)"); + } + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to create debug output update timer"); + } + } } return DebugGroupView; } @@ -288,6 +332,16 @@ namespace OHOS void FreeDebugOutputMainView(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FreeDebugOutputMainView"); + + /* 停止并删除2秒定时器 */ + if (g_debugOutputUpdateTimer != nullptr) + { + osTimerStop(g_debugOutputUpdateTimer); + osTimerDelete(g_debugOutputUpdateTimer); + g_debugOutputUpdateTimer = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Debug output update timer stopped"); + } + ScreenAlwaysOnCtr(0); if (DebugGroupView != nullptr) { diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/api/tcpip.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/api/tcpip.c index c7824297f..7324632f8 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/api/tcpip.c +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/api/tcpip.c @@ -226,7 +226,11 @@ tcpip_thread_handle_msg(struct tcpip_msg *msg) break; #if LWIP_LOWPOWER /* just wake up thread do nothing */ - case TCPIP_MSG_NA: + case TCPIP_MSG_NA: { + /* 异步唤醒websocket(避免阻塞数据包处理路径) */ + extern int uapi_ws_resume(void); + uapi_ws_resume(); + if (msg->msg.lowpower.type == LOW_BLOCK) { LOWPOWER_SIGNAL(msg->msg.lowpower.wait_up); } else { @@ -234,6 +238,7 @@ tcpip_thread_handle_msg(struct tcpip_msg *msg) } sys_timeout_set_wake_time(LOW_TMR_DELAY); break; + } #endif default: @@ -292,9 +297,7 @@ tcpip_send_msg_na(enum lowpower_msg_type type) return; } - /* 唤醒websocket(当tcpip_thread被唤醒时,同时唤醒websocket) */ - extern int uapi_ws_resume(void); - uapi_ws_resume(); + /* 注意:uapi_ws_resume() 已移到 tcpip_thread 中异步处理,避免阻塞数据包处理路径 */ if (type == LOW_BLOCK) { LOWPOWER_SEM_WAIT(msg->msg.lowpower.wait_up); diff --git a/code/sdk/zhihui/4g/cat1Service/Service/cat1_ctl.c b/code/sdk/zhihui/4g/cat1Service/Service/cat1_ctl.c index 2612c62fc..c18db4ca3 100644 --- a/code/sdk/zhihui/4g/cat1Service/Service/cat1_ctl.c +++ b/code/sdk/zhihui/4g/cat1Service/Service/cat1_ctl.c @@ -409,7 +409,7 @@ void check_cat1_uart_wakeup(void) uint16_t status = pmu_lpm_wakeup_get_status(LPM_EVT_ACTION, PMU_LPM_MCPU_UART_L0_RX_WAKEUP); cat1_print_dbg("Cat1 UART wakeup status = %d", status); if (status != 0) { - cat1_print_warning("Cat1 UART wakeup detected, add cat1 sleep veto"); + printf("Cat1 UART wakeup detected, add cat1 sleep veto\r\n"); if (pm_veto_get_id_cnt(PM_ID_CAT1) == 0) { uapi_pm_add_sleep_veto(PM_ID_CAT1); } diff --git a/code/sdk/zhihui/4g/cat1Service/Service/cat1_runtime.c b/code/sdk/zhihui/4g/cat1Service/Service/cat1_runtime.c index b00c0fa1b..d8d2805f0 100644 --- a/code/sdk/zhihui/4g/cat1Service/Service/cat1_runtime.c +++ b/code/sdk/zhihui/4g/cat1Service/Service/cat1_runtime.c @@ -23,6 +23,8 @@ typedef struct uint8_t cat1_network_type ; int sim ; int signal ; + int signal_bars ; + char cesq[64] ; char opera[64] ; char imei[32] ; char pyVer[32] ; @@ -32,7 +34,34 @@ typedef struct static cat1_runtime_status_t g_runtime={0}; - +void cat1_api_runtime_set_cat1_signal_bars(int signal_bars) +{ + g_runtime.signal_bars=signal_bars; +} +int cat1_api_runtime_get_cat1_signal_bars(void) +{ + return g_runtime.signal_bars; +} +void cat1_api_runtime_set_cat1_cesq(char* cesq) +{ + if (cesq == NULL) return; + + // 计算长度并去除末尾的换行符(\r\n 或 \n) + int len = strlen(cesq); + // 去除末尾的换行符 + while (len > 0 && (cesq[len-1] == '\n' || cesq[len-1] == '\r')) { + len--; + } + + memset_s(g_runtime.cesq,sizeof(g_runtime.cesq),0,sizeof(g_runtime.cesq)); + memcpy_s(g_runtime.cesq,sizeof(g_runtime.cesq),cesq,len); + // printf("cat1_api_runtime_set_cat1_cesq %d: %s\n",len, g_runtime.cesq); + // printf("cat1_api_runtime_set_cat1_cesq end\n"); +} +char* cat1_api_runtime_get_cat1_cesq(void) +{ + return (char*)g_runtime.cesq; +} void cat1_api_runtime_set_cat1_powerstat(uint8_t cat1_powerOn) { g_runtime.cat1_powerOn=cat1_powerOn; diff --git a/code/sdk/zhihui/4g/cat1Service/Service/cat1_server.c b/code/sdk/zhihui/4g/cat1Service/Service/cat1_server.c index 505246179..2ed2a9ccf 100644 --- a/code/sdk/zhihui/4g/cat1Service/Service/cat1_server.c +++ b/code/sdk/zhihui/4g/cat1Service/Service/cat1_server.c @@ -712,6 +712,34 @@ static int decodeVersion(char* msg) return -3; } } + +static int CalculateSignalBars(int signalStrength) +{ + if (signalStrength >= 1 && signalStrength <= 8) // 0信号 + { + return 0; + } + else if (signalStrength >= 9 && signalStrength <= 16) // 1格信号,信号很弱偶尔可以接打电话,很容易失败 + { + return 1; + } + else if (signalStrength >= 17 && signalStrength <= 21) // 2格信号,信号一般 + { + return 2; + } + else if (signalStrength >= 22 && signalStrength <= 26) // 3格信号,信号较强 + { + return 3; + } + else if (signalStrength >= 27 && signalStrength <= 31) // 4格信号,信号很强 + { + return 4; + } + else + { + return 99; // Invalid signal strength + } +} // const char* msgnet ="imei:860132060352796,sim:0,oper:-1,signal:99,net:([99, 0, 0, 0], [0, 0, 0, 0, 0])"; // const char* msgnetfull = "imei:864430010001091,sim:1,oper:('CHN-CT', 'CT', '460', '11'),signal:22,net:([99, 99, 255, 255], [-71, -103, -12, 255, 4])"; // ([rssi, bitErrorRate, rscp, ecno], [rssi, rsrp, rsrq, cqi, sinr]) @@ -796,10 +824,12 @@ static int decodeNetStat(char* msg) { ppbuf=s+7; int signals = atoi(ppbuf); - cat1_print_dbg("=== signal = %d\r\n",signals); + int signal_bars = CalculateSignalBars(signals); + cat1_print_dbg("=== signal = %d, signal_bars = %d\r\n",signals,signal_bars); if ( cat1_api_runtime_get_cat1_signal() != signals) { update++; + cat1_api_runtime_set_cat1_signal_bars(signal_bars); cat1_api_runtime_set_cat1_signal(signals); } continue; @@ -1077,6 +1107,8 @@ static int cat1_parse_cesq_response(const char *response) return -1; } + cat1_api_runtime_set_cat1_cesq(cesq_line); + // 跳过"+CESQ:" cesq_line += 6; while (*cesq_line == ' ' || *cesq_line == '\t') cesq_line++; @@ -1118,14 +1150,14 @@ static int cat1_parse_cesq_response(const char *response) } // 更新信号强度到运行时状态 - int current_signal = cat1_api_runtime_get_cat1_signal(); - bool signal_changed = (current_signal != signal_strength); + int current_signal_bars = cat1_api_runtime_get_cat1_signal_bars(); + bool signal_changed = (current_signal_bars != signal_strength); bool network_stat_changed = false; if (signal_changed) { - cat1_api_runtime_set_cat1_signal(signal_strength); - cat1_print_warning("cat1_getsignal: Updated signal strength via AT+CESQ - signal=%d (was %d)\n", - signal_strength, current_signal); + // cat1_api_runtime_set_cat1_signal_bars(signal_strength); + cat1_print_warning("cat1_getsignal: Updated signal strength via AT+CESQ - signal_bars=%d (was %d)\n", + signal_strength, current_signal_bars); } // 如果信号强度有效(不是0),说明网络已连接,更新网络状态 diff --git a/code/sdk/zhihui/4g/cat1Service/include/cat1_runtime.h b/code/sdk/zhihui/4g/cat1Service/include/cat1_runtime.h index cb5f9b280..eebf05eea 100644 --- a/code/sdk/zhihui/4g/cat1Service/include/cat1_runtime.h +++ b/code/sdk/zhihui/4g/cat1Service/include/cat1_runtime.h @@ -26,6 +26,9 @@ extern "C" { */ /***************************************cat1 runtime 变量设置获取函数**************************************************/ +void cat1_api_runtime_set_cat1_cesq(char* cesq); +char* cat1_api_runtime_get_cat1_cesq(void); + void cat1_api_runtime_set_cat1_powerstat(uint8_t cat1_powerOn); uint8_t cat1_api_runtime_get_cat1_powerstat(void); @@ -35,6 +38,9 @@ uint8_t cat1_api_runtime_get_cat1_networkstat(void); void cat1_api_runtime_set_cat1_signal(int signal); int cat1_api_runtime_get_cat1_signal(void); +void cat1_api_runtime_set_cat1_signal_bars(int signal_bars); +int cat1_api_runtime_get_cat1_signal_bars(void); + void cat1_api_runtime_set_cat1_simstat(int simstat); int cat1_api_runtime_get_cat1_simstat(void);