From 4dec07254d04081d54e105cfc13c7e85f582fc1e Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Wed, 10 Dec 2025 11:32:49 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E6=A8=A1=E7=BB=84=E5=8D=87?= =?utf8?q?=E7=BA=A7=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeapp/nativeui/ota/src/OtaModel.cpp | 8 +- .../nativeui/ota/src/OtaPresenter.cpp | 8 +- .../thunderbird/include/ThunderBirdModel.h | 5 ++ .../thunderbird/src/ThunderBirdModel.cpp | 81 ++++++++++++++----- .../4g/cat1Service/Service/cat1_server.c | 15 +++- .../4g/cat1Service/Service/cat1_tcpServer.c | 23 +++++- code/sdk/zhihui/leiniao/imsl_ln/ln_api.c | 2 +- code/sdk/zhihui/leiniao/imsl_ln/ln_api.h | 2 +- code/sdk/zhihui/leiniao/imsl_ln/ln_api_ota.c | 7 +- .../leiniao/ln_api_cpp/ln_api_interface.h | 1 + 10 files changed, 108 insertions(+), 44 deletions(-) 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 8ee7654d2..7c8679a07 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 @@ -257,13 +257,9 @@ namespace OHOS // 跳转到升级中界面 if (OtaView::GetInstance()) { - std::string cat1_pyver = uapi_dev_runtime_get_cat1_pyver(); - if(cat1_pyver == "PY_SRV_V27") - { - do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_OTA_GET_TASK_CAT1_RUN, NULL, 0); - } - else + if(!ThunderBirdModel::GetInstance()->is_Cat1_OtaUpgrade()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "普通ota下载"); do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_OTA_DOWNLOAD, NULL, 0); } OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_COUNTDOWN, OtaView::OTA_VIEW_UPDATING); diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaPresenter.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaPresenter.cpp index 41d44abf2..ecdd370b5 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaPresenter.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaPresenter.cpp @@ -164,13 +164,9 @@ namespace OHOS //倒计时界面确认,开始升级,定时器停止,进入升级中界面 else if (currentView == OtaView::OTA_VIEW_COUNTDOWN) { // do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_OTA_DOWNLOAD, NULL, 0); - std::string cat1_pyver = uapi_dev_runtime_get_cat1_pyver(); - if(cat1_pyver == "PY_SRV_V27") - { - do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_OTA_GET_TASK_CAT1_RUN, NULL, 0); - } - else + if(!ThunderBirdModel::GetInstance()->is_Cat1_OtaUpgrade()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "普通ota下载"); do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_OTA_DOWNLOAD, NULL, 0); } OtaModel::GetInstance()->StopCountdownTimer(); diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h index a3f3c9c96..c239d412b 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h @@ -299,6 +299,11 @@ namespace OHOS void at_set_fps(uint32_t freq); uint32_t at_get_fps(void); + /* --------------------------- cat1 OTA升级状态查询函数,特殊的ota升级 -------------------------- */ + bool is_Cat1_OtaUpgrade(); + void Cat1OtaUpgrade(); + /* -------------------------------------------------------------------------- */ + public: bool RegisterFuncKeyOnClick_6_timesEvent(void); void RegisterAllKeyEvents(void); 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 9c1767bc6..cea829d84 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 @@ -64,6 +64,7 @@ extern "C" { #include "cat1_server.h" #include "cat1_pub_api.h" #include "cat1_types.h" +#include "cat1_tcpServer.h" #endif #ifdef SUPPORT_PPP_SERVICE #include "ppp_api.h" @@ -95,6 +96,7 @@ extern "C" { #include #include "broadcast_feature.h" + int32_t AudioCaptureSample(int32_t argc, const char *argv[]); #ifdef __cplusplus @@ -1586,6 +1588,61 @@ extern "C" { } } + /* -------------------------------------------------------------------------- */ + + bool ThunderBirdModel::is_Cat1_OtaUpgrade() + { + std::string cat1_pyver = uapi_dev_runtime_get_cat1_pyver(); + if(cat1_pyver == "PY_SRV_V27") + { + return true; + } + else + { + return false; + } + } + + /** + * @brief cat1模组升级函数 + */ + void ThunderBirdModel::Cat1OtaUpgrade() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cat1模组升级"); + LOS_Msleep(1000); + uint32_t ret = 0; + const char * text1 = "EG8AK1022V27_1"; + ret = ln_ota_get_task_http_CAT1(uapi_ln_get_device_id(), uapi_ln_get_device_token(), text1, g_ln_last_package_url_new1); + if(ERRCODE_SUCC != ret) + { + ln_ota_get_task_http_CAT1(uapi_ln_get_device_id(), uapi_ln_get_device_token(), text1, g_ln_last_package_url_new1); + } + const char * text2 = "EG8AK1022V27_2"; + ret = ln_ota_get_task_http_CAT1(uapi_ln_get_device_id(), uapi_ln_get_device_token(), text2, g_ln_last_package_url_new2); + if(ERRCODE_SUCC != ret) + { + ln_ota_get_task_http_CAT1(uapi_ln_get_device_id(), uapi_ln_get_device_token(), text2, g_ln_last_package_url_new2); + } + + // 检查cat1模组升级url是否为空 + if(strlen(g_ln_last_package_url_new1) == 0) + { + ln_ota_get_task_http_CAT1(uapi_ln_get_device_id(), uapi_ln_get_device_token(), text1, g_ln_last_package_url_new1); + } + if(strlen(g_ln_last_package_url_new2) == 0) + { + ln_ota_get_task_http_CAT1(uapi_ln_get_device_id(), uapi_ln_get_device_token(), text2, g_ln_last_package_url_new2); + } + + #ifdef SUPPORT_CAT1_SERVICE + star_http_ota_updata(g_ln_last_package_url_new1,g_ln_last_package_url_new2,27); + #endif + push_ota_status(OTA_UI_STATUS_FORCE_START); + } + + /* -------------------------------------------------------------------------- */ + + /** * @brief 状态管理回调处理 */ @@ -1610,29 +1667,9 @@ extern "C" { // 需要是绑定状态才更新 // if(bind_status == true) // { - std::string cat1_pyver = uapi_dev_runtime_get_cat1_pyver(); - if(cat1_pyver == "PY_SRV_V27") + if(is_Cat1_OtaUpgrade()) { - LOS_Msleep(1000); - push_ota_status(OTA_UI_STATUS_FORCE_START); - const char * text1 = "EG8AK1022V27_1"; - if(ERRCODE_SUCC == ln_ota_get_task_http_CAT1(uapi_ln_get_device_id(), uapi_ln_get_device_token(), text1)) - { - LOS_Msleep(1000); - } - else - { - ln_ota_get_task_http_CAT1(uapi_ln_get_device_id(), uapi_ln_get_device_token(), text1); - } - const char * text2 = "EG8AK1022V27_2"; - if(ERRCODE_SUCC == ln_ota_get_task_http_CAT1(uapi_ln_get_device_id(), uapi_ln_get_device_token(), text2)) - { - LOS_Msleep(1000); - } - else - { - ln_ota_get_task_http_CAT1(uapi_ln_get_device_id(), uapi_ln_get_device_token(), text2); - } + Cat1OtaUpgrade(); } else { diff --git a/code/sdk/zhihui/4g/cat1Service/Service/cat1_server.c b/code/sdk/zhihui/4g/cat1Service/Service/cat1_server.c index f1becd361..ba704ba92 100644 --- a/code/sdk/zhihui/4g/cat1Service/Service/cat1_server.c +++ b/code/sdk/zhihui/4g/cat1Service/Service/cat1_server.c @@ -1284,7 +1284,10 @@ int cat1_handle_call_incomming(char * msg) } - +#ifdef BOARD_LEINIAO +extern int cat1_model_oat_suc_flag;//模组升级标志 +#include "ln_api_interface.h" +#endif int cat1_handle_networ_msg(char *msg) { // cat1_print_info("cat1 cat1_handle_networ_msg %s\n",msg->buffer); @@ -1295,6 +1298,16 @@ int cat1_handle_networ_msg(char *msg) g_msg_callback_func(MESSAGE_4G_NETWORK_STAT_CHANGED,NULL,0); } //显示UI 信号 + #ifdef BOARD_LEINIAO + if(cat1_model_oat_suc_flag == 1) //验证cat1模组有没有升级成功,如果收到消息,说明升级成功 + { + cat1_model_oat_suc_flag = 0;//升级成功后,将标志位设为0 + printf("模组升级成功\n"); + push_ota_status(OTA_UI_STATUS_SUCCESS); + LOS_Msleep(1000); + shutdown_reboot_prejobs(2);//重启 + } + #endif return 1; } diff --git a/code/sdk/zhihui/4g/cat1Service/Service/cat1_tcpServer.c b/code/sdk/zhihui/4g/cat1Service/Service/cat1_tcpServer.c index f8cf2c54b..e39a7bf2f 100644 --- a/code/sdk/zhihui/4g/cat1Service/Service/cat1_tcpServer.c +++ b/code/sdk/zhihui/4g/cat1Service/Service/cat1_tcpServer.c @@ -1373,17 +1373,17 @@ static uint16 mode_ota_count=0; #ifdef BOARD_LEINIAO #include "ln_api_interface.h" +int cat1_model_oat_suc_flag = 0;//模组升级标志 #endif static void modem_ota_timer_CallBack(int data_tmp) { - printf("modem_ota_timer_CallBack mode_ota_count:%d\n",mode_ota_count); + printf("modem_ota_timer_CallBack %d old_model_ver %d g_py_ver %d\n",mode_ota_count,old_model_ver,g_py_ver); if(old_model_ver!=g_py_ver) { uint8_t TRANSMIT_DATA=TRANS_FREE; #ifdef BOARD_LEINIAO push_ota_status(OTA_UI_STATUS_SUCCESS); - LOS_Msleep(1000); shutdown_reboot_prejobs(REBOOT_TYPE); #else CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); @@ -1410,6 +1410,18 @@ static void modem_ota_timer_CallBack(int data_tmp) modem_ota_timer = NULL; } } + + #ifdef BOARD_LEINIAO + if(mode_ota_count > 100) //3分钟验证cat1模组有没有升级成功,发消息给模型,如果收到消息,说明升级成功 + { + printf("cat1_model_oat_suc_flag %d\n",cat1_model_oat_suc_flag); + if(cat1_model_oat_suc_flag == 0) + { + udp_send_msg_toCat1(0x07,"0"); + } + cat1_model_oat_suc_flag = 1; + } + #endif } } @@ -1432,6 +1444,13 @@ void start_mode_ota_timer() } void star_http_ota_updata(char*buf_1,char* buf_2,uint8_t ver) { + printf("star_http_ota_updata:buf_1 %s\n",buf_1); + printf("star_http_ota_updata:buf_2 %s\n",buf_2); + if(buf_1 == NULL || buf_2 == NULL) + { + printf("star_http_ota_updata:buf_1 or buf_2 is NULL\n"); + return; + } int ret=0; char * send_buf=(char *) malloc(strlen(buf_1)+strlen(buf_2)+40); memset(send_buf,0,strlen(buf_1)+strlen(buf_2)+40); diff --git a/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c b/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c index 052f4394a..acf62a988 100644 --- a/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c +++ b/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c @@ -1219,7 +1219,7 @@ static void ln_http_server_send_task(void const *arg) } if (source_url) { - ln_ota_get_task_http_CAT1(uapi_ln_get_device_id(), uapi_ln_get_device_token(), source_url); + // ln_ota_get_task_http_CAT1(uapi_ln_get_device_id(), uapi_ln_get_device_token(), source_url); free(source_url); } } diff --git a/code/sdk/zhihui/leiniao/imsl_ln/ln_api.h b/code/sdk/zhihui/leiniao/imsl_ln/ln_api.h index de32d45d0..4b9c1564a 100644 --- a/code/sdk/zhihui/leiniao/imsl_ln/ln_api.h +++ b/code/sdk/zhihui/leiniao/imsl_ln/ln_api.h @@ -152,7 +152,7 @@ extern char g_ln_last_package_url_new2[256]; #define LN_HTTP_SERVICE_CMD_OTA_GET_TASK_CAT1_RUN 0x1019 uint32_t ln_ota_get_task_http_CAT1(const char *device_id, const char *device_token, - const char *source_version); + const char *source_version, char *url); /* -------------------------------------------------------------------------- */ /* 下载文件相关结构体 */ diff --git a/code/sdk/zhihui/leiniao/imsl_ln/ln_api_ota.c b/code/sdk/zhihui/leiniao/imsl_ln/ln_api_ota.c index 88ffc8e60..2e08c8250 100644 --- a/code/sdk/zhihui/leiniao/imsl_ln/ln_api_ota.c +++ b/code/sdk/zhihui/leiniao/imsl_ln/ln_api_ota.c @@ -1319,7 +1319,7 @@ static void ln_handle_ota_task_response_CAT1(const char *json_buf, int json_len, } uint32_t ln_ota_get_task_http_CAT1(const char *device_id, const char *device_token, - const char *source_version) + const char *source_version,char *url) { if (!device_id || !device_token || !source_version) return ERRCODE_FAIL; @@ -1422,10 +1422,7 @@ uint32_t ln_ota_get_task_http_CAT1(const char *device_id, if (clientData.responseBuf && clientData.responseBufLen > 0) { int real_len = clientData.responseContentLen > 0 ? clientData.responseContentLen : clientData.responseBufLen; - if(g_ln_last_package_url_new1[0] == '\0') - ln_handle_ota_task_response_CAT1(clientData.responseBuf, real_len,g_ln_last_package_url_new1); - else if(g_ln_last_package_url_new2[0] == '\0') - ln_handle_ota_task_response_CAT1(clientData.responseBuf, real_len,g_ln_last_package_url_new2); + ln_handle_ota_task_response_CAT1(clientData.responseBuf, real_len,url); } end: diff --git a/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.h b/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.h index 5d2314ed7..f884095c0 100644 --- a/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.h +++ b/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.h @@ -35,6 +35,7 @@ typedef enum { OTA_UI_STATUS_NOT_START = 0, /* 未开始 */ OTA_UI_STATUS_FORCE_START, /* ota强制开始升级状态 */ OTA_UI_STATUS_OPTIONAL_START, /* ota可选开始升级状态 */ + OTA_UI_STATUS_CAT1_START, /* cat1模组升级开始 */ OTA_UI_STATUS_FAILED, /* 失败 */ OTA_UI_STATUS_SUCCESS, /* 成功 */ } ota_ui_status_t; -- 2.17.1