修复小睡死机问题
authorhcj <1224667075@qq.com>
Tue, 8 Oct 2024 09:17:11 +0000 (17:17 +0800)
committerhcj <1224667075@qq.com>
Tue, 8 Oct 2024 09:17:11 +0000 (17:17 +0800)
code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp
code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c

index 01559db..b4337a2 100644 (file)
@@ -689,8 +689,8 @@ uint8_t ble_get_sleep_data(uint32_t file_size,uint8_t day_,uint8_t *data)
                                 uint16_t read_size_status =fread(data+offset+3+read_size,1,sleep_file_size,fp);
                                 read_size+=read_size_status;
                                 memcpy(data+offset,&read_size,2);
-                                
-                                offset+=read_size_status;
+                                fclose(fp);
+
                             }
                             offset+=read_size;
                             offset+=3;
@@ -699,6 +699,7 @@ uint8_t ble_get_sleep_data(uint32_t file_size,uint8_t day_,uint8_t *data)
                     }
                     else if(fileName!="sleep_status.bin")
                     {
+                        printf("offset %d\r\n",offset);
                         char file_path[128]={0};
                         sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name);
                         
index 767adb9..c24b4b9 100644 (file)
@@ -5471,132 +5471,7 @@ static void GetSynDataEndCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *to
         sendBleData(value,19);\r
     }\r
 }\r
-//同步历史步数\r
-static void stepDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue)\r
-{\r
-    uint8_t value[58];\r
-    memset(value,0,58);\r
-    uint32_t tmp = 1;\r
-    uint32_t tmpToall = 40;\r
-    uint16_t tmp_data = 40;\r
-    value[0] = 0x72;\r
-    value[1] = 0x01;\r
-    value[2] = 0x43;\r
-    memcpy(value+3,&tmp,4);\r
-    memcpy(value+7,&tmpToall,4);\r
-    memcpy(value+11,&tmp,4);\r
-    memcpy(value+15,&tmp_data,2);\r
-    if(Check_CRC(data,len,crcvalue))\r
-    {\r
-        uint8_t data_buf[40]; //\r
-        uint8_t data_len = 0;\r
-        uint32_t time = 1704090976;\r
-        uint32_t step = 0;\r
-        int ret = uapi_get_timestampe_ss(&time);\r
-        \r
-        for(uint16_t i = 0;i<5;i++)\r
-        {\r
-            time = time+i*3600;\r
-            memcpy(data_buf+data_len,&time,4);\r
-            data_len=data_len+4;\r
-            step = i*100;\r
-            memcpy(data_buf+data_len,&step,4);//1 3 5 7 9 \r
-            data_len = data_len+4;\r
-            \r
-        }\r
-        memcpy(&value[17],data_buf,40);\r
-        // value[17] = 1;// \r
-        value[17+40] = Calculate_CRC(value,57);\r
-        sendBleData(value,58);\r
-    }else\r
-    {\r
-        value[17] = 0;\r
-        value[18] = Calculate_CRC(value,18);\r
-        sendBleData(value,19);\r
-    }\r
-}\r
-//同步卡路里历史数据\r
-static void kcalDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue)\r
-{\r
-    uint8_t value[58];\r
-    memset(value,0,58);\r
-    uint32_t tmp = 1;\r
-    uint32_t tmpToall = 40;\r
-    uint16_t tmp_data = 40;\r
-    value[0] = 0x72;\r
-    value[1] = 0x01;\r
-    value[2] = 0x46;\r
-    memcpy(value+3,&tmp,4);\r
-    memcpy(value+7,&tmpToall,4);\r
-    memcpy(value+11,&tmp,4);\r
-    memcpy(value+15,&tmp_data,2);\r
-    if(Check_CRC(data,len,crcvalue))\r
-    {\r
-        uint8_t data_buf[40]; //\r
-        uint8_t data_len = 4;\r
-        for(uint16_t i = 0;i<10;i++)\r
-        {\r
-            if( i % 2 == 0){\r
-                uint32_t time = 1710484844+i*3600;\r
-                memcpy(&data_buf[4*i],&time,data_len); //0 2 4 6 8\r
-            }else{\r
-                float kcal = 189+i*20;\r
-                memcpy(&data_buf[4*i],&kcal,data_len);//1 3 5 7 9 \r
-            }\r
-            \r
-        }\r
-        memcpy(&value[17],data_buf,40);\r
-        // value[17] = 1;// \r
-        value[17+40] = Calculate_CRC(value,57);\r
-        sendBleData(value,58);\r
-    }else\r
-    {\r
-        value[17] = 0;\r
-        value[18] = Calculate_CRC(value,18);\r
-        sendBleData(value,19);\r
-    }\r
-}\r
-//同步距离历史数据\r
-static void disDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue)\r
-{\r
-    uint8_t value[58];\r
-    memset(value,0,58);\r
-    uint32_t tmp = 1;\r
-    uint32_t tmpToall = 40;\r
-    uint16_t tmp_data = 40;\r
-    value[0] = 0x72;\r
-    value[1] = 0x01;\r
-    value[2] = 0x47;\r
-    memcpy(value+3,&tmp,4);\r
-    memcpy(value+7,&tmpToall,4);\r
-    memcpy(value+11,&tmp,4);\r
-    memcpy(value+15,&tmp_data,2);\r
-    if(Check_CRC(data,len,crcvalue))\r
-    {\r
-        uint8_t data_buf[40]; //\r
-        uint8_t data_len = 4;\r
-        for(uint16_t i = 0;i<10;i++)\r
-        {\r
-            if( i % 2 == 0){\r
-                uint32_t time = 1710484844+i*3600;\r
-                memcpy(&data_buf[4*i],&time,data_len); //0 2 4 6 8\r
-            }else{\r
-                float kcal = 189+i*20;\r
-                memcpy(&data_buf[4*i],&kcal,data_len);//1 3 5 7 9 \r
-            }\r
-            \r
-        }\r
-        memcpy(&value[17],data_buf,40);\r
-        // value[17] = 1;// \r
-        value[17+40] = Calculate_CRC(value,57);\r
-        sendBleData(value,58);\r
-    }else\r
-    {\r
-        value[17] = 0;\r
-        value[18] = Calculate_CRC(value,18);\r
-        sendBleData(value,19);\r
-    }\r
-}\r
+\r
 //同步基础训练历史数据 training history data\r
 static void Send_json_Data_Cmd(uint8_t day,uint16_t pack_size,uint8_t id)\r
 {\r
@@ -5658,35 +5533,8 @@ static void Send_json_Data_Cmd(uint8_t day,uint16_t pack_size,uint8_t id)
            pack_id++;\r
         }\r
         cJSON_free(json_format);\r
-        // ym_free(json_format);\r
-}\r
-//同步睡眠数据\r
-static void sleepDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue)\r
-{\r
-    uint8_t value[18+1];\r
-    memset(value,0,18+1);\r
-    uint32_t tmp = 1;\r
-    uint32_t tmpToall = 0;\r
-    uint16_t tmp_data = 0;\r
-    value[0] = 0x72;\r
-    value[1] = 0x01;\r
-    value[2] = 0x4b;\r
-    memcpy(value+3,&tmp,4);\r
-    memcpy(value+7,&tmpToall,4);\r
-    memcpy(value+11,&tmp,4);\r
-    memcpy(value+15,&tmp_data,2);\r
-    if(Check_CRC(data,len,crcvalue))\r
-    {\r
-        value[17] = 0;\r
-        value[18] = 0xff;\r
-        sendBleData(value,19);\r
-    }else\r
-    {\r
-        value[17] = 0;\r
-        value[18] = Calculate_CRC(value,18);\r
-        sendBleData(value,19);\r
-    }\r
 }\r
+\r
 //同步数据结束完成\r
 static void synEndDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue)\r
 {\r
@@ -5714,134 +5562,8 @@ static void synEndDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *total
         sendBleData(value,19);\r
     }\r
 }\r
-//同步站立历史数据\r
-static void standDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue)\r
-{\r
-    uint8_t value[58];\r
-    memset(value,0,58);\r
-    uint32_t tmp = 1;\r
-    uint32_t tmpToall = 40;\r
-    uint16_t tmp_data = 40;\r
-    value[0] = 0x72;\r
-    value[1] = 0x01;\r
-    value[2] = 0x45;\r
-    memcpy(value+3,&tmp,4);\r
-    memcpy(value+7,&tmpToall,4);\r
-    memcpy(value+11,&tmp,4);\r
-    memcpy(value+15,&tmp_data,2);\r
-    if(Check_CRC(data,len,crcvalue))\r
-    {\r
-        uint8_t data_buf[40]; //\r
-        uint8_t data_len = 4;\r
-        for(uint16_t i = 0;i<10;i++)\r
-        {\r
-            if( i % 2 == 0){\r
-                uint32_t time = 1710484844+i*3600;\r
-                memcpy(&data_buf[4*i],&time,data_len); //0 2 4 6 8\r
-            }else{\r
-                float kcal = 189+i*20;\r
-                memcpy(&data_buf[4*i],&kcal,data_len);//1 3 5 7 9 \r
-            }\r
-            \r
-        }\r
-        memcpy(&value[17],data_buf,40);\r
-        // value[17] = 1;// \r
-        value[17+40] = Calculate_CRC(value,57);\r
-        sendBleData(value,58);\r
-    }else\r
-    {\r
-        value[17] = 0;\r
-        value[18] = Calculate_CRC(value,18);\r
-        sendBleData(value,19);\r
-    }\r
-}\r
 \r
-//同步燃脂时间数据\r
-static void burntimeDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue)\r
-{\r
-    uint8_t value[48];\r
-    memset(value,0,48);\r
-    uint32_t tmp = 1;\r
-    uint32_t tmpToall = 30;\r
-    uint16_t tmp_data = 30;\r
-    value[0] = 0x72;\r
-    value[1] = 0x01;\r
-    value[2] = 0x44;\r
-    memcpy(value+3,&tmp,4);\r
-    memcpy(value+7,&tmpToall,4);\r
-    memcpy(value+11,&tmp,4);\r
-    memcpy(value+15,&tmp_data,2);\r
-    if(Check_CRC(data,len,crcvalue))\r
-    {\r
-        uint8_t data_buf[30]; //\r
-        uint32_t data_len = 0;\r
-        for(uint16_t i = 0;i<5;i++)\r
-        {\r
-            uint32_t time = 1710484844+i*3600;\r
-            uint16_t fatTime = 189+i*20;//1 \r
-            memcpy(value+17+data_len,&time,4);\r
-            data_len=data_len+4;//4 6\r
-            memcpy(value+17+data_len,&fatTime,2);//1 3 5 7 9\r
-            data_len=data_len+2;//6 \r
-        }\r
-        printf("data_len:%d",data_len);\r
-        // memcpy(&value[17],data_buf,30);\r
-        // value[17] = 1;// \r
-        value[17+data_len] = Calculate_CRC(value,data_len+17);\r
-        sendBleData(value,data_len+17+1);\r
-    }else\r
-    {\r
-        value[17] = 0;\r
-        value[18] = Calculate_CRC(value,18);\r
-        sendBleData(value,19);\r
-    }\r
-}\r
-uint8 read_hart_jsondata(uint8 day)\r
-{\r
-    // char path[64]={0};\r
-    // sprintf(path,"%s/%d",HEALTH_JSON_PATH,day);\r
-    // fopen();\r
-    // {\r
-        return 0;\r
-    // }\r
-}\r
 \r
-//同步血氧历史数据\r
-static void spo2DataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue)\r
-{\r
-    uint8_t value[43];\r
-    memset(value,0,43);\r
-    uint32_t tmp = 1;\r
-    uint32_t tmpToall = 25;\r
-    uint16_t tmp_data = 25;\r
-    value[0] = 0x72;\r
-    value[1] = 0x01;\r
-    value[2] = 0x41;\r
-    memcpy(value+3,&tmp,4);\r
-    memcpy(value+7,&tmpToall,4);\r
-    memcpy(value+11,&tmp,4);\r
-    memcpy(value+15,&tmp_data,2);\r
-    if(Check_CRC(data,len,crcvalue))\r
-    {\r
-        uint32_t data_len = 0;\r
-        for(uint16_t i = 0;i<5;i++)\r
-        {\r
-            uint32_t time = 1710484844+i*3600;\r
-            uint8_t spo2 = 90+i;//1 \r
-            memcpy(value+17+data_len,&time,4);\r
-            data_len=data_len+4;//4 6\r
-            memcpy(value+17+data_len,&spo2,1);//1 3 5 7 9\r
-            data_len=data_len+1;//6 \r
-        }\r
-        value[17+data_len] = Calculate_CRC(value,data_len+17);\r
-        sendBleData(value,data_len+17+1);\r
-    }else\r
-    {\r
-        value[17] = 0;\r
-        value[18] = Calculate_CRC(value,18);\r
-        sendBleData(value,19);\r
-    }\r
-}\r
 \r
 \r
 //01类型 \r
@@ -6185,8 +5907,6 @@ void Send_Sleep_Bin_Data(uint8_t day, uint16_t num)
 \r
             ble_data_type type_={0x01,0x4b,file_size,pack,pack_id};\r
             send_big_data(type_,data+offset,num);\r
-           \r
-            //send_big_data(1,data+offset,num,file_size,pack_id,pack,0x4b,1);\r
             offset+=num;\r
         }\r
         else\r
@@ -6202,8 +5922,6 @@ void Send_Sleep_Bin_Data(uint8_t day, uint16_t num)
                 printf("%02X ",(uint8_t)data[i]);\r
             }\r
             printf("结束\r\n");\r
-\r
-            //send_big_data(1,data+offset,surplus_len,file_size,pack_id,pack,0x4b,1);\r
             break;\r
         }\r
         pack_id++;\r