修复部分历史数据无法上传BUG
authorhcj <1224667075@qq.com>
Sat, 3 Aug 2024 01:55:49 +0000 (09:55 +0800)
committerhcj <1224667075@qq.com>
Sat, 3 Aug 2024 01:55:49 +0000 (09:55 +0800)
code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp
code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h
code/sdk/drivers/peripheral/cywee/src/board_yh601s.c
code/sdk/drivers/peripheral/cywee/src/main_dml.c

index 14404c1..e644336 100644 (file)
@@ -720,11 +720,11 @@ char * ble_sywee_history(uint8_t day,uint16_t *len ,uint8_t type)
         timeinfo = localtime(&currtime);
         printf("localtime %d",timeinfo->tm_min);
         creationTime=creationTime-(timeinfo->tm_min*60)-(timeinfo->tm_sec);
-
+        float f_value=0;
         switch (type)
         {
             case 0x43: //同步步数历史数据
-                value=get_now_hour_data(CYWEE_SAVE_DATA_STEP);
+                get_now_hour_data(&value,CYWEE_SAVE_DATA_STEP);
                 if(value>0)
                 {
                     memcpy(buf+size,&creationTime,4);
@@ -734,12 +734,12 @@ char * ble_sywee_history(uint8_t day,uint16_t *len ,uint8_t type)
                 }
                 break;
             case 0x44://同步燃脂时间数据
-                value=get_now_hour_data(CYWEE_SAVE_DATA_FAT);
+                get_now_hour_data(&value,CYWEE_SAVE_DATA_FAT);
                 if(value>0)
                 {
                     memcpy(buf+size,&creationTime,4);
                     size+=4;
-                    uint16 temp_value= (value/60);
+                    uint16 temp_value= (value);
                     memcpy(buf+size,&(temp_value),2);
                     size+=2;
                 }
@@ -753,22 +753,22 @@ char * ble_sywee_history(uint8_t day,uint16_t *len ,uint8_t type)
                
                 break;
             case 0x46://同步卡路里历史数据
-                value=get_now_hour_data(CYWEE_SAVE_DATA_CALORIES);
-                if(value>0)
+                get_now_hour_data(&f_value,CYWEE_SAVE_DATA_CALORIES);
+                if(f_value>0)
                 {
                     memcpy(buf+size,&creationTime,4);
                     size+=4;
-                    memcpy(buf+size,&value,4);
+                    memcpy(buf+size,&f_value,4);
                     size+=4;
                 }
                 break;
             case 0x47://同步距离历史数据
-                value=get_now_hour_data(CYWEE_SAVE_DATA_DISTANCE);
-                if(value>0)
+                get_now_hour_data(&f_value,CYWEE_SAVE_DATA_DISTANCE);
+                if(f_value>0)
                 {
                     memcpy(buf+size,&creationTime,4);
                     size+=4;
-                    memcpy(buf+size,&value,4);
+                    memcpy(buf+size,&f_value,4);
                     size+=4;
                 }
                 break;
index aa30c6a..ac2d9c5 100644 (file)
@@ -38,13 +38,13 @@ extern int CWM_OS_i2cTransfer(uint16_t slaveAddr, uint16_t reg, int regLength, u
 extern void* CWM_OS_malloc(int size);
 extern void CWM_OS_free(void *ptr);
 extern void CWM_OS_saveData(int* data, uint32_t len,uint8_t type);
-extern  void CWM_OS_OneHourAgo_saveData(int* data, uint32_t len,uint8_t type);
+extern  void CWM_OS_OneHourAgo_saveData(void* data, uint32_t len,uint8_t type);
 
 extern void CWM_OS_saveData_history(int* new_data,int *history ,uint32_t len,uint8_t type);
 extern void CWM_OS_saveData_STAND_history(uint8_t *falg,uint32_t len);
 extern uint8_t get_stand_count(void);
 extern void CWM_OS_restoreData(int* data, uint32_t len,uint8_t type);
-extern void CWM_OS_OneHourAgo_restoreData(int* data, uint32_t len,uint8_t type);
+extern void CWM_OS_OneHourAgo_restoreData(void* data, uint32_t len,uint8_t type);
 
 /********************CYWEE LIB*************************/
 
@@ -538,7 +538,7 @@ void stand_history_save(void);
 void calories_history_save(void);
 void distances_history_save(void);
 void fat_history_save(void);
-int32_t get_now_hour_data(uint8_t type);
+int32_t get_now_hour_data(void*value, uint8_t type);
 
 void cywee_goal_history_save(void);
 
index a4f36c2..791174c 100644 (file)
@@ -328,7 +328,7 @@ void CWM_OS_saveData(int* data, uint32_t len,uint8_t type){
 }
 
 
-void CWM_OS_OneHourAgo_saveData(int* data, uint32_t len,uint8_t type){
+void CWM_OS_OneHourAgo_saveData(void* data, uint32_t len,uint8_t type){
     
      struct stat info;
 
@@ -366,7 +366,7 @@ void CWM_OS_OneHourAgo_saveData(int* data, uint32_t len,uint8_t type){
     }
     int ret =fwrite(data,1,len,fp);
    
-    CWM_OS_dbgPrintf("CWM_OS_saveData fwrite failed %d %d\n",ret,*data);
+    //CWM_OS_dbgPrintf("CWM_OS_saveData fwrite failed %d %d\n",ret,*(int *)data);
     
     fclose(fp);
 }
@@ -583,12 +583,12 @@ void CWM_OS_restoreData(int* data, uint32_t len,uint8_t type){
     }
     int ret =fread(data,1,len,fp);
    
-    CWM_OS_dbgPrintf("CWM_OS_restoreData fread failed %d %d\n",ret,*data);
+    //CWM_OS_dbgPrintf("CWM_OS_restoreData fread failed %d %d\n",ret,*data);
     
     fclose(fp);
 }
 
-void CWM_OS_OneHourAgo_restoreData(int* data, uint32_t len,uint8_t type){
+void CWM_OS_OneHourAgo_restoreData(void* data, uint32_t len,uint8_t type){
 
 
     FILE * fp=NULL;
@@ -618,7 +618,7 @@ void CWM_OS_OneHourAgo_restoreData(int* data, uint32_t len,uint8_t type){
     }
     int ret =fread(data,1,len,fp);
    
-    CWM_OS_dbgPrintf("CWM_OS_restoreData fread failed %d %d\n",ret,*data);
+    //CWM_OS_dbgPrintf("CWM_OS_restoreData fread failed %d %d\n",ret,*(int*)data);
     
     fclose(fp);
 }
\ No newline at end of file
index aaddbde..206b559 100644 (file)
@@ -48,11 +48,11 @@ uint8_t stand_falg=0;//站立falg,如果发生站立,一个小时内会被
 
 int new_calories=0; //存卡路里数据 
 int history_calories=0; //
-int history_calories_=0;//一小时前卡路里数据
+float history_calories_=0;//一小时前卡路里数据
 
 int new_distance=0; //存距离数据 
 int history_distances=0; //历史数据
-int history_distances_=0; //一小时前距离数据
+float history_distances_=0; //一小时前距离数据
 
 
 int new_fat=0; //存燃脂数据 
@@ -129,15 +129,15 @@ void cywee_save_data(void)
     new_calories+=history_calories;
     CWM_OS_saveData(&(new_calories),sizeof(int),CYWEE_SAVE_DATA_CALORIES);
 
-    CWM_OS_OneHourAgo_saveData(&history_calories_,sizeof(int),CYWEE_SAVE_DATA_CALORIES);
+    CWM_OS_OneHourAgo_saveData(&history_calories_,sizeof(float),CYWEE_SAVE_DATA_CALORIES);
 
     new_distance+=history_distances;
     CWM_OS_saveData(&(new_distance),sizeof(int),CYWEE_SAVE_DATA_DISTANCE);
-    CWM_OS_OneHourAgo_saveData(&history_distances_,sizeof(int),CYWEE_SAVE_DATA_DISTANCE);
+    CWM_OS_OneHourAgo_saveData(&history_distances_,sizeof(float),CYWEE_SAVE_DATA_DISTANCE);
 
     new_fat+=history_fat;
     CWM_OS_saveData(&new_fat,sizeof(int),CYWEE_SAVE_DATA_FAT);
-    CWM_OS_OneHourAgo_saveData(&history_fat_,sizeof(int),CYWEE_SAVE_DATA_FAT);
+    CWM_OS_OneHourAgo_saveData(&history_fat_,sizeof(uint16_t),CYWEE_SAVE_DATA_FAT);
 
 }
 
@@ -147,14 +147,14 @@ void cywee_restoreData(void)
     CWM_OS_OneHourAgo_restoreData(&history_step_,sizeof(int),CYWEE_SAVE_DATA_STEP);
 
     CWM_OS_restoreData(&history_calories,sizeof(int),CYWEE_SAVE_DATA_CALORIES);
-    CWM_OS_OneHourAgo_restoreData(&history_calories_,sizeof(int),CYWEE_SAVE_DATA_CALORIES);
+    CWM_OS_OneHourAgo_restoreData(&history_calories_,sizeof(float),CYWEE_SAVE_DATA_CALORIES);
 
     CWM_OS_restoreData(&history_distances,sizeof(int),CYWEE_SAVE_DATA_DISTANCE);
-    CWM_OS_OneHourAgo_restoreData(&history_distances_,sizeof(int),CYWEE_SAVE_DATA_DISTANCE);
+    CWM_OS_OneHourAgo_restoreData(&history_distances_,sizeof(float),CYWEE_SAVE_DATA_DISTANCE);
    
 
     CWM_OS_restoreData(&history_fat,sizeof(int),CYWEE_SAVE_DATA_FAT);
-    CWM_OS_OneHourAgo_restoreData(&history_fat_,sizeof(int),CYWEE_SAVE_DATA_FAT);
+    CWM_OS_OneHourAgo_restoreData(&history_fat_,sizeof(uint16_t),CYWEE_SAVE_DATA_FAT);
    
 
     //WM_OS_restoreData(int* data, uint32_t len,uint8_t type)(int* data, uint32_t len,uint8_t type);
@@ -237,37 +237,50 @@ void calories_history_save(void)
 {
 
     int data= get_calories_data();
-    CWM_OS_saveData_history(&data,&history_calories_,sizeof(int),CYWEE_SAVE_DATA_CALORIES);
+    float history_calories=(float)data;
+    CWM_OS_saveData_history(&history_calories,&history_calories_,sizeof(float),CYWEE_SAVE_DATA_CALORIES);
 }
 
 void distances_history_save(void)
 {
     int data= get_distance_data();
-    CWM_OS_saveData_history(&data,&history_distances_,sizeof(int),CYWEE_SAVE_DATA_DISTANCE);
+    float history_distances_now=(float)data/1000.0;
+    CWM_OS_saveData_history(&history_distances_now,&history_distances_,sizeof(float),CYWEE_SAVE_DATA_DISTANCE);
 }
 
 void fat_history_save(void)
 {
-    int data= get_fat_time_data();
+    uint16_t data= get_fat_time_data();
     data=data/60;
     CWM_OS_saveData_history(&data,&history_fat_,sizeof(uint16_t),CYWEE_SAVE_DATA_FAT);
 }
 
-int32_t get_now_hour_data(uint8_t type)
+int32_t get_now_hour_data(void*value, uint8_t type)
 {   
+    int data;
+    float f_data;
     switch (type)
     {
         case CYWEE_SAVE_DATA_STEP:
-            return get_step_data()-history_step_;
-            break;
+          
+            data= get_step_data()-history_step_;
+            memcpy_s(value,4,&data,4);
+            return 1;
+
         case CYWEE_SAVE_DATA_CALORIES:
-            return get_calories_data()-history_calories_;
-            break;
+            data =get_calories_data();
+            f_data=(float)data-history_calories_;
+            memcpy_s(value,4,&f_data,4);
+            return 1;
         case CYWEE_SAVE_DATA_DISTANCE:
-            return get_distance_data()-history_distances_;
+            data= get_distance_data();
+            f_data=(float)data/1000.0-history_distances_;
+            memcpy_s(value,4,&f_data,4);
             break;
         case CYWEE_SAVE_DATA_FAT:
-            return get_fat_time_data()-history_fat_;
+            data= get_fat_time_data();
+            uint32_t data_=data/60-history_fat_;
+            memcpy_s(value,4,&data,4);
         break;
     default:
         break;