From 0280b020e1c999de3be73cde003bcbe9c1fe8060 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Thu, 27 Jun 2024 17:02:59 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E6=94=B9ble=E6=89=93=E5=8D=B0=20?= =?utf8?q?=E5=8F=8A=E9=94=99=E8=AF=AF=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../service/ble_service/blemoder/bletest.cpp | 8 +-- .../service/ble_service/bleservice/bleEvent.c | 62 ++++++++++++++----- .../ble_service/bleservice/bleService.c | 8 +-- 3 files changed, 54 insertions(+), 24 deletions(-) diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp index 0381dc7b2..8faa4ecdd 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -1076,7 +1076,7 @@ const char *get_health_HEART_data_path( uint8_t day) JSON_F_buf=NULL; } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "!!!!!!!!!!!%x strlen(buf):%d",JSON_F_buf,strlen(buf)); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "!!!!!!!!!!!%x strlen(buf):%d",JSON_F_buf,strlen(buf)); uint8_t len = PATH_MAX_LEN+1; JSON_F_buf=(char *)malloc(len); memset(JSON_F_buf,0,len); @@ -1084,7 +1084,7 @@ const char *get_health_HEART_data_path( uint8_t day) { strcpy(JSON_F_buf,buf); } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",JSON_F_buf); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "%s",JSON_F_buf); #endif return JSON_F_buf; } @@ -1106,7 +1106,7 @@ const char *get_health_OXYGEN_data_path(uint8_t day) JSON_F_buf=NULL; } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "!!!!!!!!!!!%x strlen(buf):%d",JSON_F_buf,strlen(buf)); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "!!!!!!!!!!!%x strlen(buf):%d",JSON_F_buf,strlen(buf)); uint8_t len = PATH_MAX_LEN+1; JSON_F_buf=(char *)malloc(len); memset(JSON_F_buf,0,len); @@ -1114,7 +1114,7 @@ const char *get_health_OXYGEN_data_path(uint8_t day) { strcpy(JSON_F_buf,buf); } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",JSON_F_buf); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "%s",JSON_F_buf); #endif return JSON_F_buf; } 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 075b798bc..56255aab2 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -323,11 +323,12 @@ static bool Check_CRC(uint8_t *data,uint16_t len,uint8_t crcvalue)//计算20byte crcbuf = get_crc_from_lrc(lrcValue); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Check_CRC lrc: 0x%x ,ret crc: 0x%x ,crcvalue 0x%x , len:%d\r\n",lrcValue,crcbuf,crcvalue,len); - + #ifdef BLE_LOG + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Check_CRC lrc: 0x%x ,ret crc: 0x%x ,crcvalue 0x%x , len:%d\r\n",lrcValue,crcbuf,crcvalue,len); + #endif if(crcbuf == crcvalue) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Check_CRC true:\r\n"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Check_CRC true:\r\n"); return true; } else{ @@ -368,7 +369,9 @@ static cJSON *cjson_json_tmp = NULL; errcode_t sendBleData(uint8_t *buf,uint16_t len) { errcode_t ret = ERRCODE_FAIL; - printf("bigDataBufState:%d and sendbigDataBufState %d\r\n",bigDataBufState,sendbigDataBufState); + #ifdef BLE_LOG + printf("bigDataBufState:%d and sendbigDataBufState %d\r\n",bigDataBufState,sendbigDataBufState); + #endif if(bigDataBufState == true || sendbigDataBufState == true)return ERRCODE_FAIL; //在手表发送分包数据时 手表不允许发指令给app if(Bleconnect == true ) { @@ -2385,7 +2388,9 @@ void getAPPaddressbook(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalDat void type2AE4Data(ble_read_data *buffer_handle,uint8_t *buf_cmd,uint8_t *data,uint16_t datalen,uint8_t *totalData,uint8_t crcvalue) { uint16_t typeID = buf_cmd[1]*256+buf_cmd[2]; + #ifdef BLE_LOG printf("type2AE4Data typeID:0x%04X\r\n",typeID); + #endif switch (typeID) //ID { case USER_INFOR_CMD://app下发的获取用户信息 @@ -4518,7 +4523,9 @@ void GetDMPModeCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,ui void type2AE3Data(ble_read_data *buffer_handle,uint8_t *cmd_buf ,uint8_t *data,uint16_t datalen,uint8_t *totaldata,uint8_t crcvalue) { uint16_t cmd = cmd_buf[1]*256+cmd_buf[2]; + #ifdef BLE_LOG printf("typeHexOneData:0x%04X\r\n",cmd); + #endif // uint8_t typeID = cmd_buf[2]; switch (cmd) { @@ -4753,7 +4760,9 @@ void Read_JSON_file_buf_send_bin_Data(uint8_t day, uint8_t num,uint16_t id,char if(fp==NULL) { send_big_data(1,NULL,0,0,1,1,id,1); - printf("打开文件失败 %s \r\n",path); + #ifdef BLE_LOG + printf("打开文件失败 %s \r\n",path); + #endif if(path) { ym_free(path); @@ -4779,10 +4788,14 @@ void Read_JSON_file_buf_send_bin_Data(uint8_t day, uint8_t num,uint16_t id,char path = NULL; } cJSON *heart_data=cJSON_Parse(buf); - printf("读文件\r\n"); + #ifdef BLE_LOG + printf("读文件\r\n"); + #endif if(heart_data==NULL) { - printf("解析失败\r\n"); + #ifdef BLE_LOG + printf("解析失败\r\n"); + #endif send_big_data(1,NULL,0,0,1,1,id,1); sendbigDataBufState = false;//分包同步数据不允许打断 return; @@ -4807,8 +4820,10 @@ void Read_JSON_file_buf_send_bin_Data(uint8_t day, uint8_t num,uint16_t id,char uint32_t timestamp=cJSON_GetObjectItem(heart_data_item,"timestamp")->valueint; uint8_t value=cJSON_GetObjectItem(heart_data_item,"value")->valueint; // value =450; + #ifdef BLE_LOG printf("value :%d\r\n",value); printf("timestamp :%d\r\n",timestamp); + #endif memcpy(send_buf+send_len,×tamp,timeBit); send_len+=timeBit; memcpy(send_buf+send_len,&value,dataBit); @@ -4819,7 +4834,9 @@ void Read_JSON_file_buf_send_bin_Data(uint8_t day, uint8_t num,uint16_t id,char //发送数据 if(item_num-1==i) { - printf("sendbuf :%s sendbuf_len%d\r\n",send_buf,send_len); + #ifdef BLE_LOG + printf("sendbuf :%s sendbuf_len%d\r\n",send_buf,send_len); + #endif send_big_data(1,send_buf,send_len,item_num*5,Packet_id,packet_total,id,1); if(send_buf) { @@ -4899,8 +4916,9 @@ void Read_BIN_file_buf_send_bin_Data(uint8_t day,uint32_t pack_size,uint16_t id) } else { - - printf("%d %d %d %d\r\n",data_len,surplus_len,pack_id,pack); + #ifdef BLE_LOG + printf("%d %d %d %d\r\n",data_len,surplus_len,pack_id,pack); + #endif send_big_data(1,data+offset,surplus_len,data_len,pack_id,pack,id,1); break; } @@ -4947,11 +4965,12 @@ void readDevDataBle(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,u { num=96; } + #ifdef BLE_LOG printf("同步心率数据,每包最多:%d 条数据 data:%d %d\r\n",num,data[0],len); + #endif Read_JSON_file_buf_send_bin_Data(data[0],num,0x40,"heart_data_list"); break; case 0x41://同步血氧历史数据 - printf("同步血氧数据\r\n"); EACH_DATA_LEN = SPO2_DATA_LEN; num=(ble_nus_max_data_len-18)/EACH_DATA_LEN; Read_JSON_file_buf_send_bin_Data(data[0],num,0x41,"spo2_data_list"); @@ -5389,7 +5408,9 @@ void CustomEventPublish_TOPIC_EVENT_MESSAGENOTE(void) void type2AE1Data(uint8_t *buf_cmd,uint8_t *data,uint16_t datalen,uint8_t *totalData,uint8_t crcvalue) { uint16_t typeID = buf_cmd[1]*256+buf_cmd[2]; + #ifdef BLE_LOG printf("type2AE1Data typeID:0x%4X\r\n",typeID); + #endif switch (typeID) //ID { case ANDROID_ANCS_CMD:// @@ -5997,7 +6018,9 @@ void decode_file_checksum(ble_read_data *buffer_handle) void type2AE0Data(ble_read_data *buffer_handle) { uint16_t typeID = buffer_handle->cmd_header.cmdtype*256 + buffer_handle->cmd_header.cmdid; - printf("type2AE0Data typeID:0x%04X datalen %d\r\n",typeID,buffer_handle->totalDataLen); + #ifdef BLE_LOG + printf("type2AE0Data typeID:0x%04X datalen %d\r\n",typeID,buffer_handle->totalDataLen); + #endif bool checkcrc = (get_crc_from_lrc(buffer_handle->lrcvalue) == buffer_handle->crcvalue); uint32_t num; if ( (checkcrc == true ) || @@ -6092,6 +6115,7 @@ void type2AE0Data(ble_read_data *buffer_handle) void dumpHeader(msg_header_t *msgheader) { + #ifdef BLE_LOG printf("dumpHeader(%d) direction %02X, type %02X, id %02X, package_count %d, total_data_len %d,package_index %d , package_len %d\n", sizeof(msg_header_t), msgheader->direction, @@ -6102,6 +6126,7 @@ void dumpHeader(msg_header_t *msgheader) msgheader->package_index, msgheader->package_len ); + #endif } errcode_t check_header(msg_header_t *header ) @@ -6239,12 +6264,14 @@ errcode_t handle_recv_file(ble_read_data *buffer_handle,uint8_t *data, uint16_t void bleLongRecvData(ble_read_data *buffer_handle,uint8_t *data, uint16_t data_size,uint8_t *buf_cmd,uint8_t *totalData,uint8_t crcvalue)//buf_cmd 指令前17个字节数据 { uint8_t type=buf_cmd[1]; + #ifdef BLE_LOG printf("type:%d %d data_size:%d data:%x crcvalue:%x\r\n", buffer_handle->cmd_header.cmdtype, buffer_handle->cmd_header.cmdid, data_size, data, crcvalue); + #endif switch (type) { @@ -6476,14 +6503,17 @@ void bleDataRecv(uint8_t *totalData, uint16_t event_size,uint16_t handle) if (event_size < sizeof(msg_header_t)) { printf("event size (%d) is less than msg_header_t (%d) ",event_size,sizeof(msg_header_t)); - return ; + // return ; } if(sendbigDataBufState == true)//正在发送大数据不接收任何app指令下发的数据 { printf("sendbigDataBufState :(%d)",sendbigDataBufState); - return; + + // return; } - printf("bleDataRecv handle:%d\r\n",handle); + #ifdef BLE_LOG + printf("bleDataRecv handle:%d\r\n",handle); + #endif int last_unused_handle_index = -1; int handle_index_found = -1; for(int i = 0;i=0) { - printf("handle_index_found:index %d addr %X\r\n",handle_index_found,&handle_l[handle_index_found]); + // printf("handle_index_found:index %d addr %X\r\n",handle_index_found,&handle_l[handle_index_found]); handle_l[handle_index_found].handle = handle; combine_data_internal(&handle_l[handle_index_found],totalData,event_size); } diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c index 998ee66fa..402d075cb 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c @@ -981,7 +981,7 @@ errcode_t svr_ble_bt_gatts_noyify(uint8_t *data, uint16_t data_len)//这里是 data_info.value = data; data_info.value_len = data_len; errcode_t ret = gatts_notify_indicate(g_ble_server_id, g_ble_conn_id, &data_info); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gatts_notify_indicate ret:0x%x. serverid:%u,conn_id:%u,handle:%u.data_len:%d", ret, g_ble_server_id, + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "gatts_notify_indicate ret:0x%x. serverid:%u,conn_id:%u,handle:%u.data_len:%d", ret, g_ble_server_id, g_ble_conn_id, g_ble_server_handle,data_len); return ret; @@ -999,7 +999,7 @@ static uint8_t falg = 0; static void svr_ble_bt_gatts_req_write_cb(uint8_t server_id, uint16_t conn_id, gatts_req_write_cb_t *write_cb_para, errcode_t status) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "g_ble_server_handle %d conn_id :%d write_cb_para->length:%d write_cb_para->handle %d write_cb_para->request_id:%d",g_ble_server_handle,conn_id,write_cb_para->length, + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "g_ble_server_handle %d conn_id :%d write_cb_para->length:%d write_cb_para->handle %d write_cb_para->request_id:%d",g_ble_server_handle,conn_id,write_cb_para->length, write_cb_para->handle,write_cb_para->request_id); // printf("alipay_handle%d",alipay_handle); #if 0 @@ -1348,7 +1348,7 @@ void blesrv_service_recv_msg_handler(uint16_t srv_handle, uint8_t * msg_data, ui return ; } memcpy_s((blesrv_mail.msg_data),msg_len,msg_data,msg_len); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"g_blesrv_queue:%d ble_recv:mail.msg_data %X %02X %02X %02X msg_data:%02X %02X %02X\r\n", + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"g_blesrv_queue:%d ble_recv:mail.msg_data %X %02X %02X %02X msg_data:%02X %02X %02X\r\n", g_blesrv_queue, blesrv_mail.msg_data, blesrv_mail.msg_data[0], @@ -1387,7 +1387,7 @@ static void blesrv_service_check_task(void const *arg) uint16_t server_handle = mail.service_handle; uint32_t msg_len = mail.msg_len; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"mail.msg_data:%X,g_blesrv_queue:%d ble_recv:%d %d %02X %02X %02X mail.msg_data: %02X %02X %02X\r\n", + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"mail.msg_data:%X,g_blesrv_queue:%d ble_recv:%d %d %02X %02X %02X mail.msg_data: %02X %02X %02X\r\n", mail.msg_data, g_blesrv_queue, msg_len, -- 2.17.1