From 88cebe6f450558addcab3c0e3b22b1a69b4fee61 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Tue, 11 Jun 2024 09:55:14 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0OTA=E4=BC=A0=E8=BE=93=E4=B8=AD?= =?utf8?q?=E7=9A=84=E8=BF=9B=E5=BA=A6=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../service/ble_service/bleservice/bleEvent.c | 79 +++++++++++++++++-- .../service/ble_service/bleservice/bleEvent.h | 3 +- .../msg_center/src/notify/transmitting.cpp | 36 ++++++++- 3 files changed, 109 insertions(+), 9 deletions(-) diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c index e12514893..2dbc96b32 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -5260,6 +5260,10 @@ errcode_t decode_dial_info(ble_read_data *buffer_handle) buffer_handle->file_recv_stat.lrcvalue = 0; buffer_handle->receive_file_flag = 0; + //进入特殊UI + TRANSMIT_DATA=TRANS_DIAL_TRANSMITTING; + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + free(filename); return ERRCODE_SUCC; @@ -5396,6 +5400,11 @@ void decode_file_checksum(ble_read_data *buffer_handle) { case 1: //ota do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_STARTOTA,NULL,0); + + TRANSMIT_DATA=TRANS_OTA_SUCC; + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + + break; case 2://mp3 @@ -5403,18 +5412,66 @@ void decode_file_checksum(ble_read_data *buffer_handle) case 3://dial //TODO: 设置成当前下载的表盘 if (install_dial() == ERRCODE_SUCC) + { + + TRANSMIT_DATA= TRANS_DIAL_SUCC; + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + ble_reply_cmd(DIAL_INSTALL_REPY_CMD,1); + } else + { + TRANSMIT_DATA= TRANS_DIAL_FAIL; + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + ble_reply_cmd(DIAL_INSTALL_REPY_CMD,0); + + } + break; default: break; } }else{ - ble_reply_cmd(FILE_CHECKSUM_RECV_CMD,2); + ble_reply_cmd(FILE_CHECKSUM_RECV_CMD,2); + switch (buffer_handle->file_recv_stat.file_type) + { + case 1: //ota + TRANSMIT_DATA=TRANS_OTA_FAIL; + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + break; + case 2://mp3 + + break; + case 3://dial + TRANSMIT_DATA= TRANS_DIAL_FAIL; + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + ble_reply_cmd(DIAL_INSTALL_REPY_CMD,0); + break; + default: + break; + } + } }else{ ble_reply_cmd(FILE_CHECKSUM_RECV_CMD,0); + switch (buffer_handle->file_recv_stat.file_type) + { + case 1: //ota + TRANSMIT_DATA=TRANS_OTA_FAIL; + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + break; + case 2://mp3 + + break; + case 3://dial + TRANSMIT_DATA= TRANS_DIAL_FAIL; + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + ble_reply_cmd(DIAL_INSTALL_REPY_CMD,0); + break; + default: + break; + } } } @@ -5539,6 +5596,18 @@ errcode_t cancel_recv_file(ble_read_data *buffer_handle) return ERRCODE_SUCC; } +uint8_t OTA_FILE_value=0; + +uint8_t get_OTA_recv_value() +{ + return OTA_FILE_value; +} + +void Set_OTA_recv_value() +{ + OTA_FILE_value=0; + return; +} errcode_t handle_recv_file(ble_read_data *buffer_handle,uint8_t *data, uint16_t event_size) { @@ -5572,6 +5641,7 @@ errcode_t handle_recv_file(ble_read_data *buffer_handle,uint8_t *data, uint16_t return ERRCODE_FAIL; } buffer_handle->file_recv_stat.recv_file_stat = 1; + OTA_FILE_value=0; } if (buffer_handle->file_recv_stat.file == NULL) @@ -5585,6 +5655,7 @@ errcode_t handle_recv_file(ble_read_data *buffer_handle,uint8_t *data, uint16_t buffer_handle->file_recv_stat.lrcvalue = calculate_lrc(data,event_size,buffer_handle->file_recv_stat.lrcvalue); buffer_handle->file_recv_stat.received_size += event_size; printf("handle_recv_file received_size %d\n",buffer_handle->file_recv_stat.received_size); + OTA_FILE_value= ((float) buffer_handle->file_recv_stat.received_size / (float)buffer_handle->file_recv_stat.file_size) *100; }else{ printf("handle_recv_file write file failed! ret %d != %d\n",writtensize,event_size); @@ -5608,11 +5679,7 @@ errcode_t handle_recv_file(ble_read_data *buffer_handle,uint8_t *data, uint16_t buffer_handle->receive_file_flag = 0; printf("handle_recv_file received success \n"); - if (buffer_handle->file_recv_stat.file_type == 1) - { - TRANSMIT_DATA=TRANS_OTA_SUCC; - CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); - } + ble_reply_cmd(FILE_RECV_REPLY_STAT_CMD,1);//接收成功 } diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h index 3ec0f3cc2..acae1d070 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h @@ -700,8 +700,9 @@ typedef struct +uint8_t get_OTA_recv_value(void); - +void Set_OTA_recv_value(void); void revBleOldData(uint8_t *buf, uint16_t event_size,uint16_t handle);//协议接收client下发的数据接口 //02类型的指令数据 diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/transmitting.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/transmitting.cpp index 7e943a150..b76cb6d03 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/transmitting.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/transmitting.cpp @@ -11,6 +11,7 @@ #include "custom_utils.h" #include "components/ui_slider.h" // #include "UiConfig.h" +#include "bleEvent.h" namespace OHOS { @@ -105,6 +106,7 @@ namespace OHOS } static osTimerId_t transmitting_timer= NULL; + void Freetransmitting(void) { if (UIViewGroup_transmitting != nullptr) @@ -131,11 +133,20 @@ namespace OHOS delete downImageAnimatorView; downImageAnimatorView = nullptr; } - if(updatasider) + if(updatasider) { delete updatasider; updatasider = nullptr; } + if(transmitting_timer) + { + osStatus_t ret = osTimerDelete(transmitting_timer); + if (ret != osOK) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Disatransmitting_timer failed ret = %lx!", ret); + return; + } + transmitting_timer = nullptr; + } RootView::GetInstance()->Remove(UIViewGroup_transmitting); @@ -144,7 +155,14 @@ namespace OHOS } } static uint8_t timer_falg_low_power=5; - + + void OTATimerCallBack(int data) + { + updatasider->SetValue(get_OTA_recv_value()); + RootView::GetInstance()->Invalidate(); + } + + void creat_down_OTA() { @@ -198,6 +216,20 @@ namespace OHOS const char *imagesPath = TRANSMITTING_OTA_DOWN; transmitting_img->SetSrc(imagesPath); UIViewGroup_transmitting->Add(transmitting_img); + + uint32_t tick; + osStatus_t retTimer; + + Set_OTA_recv_value(); + transmitting_timer = osTimerNew((osTimerFunc_t)OTATimerCallBack, osTimerPeriodic, NULL, NULL); + tick =500;// osMs2Tick(1000); + retTimer = osTimerStart(transmitting_timer, tick); + if (retTimer != osOK && transmitting_timer != NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer); + osTimerDelete(transmitting_timer); + transmitting_timer = NULL; + return ; + } } -- 2.17.1