From 6fb3b6e8d4e591d90008315d5a079dfcd985ca3d Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Tue, 13 Aug 2024 11:24:59 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0M=E6=8B=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../musicplayer/include/MusicPlayerModel.h | 2 +- .../musicplayer/src/MusicPlayerModel.cpp | 5 +- .../ble_service/blemoder/CMakeLists.txt | 9 +- .../service/ble_service/blemoder/bletest.cpp | 173 ++++++++++++++++-- .../service/ble_service/blemoder/bletest.h | 6 +- .../service/ble_service/bleservice/bleEvent.c | 125 +++++++++++-- .../peripheral/cywee/src/board_yh601s.c | 74 +++++++- 7 files changed, 355 insertions(+), 39 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/musicplayer/include/MusicPlayerModel.h b/code/sdk/application/wearable/fd230app/nativeui/musicplayer/include/MusicPlayerModel.h index 16ae9bff1..3b8d03bfe 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/musicplayer/include/MusicPlayerModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/musicplayer/include/MusicPlayerModel.h @@ -27,7 +27,7 @@ namespace OHOS MusicPlayerModel &operator=(const MusicPlayerModel &) = delete; private: - std::string musicPlayPath = "/user/userdata/music/"; /*音乐播放路径*/ + std::string musicPlayPath = "/user/userdata/music"; /*音乐播放路径*/ }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/musicplayer/src/MusicPlayerModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/musicplayer/src/MusicPlayerModel.cpp index 954a9a0d1..209ae5dac 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/musicplayer/src/MusicPlayerModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/musicplayer/src/MusicPlayerModel.cpp @@ -8,7 +8,7 @@ #include "musicplayer/include/MusicPlayerModel.h" #include "wearable_log.h" - +#include "player/include/PlayersModel.h" namespace OHOS { MusicPlayerModel::MusicPlayerModel() {} @@ -24,7 +24,8 @@ namespace OHOS /*获取音乐播放路径*/ std::string MusicPlayerModel::GetMusicPlayPath(void) { - return musicPlayPath; + + return PlayersModel::GetInstance()->GetMusicPlayPath(); } } diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/CMakeLists.txt b/code/sdk/application/wearable/service/ble_service/blemoder/CMakeLists.txt index 58e1a426c..f7b3d8e6d 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/CMakeLists.txt +++ b/code/sdk/application/wearable/service/ble_service/blemoder/CMakeLists.txt @@ -35,9 +35,14 @@ ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include/common ${ROOT_DIR}/application/wearable/fd230app/nativeui/set_dial/include ${ROOT_DIR}/application/wearable/fd230app/nativeui/aivoice/include +${ROOT_DIR}/application/wearable/fd230app/nativeui/alarm/include +${ROOT_DIR}/application/wearable/fd230app/nativeui/musicplayer/include - - +#/home/hcj/FD230/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmClockModel.h +#/home/hcj/FD230/code/sdk/middleware/services/media/foundation/player/interfaces/kits/player.h +#/home/hcj/FD230/code/sdk/middleware/services/gui/uikit/surface/interfaces/kits/surface.h +# ${ROOT_DIR}/middleware/services/media/foundation/player/interfaces/kits +# ${ROOT_DIR}/middleware/services/gui/uikit/surface/interfaces/kits ) set(SOURCES 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 56caa029a..e98e7ab23 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -42,6 +42,8 @@ #include "AiVoiceModel.h" #include "SleepModel.h" #include "BluetoothModel.h" +#include "MusicPlayerModel.h" + //#include "AlarmClockModel.h" #ifdef __cplusplus #if __cplusplus @@ -77,6 +79,14 @@ extern "C" { #include #include +#define before_file_day 30 + +void get_music_path(char *buf,uint8_t max_len) +{ + std::string path= OHOS::MusicPlayerModel::GetInstance().GetMusicPlayPath(); + memcpy_s(buf,max_len,path.c_str(),path.length()); +} + //在此处实现,给UI回复消息。 void ble_app_reply(bool data) { @@ -105,9 +115,9 @@ void ble_set_ai_Question_str(char *buf) OHOS::AiVoiceModel::GetInstance().SetUserQuestionStr(std::string(buf)); } -void ble_set_ai_Answer_str(char *buf) +void ble_set_ai_Answer_str(char *buf,uint8_t type) { - OHOS::AiVoiceModel::GetInstance().SetAiAnswerStrStr(std::string(buf)); + OHOS::AiVoiceModel::GetInstance().SetAiAnswerStrStr(std::string(buf),type); } char* ble_get_ai_audio_path_str(void) @@ -254,7 +264,7 @@ char * dir_to_json_buf_malloc_(uint8_t type) switch (type) { case 2: // - sprintf_s(dir_path,64,"%s","user/music"); + get_music_path(dir_path,128); break; case 3: // sprintf_s(dir_path,64,"%s","user/userdata/dial"); @@ -283,7 +293,7 @@ char * dir_to_json_buf_malloc_(uint8_t type) if (ent->d_type == DT_REG || ent->d_type == DT_UNKNOWN ) // 普通文件 { char file_path[128]={0}; - sprintf_s(file_path,128,"%s/%s","user/music",ent->d_name); + sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name); FILE * fp = fopen(file_path,"rb+"); if(fp==NULL) @@ -373,7 +383,7 @@ uint8_t ble_get_sleep_data(uint32_t file_size,uint8_t day_,uint8_t *data) struct DIR *dir; struct dirent *ent; - std::string fileName = ent->d_name; + uint32_t offset=0; uint8_t sleep_count=1; @@ -381,6 +391,7 @@ uint8_t ble_get_sleep_data(uint32_t file_size,uint8_t day_,uint8_t *data) { while ((ent = readdir(dir)) != NULL) { + std::string fileName = ent->d_name; if (fileName != "." && fileName != "..") { @@ -443,13 +454,14 @@ uint8_t ble_get_sleep_data_dir(uint32_t *file_size,uint8_t day_) struct DIR *dir; struct dirent *ent; - std::string fileName = ent->d_name; + uint8_t file_count=0; if ((dir = opendir(dir_path)) != NULL) { while ((ent = readdir(dir)) != NULL) { + std::string fileName = ent->d_name; if (fileName != "." && fileName != "..") { @@ -629,15 +641,151 @@ void install_Register_dial( char * name,uint16_t id) } -#define CWM_HISTORY_DATA_PATH "/user/userdata/goal/step_" +#define CWM_HISTORY_DATA_PATH "/user/userdata/goal/step/step_" + +#define CWM_HISTORY_DATA_CALORIES_PATH "/user/userdata/goal/calories/calories_" + +#define CWM_HISTORY_DATA_DISTANCE_PATH "/user/userdata/goal/distance/distance_" + +#define CWM_HISTORY_STAND_DATA_PATH "/user/userdata/goal/stand/stand_" + +#define CWM_HISTORY_DATA_FAT_PATH "/user/userdata/goal/fat/fat_" + + +#define GOAL_DATA_CONFIG_DIR_STEP "/user/userdata/goal/step" + +#define GOAL_DATA_CONFIG_DIR_DISTANCE "/user/userdata/goal/distance" + +#define GOAL_DATA_CONFIG_DIR_STAND "/user/userdata/goal/stand" + +#define GOAL_DATA_CONFIG_DIR_FAT "/user/userdata/goal/fat" + +#define GOAL_DATA_CONFIG_DIR_CALORIES "/user/userdata/goal/calories" + + + +void delete_before_file(uint8_t type) +{ + time_t currtime; + struct tm *timeinfo; + time(&currtime); + timeinfo = localtime(&currtime); + + int y=timeinfo->tm_year+ 1900; + int m=timeinfo->tm_mon+1; + int d=timeinfo->tm_mday; + + printf("delete_before_file now day%d %d %d\r\n ",y,m,d); + + char path_[64]={0}; + + switch (type) + { + case 0x43: //同步步数历史数据 + sprintf_s(path_,64,"%s",GOAL_DATA_CONFIG_DIR_STEP); + break; + case 0x44://同步燃脂时间数据 + sprintf_s(path_,64,"%s",GOAL_DATA_CONFIG_DIR_FAT); + break; + case 0x45://同步站立历史数据 + sprintf_s(path_,64,"%s",GOAL_DATA_CONFIG_DIR_STAND); + break; + case 0x46://同步卡路里历史数据 + sprintf_s(path_,64,"%s",GOAL_DATA_CONFIG_DIR_CALORIES); + break; + case 0x47://同步距离历史数据 + sprintf_s(path_,64,"%s",GOAL_DATA_CONFIG_DIR_DISTANCE); + break; + default: + break; + } + + + struct DIR *dir; + struct dirent *ent; + + + if ((dir = opendir(path_)) != NULL) + { + while ((ent = readdir(dir)) != NULL) + { + std::string fileName = ent->d_name; + if (fileName != "." && fileName != "..") + { + + if (ent->d_type == DT_REG || ent->d_type == DT_UNKNOWN ) // 普通文件 + { + int flag=0; + printf("%s\r\n",fileName.c_str()); + int y_; + int m_; + int d_; -#define CWM_HISTORY_DATA_CALORIES_PATH "/user/userdata/goal/calories_" + for(int i=0;i0) + { + + if(flag==0) + { + i=i+4; + printf("data %d\r\n",data); + y_=y-data; + flag++; + } + else if (flag==1) + { + i=i+2; + printf("data %d\r\n",data); + m_=m-data; + flag++; + } + else if (flag==2) + { + i=i+2; + printf("data %d\r\n",data); + d_=d-data; + flag++; + } + + + } + } + + if((y_*24+m_)*30+d_>before_file_day) + { + char path_remove[64]={0}; + sprintf_s(path_remove,64,"%s/%s",path_,fileName.c_str()); + remove(path_remove); + printf("succ remove %s\r\n ",path_remove); + } + else + { + printf("is 30d %d\r\n ",(y_*24+m_)*30+d_); + } + + } + } + else if (ent->d_type == DT_DIR) // 目录 + { + continue; + } + } + } + else + { + + return ; + } + closedir(dir); -#define CWM_HISTORY_DATA_DISTANCE_PATH "/user/userdata/goal/distance_" -#define CWM_HISTORY_STAND_DATA_PATH "/user/userdata/goal/stand_" -#define CWM_HISTORY_DATA_FAT_PATH "/user/userdata/goal/fat_" + +} char * ble_sywee_history(uint8_t day,uint16_t *len ,uint8_t type) { @@ -797,6 +945,9 @@ char * ble_sywee_history(uint8_t day,uint16_t *len ,uint8_t type) } + + + void ble_set_sleep_remind(msg_get_sleep_param_info_t data) { OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h index 21893e2e1..e87a66665 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h @@ -261,12 +261,13 @@ uint8_t ble_AT_add_nap_data(uint16_t time); /////////////////////////////AI相关///////////////////////// void ble_set_ai_Question_str(char *buf); -void ble_set_ai_Answer_str(char *buf); +void ble_set_ai_Answer_str(char *buf,uint8_t type); char* ble_get_ai_audio_path_str(void); void ble_app_reply(bool data); + /////////////////////////////MP3相关///////////////////////// typedef struct Tag_Trailer @@ -311,6 +312,7 @@ char * dir_to_json_buf_malloc_(uint8_t type); char * dir_to_json_buf_malloc_(uint8_t type); +void get_music_path(char *buf,uint8_t max_len); /////////////////////数据同步//////////////////////////// @@ -336,6 +338,8 @@ void hand_watch_first_time_Paired(void); //////////////////////////////////////// void SendDtfmStrNumberToCat1(char ch); //ble发送单个字符到CAT1 DTMF功能 +void delete_before_file(uint8_t type); + #ifdef __cplusplus #if __cplusplus } 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 9aad799a3..ed22363cd 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -962,10 +962,7 @@ void sendBindInfor(uint8_t *data) { bond = 0x01;//手表未和任何手机绑定过 //未配过使能一键双联 - errcode_t ret = gap_ble_set_ctkd_enable(true); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gap_ble_set_ctkd_enable ret = %x", ret); - set_ctkd_flag(true); - + value[17] = bond;// @@ -988,6 +985,14 @@ void sendBindInfor(uint8_t *data) buf[0] = DEVICEBIND ; buf[1] = devnamelen;//设备名称长度 0不显示 memcpy(buf+2,devname,devnamelen); + + if(strcmp("iPhone",(char *)devname)==0) + { + errcode_t ret = gap_ble_set_ctkd_enable(true); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "iPhone gap_ble_set_ctkd_enable ret = %x", ret); + set_ctkd_flag(true); + } + CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,(uint8_t *)buf,devnamelen+2); if(devname) { @@ -1027,9 +1032,16 @@ void sendBindInfor(uint8_t *data) if(result == 0) { //已经配对就关闭一键双连 - errcode_t ret = gap_ble_set_ctkd_enable(true); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gap_ble_set_ctkd_enable ret = %x", ret); - set_ctkd_flag(false); + // errcode_t ret = gap_ble_set_ctkd_enable(true); + // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gap_ble_set_ctkd_enable ret = %x", ret); + // set_ctkd_flag(false); + + // if(strcmp("iPhone",devname)==0) + // { + // errcode_t ret = gap_ble_set_ctkd_enable(true); + // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gap_ble_set_ctkd_enable ret = %x", ret); + // set_ctkd_flag(true); + // } printf("phone_addr:%02x-%02x-%02x-%02x-%02x-%02x type:%d ",phone_addr.addr[0],phone_addr.addr[1],phone_addr.addr[2], phone_addr.addr[3],phone_addr.addr[4],phone_addr.addr[5],phone_addr.type); @@ -2122,10 +2134,13 @@ uint8_t binCheck_AI(uint8_t *buf,uint8_t *check,uint16_t len)//json 格式解析 if(buf[offset]==1) { offset++; + if(offset>=len)break; uint16_t txt_len; memcpy_s(&txt_len,2,&buf[offset],2); offset+=2; + if(offset>=len)break; + char txt_buf[256]={0}; memcpy_s(txt_buf,256,&buf[offset],txt_len); printf("binCheck_AI Question txtbuf:%s %d\r\n",txt_buf,txt_len); @@ -2138,10 +2153,13 @@ uint8_t binCheck_AI(uint8_t *buf,uint8_t *check,uint16_t len)//json 格式解析 if(buf[offset]==2) { offset++; + if(offset>=len)break; + uint16_t txt_len; memcpy_s(&txt_len,2,&buf[offset],2); offset+=2; + if(offset>=len)break; if(txt_len>=AI_TXT_BUF_MAX_LEN) txt_len=AI_TXT_BUF_MAX_LEN; @@ -2150,7 +2168,7 @@ uint8_t binCheck_AI(uint8_t *buf,uint8_t *check,uint16_t len)//json 格式解析 if(txt_buf==NULL) { printf("binCheck_AI txtbuf malloc fail\r\n"); - ble_set_ai_Answer_str("手表缓存不足"); + ble_set_ai_Answer_str("手表缓存不足",0); return 0; } @@ -2158,7 +2176,7 @@ uint8_t binCheck_AI(uint8_t *buf,uint8_t *check,uint16_t len)//json 格式解析 memcpy_s((char *)txt_buf,1024*3,&buf[offset],txt_len); printf("binCheck_AI txtbuf Answer %s %d\r\n",txt_buf,txt_len); - ble_set_ai_Answer_str(txt_buf); + ble_set_ai_Answer_str(txt_buf,2); free(txt_buf); offset+=txt_len; @@ -2167,9 +2185,69 @@ uint8_t binCheck_AI(uint8_t *buf,uint8_t *check,uint16_t len)//json 格式解析 if(offset>=len)break; if(buf[offset]==0) { + offset++; + if(offset>=len)break; + + uint16_t txt_len; + memcpy_s(&txt_len,2,&buf[offset],2); + + offset+=2; + if(offset>=len)break; + + char error_buf[256]={0}; + memcpy_s(error_buf,256,&buf[offset],txt_len); + printf("binCheck_AI Question txtbuf:%s %d\r\n",error_buf,txt_len); + ble_set_ai_Answer_str(error_buf,0); + printf("AI 解析失败\r\n"); + + } + if(offset>=len)break; + + if(buf[offset]==3) + { + offset++; + if(offset>=len)break; + + uint16_t txt_len; + memcpy_s(&txt_len,2,&buf[offset],2); + + offset+=2; + if(offset>=len)break; + + char error_buf[256]={0}; + memcpy_s(error_buf,256,&buf[offset],txt_len); + printf("binCheck_AI Question txtbuf:%s %d\r\n",error_buf,txt_len); + ble_set_ai_Answer_str(error_buf,3); + + printf("AI 解析失败\r\n"); + + } + if(offset>=len)break; + + if(buf[offset]==4) + { + offset++; + if(offset>=len) + { + ble_set_ai_Answer_str("",4); + break; + } + + uint16_t txt_len; + memcpy_s(&txt_len,2,&buf[offset],2); + + offset+=2; + if(offset>=len)break; + + char error_buf[256]={0}; + memcpy_s(error_buf,256,&buf[offset],txt_len); + printf("binCheck_AI Question txtbuf:%s %d\r\n",error_buf,txt_len); + ble_set_ai_Answer_str(error_buf,4); + + printf("AI 解析失败\r\n"); + } - if(offset>=len)break; offset++; } @@ -5862,7 +5940,7 @@ errcode_t decode_ota_json(ble_read_data *buffer_handle) cJSON* ota_name_json = cJSON_GetObjectItem(root, "name"); if ( ota_name_json != NULL && cJSON_IsString(ota_name_json)) { - uint32_t filenamelen=strlen(ota_name_json->valuestring); + uint32_t filenamelen=strlen(ota_name_json->valuestring)+1; if (filenamelen > 0 && filenamelen < 255) { buffer_handle->file_recv_stat.file_name = malloc(filenamelen); @@ -5953,12 +6031,17 @@ errcode_t decode_mp3_json(ble_read_data *buffer_handle) cJSON* ota_name_json = cJSON_GetObjectItem(root, "name"); if ( ota_name_json != NULL && cJSON_IsString(ota_name_json)) { - uint32_t filenamelen=strlen(ota_name_json->valuestring); + uint32_t filenamelen=strlen(ota_name_json->valuestring)+1; + if (filenamelen > 0 && filenamelen < 255) { buffer_handle->file_recv_stat.file_name = malloc(filenamelen); if (buffer_handle->file_recv_stat.file_name!=NULL) + { + memset_s(buffer_handle->file_recv_stat.file_name,filenamelen,0,filenamelen); memcpy_s(buffer_handle->file_recv_stat.file_name,filenamelen,ota_name_json->valuestring,filenamelen); + } + //下载完成再在 cancel download 里 free filename }else{ buffer_handle->file_recv_stat.file_name = NULL; @@ -6313,7 +6396,8 @@ void decode_file_checksum(ble_read_data *buffer_handle) break; case 2://mp3 - + ble_reply_cmd(DIAL_INSTALL_REPY_CMD,1); + break; case 3://dial //TODO: 设置成当前下载的表盘 @@ -6695,7 +6779,18 @@ errcode_t handle_recv_file(ble_read_data *buffer_handle,uint8_t *data, uint16_t buffer_handle->file_recv_stat.file = fopen("/update/update.fwpkg","w+"); printf("create file /update/update.fwpkg %X\n",buffer_handle->file_recv_stat.file); - }else{ + } + else if (buffer_handle->file_recv_stat.file_type == 2) + { + char musicpath[64]={0}; + get_music_path(musicpath,64); + char filepath[256]={0}; + sprintf_s(filepath,256,"%s/%s",musicpath,buffer_handle->file_recv_stat.file_name); + buffer_handle->file_recv_stat.file = fopen(filepath,"w+"); + printf("%s\r\n",filepath); + } + else + { char filepath[128]={0}; if (get_file_recv_file_path(buffer_handle->file_recv_stat.file_name,strlen(buffer_handle->file_recv_stat.file_name),filepath,sizeof(filepath)) == ERRCODE_SUCC) { @@ -6707,7 +6802,7 @@ errcode_t handle_recv_file(ble_read_data *buffer_handle,uint8_t *data, uint16_t } if (buffer_handle->file_recv_stat.file == NULL) { - printf("6185 buffer_handle->file_recv_stat.file \n"); + printf("6185 buffer_handle->file_recv_stat.file NULL\n"); return ERRCODE_FAIL; } buffer_handle->file_recv_stat.recv_file_stat = 1; diff --git a/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c b/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c index ef4196205..0f00dc186 100644 --- a/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c +++ b/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c @@ -374,17 +374,28 @@ void CWM_OS_OneHourAgo_saveData(void* data, uint32_t len,uint8_t type){ -#define CWM_HISTORY_DATA_PATH "/user/userdata/goal/step_" +#define CWM_HISTORY_DATA_PATH "/user/userdata/goal/step/step_" -#define CWM_HISTORY_DATA_CALORIES_PATH "/user/userdata/goal/calories_" +#define CWM_HISTORY_DATA_CALORIES_PATH "/user/userdata/goal/calories/calories_" -#define CWM_HISTORY_DATA_DISTANCE_PATH "/user/userdata/goal/distance_" +#define CWM_HISTORY_DATA_DISTANCE_PATH "/user/userdata/goal/distance/distance_" -#define CWM_HISTORY_DATA_FAT_PATH "/user/userdata/goal/fat_" +#define CWM_HISTORY_STAND_DATA_PATH "/user/userdata/goal/stand/stand_" + +#define CWM_HISTORY_DATA_FAT_PATH "/user/userdata/goal/fat/fat_" #define GOAL_DATA_CONFIG_DIR "/user/userdata/goal" +#define GOAL_DATA_CONFIG_DIR_STEP "/user/userdata/goal/step" + +#define GOAL_DATA_CONFIG_DIR_DISTANCE "/user/userdata/goal/distance" + +#define GOAL_DATA_CONFIG_DIR_STAND "/user/userdata/goal/stand" + +#define GOAL_DATA_CONFIG_DIR_FAT "/user/userdata/goal/fat" + +#define GOAL_DATA_CONFIG_DIR_CALORIES "/user/userdata/goal/calories" void CWM_OS_saveData_history(void* new_data,void *history ,uint32_t len,uint8_t type){ @@ -398,6 +409,49 @@ void CWM_OS_saveData_history(void* new_data,void *history ,uint32_t len,uint8_t return ; // Failed to create folder } } + + if (stat(GOAL_DATA_CONFIG_DIR_STEP, &info) != 0) + { + if (mkdir(GOAL_DATA_CONFIG_DIR_STEP, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) + { + return ; // Failed to create folder + } + } + + if (stat(GOAL_DATA_CONFIG_DIR_DISTANCE, &info) != 0) + { + if (mkdir(GOAL_DATA_CONFIG_DIR_DISTANCE, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) + { + return ; // Failed to create folder + } + } + + if (stat(GOAL_DATA_CONFIG_DIR_STAND, &info) != 0) + { + if (mkdir(GOAL_DATA_CONFIG_DIR_STAND, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) + { + return ; // Failed to create folder + } + } + + if (stat(GOAL_DATA_CONFIG_DIR_FAT, &info) != 0) + { + if (mkdir(GOAL_DATA_CONFIG_DIR_FAT, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) + { + return ; // Failed to create folder + } + } + + if (stat(GOAL_DATA_CONFIG_DIR_CALORIES, &info) != 0) + { + if (mkdir(GOAL_DATA_CONFIG_DIR_CALORIES, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) + { + return ; // Failed to create folder + } + } + + + char path_[64]={0}; char timeday[12] = {0}; uapi_get_YYMMDD_Time(timeday, '_'); @@ -428,7 +482,7 @@ void CWM_OS_saveData_history(void* new_data,void *history ,uint32_t len,uint8_t case CYWEE_DATA_FAT: sprintf_s(path_,64,"%s%s.bin",CWM_HISTORY_DATA_FAT_PATH,timeday); i_data_16= *(uint16_t*)new_data-*(uint16_t*)history;//新数据减去旧数据,作为这一个小时的值 - + break; default: @@ -495,7 +549,6 @@ void CWM_OS_saveData_history(void* new_data,void *history ,uint32_t len,uint8_t fclose(fp); } -#define CWM_HISTORY_STAND_DATA_PATH "/user/userdata/goal/stand_" void CWM_OS_saveData_STAND_history(uint8_t *falg,uint32_t len){ if(*falg) @@ -509,7 +562,14 @@ void CWM_OS_saveData_STAND_history(uint8_t *falg,uint32_t len){ return ; // Failed to create folder } } - + + if (stat(GOAL_DATA_CONFIG_DIR_STAND, &info) != 0) + { + if (mkdir(GOAL_DATA_CONFIG_DIR_STAND, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) + { + return ; // Failed to create folder + } + } char path_[64]={0}; char timeday[12] = {0}; -- 2.17.1