修改步数同步协议 193/2 193/head 197/target/1
authorhcj_ <1224667075@qq.com>
Thu, 30 May 2024 05:17:13 +0000 (13:17 +0800)
committerhcj_ <1224667075@qq.com>
Thu, 30 May 2024 05:17:13 +0000 (13:17 +0800)
code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp
code/sdk/application/wearable/service/ble_service/blemoder/bletest.h
code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c
code/sdk/drivers/peripheral/cywee/src/board_yh601s.c

index aa82c75..865c83e 100644 (file)
@@ -58,9 +58,9 @@ extern "C" {
 #include "bletest.h"
 
 
-#define CWM_HISTORY_DATA_PATH "/system/"
+#define CWM_HISTORY_DATA_PATH "/user/userdata/step_"
 
-char * ble_step_history(uint8_t day)
+char * ble_step_history(uint8_t day,uint16_t *len)
 {
     char path_[64]={0};
     char timeday[12] = {0};
@@ -70,6 +70,7 @@ char * ble_step_history(uint8_t day)
     FILE * fp = fopen(path_,"rb+");
     if(fp==NULL)
     {
+         printf("fopen fail\r\n");
         return NULL;
     }
     uint32_t size;
@@ -79,11 +80,22 @@ char * ble_step_history(uint8_t day)
         size = ftell(fp);       // 获取当前文件指针位置,即文件大小
         fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头
     }
+    printf("size %d \r\n",size);
 
     char * buf=(char *)malloc(size);
+    if(buf==NULL)
+    {
+        printf("malloc fail\r\n");
+        return buf;
+    }
     uint32_t ret= fread(buf,1,size,fp);
-    printf("fread %d \r\n",ret);
 
+    printf("fread %d \r\n",ret);
+    for(int i=0;i<ret;i++)
+    {
+        printf(" %X",buf[i]);
+    }
+    *len=size;
     return buf;
 
 }
index c4b12c1..fed09c7 100644 (file)
@@ -181,7 +181,7 @@ void ble_get_sleep_remind(msg_get_sleep_param_info_t *data);
 
 void ble_set_sleep_remind(msg_get_sleep_param_info_t data);
 
-char * ble_step_history(uint8_t day);
+char * ble_step_history(uint8_t day,uint16_t *len);
 #ifdef __cplusplus
 #if __cplusplus
 }
index 3205727..81d6daa 100644 (file)
@@ -279,7 +279,7 @@ static uint8_t get_crc_from_lrc(uint8_t lrcValue)
     return crcbuf;\r
 }\r
 \r
-#define USE_DEMO\r
+//#define USE_DEMO\r
 static bool Check_CRC(uint8_t *data,uint16_t len,uint8_t crcvalue)//计算20byte的的校验位\r
 {\r
        uint8_t crcbuf  = 0;\r
@@ -4370,10 +4370,11 @@ void Read_BIN_file_buf_send_bin_Data(uint32_t pack_size,uint16_t id)
     const char *data=NULL;\r
     uint8_t timeBit = 4;//默认是4个字节的时间戳\r
     uint8_t dataBit = 1;//默认是1个字节的数据\r
+    uint32_t data_len = 0;\r
     switch (id)\r
     {\r
         case 0x43: //同步步数历史数据\r
-            data=ble_step_history(0);\r
+            data=ble_step_history(0,&data_len);\r
             dataBit = 4;//心率数据字节4个字节 uint32_t\r
             break;\r
         case 0x44://同步燃脂时间数据\r
@@ -4403,7 +4404,7 @@ void Read_BIN_file_buf_send_bin_Data(uint32_t pack_size,uint16_t id)
         return;\r
     }\r
     \r
-        uint32_t data_len = strlen(data);\r
+        \r
 \r
         uint32_t surplus_len=data_len;\r
         uint32_t pack;\r
index 074456e..08d7368 100644 (file)
@@ -280,7 +280,7 @@ void CWM_OS_saveData(int* data, uint32_t len){
 }
 
 
-#define CWM_HISTORY_DATA_PATH "/system/"
+#define CWM_HISTORY_DATA_PATH "/user/userdata/step_"
 
 void CWM_OS_saveData_history(int* new_data,int *history ,uint32_t len){
     char path_[64]={0};
@@ -307,15 +307,25 @@ void CWM_OS_saveData_history(int* new_data,int *history ,uint32_t len){
         CWM_OS_dbgPrintf("fwrite failed %d\n",ret);
     }
 
+   
+
     //新数据减去旧数据,作为这一个小时的步数值
     
     int data= *new_data-*history;
+    if(data<0)
+    {
+        data=0;
+        *history=0;
+        CWM_OS_dbgPrintf("异常 清除步数数据\n");
+    }
+
     ret =fwrite(&data,1,len,fp);
     if(ret==0)
     {
         CWM_OS_dbgPrintf("fwrite failed %d\n",ret);
     }
-   
+    CWM_OS_dbgPrintf("fwrite data %d\n",data);
+
     *history=*new_data;
 
     fclose(fp);