From: DXY <1731678236@qq.com> Date: Mon, 6 May 2024 01:45:29 +0000 (+0800) Subject: 查找手表弹窗对接协议已完成:声音与振动ui对接已完成 屏幕参数已完成 X-Git-Tag: release_V1.2.70_20241020_135402~1108^2~24 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=6f46f62be4bb03a767f0dd2959550f177a410f11;p=mirrors%2FFD230.git 查找手表弹窗对接协议已完成:声音与振动ui对接已完成 屏幕参数已完成 --- 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 3ade5fb86..cc227a735 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -188,6 +188,71 @@ void set_traning_heart_max(uint8_t data) p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_TRAINING_HEART_MAX,data); return; } +void set_brigthness(uint8_t data) //设置屏幕亮度 +{ + OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); + p_ConfigModel->SetBrightness(data); + return; +} + +int get_brigthness(void) //获取屏幕亮度 +{ + OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); + + return p_ConfigModel->GetBrightness(); +} +void set_ScreenDuration(int data) //设置亮屏时长 +{ + OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); + p_ConfigModel->SetScreenDuration(data); + return; +} + +int get_ScreenDuration(void) //获取亮屏时长 +{ + OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); + + return p_ConfigModel->GetScreenDuration(); +} +void Set_RaiseToWake(bool value) //抬婉亮屏开关 +{ + OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); + p_ConfigModel->SetRaiseToWake(value); + return; +} + +int Get_RaiseToWake(void) //获取抬婉亮屏开关 +{ + OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); + + return p_ConfigModel->GetRaiseToWake(); +} +void Set_SystemVolume(int value) //设置系统音量 +{ + OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); + p_ConfigModel->SetSystemVolume(value); + return; +} + +int Get_SystemVolume(void) //获取系统音量 +{ + OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); + + return p_ConfigModel->GetSystemVolume(); +} +void Set_CallVolume(int value) //设置铃声和媒体音量 +{ + OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); + p_ConfigModel->SetCallVolume(value); + return; +} + +int Get_CallVolume(void) //获取铃声和媒体音量 +{ + OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); + + return p_ConfigModel->GetCallVolume(); +} uint8_t ble_is_ready(void) { @@ -266,7 +331,7 @@ void read_message_data(void) char path[100]; uint32_t data_len = 0; char *str_data = get_message_dir_path(); - sprintf(path,"%s%s",str_data,ANCS_DATA_CJSON); + sprintf(path,"%s/%s",str_data,ANCS_DATA_CJSON); printf("buf file %s\n",path); FILE *jsfile = fopen(path, "r"); cJSON *data_root; @@ -304,7 +369,6 @@ void read_message_data(void) cJSON *time = NULL; cJSON *hasCode = NULL; cJSON *read_t = NULL; - cJSON *detialJSON = cJSON_CreateObject(); object = cJSON_GetArrayItem(dataList,i);//1 0 uid_t = cJSON_GetObjectItem(object, "uid"); appid_t = cJSON_GetObjectItem(object, "appid_t"); @@ -313,29 +377,36 @@ void read_message_data(void) time = cJSON_GetObjectItem(object, "time"); hasCode = cJSON_GetObjectItem(object, "hasCode"); read_t = cJSON_GetObjectItem(object, "read"); - message_infor_s.message_t[count - 1- i].uid = uid_t->valueint;// - message_infor_s.message_t[count - 1- i].appid = appid_t->valueint; - if(strlen(title_buf->valuestring) == 0) + message_infor_s.message_t[i].uid = uid_t->valueint;// + message_infor_s.message_t[i].appid = appid_t->valueint; + if(strlen(title_buf->valuestring) != 0)//10 { - memcpy(message_infor_s.message_t[count - 1- i].title,title_buf->valuestring,strlen(title_buf->valuestring)); + memcpy(message_infor_s.message_t[i].title,title_buf->valuestring,strlen(title_buf->valuestring)); }else{ - memset(message_infor_s.message_t[count - 1- i].title,0,TITLE_BUF_LEN); + memset(message_infor_s.message_t[i].title,0,TITLE_BUF_LEN); } + printf("message_infor_s.message_t[i].title:%s",message_infor_s.message_t[i].title); - if(strlen(msg_buf->valuestring) == 0) + if(strlen(msg_buf->valuestring) != 0) { - memcpy(message_infor_s.message_t[count - 1- i].msg,msg_buf->valuestring,strlen(msg_buf->valuestring)); + memcpy(message_infor_s.message_t[i].msg,msg_buf->valuestring,strlen(msg_buf->valuestring)); }else{ - memset(message_infor_s.message_t[count - 1- i].msg,0,MSG_BUF_LEN); + memset(message_infor_s.message_t[i].msg,0,MSG_BUF_LEN); } - message_infor_s.message_t[count - 1- i].time = time->valueint; - message_infor_s.message_t[count - 1- i].hasCode = hasCode->valueint; - message_infor_s.message_t[count - 1- i].read = read_t->valueint; + printf("message_infor_s.message_t[count - 1- i].msg:%s",message_infor_s.message_t[i].msg); + message_infor_s.message_t[i].time = time->valueint; + message_infor_s.message_t[i].hasCode = hasCode->valueint; + message_infor_s.message_t[i].read = read_t->valueint; } } } } + 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); + } } 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 5eef800f5..e203bcde4 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h @@ -88,6 +88,9 @@ struct message_infor_t uint8_t num; struct ancs_data_info_t message_t[MAX_MESSAGE_NUM]; }; + +void read_message_data(void);//读内存信息数据开机读一次 +struct message_infor_t *get_message_info(void); void set_weather_now_data(int humidity, char* windScale, char* textNight,int uvIndex,int temp,int iconNight); void set_weather_address_data(int lat, char* atm, char* city,char* subLocality,int lon); @@ -119,6 +122,26 @@ void set_SilentMode(uint8_t falg); void set_traning_updata_freq(uint8_t freq); void set_traning_heart_max(uint8_t data); + +void set_brigthness(uint8_t data); //设置屏幕亮度 + +int get_brigthness(void); //获取屏幕亮度 + +void set_ScreenDuration(int data); //设置亮屏时长 + +int get_ScreenDuration(void); //获取亮屏时长 + +void Set_RaiseToWake(bool value); //抬婉亮屏开关 + +int Get_RaiseToWake(void); //获取抬婉亮屏开关 + +void Set_SystemVolume(int value); //设置系统音量 +int Get_SystemVolume(void); //获取系统音量 + +void Set_CallVolume(int value); //设置铃声和媒体音量 +int Get_CallVolume(void); //获取铃声和媒体音量 + + #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 7cc91b471..f576b3ee6 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -148,8 +148,6 @@ int ble_recv_msg_callback(uint8_t writ_read,uint16_t msg_typeID, uint8_t *msg_da break; case USER_INFOR_CMD: - // memset(&user_info,0,sizeof(user_info)); - // memcpy(&user_info,msg_data,sizeof(user_info)); set_user_data(user_info); break; @@ -1417,18 +1415,42 @@ void GetWatchLcdParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tota if(Check_CRC(crcnum,len,crcvalue)) { - ble_recv_msg_callback_t func = ble_recv_get_send_msg_callback_func(); - memset(&watch_lcd_param,0,sizeof(msg_watch_lcd_param_info_t)); - - // printf("drink_info:%d %d %d\r\n",drink_info.drink_on,drink_info.alarm_mode,drink_info.start_hour); - watch_lcd_param.brigntess = crcnum[0]; - watch_lcd_param.screen_time = crcnum[1]; - watch_lcd_param.wrist_on = crcnum[2]; - if(func != NULL) + uint8_t type = crcnum[0]; + if(type == 0)//只设置屏幕亮度 + { + uint8_t brightness = crcnum[1]; + set_brigthness(brightness); + }else if(type == 1)//设置亮屏时长 抬碗亮屏 { - func(WRITE_FLASH_DATA,cmd,&watch_lcd_param,sizeof(msg_watch_lcd_param_info_t)); + uint8_t screen_type = crcnum[1];//ms级别 + int screen_time = 5*1000; + switch (screen_type) + { + case 0: + screen_time = 5*1000; + break; + case 1: + screen_time = 10*1000; + break; + case 2: + screen_time = 15*1000; + break; + case 3: + screen_time = 30*1000; + break; + case 4: + screen_time = 60*1000; + break; + case 5: + screen_time = 60*5*1000; + break; + default: + break; + } + bool raise = crcnum[2]; + set_ScreenDuration(screen_time); + Set_RaiseToWake(raise); } - sendBuf[17] = 1; sendBuf[18] = Calculate_CRC(sendBuf,18); sendBleData(sendBuf,19); @@ -1460,30 +1482,33 @@ void GetVoiceVibrateParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t * if(Check_CRC(crcnum,len,crcvalue)) { - ble_recv_msg_callback_t func = ble_recv_get_send_msg_callback_func(); - memset(&voice_vibration,0,sizeof(msg_get_voice_vibration_info_t)); - if(func != NULL) - { - func(READ_FLASH_DATA,cmd,&voice_vibration,sizeof(msg_get_voice_vibration_info_t)); - } - // printf("drink_info:%d %d %d\r\n",drink_info.drink_on,drink_info.alarm_mode,drink_info.start_hour); + uint8_t type = crcnum[0]; if(type == 0)//只改变系统音量参数 其他还是保持不变 按照原来的参数 { - voice_vibration.sys_volume = crcnum[1]; + int sys_volume = crcnum[1]; + Set_SystemVolume(sys_volume); + }else if(type == 1)//只改变铃声音量参数 其他还是保持不变 按照原来的参数 { - voice_vibration.ring_volume = crcnum[1]; - }else if(type == 2)//只改变铃声和振动开关 + int ring_volume = 0; + ring_volume = crcnum[1]; + Set_CallVolume(ring_volume); + + }else if(type == 2)//只改变媒体音量 { - voice_vibration.bell_on = crcnum[1]; - voice_vibration.vibrate_on = crcnum[2]; + int ring_volume = 0; + ring_volume = crcnum[1]; + Set_CallVolume(ring_volume); } - if(func != NULL) + else if(type == 3)//只改变铃声和振动开关 { - func(WRITE_FLASH_DATA,cmd,&voice_vibration,sizeof(msg_get_voice_vibration_info_t)); + int bell_on = crcnum[1]; + int vibrate_on = crcnum[2]; + set_SilentMode(bell_on); + set_vibrationremiander(vibrate_on); } - + sendBuf[17] = 1; sendBuf[18] = Calculate_CRC(sendBuf,18); sendBleData(sendBuf,19); @@ -2190,11 +2215,12 @@ static void findWatchCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tota //弹窗界面 if(findFlag)//查找手表弹窗界面 { - + CustomEventPublish(TOPIC_EVENT_FIND_WATCH,NULL,0); }else//停止查找手表 如果在查找手表界面就要停止回到上一级界面 { - + CustomEventPublish(TOPIC_EVENT_CANCEL_FIND_WATCH,NULL,0); } + setFindWatchFlag(1); }else { setFindWatchFlag(0); @@ -2762,16 +2788,36 @@ static void GetScreenParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - ble_recv_msg_callback_t func = ble_recv_get_send_msg_callback_func(); - memset(&watch_lcd_param,0,sizeof(msg_watch_lcd_param_info_t)); - - if(func != NULL) + int brigntess = get_brigthness(); + int screen_time = 0; + switch (get_ScreenDuration()/1000) { - func(READ_FLASH_DATA,cmd,&watch_lcd_param,sizeof(msg_watch_lcd_param_info_t)); - }//读设备内存 - value[17] = watch_lcd_param.brigntess; - value[18] = watch_lcd_param.screen_time; - value[19] = watch_lcd_param.wrist_on; + case 5: + screen_time = 0; + break; + case 10: + screen_time = 1; + break; + case 15: + screen_time = 2; + break; + case 30: + screen_time = 3; + break; + case 60: + screen_time = 4; + break; + case 60*5: + screen_time = 5; + break; + default: + screen_time = 0; + break; + } + bool wrist_on = Get_RaiseToWake(); + value[17] = brigntess; + value[18] = screen_time; + value[19] = wrist_on; value[20] = Calculate_CRC(value,20); sendBleData(value,21); } @@ -2825,26 +2871,19 @@ static void GetSoundVibrationCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8 memcpy(value+15,&tmp_data,2); if(Check_CRC(crcnum,len,crcvalue)) { - memset(&voice_vibration,0,sizeof(msg_get_voice_vibration_info_t)); - // uint8_t sysSoundLevel = 0;//系统音量调节 - // uint8_t sysRing = 0;//铃声音量调节 - // uint8_t sysMedia = 0;//媒体音量调节 - // uint8_t RingSwitch = 0;//铃声开关 - // uint8_t VibiationSwitch = 0;//振动开关 - ble_recv_msg_callback_t func = ble_recv_get_send_msg_callback_func(); - memset(&voice_vibration,0,sizeof(msg_get_voice_vibration_info_t)); - - // printf("drink_info:%d %d %d\r\n",drink_info.drink_on,drink_info.alarm_mode,drink_info.start_hour); - - if(func != NULL) - { - func(READ_FLASH_DATA,cmd,&voice_vibration,sizeof(msg_get_voice_vibration_info_t)); - } - value[17] = voice_vibration.sys_volume;// - value[18] = voice_vibration.ring_volume;// - value[19] = voice_vibration.media_volume;// - value[20] = voice_vibration.bell_on;// - value[21] = voice_vibration.vibrate_on;// + + int sys_volume = Get_SystemVolume(); + int ring_volume = Get_CallVolume(); + int media_volume = Get_CallVolume(); + uint8_t vibrate_on = get_vibrationremiander(); + + bool bell_on = get_SilentMode(); + + value[17] = sys_volume;// + value[18] = ring_volume;// + value[19] = media_volume;// + value[20] = bell_on;// + value[21] = vibrate_on;// value[22] = Calculate_CRC(value,22); sendBleData(value,23); }else @@ -4245,7 +4284,7 @@ void message_data(int uid,int appid,char *title,char *msg,int hasCode) return; } char *str_data = get_message_dir_path(); - sprintf(path,"%s%s",str_data,ANCS_DATA_CJSON); + sprintf(path,"%s/%s",str_data,ANCS_DATA_CJSON); printf("creat file %s\n",path); FILE *jsfile = fopen(path, "r"); cJSON *data_root; @@ -4265,11 +4304,13 @@ void message_data(int uid,int appid,char *title,char *msg,int hasCode) data_root= cJSON_Parse(jsonData); // data_root = cJSON_GetObjectItem(modifiedJson,"infor"); free(jsonData); + }else{ data_root = cJSON_Parse("{\ \"infor\": [\ ]}"); } + cJSON *dataJSON = cJSON_CreateObject(); cJSON *detialJSON = cJSON_CreateObject(); @@ -4281,22 +4322,30 @@ void message_data(int uid,int appid,char *title,char *msg,int hasCode) { timeBuf = 0; } + 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"); if (dataList != NULL && cJSON_IsArray(dataList)) { int numData = cJSON_GetArraySize(dataList); if(numData >= MAX_MESSAGE_NUM)//大于20条就循环迭代显示并保存数据 { - for (uint8_t i = MAX_MESSAGE_NUM-1; i > 0; i--)//2-1 1 0 + for (uint8_t i = 0; i < MAX_MESSAGE_NUM-1; i++)//2-1 1 0 { - // printf("ancs !!!!!!!!!!!!\r\n"); + // printf("ancs !!!!!!!!!!!! i:%d\r\n",i); cJSON *object = NULL; cJSON *uid = NULL; cJSON *appid_t = NULL; @@ -4307,7 +4356,7 @@ void message_data(int uid,int appid,char *title,char *msg,int hasCode) cJSON *read = NULL; cJSON* deitemJSON = cJSON_CreateObject(); cJSON *detialJSON = cJSON_CreateObject(); - object = cJSON_GetArrayItem(dataList,i);//1 0 + object = cJSON_GetArrayItem(dataList,i+1);//9 9-18 0+1 9+1 uid = cJSON_GetObjectItem(object, "uid"); appid_t = cJSON_GetObjectItem(object, "appid_t"); title = cJSON_GetObjectItem(object, "title"); @@ -4323,7 +4372,7 @@ void message_data(int uid,int appid,char *title,char *msg,int hasCode) cJSON_AddNumberToObject(deitemJSON,"time",time->valueint);//时间戳 cJSON_AddNumberToObject(deitemJSON,"hasCode",hasCode->valueint);//暂时不需要预留接口 cJSON_AddBoolToObject(deitemJSON,"read",read->valueint);//是否已读 false未读 1 已读默认存的时候已经未读 - cJSON_ReplaceItemInArray(dataList, i-1, deitemJSON); + cJSON_ReplaceItemInArray(dataList, i, deitemJSON);// } cJSON_ReplaceItemInArray(dataList,MAX_MESSAGE_NUM-1, itemJSON); }else{ @@ -4332,17 +4381,18 @@ void message_data(int uid,int appid,char *title,char *msg,int hasCode) } char *jsonString = cJSON_Print(data_root); printf("ancs %s",jsonString); - FILE *file = fopen(path, "wb"); - if (file) + FILE *fp = fopen(path, "wb"); + if (fp) { - fwrite(jsonString, 1, strlen(jsonString), file); - fclose(file); + fwrite(jsonString, 1, strlen(jsonString), fp); + fclose(fp); } free(jsonString); if(path != NULL) { free(path); } + read_message_data(); } @@ -4406,9 +4456,9 @@ uint8_t jscheck_ancs(uint8_t *data) hasCode_t = hasCode->valueint; } cJSON_Delete(root); - message_data(uid_t,appid_t,title_c,msgBuf,hasCode); - if(title_c != NULL){ - free(title_c); + message_data(uid_t,appid_t,titleBuf,msgBuf,hasCode_t); + if(titleBuf != NULL){ + free(titleBuf); } if(msgBuf != NULL){ free(msgBuf); diff --git a/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c b/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c index 32517d7b1..81f9b4c74 100755 --- a/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c +++ b/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c @@ -56,6 +56,8 @@ static const TopicToCore topicToCoreArray[] = { {TOPIC_EVENT_DEVICE_UNBIND,A_CORE_MASK, 1}, {TOPIC_EVENT_DEVICE_UNBINDING_REQUEST,A_CORE_MASK, 1}, #endif + {TOPIC_EVENT_FIND_WATCH,A_CORE_MASK, 1},//查找手表 + {TOPIC_EVENT_CANCEL_FIND_WATCH,A_CORE_MASK, 1}, #ifdef SUPPORT_CAT1_MODEM {TOPIC_EVENT_CAT1_INCOMMING, A_CORE_MASK, 1}, {TOPIC_EVENT_CAT1_CALLCONNTED, A_CORE_MASK, 1}, diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp index 61aa3bbfc..31657ab2b 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp @@ -31,6 +31,7 @@ #include #include "ui_service.h" #include +#include "bleEvent.h" namespace OHOS { UIViewGroup *FindWatchGroupView{nullptr}; @@ -57,6 +58,9 @@ namespace OHOS UNUSED(event); if (&view == FindWatchButton) // 手表已找到 { + #ifdef SUPPORT_BLE_SERVICE + setFindWatchFlag(2);//表示已找到手表 + #endif FindWatchRingPlayStop(); NotificationManager::GetInstance()->StopNotify(); SetFindWatchNotifyFlag(false);