From: hcj <1224667075@qq.com> Date: Thu, 11 Jul 2024 06:55:29 +0000 (+0800) Subject: 增加手表端文件接收超时判断 X-Git-Tag: release_V1.2.70_20241020_135402~830^2 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F501%2Fhead;p=mirrors%2FFD230.git 增加手表端文件接收超时判断 --- 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);//接收成功 }