From a184eaec6788e797cebc29fc32412374545160a6 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Thu, 11 Jul 2024 14:55:29 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E6=89=8B=E8=A1=A8=E7=AB=AF?= =?utf8?q?=E6=96=87=E4=BB=B6=E6=8E=A5=E6=94=B6=E8=B6=85=E6=97=B6=E5=88=A4?= =?utf8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../service/ble_service/bleservice/bleEvent.c | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) 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 972a7bd1f..35692e0f6 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -57,6 +57,8 @@ static bool ANCSBigBufFlag = 0;//ANCS多包数据flag static uint16_t data_len = 0; ble_recv_data_info_t ble_recv_data; static uint8_t TRANSMIT_DATA; +static osTimerId_t BR_TRANSFER_timer=NULL; + #if 1 #include "app_msg_manager.h" #include "app_tx_process.h" @@ -6048,6 +6050,36 @@ errcode_t cancel_recv_file(ble_read_data *buffer_handle) return ERRCODE_SUCC; } +static uint8_t timer_flie_type=0; +static uint32_t timer_flie_flag=0; +static void ble_transfer_Timer_CallBack(int data) +{ + timer_flie_flag--; + + if(timer_flie_flag==0) + { + if(timer_flie_type==1) + { + TRANSMIT_DATA=TRANS_OTA_FAIL; + } + else if (timer_flie_type==3) + { + TRANSMIT_DATA=TRANS_DIAL_FAIL; + } + else + { + TRANSMIT_DATA=TRANS_FREE; + } + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + if(BR_TRANSFER_timer) + { + osTimerStop(BR_TRANSFER_timer); + osTimerDelete(BR_TRANSFER_timer); + BR_TRANSFER_timer = NULL; + } + + } +} uint8_t OTA_FILE_value=0; uint8_t get_OTA_recv_value() @@ -6149,6 +6181,29 @@ errcode_t handle_recv_file(ble_read_data *buffer_handle,uint8_t *data, uint16_t } buffer_handle->file_recv_stat.recv_file_stat = 1; OTA_FILE_value=0; + ////////////////创建文件传输超时定时器////////////////// + uint32_t tick; + osStatus_t retTimer; + if(BR_TRANSFER_timer!=NULL) + { + osTimerDelete(BR_TRANSFER_timer); + BR_TRANSFER_timer = NULL; + } + timer_flie_type=buffer_handle->file_recv_stat.file_type; + timer_flie_flag=3; + + BR_TRANSFER_timer = osTimerNew((osTimerFunc_t)ble_transfer_Timer_CallBack, osTimerPeriodic, NULL, NULL); + tick =1000;// osMs2Tick(1000); + retTimer = osTimerStart(BR_TRANSFER_timer, tick); + if (retTimer != osOK && BR_TRANSFER_timer != NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer); + osTimerDelete(BR_TRANSFER_timer); + BR_TRANSFER_timer = NULL; + return ERRCODE_FAIL; + } + /////////////////////////////////////////////////////////// + + } if (buffer_handle->file_recv_stat.file == NULL) @@ -6160,6 +6215,8 @@ errcode_t handle_recv_file(ble_read_data *buffer_handle,uint8_t *data, uint16_t size_t writtensize = fwrite(data,1,event_size,buffer_handle->file_recv_stat.file); if(writtensize == event_size) { + timer_flie_flag=10; + 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); @@ -6188,6 +6245,13 @@ 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(BR_TRANSFER_timer) + { + osTimerStop(BR_TRANSFER_timer); + osTimerDelete(BR_TRANSFER_timer); + BR_TRANSFER_timer = NULL; + } + ble_reply_cmd(FILE_RECV_REPLY_STAT_CMD,1);//接收成功 } -- 2.17.1