From 2150f741f9190133cf5f145295189603072ddc33 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Mon, 17 Jun 2024 19:01:27 +0800 Subject: [PATCH] =?utf8?q?ble=E4=B9=85=E5=9D=90=E5=8D=8F=E8=AE=AE=E5=AF=B9?= =?utf8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../fd230app/nativeui/goal/src/goalother.cpp | 52 +-------- .../service/ble_service/blemoder/bletest.cpp | 36 ++++-- .../service/ble_service/blemoder/bletest.h | 6 + .../service/ble_service/bleservice/bleEvent.c | 110 +++++++++++++++++- .../service/ble_service/bleservice/bleEvent.h | 16 ++- .../peripheral/config/include/ConfigModel.h | 2 +- 6 files changed, 158 insertions(+), 64 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalother.cpp b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalother.cpp index da1b7c5d3..9ff0d7c60 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalother.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalother.cpp @@ -11,57 +11,7 @@ namespace OHOS { - /*主天气背景图片*/ - static constexpr int16_t WEATHER_BACKGROUND_IMAGE_X = 0; - static constexpr int16_t WEATHER_BACKGROUND_IMAGE_Y = 0; - static constexpr int16_t WEATHER_BACKGROUND_IMAGE_W = 466; - static constexpr int16_t WEATHER_BACKGROUND_IMAGE_H = 466; - - /*天气图片*/ - static constexpr int16_t WEATHER_IMAGE_X = 77; - static constexpr int16_t WEATHER_IMAGE_Y = 124; - static constexpr int16_t WEATHER_IMAGE_W = 130; - static constexpr int16_t WEATHER_IMAGE_H = 130; - - /*当前时间标签*/ - static constexpr int16_t CURRENT_TIME_LABEL_X = 133; - static constexpr int16_t CURRENT_TIME_LABEL_Y = 52; - static constexpr int16_t CURRENT_TIME_LABEL_W = 200; - static constexpr int16_t CURRENT_TIME_LABEL_H = 47; - static constexpr int16_t CURRENT_TIME_LABEL_TEXT_FONT = 40; - static constexpr int16_t CURRENT_TIME_LABEL_LINE_HEIGHT = 47; - - /*温度标签*/ - static constexpr int16_t TEMPERATURE_LABEL_X = 211; - static constexpr int16_t TEMPERATURE_LABEL_Y = 126; - static constexpr int16_t TEMPERATURE_LABEL_W = 178; - static constexpr int16_t TEMPERATURE_LABEL_H = 125; - static constexpr int16_t TEMPERATURE_LABEL_TEXT_FONT = 100; - static constexpr int16_t TEMPERATURE_LABEL_LINE_HEIGHT = 125; - - /*天气描述标签*/ - static constexpr int16_t WEATHER_DESCRIPTION_LABEL_X = 33; - static constexpr int16_t WEATHER_DESCRIPTION_LABEL_Y = 264; - static constexpr int16_t WEATHER_DESCRIPTION_LABEL_W = 400; - static constexpr int16_t WEATHER_DESCRIPTION_LABEL_H = 43; - static constexpr int16_t WEATHER_DESCRIPTION_LABEL_TEXT_FONT = 35; - static constexpr int16_t WEATHER_DESCRIPTION_LABEL_LINE_HEIGHT = 41; - - /*天气地区标签*/ - static constexpr int16_t WEATHER_AREA_LABEL_X = 43; - static constexpr int16_t WEATHER_AREA_LABEL_Y = 330; - static constexpr int16_t WEATHER_AREA_LABEL_W = 380; - static constexpr int16_t WEATHER_AREA_LABEL_H = 33; - static constexpr int16_t WEATHER_AREA_LABEL_TEXT_FONT = 26; - static constexpr int16_t WEATHER_AREA_LABEL_LINE_HEIGHT = 30; - - /*最高与最低气温标签*/ - static constexpr int16_t MAXANDMIN_TEMPERATURE_LABEL_X = 83; - static constexpr int16_t MAXANDMIN_TEMPERATURE_LABEL_Y = 368; - static constexpr int16_t MAXANDMIN_TEMPERATURE_LABEL_W = 300; - static constexpr int16_t MAXANDMIN_TEMPERATURE_LABEL_H = 33; - static constexpr int16_t MAXANDMIN_TEMPERATURE_LABEL_TEXT_FONT = 20; - static constexpr int16_t MAXANDMIN_TEMPERATURE_LABEL_LINE_HEIGHT = 23; + static constexpr int16_t PULLUP_ANIMATOR_VIEW_X = 213; static constexpr int16_t PULLUP_ANIMATOR_VIEW_Y = 430; 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 0e31908bd..5f7eeff7f 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -63,6 +63,35 @@ extern "C" { #include "bletest.h" #include +void set_sedent_param( msg_sedent_set_param_info_t * data) +{ + OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); + + p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SEDENTARY_SWITCH,data->sedent_on); + + p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SEDENTARY_REMINDERTIME,data->sedent_time ); + + p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SEDENTARY_INTERVAL,data->frequenc); + + return; +} + + +void get_sedent_param( msg_sedent_set_param_info_t * data) +{ + OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); + + data->sedent_on = p_ConfigModel->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SEDENTARY_SWITCH); + + data->sedent_time = p_ConfigModel->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SEDENTARY_REMINDERTIME); + + data->frequenc = p_ConfigModel->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SEDENTARY_INTERVAL); + + return; +} + + + void ble_set_dial_by_id(uint16_t id) { return OHOS::SetDialModel::GetInstance().UpdateDialSetting(id); @@ -107,8 +136,6 @@ void install_Register_dial( char * name,uint16_t id) } - - #define CWM_HISTORY_DATA_PATH "/user/userdata/goal/step_" #define CWM_HISTORY_DATA_CALORIES_PATH "/user/userdata/goal/calories_" @@ -183,7 +210,6 @@ void ble_set_sleep_remind(msg_get_sleep_param_info_t data) p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SLEEP,data.schedule); if(data.schedule) { - printf("开始时间:%d\r\n",data.bedtime_hour); printf("开始时间:%d\r\n",data.bedtime_min); p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SLEEP_BEDTIME,data.bedtime_hour<<16|data.bedtime_min); @@ -246,7 +272,6 @@ void ble_set_drink_remind(msg_drink_info_t data) p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_DRINK_END,data.time_end); printf("频率:%d\r\n",data.freq); p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_DRINK_FREQ,data.freq); - } } return; @@ -263,8 +288,6 @@ void ble_get_drink_remind(msg_drink_info_t *data) return; } - - // 闹钟数据: // { //     //"code":1, @@ -533,7 +556,6 @@ uint8_t ble_falg=0; void set_user_data(msg_user_info_t *data) { - OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); printf("高:%d\r\n",data->height); p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_CUSTOM_DATA_HEIGHT,data->height); 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 5540c0cc8..37bae6960 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h @@ -223,6 +223,12 @@ void install_Register_dial( char * name,uint16_t id); bool dial_file_save(void); +//////////////////////久坐提醒//////////////////////////// +void set_sedent_param( msg_sedent_set_param_info_t * data); + +void get_sedent_param( msg_sedent_set_param_info_t * data); + + #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 c64a8d524..ccf32a5f6 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -1835,6 +1835,59 @@ void SetDrinkSetParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalD } } + +void SetsedentarinessSetParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//设置久坐设置 +{ + uint32_t tmp = 1; + uint16_t tmp_data = 1; + uint8_t sendBuf[19]; + memset(sendBuf,0,19); + sendBuf[0] = 0x72; + sendBuf[1] = 0x02; + sendBuf[2] = 0x1D; + memcpy(sendBuf+3,&tmp,4); + memcpy(sendBuf+7,&tmp,4); + memcpy(sendBuf+11,&tmp,4); + memcpy(sendBuf+15,&tmp_data,2); + + if(Check_CRC(data,len,crcvalue)) + { + msg_sedent_set_param_info_t sedent_data={0}; + sedent_data.sedent_on=data[0]; + + // uint32_t sedent_on_time=data[1]; + // sedent_data.sedent_time |= sedent_on_time<<24; + + // sedent_on_time=data[2]; + // sedent_data.sedent_time |= sedent_on_time<<16; + + // sedent_on_time=data[3]; + // sedent_data.sedent_time |= sedent_on_time<<8; + + // sedent_on_time=data[4]; + // sedent_data.sedent_time |= sedent_on_time<<0; + memcpy_s( &sedent_data.sedent_time,4,&data[1],4); + + + sedent_data.frequenc = data[5]; + + set_sedent_param(&sedent_data); + + sendBuf[17] = 1; + sendBuf[18] = Calculate_CRC(sendBuf,18); + sendBleData(sendBuf,19); + } + else + { + sendBuf[17] = 0; + sendBuf[18] = Calculate_CRC(sendBuf,18); + sendBleData(sendBuf,19); + } +} + + + + //APP设置步数目标 void SetsteptargetParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue) { @@ -2215,12 +2268,18 @@ void type2AE4Data(ble_read_data *buffer_handle,uint8_t *buf_cmd,uint8_t *data,ui getAPPaddressbook(typeID,data,datalen,totalData,crcvalue); break; case SET_ALARM_DATA_CMD: + SetAlarmDataCmd(typeID,data,datalen,totalData,crcvalue); - break; case SET_OTHER_TARGET_CMD: GetOtherTarget(typeID,data,datalen,totalData,crcvalue); break; + case SET_PASSWORD_CMD: + + break; + case SET_SEDENTARINESS_PARAM_CMD: + SetsedentarinessSetParamCmd(typeID,data,datalen,totalData,crcvalue); + break; case QUERY_DIAL_INSTALLED_PARAM_CMD: query_dial_installed(buffer_handle,typeID,data,datalen,totalData,crcvalue); break; @@ -3455,7 +3514,46 @@ static void GetMetricCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totald } } -//app获取睡眠设置 +//app获取久坐设置 +static void GetSedentParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +{ + uint8_t value[24]; + memset(value,0,24); + uint32_t tmp = 1; + uint32_t datalen = 6; + uint16_t tmp_data =6; + value[0] = 0x72; + value[1] = 0x01; + value[2] = 0x31; + memcpy(value+3,&tmp,4); + memcpy(value+7,&datalen,4); + memcpy(value+11,&tmp,4); + memcpy(value+15,&tmp_data,2); + if(1) + { + msg_sedent_set_param_info_t data; + get_sedent_param( &data); + + uint8_t on = data.sedent_on;//作息时间设定 0关闭 1开启 1 + uint32_t time = data.sedent_time;//时间 4 + uint8_t frequenc = data.frequenc;//间隔 1 + + printf("%04X %d %d\r\n",time,frequenc,on); + value[17] = on; + memcpy_s(&value[18],4,&time,4); + + value[22] = frequenc; + value[23] = Calculate_CRC(value,23); + sendBleData(value,24); + }else + { + value[17] = 0; + value[18] = Calculate_CRC(value,18); + sendBleData(value,19); + } +} + + static void GetSleepParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[24]; @@ -4203,6 +4301,9 @@ void type2AE3Data(ble_read_data *buffer_handle,uint8_t *cmd_buf ,uint8_t *data,u case SLEEP_GET_CMD://app获取睡眠设置 GetSleepParamCmd(cmd,data,datalen,totaldata,crcvalue); break; + case GET_SEDENT_CMD: + GetSedentParamCmd(cmd,data,datalen,totaldata,crcvalue); + break; case DELETE_ALL_DILA_CMD://app所有表盘UID GetAllDialUidCmd(cmd,data,datalen,totaldata,crcvalue); break; @@ -5401,8 +5502,11 @@ void decode_file_checksum(ble_read_data *buffer_handle) TRANSMIT_DATA= TRANS_DIAL_SUCC; CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); - + //0504 ble_reply_cmd(DIAL_INSTALL_REPY_CMD,1); + + // ble_reply_cmd(GET_TRANS_END_CMD,1); + } else { 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 acae1d070..0657e1995 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h @@ -81,6 +81,7 @@ void cameram_send_data(void); #define GET_UNPAIR_CMD 0x012D //发送解除配对消息 #define SYN_DATA_END_CMD 0x012E //app发送同步数据结束消息 #define ENTER_FACTORY_TEST_CMD 0x0130 //进入工厂测试模式 +#define GET_SEDENT_CMD 0x0131 //获取久坐提醒设置 #define SYN_HEART_HISTORY_DATA_CMD 0x0140 //同步心率历史数据 #define SYN_SPO2_HISTORY_DATA_CMD 0x0141 //同步血氧历史数据 #define SYN_STRESS_HISTORY_DATA_CMD 0x0142 //同步压力历史数据 @@ -92,8 +93,8 @@ void cameram_send_data(void); #define SYN_BASIC_TRANIN_HISTORY_DATA_CMD 0x0149 //同步基础训练历史数据basic training #define SYN_SLEEP_HISTORY_DATA_CMD 0x014B //同步睡眠历史数据 -#define SET_DMP_MODE_CMD 0x0131 -#define GET_DMP_MODE_CMD 0x0132 +#define SET_DMP_MODE_CMD 0x0135 +#define GET_DMP_MODE_CMD 0x0136 #define FIND_PHONE_CMD 0x0501 //同步睡眠历史数据 @@ -594,11 +595,14 @@ TYPE:02 #define SET_SLEEP_PARAM_CMD 0x0215 //app发送睡眠设置 #define SET_STEP_TARGET_CMD 0x0216 //app发送步数目标 #define SET_OTHER_TARGET_CMD 0x0217 //app发送其他目标 +#define SET_PASSWORD_CMD 0x021C //APP设置手表密码password +#define SET_SEDENTARINESS_PARAM_CMD 0x021D //APP设置久坐提醒 #define SET_WEATHER_DATA_CMD 0x0220 //发送天气数据 #define SET_ALARM_DATA_CMD 0x0221 //发送闹钟数据 #define DELETE_FILE_CMD 0x0222 //删除指定文件 #define SYN_BASIC_REAL_HEATR_CMD 0x024B //同步基础训练试试心率记录 #define SYN_TODAY_BASIC_TRAIN_TXT_CMD 0x024D //同步当天任意时间之后的基础训练记录 + #pragma pack(1) typedef struct { uint8_t drink_on;//提醒开关 0关闭 1开启 @@ -623,6 +627,14 @@ typedef struct uint8_t timeformat;//时间制 0 24小时制 1 12小时制 }msg_user_info_t;//获取用户信息 身高体重 + +typedef struct { + uint8_t sedent_on;//提醒开关 0关闭 1开启 + uint32_t sedent_time;//时间 + uint8_t frequenc;//提醒频率 +}msg_sedent_set_param_info_t; + + #pragma pack() /****************************************** * diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModel.h b/code/sdk/drivers/peripheral/config/include/ConfigModel.h index d29fa57aa..c274a3baa 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModel.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModel.h @@ -309,7 +309,7 @@ namespace OHOS {ConfigDataType::DATATYPE_INT, "sleep_remide", "0" }, // CONFIGMODEL_ITEM_SLEEP_REMIND,//提前20分钟提醒开关 {ConfigDataType::DATATYPE_BOOL, "sedentary_switch", "false" }, // CONFIGMODEL_ITEM_SEDENTARY_SWITCH,//久坐提醒开关 {ConfigDataType::DATATYPE_INT, "sedentary_interval", "1" }, // CONFIGMODEL_ITEM_SEDENTARY_INTERVAL,//久坐提醒时间间隔 - {ConfigDataType::DATATYPE_STRING, "sedentary_reminderTime ", "10:00-22:00" }, // CONFIGMODEL_ITEM_SEDENTARY_REMINDERTIME,//久坐提醒时间段 + {ConfigDataType::DATATYPE_INT, "sedentary_reminderTime", "0" }, // CONFIGMODEL_ITEM_SEDENTARY_REMINDERTIME,//久坐提醒时间段 前16位是开始时间 前8 为小时 后8为分钟 后16位为结束时间规则同前 例: 1600 0B00 11点开始到 22点结束 {ConfigDataType::DATATYPE_STRING, "sim_iccid", "" },//CONFIGMODEL_ITEM_SIM_ICCID cat1的iccid {ConfigDataType::DATATYPE_STRING, "telecom_regist_timesec", "" },//CONFIGMODEL_ITEM_TELECOM_DMP_TIMESEC {ConfigDataType::DATATYPE_INT, "dmp_factory_status", "0" },//CONFIGMODEL_ITEM_DMP_FACTORY_STATUS默认是0 -- 2.17.1