From: DXY <1731678236@qq.com> Date: Wed, 8 May 2024 11:08:07 +0000 (+0800) Subject: 快捷辅助功能参数协议对接完成:修复协议下发声音与振动UI不更新问题:修改亮度调节实时更新协议:优化安卓ancs存储问题:增加拍照topic X-Git-Tag: release_V1.2.70_20241020_135402~1108^2~16 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=007dc218bb5eda4d0f3323d22cdc8766dcc8d7e3;p=mirrors%2FFD230.git 快捷辅助功能参数协议对接完成:修复协议下发声音与振动UI不更新问题:修改亮度调节实时更新协议:优化安卓ancs存储问题:增加拍照topic --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h b/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h index 0e8465a7d..ae73f06fd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h @@ -81,6 +81,8 @@ namespace OHOS CONFIFMOFEL_ITEM_NOTIFY,//消息通知开关 + CONFIFMOFEL_ITEM_QUICK_AUXILIARY_PARAMETERS,//快捷辅助功能参数 + CONFIGMODEL_ITEM_MAX, } ; @@ -233,6 +235,8 @@ namespace OHOS {ConfigDataType::DATATYPE_INT, "HeartRateDetected", "0" },// CONFIFMOFEL_ITEM_HEARTRATE_DETECTED//心率周期检测频率 {ConfigDataType::DATATYPE_INT, "HeartRateMax", "0" },// CONFIFMOFEL_ITEM_HEARTRATE_MAX//最大心率 {ConfigDataType::DATATYPE_INT, "HeartRateMin", "0" },// CONFIFMOFEL_ITEM_HEARTRATE_MIN//最小心率 + {ConfigDataType::DATATYPE_BOOL, "Notify", "0" },// CONFIFMOFEL_ITEM_NOTIFY//消息通知开关 + {ConfigDataType::DATATYPE_INT, "QuickAuxilParameter", "0" },// CONFIFMOFEL_ITEM_QUICK_AUXILIARY_PARAMETERS//快捷辅助功能参数 }; ConfigModel(); // 私有构造函数,确保无法在外部实例化 ConfigModel(const ConfigModel &) = delete; // 禁止拷贝构造 diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp index e6d7ae706..57cf3e384 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp @@ -519,6 +519,7 @@ namespace OHOS void ConfigModel::SetScreenDuration(unsigned int value) { set_condigData_Int(CONFIGMODEL_ITEM_SCREEN_OFF_TIMEOUT_VALUE,value); + initializeScreenDuration(); } /// @brief 获取亮屏时长单位ms @@ -697,6 +698,7 @@ namespace OHOS void ConfigModel::SetBrightness(int level) { set_condigData_Int(CONFIGMODEL_ITEM_SCREEN_BRIGHTNESS_VALUE,level); + initScreenBrightness();//实时更新屏幕亮度用于协议下发亮度值 } // 获取亮度值 diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/BrightnessControlView.cpp b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/BrightnessControlView.cpp index 0ec230815..100d2fcd0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/BrightnessControlView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/BrightnessControlView.cpp @@ -33,8 +33,8 @@ namespace OHOS { BrightnessControlScrollView->RemoveAll(); - int value = BrightnessControlViewSlider->GetValue(); - ConfigModel::GetInstance()->SetBrightness(value); + // int value = BrightnessControlViewSlider->GetValue(); + // ConfigModel::GetInstance()->SetBrightness(value); delete BrightnessControlViewSlider; BrightnessControlViewSlider = nullptr; @@ -276,6 +276,7 @@ namespace OHOS { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnRelease %d", value); ChangeBrightness(BRIGHTNESSDRAG, value); + ConfigModel::GetInstance()->SetBrightness(value); } bool BrightnessSliderEventListener::OnClick(UIView &view, const ClickEvent &event) diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.h b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.h index 3b8b54fa6..d297fc5d9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.h +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.h @@ -10,8 +10,8 @@ namespace OHOS const char * GET_HEALTH_JSON_PATH_C_STR(); typedef struct { - uint16_t SPO2; // 血氧值 - uint64_t timestamp; // 最近一次检测时间 + uint8_t SPO2; // 血氧值 + uint32_t timestamp; // 最近一次检测时间 } BloodOxygenData; typedef struct @@ -34,8 +34,8 @@ namespace OHOS typedef struct { - uint16_t Heart; // 心率值 - uint64_t timestamp; // 最近一次检测时间 + uint8_t Heart; // 心率值 + uint32_t timestamp; // 最近一次检测时间 } HeartRateData; class HealthService diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp index f835cd9b4..cbca79846 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp @@ -14,6 +14,7 @@ #include "phoneservice/include/PhoneService.h" #include "../../../../../../middleware/services/media/foundation/audiomanager/frameworks/audioservice/include/audio_service.h" #include "vibrator_service.h" +#include "config/include/ConfigModel.h" namespace OHOS { @@ -129,6 +130,15 @@ namespace OHOS { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnRelease %d", value); ChangeVolumeValue(OTHER, value); + + if ( SoundAndVibrationVolumeSettingView::GetInstance()->GetVolumeType() == SYSTEM_VOLUME) + { + ConfigModel::GetInstance()->SetSystemVolume(value); + } + else if (SoundAndVibrationVolumeSettingView::GetInstance()->GetVolumeType() == CALL_VOLUME) + { + ConfigModel::GetInstance()->SetCallVolume(value); + } } bool VoumeProcessSliderEventListener::OnClick(UIView &view, const ClickEvent &event) diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp index 9336438e5..c759049ce 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp @@ -31,15 +31,15 @@ namespace OHOS { ScrollView->RemoveAll(); - int volume = VolumeProcess->GetValue(); - if (m_VolumeType == SYSTEM_VOLUME) - { - ConfigModel::GetInstance()->SetSystemVolume(volume); - } - else if (m_VolumeType == CALL_VOLUME) - { - ConfigModel::GetInstance()->SetCallVolume(volume); - } + // int volume = VolumeProcess->GetValue(); + // if (m_VolumeType == SYSTEM_VOLUME) + // { + // ConfigModel::GetInstance()->SetSystemVolume(volume); + // } + // else if (m_VolumeType == CALL_VOLUME) + // { + // ConfigModel::GetInstance()->SetCallVolume(volume); + // } delete VolumeProcess; VolumeProcess = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h index 4b995066f..c30c2e8db 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h @@ -88,6 +88,16 @@ extern "C" uint32_t cir; // 最高海拔高度 uint32_t alt; + //平均配速 + uint32_t apc; + //最快配速 + uint32_t fpc; + //最慢配速 + uint32_t spc; + //步幅 + uint32_t std; + //步频 + uint32_t cdc; }; Trainingdata *read_Trainingdata_data(char *timedata, uint16_t offset); @@ -166,6 +176,7 @@ namespace OHOS int heart; // 运动心率 int avgheart; // 训练平均心率 int tag; // 训练目标 + int pc; //训练配速 std::string start_date; // 训练开始日期 std::string start_time; // 训练开始时间 std::string end_time; // 训练结束时间 diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp index 8b73ae63a..b85e085d5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp @@ -707,8 +707,10 @@ namespace OHOS data.st = sportdata->starttime; data.hr = sportdata->heart; data.ca = sportdata->calories; + data.di = sportdata->distance; data.stp = sportdata->steps; data.ti = sportdata->intensity; + data.pc = sportdata->pc; WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SendLiveData Begin!"); sendtraningdata(&data); // 发送数据函数 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SendLiveData Stop!"); diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp index 473a6d299..72bd30d33 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp @@ -100,7 +100,7 @@ namespace OHOS WeatherModel::WeatherModel() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherModel::WeatherModel"); - jsonCheck_weather((uint8_t *)json_data); + // jsonCheck_weather((uint8_t *)json_data); } WeatherModel::~WeatherModel() 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 0a75eb428..5c2ff21b9 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -368,7 +368,17 @@ int get_SilentMode(void) OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); return p_ConfigModel->GetSilentMode(); } - +void set_quick_auxiliary_paramters(uint8_t id)//设置快捷辅助功能参数id +{ + OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); + + p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIFMOFEL_ITEM_QUICK_AUXILIARY_PARAMETERS,id); +} +int get_quick_auxiliary_paramters(void)//获取快捷辅助功能参数id +{ + OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); + return p_ConfigModel->get_configData_int(OHOS::ConfigModel::CONFIFMOFEL_ITEM_QUICK_AUXILIARY_PARAMETERS); +} void set_goal_stepcount(uint32_t step) { OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); @@ -383,7 +393,7 @@ void set_goal_caloriescount(uint32_t kcal) p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_CALORIES,kcal); return ; } -void set_notify_switch(uint8_t on) +void set_notify_switch(bool on) { OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); @@ -596,19 +606,15 @@ void set_weather_one_data(int tempMin, int iconDay,int fxDate, int tempMax, char if(x==6) return UI_set_weather_seven_day_data(data_t); } -struct message_infor_t message_infor_s; +message_infor_t message_infor_s; void read_message_data(void) { if(!creatMessageDir())//创建失败 { return; } - char path[100]; uint32_t data_len = 0; - char *str_data = get_message_dir_path(); - sprintf(path,"%s/%s",str_data,ANCS_DATA_CJSON); - printf("buf file %s\n",path); - FILE *jsfile = fopen(path, "r"); + FILE *jsfile = fopen(ANCS_DATA_CJSON_PATH, "r"); cJSON *data_root; if (jsfile != NULL) { printf("succes opening file\n"); @@ -622,7 +628,7 @@ void read_message_data(void) fclose(jsfile); // 解析JSON数据 - printf("jsonData %s",jsonData); + // printf("jsonData %s",jsonData); data_len = strlen(jsonData); data_root= cJSON_Parse(jsonData); free(jsonData); @@ -678,10 +684,10 @@ void read_message_data(void) } } // printf("message_infor_s.num%d\r\n",message_infor_s.num); //2 1 0 - for(uint8_t i = message_infor_s.num-1;i > 0 ;i--) - { - // printf("message_infor_s:title %s msg :%s\r\n",message_infor_s.message_t[i].title,message_infor_s.message_t[i].msg); - } + // for(uint8_t i = message_infor_s.num-1;i > 0 ;i--) + // { + // // printf("message_infor_s:title %s msg :%s\r\n",message_infor_s.message_t[i].title,message_infor_s.message_t[i].msg); + // } } message_infor_t *get_message_info(void) { 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 6d5cd6552..b6e8c74f8 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h @@ -62,14 +62,14 @@ extern "C" #define MAX_MESSAGE_NUM 10 #define TITLE_BUF_LEN 256 -#define MSG_BUF_LEN 301 +#define MSG_BUF_LEN 300 struct ancs_data_info_t { uint32_t time;//时间戳 int uid;//uid 消息唯一编号 int appid;//消息类型:1:微信 2:QQ 3:短信 4:其他 - char title[TITLE_BUF_LEN];//消息发送者 - char msg[MSG_BUF_LEN];//消息内容 + char title[TITLE_BUF_LEN+1];//消息发送者 + char msg[MSG_BUF_LEN+1];//消息内容 int hasCode;//消息hash code int read;//是否已读 0 未读 1 已读 }; @@ -140,7 +140,7 @@ int get_goal_caloriescount(void);//获取目标卡路里 void set_goal_discount(uint32_t dis);//设置目标里程 int get_goal_discount(void);//获取目标里程 -void set_notify_switch(uint8_t on);//设置消息通知开关 +void set_notify_switch(bool on);//设置消息通知开关 bool get_notify_switch(void);//获取消息通知开关 void set_goal_durationcount(uint32_t time);//设置目标燃脂时间 @@ -159,6 +159,9 @@ void ble_SetAlarmInfo(uint32_t time_hour, uint32_t time_min, uint8_t week,uint8_ void ble_delet_all_AlarmInfo(void); +void set_quick_auxiliary_paramters(uint8_t id);//设置快捷辅助功能参数id +int get_quick_auxiliary_paramters(void);//获取快捷辅助功能参数id + #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 32f789c21..3fb30f0c7 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -181,12 +181,13 @@ static bool Check_CRC(uint8_t *crcnum,uint16_t len,uint8_t crcvalue)//计算20by uint8_t lrcValue = 0x00; if(crcnum == NULL) { - if(crcvalue == 0x00) - { - return true; - }else{ - return false; - } + return true; + // if(crcvalue == 0x00) + // { + // return true; + // }else{ + // return false; + // } } for(uint16_t i = 0; i < len; i++) { @@ -348,7 +349,7 @@ void sendtraningdata(msg_get_train_data_info_t *data) cJSON_AddNumberToObject(dataJSON,"di",data->di); cJSON_AddNumberToObject(dataJSON,"stp",data->stp); cJSON_AddNumberToObject(dataJSON,"ti",data->ti); - + cJSON_AddNumberToObject(dataJSON,"pc",data->pc); char *jsonString = cJSON_PrintUnformatted(dataJSON); uint32_t data_len=strlen(jsonString); @@ -1974,7 +1975,34 @@ void getUserInfo(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,ui sendBleData(value,19); } } - +//APP下发快捷辅助功能参数 +void get_auxil_fun_parm(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)// +{ + uint8_t value[19]; + memset(value,0,19); + uint32_t tmp = 1; + uint16_t packtmp = 1; + value[0] =0x72; + value[1] =0x02; + value[2] =0x11; + memcpy(value+3,&tmp,4); + memcpy(value+7,&tmp,4); + memcpy(value+11,&tmp,4); + memcpy(value+15,&packtmp,2); + + if(Check_CRC(crcnum,len,crcvalue)) + { + uint8_t paramCnt = crcnum[0];//快捷辅助功能 按照协议文档要区分 + set_quick_auxiliary_paramters(paramCnt); + value[17] = 1; + value[18] = Calculate_CRC(value,18); + sendBleData(value,19); + }else{ + value[17] = 0x00; + value[18] = Calculate_CRC(value,18); + sendBleData(value,19); + } +} void getTRAIN_TARGETInfo(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)// { @@ -2094,6 +2122,9 @@ void type2AE4Data(uint8_t *buf_cmd,uint8_t *data,uint16_t datalen,uint8_t *total case SET_PHONE_INFOR_CMD://app下发的下发的手机信息 getPhoneInfo(typeID,data,datalen,totalData,crcvalue); break; + case SET_WATCH_AUXIL_FUN_PARAM_CMD://app下发快捷辅助功能参数 + get_auxil_fun_parm(typeID,data,datalen,totalData,crcvalue); + break; case CURR_TIME_CMD: GetUTCtime(typeID,data,datalen,totalData,crcvalue);//获取时间app下发的时间进行解析 break; @@ -3034,8 +3065,9 @@ static void GetWatchAuxFuncCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t memcpy(value+15,&tmp_data,2); if(Check_CRC(crcnum,len,crcvalue)) { - uint8_t paramCmt = crcnum[0];//辅助功能 0 - + uint8_t paramCmt = 0;//辅助功能 0 + paramCmt = get_quick_auxiliary_paramters(); + printf("paramCmt:%d\r\n",paramCmt); value[17] = paramCmt;// value[18] = Calculate_CRC(value,18); sendBleData(value,19); @@ -3127,7 +3159,7 @@ static void GetSpo2GetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t } -void cameraSend(void) +void cameraSend(uint8_t flag)//2进行手势拍照 3退出拍照界面 { uint8_t value[19]; memset(value,0,19); @@ -3140,7 +3172,7 @@ void cameraSend(void) memcpy(value+7,&tmp,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - value[17] = 2;// + value[17] = flag;// value[18] = Calculate_CRC(value,18); sendBleData(value,19); } @@ -3162,11 +3194,11 @@ static void carmeraCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totald { uint8_t carmera_on = crcnum[0]; //0退出拍照界面 1进入拍照界面 //需要加界面弹窗提示 - if(carmera_on == 1)//进入拍照弹窗界面 + if(carmera_on == 1)//进入拍照界面 { - + CustomEventPublish(TOPIC_EVENT_ENTER_CMAERA,NULL,0); }else{//退出拍照弹窗界面 - + CustomEventPublish(TOPIC_EVENT_CANCEL_CMAERA,NULL,0); } value[17] = 1;// value[18] = Calculate_CRC(value,18); @@ -4220,7 +4252,17 @@ void Read_file_buf_send_bin_Data(uint8_t num,uint16_t id,char *data_item) cJSON_free(heart_data); } - +//type +void realSyncSportData(uint8_t typeid) +{ + int num; + num=(ble_nus_max_data_len-18); + if(num>482) + { + num=482; + } + Send_json_Data_Cmd(num,typeid); +} //手机app下发读设备数据指令 void readDevDataBle(uint8_t *crcnum,uint16_t len,uint8_t crcvalue) @@ -4406,9 +4448,9 @@ void bleLongRecvData(uint8_t *data, uint16_t data_size,uint8_t *buf_cmd,uint8_t bool creatMessageDir(void)//创建消息文件夹 { struct stat info; - if (stat(ANCS_DATA_CONFIG_PATH, &info) != 0) + if (stat(ANCS_DATA_CONFIG_DIR, &info) != 0) { - if (mkdir(ANCS_DATA_CONFIG_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) + if (mkdir(ANCS_DATA_CONFIG_DIR, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) { return false; // Failed to create folder } @@ -4417,39 +4459,28 @@ bool creatMessageDir(void)//创建消息文件夹 } char *get_message_dir_path(void)//获取信息的文件夹路径 { - return ANCS_DATA_CONFIG_PATH; + return ANCS_DATA_CONFIG_DIR; } -void message_data(int uid,int appid,char *title,char *msg,int hasCode) +void message_data(int uid,int appid,char *title,char *msg,int hasCode) { if(!creatMessageDir())//创建文件夹失败 { return; } uint8_t buf_size = 0; - char *path; - path = malloc(100); - if(path == NULL) - { - return; - } - char *str_data = get_message_dir_path(); - sprintf(path,"%s/%s",str_data,ANCS_DATA_CJSON); - printf("creat file %s\n",path); - FILE *jsfile = fopen(path, "r"); + FILE *jsfile = fopen(ANCS_DATA_CJSON_PATH, "r"); cJSON *data_root; if (jsfile != NULL) { printf("succes opening file\n"); fseek(jsfile, 0, SEEK_END); long fileSize = ftell(jsfile); fseek(jsfile, 0, SEEK_SET); - char *jsonData = (char *)malloc(fileSize + 1); fread(jsonData, 1, fileSize, jsfile); jsonData[fileSize] = '\0'; fclose(jsfile); - // 解析JSON数据 - printf("jsonData %s",jsonData); + // printf("jsonData %s",jsonData); data_root= cJSON_Parse(jsonData); // data_root = cJSON_GetObjectItem(modifiedJson,"infor"); free(jsonData); @@ -4473,17 +4504,11 @@ void message_data(int uid,int appid,char *title,char *msg,int hasCode) } cJSON_AddNumberToObject(itemJSON,"uid",uid); - cJSON_AddNumberToObject(itemJSON,"appid_t",appid);//消息类型 微信 qq 等看结构体或者协议定义 - cJSON_AddStringToObject(itemJSON,"title",title);//消息发送者 - cJSON_AddStringToObject(itemJSON,"msg",msg);//消息内容 - cJSON_AddNumberToObject(itemJSON,"time",timeBuf);//时间戳 - cJSON_AddNumberToObject(itemJSON,"hasCode",hasCode);//暂时不需要预留接口 - cJSON_AddBoolToObject(itemJSON,"read",false);//是否已读 false未读 1 已读默认存的时候已经未读 cJSON *dataList = cJSON_GetObjectItem(data_root, "infor"); @@ -4513,7 +4538,7 @@ void message_data(int uid,int appid,char *title,char *msg,int hasCode) time = cJSON_GetObjectItem(object, "time"); hasCode = cJSON_GetObjectItem(object, "hasCode"); read = cJSON_GetObjectItem(object, "read"); - printf("ancs title->valuestring:%s msg->valuestring:%s\r\n",title->valuestring,msg->valuestring); + // printf("ancs title->valuestring:%s msg->valuestring:%s\r\n",title->valuestring,msg->valuestring); cJSON_AddNumberToObject(deitemJSON,"uid",uid->valueint); cJSON_AddNumberToObject(deitemJSON,"appid_t",appid_t->valueint);//消息类型 微信 qq 等看结构体或者协议定义 cJSON_AddStringToObject(deitemJSON,"title",title->valuestring);//消息发送者 @@ -4529,22 +4554,47 @@ void message_data(int uid,int appid,char *title,char *msg,int hasCode) } } char *jsonString = cJSON_Print(data_root); - printf("ancs %s",jsonString); - FILE *fp = fopen(path, "wb"); + // printf("ancs %s",jsonString); + FILE *fp = fopen(ANCS_DATA_CJSON_PATH, "wb"); if (fp) { fwrite(jsonString, 1, strlen(jsonString), fp); fclose(fp); } free(jsonString); - if(path != NULL) - { - free(path); - } read_message_data(); } - +int uft8_check(char *chinese_string,int length) +{ + int i = 0; + for (i = 0; i < length;) { + // 判断是否为ASCII字符 + if ((unsigned char)chinese_string[i] < 0x80) { + printf("ASCII character: %d\n", (int)(unsigned char)chinese_string[i]); + i++; + } else { + // 假设这里我们只处理3字节的UTF-8字符 + // 实际上,中文字符通常是4字节 + if ((unsigned char)chinese_string[i] >= 0xF0) { + // 这里应处理4字节UTF-8字符的逻辑 + // 例如: return (chinese_string[i] << 24) | (chinese_string[i + 1] << 16) | (chinese_string[i + 2] << 8) | chinese_string[i + 3]; + i += 4; // 跳过4个字节 + } else if ((unsigned char)chinese_string[i] >= 0xE0) { + // 这里应处理3字节UTF-8字符的逻辑 + // 例如: return (chinese_string[i] << 16) | (chinese_string[i + 1] << 8) | chinese_string[i + 2]; + i += 3; // 跳过3个字节 + } else { + // 这里应处理2字节UTF-8字符的逻辑 + // 例如: return (chinese_string[i] << 8) | chinese_string[i + 1]; + i += 2; // 跳过2个字节 + } + } + if(i+4 > length) + break; + } + return i; +} //安卓消息接收解析数据 //ANCS 2AE1 uint8_t jscheck_ancs(uint8_t *data) { @@ -4584,15 +4634,29 @@ uint8_t jscheck_ancs(uint8_t *data) cJSON* title_c = cJSON_GetObjectItem(root, "title"); if (cJSON_IsString(title_c)) { printf("titleBuf: %s\n", title_c->valuestring); - title_c->valuestring[strlen(title_c->valuestring)]='\0'; - memcpy(titleBuf,title_c->valuestring,strlen(title_c->valuestring)); + int len = strlen(title_c->valuestring); + if(len >= TITLE_BUF_LEN){ + len = uft8_check(title_c->valuestring,TITLE_BUF_LEN-4); + title_c->valuestring[len++] ='.'; + title_c->valuestring[len++] = '.'; + title_c->valuestring[len++] = '.'; + title_c->valuestring[len++] = 0; + } + + memcpy(titleBuf,(uint8_t *)title_c->valuestring,len); } cJSON* msg = cJSON_GetObjectItem(root, "msg"); if (cJSON_IsString(msg)) { - printf("msgBuf: %s\n", msg->valuestring); - // msgBuf = msg->valuestring; - msg->valuestring[strlen(msg->valuestring)]='\0'; - memcpy(msgBuf,msg->valuestring,strlen(msg->valuestring)); + int len = strlen(msg->valuestring); + if(len >= MSG_BUF_LEN-4){ + len = uft8_check(msg->valuestring,MSG_BUF_LEN-4); + msg->valuestring[len++] ='.'; + msg->valuestring[len++] = '.'; + msg->valuestring[len++] = '.'; + msg->valuestring[len++] = 0; + } + memcpy(msgBuf,(uint8_t *)msg->valuestring,len); + printf("msgBuf: %s\n",msgBuf); } cJSON* time = cJSON_GetObjectItem(root, "time"); if (cJSON_IsString(time)) { @@ -4749,7 +4813,7 @@ void bleDataRecv(uint8_t *totalData, uint16_t event_size,uint16_t handle) memcpy(recvData+packdataLen,totalData,event_size); //先copy再加 packdataLen = packdataLen+event_size; printf("muilt 133333;%d packdataLen:%d",totalDataLen,packdataLen); - if(totalDataLen >= (packdataLen-18))//总的数据包 packdataLen-18把前面17个字节的包头和一个字节的校验和去掉得到数据部分和校验和部分 + if((packdataLen-18) >= totalDataLen)//总的数据包 packdataLen-18把前面17个字节的包头和一个字节的校验和去掉得到数据部分和校验和部分 { bigDataBuf = malloc(totalDataLen); crcvalue = totalData[event_size-1]; diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h index 7a2cb60be..3c98489f2 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h @@ -11,9 +11,9 @@ extern "C" { #include "bts_def.h" #define PHONE_WATCH_CONFIG_PATH "/user/userdata/phone_watch.json" #define ALARM_DATA_CONFIG_PATH "/user/userdata/alarm_test.json" -#define ANCS_DATA_CONFIG_PATH "/user/userdata/message" +#define ANCS_DATA_CONFIG_DIR "/user/userdata/message" -#define ANCS_DATA_CJSON "ancs.json" //消息文件可以任意更改 +#define ANCS_DATA_CJSON_PATH "/user/userdata/message/ancs.json" //消息文件可以任意更改 #define READ_FLASH_DATA 0x01 //读flash数据 #define WRITE_FLASH_DATA 0x02 //写flash数据 @@ -277,6 +277,7 @@ typedef struct uint32_t di; uint32_t stp; uint32_t ti; + uint32_t pc; }msg_get_train_data_info_t;// SET_REAL_DATA_FREQ_CM获取实时训练数据 #pragma pack() @@ -509,6 +510,7 @@ TYPE:02 #define SYN_WATCH_LCD_PARAM_CMD 0x020E//同步屏幕参数app-watch #define SYN_VOICE_VIBRATION_PARAM_CMD 0x020f //同步参数app-watch #define SET_PHONE_INFOR_CMD 0x0210 //app发送手机信息 +#define SET_WATCH_AUXIL_FUN_PARAM_CMD 0x0211 //app发送快捷访问功能参数 #define SET_WATCH_HR_SET_PARAM_CMD 0x0212 //app发送心率设置参数 #define SET_WATCH_SPO2_SET_PARAM_CMD 0x0213 //app发送血氧设置参数 #define SET_DRINK_PARAM_CMD 0x0214 //app发送喝水提醒设置 @@ -616,7 +618,7 @@ void cleanUnbindInfor(uint8_t flag);//和旧手机解绑清除配对信息 0不 void comfirmPaire(uint8_t flag);//发送确认配对指令 1确认配对 0取消配对 -void cameraSend(void); +void cameraSend(uint8_t flag);//发送拍照指令给app 2进行拍照 3退出拍照界面设备发给app void senfindphoneSend(uint8_t flag); 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 b5b39249e..3374ee70c 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c @@ -282,13 +282,11 @@ static void svr_ble_connstate_change_cb(unsigned short conn_id, bd_addr_t *addr, gap_ble_pair_state_t pair_state, gap_ble_disc_reason_t disc_reason) { - uint16_t number; - errcode_t ret = gap_ble_get_paired_devices_num(&number); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "number :%d addr!!! 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x addr->type:%d\r\n",number,addr->addr[0],addr->addr[1],addr->addr[2],addr->addr[3], - addr->addr[4],addr->addr[5],addr->type); + g_ble_conn_id = conn_id; if (GAP_BLE_STATE_DISCONNECTED == conn_state) { // restart ble adv when disconnected Bleconnect = GAP_BLE_STATE_DISCONNECTED;//蓝牙已断开 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GAP_BLE_STATE_DISCONNECTED!!! \r\n"); // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GAP_BLE_STATE_DISCONNECTED!!! svr_alipay_get_adv_start_state %d alipay_get_binding_status:%d\r\n",svr_alipay_get_adv_start_state(),alipay_get_binding_status()); // if(AdverFlag == true){ free_ble_data(); @@ -1006,8 +1004,6 @@ static void svr_ble_bt_gatts_req_write_cb(uint8_t server_id, uint16_t conn_id, g static void svr_ble_mtu_exchange(uint8_t server_id, uint16_t conn_id, uint16_t mtu_size, errcode_t status) { ble_nus_max_data_len = mtu_size-3; - // ble_nus_max_data_len = 100; - // gatts_set_mtu_size(server_id,ble_nus_max_data_len); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "svr_ble_mtu_exchange %d %d %d\r\n",server_id,conn_id,mtu_size); } diff --git a/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h b/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h index ac9ec75a5..20a2c9f78 100755 --- a/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h +++ b/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h @@ -79,7 +79,8 @@ typedef enum { TOPIC_EVENT_DEVICE_UNBIND, TOPIC_EVENT_DEVICE_UNBINDING_REQUEST, #endif - + TOPIC_EVENT_ENTER_CMAERA, + TOPIC_EVENT_CANCEL_CMAERA, TOPIC_EVENT_FIND_WATCH, //查找手表 TOPIC_EVENT_CANCEL_FIND_WATCH,//取消查找 TOPIC_END_NUM = 20000,