From: SnickerSun Date: Wed, 15 May 2024 08:55:57 +0000 (+0800) Subject: 修改部分变量名称,优化打印信息,方便代码分析。 X-Git-Tag: release_V1.2.70_20241020_135402~1115^2~3 X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=ca2a290e915c0727981dde0fbdc2a1e249f472dc;p=mirrors%2FFD230.git 修改部分变量名称,优化打印信息,方便代码分析。 添加OTA json数据接收和解析。 --- 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 ebf93ce5d..675585cfd 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -78,6 +78,21 @@ void malloc_test(void) } app_pkg_msg_send(HEAPINFO, DIAG_CONTROL_FALSE, NULL, 0); } +#include "bleService.h" + +static const char* getHandlname(uint16_t handle) +{ + + if (data2ae0Cmd == handle) return "data2ae0Cmd"; + if (data2ae1Cmd == handle) return "data2ae1Cmd"; + if (data2ae3Cmd == handle) return "data2ae3Cmd"; + if (data2ae4Cmd == handle) return "data2ae4Cmd"; + if (data2ae5Cmd == handle) return "data2ae5Cmd"; + + return "unknown handle"; + +} + // typedef void (*hx3695_msg_callback_t)(uint8_t msg_type, uint8_t *msg_data, int32_t msg_datalen); uint32_t ble_recv_register_msg_callback(ble_recv_msg_callback_t func) { @@ -206,24 +221,18 @@ void cameram_data(void)//拍照发送数据 调用这个接口即可 } bool bigDataBufState=false;//大数据传输状态 -static bool Check_CRC(uint8_t *crcnum,uint16_t len,uint8_t crcvalue)//计算20byte的的校验位 +static bool Check_CRC(uint8_t *data,uint16_t len,uint8_t crcvalue)//计算20byte的的校验位 { uint8_t crcbuf = 0; uint8_t lrcValue = 0x00; - if(crcnum == NULL) + if(data == NULL) { - return true; - // if(crcvalue == 0x00) - // { - // return true; - // }else{ - // return false; - // } + return false; } for(uint16_t i = 0; i < len; i++) { - lrcValue =lrcValue+ crcnum[i]; - // printf("%02x ",crcnum[i]); + lrcValue =lrcValue+ data[i]; + // printf("%02x ",data[i]); } //"{\"pn\":\"iPhone\",\"tp\":1}"; @@ -232,25 +241,24 @@ static bool Check_CRC(uint8_t *crcnum,uint16_t len,uint8_t crcvalue)//计算20by crcbuf = crcbuf%256; WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Check_CRC ret:0x%x len:%d\r\n",crcbuf,len); - return true; - // if(crcbuf == crcvalue) - // { - // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Check_CRC true:\r\n"); - // return true; - // } - // else{ - // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Check_CRC false:\r\n"); - // return false; - // } + if(crcbuf == crcvalue) + { + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Check_CRC true:\r\n"); + return true; + } + else{ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Check_CRC false:\r\n"); + return false; + } } -static uint8_t Calculate_CRC(uint8_t *crcnum,uint16_t len)//计算20byte +static uint8_t Calculate_CRC(uint8_t *data,uint16_t len)//计算20byte { uint8_t crcbuf = 0; uint8_t lrcValue = 0x00; for(uint16_t i = 17; i < len; i++) { - lrcValue =lrcValue+ crcnum[i]; + lrcValue =lrcValue+ data[i]; } // printf("Calculate_CRC:%x,len:%d",lrcValue,len); crcbuf = lrcValue%256; @@ -258,22 +266,22 @@ static uint8_t Calculate_CRC(uint8_t *crcnum,uint16_t len)//计算20byte crcbuf = crcbuf%256; return crcbuf; } -static uint8_t cal_sum(uint8_t *crcnum,uint16_t len)//计算20byte +static uint8_t cal_sum(uint8_t *data,uint16_t len)//计算20byte { uint8_t lrcValue = 0x00; for(uint16_t i = 0; i < len; i++) { - lrcValue =lrcValue+ crcnum[i]; + lrcValue =lrcValue+ data[i]; } return lrcValue; } -static uint8_t Calculate_CRC_Big(uint8_t *crcnum,uint16_t len)//计算20byte +static uint8_t Calculate_CRC_Big(uint8_t *data,uint16_t len)//计算20byte { uint8_t crcbuf = 0; uint8_t lrcValue = 0x00; for(uint16_t i = 0; i < len; i++) { - lrcValue =lrcValue+ crcnum[i]; + lrcValue =lrcValue+ data[i]; } crcbuf = lrcValue%256; crcbuf = 256-crcbuf; @@ -486,9 +494,9 @@ void clearPaireFlag(uint8_t flag) UnbindSucessCmd(1);//1确认解绑; uapi_reboot_device(); } -void clearPaireCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue)//发送清除配对指令 +void clearPaireCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue)//发送清除配对指令 { - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { //弹出清除配对界面不弹出是则发送0x02操作失败 1操作成功 0校验失败 clearPaireFlag(1); @@ -549,10 +557,10 @@ void alarmData(void) } -void getPhoneNameLen(uint8_t *crcnum,uint8_t *datalen)//获取手机设备名称长度 +void getPhoneNameLen(uint8_t *data,uint8_t *datalen)//获取手机设备名称长度 { uint8_t len = 0; - uint8_t *json = crcnum; + uint8_t *json = data; cJSON* root = cJSON_Parse((const char *)json); if(root != NULL) @@ -570,9 +578,9 @@ void getPhoneNameLen(uint8_t *crcnum,uint8_t *datalen)//获取手机设备名称 } } #define PHONE_NAME_MAX_LEN 50 -static uint8_t *getPhoneName(uint8_t *crcnum)//获取手机设备名称 +static uint8_t *getPhoneName(uint8_t *data)//获取手机设备名称 { - uint8_t *json = crcnum; + uint8_t *json = data; uint8_t *str = NULL; cJSON* root = cJSON_Parse((const char *)json); if(root != NULL) @@ -608,9 +616,9 @@ static uint8_t *getPhoneName(uint8_t *crcnum)//获取手机设备名称 } } -void getPhoneMac(uint8_t *crcnum,uint8_t *phoneMac)//获取手机设备mac这个是手表上传给手机的mac地址 +void getPhoneMac(uint8_t *data,uint8_t *phoneMac)//获取手机设备mac这个是手表上传给手机的mac地址 { - uint8_t *json = crcnum; + uint8_t *json = data; uint8_t phone_tmp[6]; memset(phone_tmp,0,6); cJSON* root = cJSON_Parse((const char *)json); @@ -823,7 +831,7 @@ void cleanUnbindInfor(uint8_t flag)//和旧手机解绑清除配对信息 uapi_reboot_device(); } } -void sendBindInfor(uint8_t *crcnum) +void sendBindInfor(uint8_t *data) { uint8_t value[19]; memset(value,0,19); @@ -853,7 +861,7 @@ void sendBindInfor(uint8_t *crcnum) uint8_t MacType = 0; GetwatchSaveMac(&save_mac,&MacType);//获取手表设备本地保存的mac地址和mac地址类型 - getPhoneMac(crcnum,&copare_mac); + getPhoneMac(data,&copare_mac); if(save_mac[0] == 0 && save_mac[1] == 0 && save_mac[2] == 0 && save_mac[3] == 0 && save_mac[4] == 0 && save_mac[5] == 0)//只要手表本地存储没有mac地址就走连接流程重新绑定 { bond = 0x01;//手表未和任何手机绑定过 @@ -862,10 +870,10 @@ void sendBindInfor(uint8_t *crcnum) sendBleData(value,19); #ifdef SUPPORT_DEVICE_PAIRING_NOTIFICATION devnamelen = 0; - getPhoneNameLen(crcnum,&devnamelen);//获取手机下发的手机设备名称长度 + getPhoneNameLen(data,&devnamelen);//获取手机下发的手机设备名称长度 if(devnamelen > 0 ) { - devname = getPhoneName(crcnum); + devname = getPhoneName(data); printf("devname!!!!!!!!!:%s devnamelen:%d",devname,devnamelen); if (devname != NULL){ printf("phone devname is name!!!!!!!!!:"); @@ -967,7 +975,7 @@ void sendBindInfor(uint8_t *crcnum) value[18] = Calculate_CRC(value,18); sendBleData(value,19); } -void getPhoneInfo(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取手机信息 +void getPhoneInfo(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取手机信息 { uint8_t value[19]; memset(value,0,19); @@ -982,9 +990,9 @@ void getPhoneInfo(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,u memcpy(value+15,&tmp_fen,2); phoneDataFlag = 1; - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { - sendBindInfor(crcnum); + sendBindInfor(data); }else{ value[17] = 0x00; value[18] = Calculate_CRC(value,18); @@ -1184,7 +1192,7 @@ static uint8_t jsonCheck_time(uint8_t *buf)//json 格式解析 -void GetUTCtime(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取时间 +void GetUTCtime(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取时间 { uint32_t tmp = 1; uint16_t tmp_data = 1; @@ -1198,11 +1206,9 @@ void GetUTCtime(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uin memcpy(sendBuf+11,&tmp,4); memcpy(sendBuf+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { - uint8_t *data; - data = crcnum; uint8_t set_ok = 1; set_ok = jsonCheck_time(data); sendBuf[17] = set_ok; @@ -1270,7 +1276,7 @@ static uint8_t jsonCheck_targetparam(uint8_t *buf) } -void GetTarinTarget(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取时间 +void GetTarinTarget(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取时间 { uint32_t tmp = 1; uint16_t tmp_data = 1; @@ -1284,10 +1290,8 @@ void GetTarinTarget(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData memcpy(sendBuf+11,&tmp,4); memcpy(sendBuf+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { - uint8_t *data; - data = crcnum; uint8_t set_ok = 1; set_ok = jsonCheck_targetparam(data); sendBuf[17] = set_ok; @@ -1303,7 +1307,7 @@ void GetTarinTarget(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData } -static void GetOtherTarget(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取其他目标 +static void GetOtherTarget(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取其他目标 { uint32_t tmp = 1; uint16_t tmp_data = 1; @@ -1317,17 +1321,17 @@ static void GetOtherTarget(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *to memcpy(sendBuf+11,&tmp,4); memcpy(sendBuf+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { // 73 2 17 1 0 0 0 8 0 0 0 1 0 0 0 8 0 2c 1 a 8 1e 1 1 1 2 - uint16_t target_kcal = crcnum[0]+crcnum[1]*256;//目标卡路里 - uint8_t target_km = crcnum[2];//目标里程 - uint8_t target_stand = crcnum[3];//目标站立 - uint8_t target_fattime = crcnum[4];//目标燃脂 - uint8_t ring = crcnum[5];//铃声 - uint8_t vibratior = crcnum[6];//振动 - uint8_t notify = crcnum[7];//通知 + uint16_t target_kcal = data[0]+data[1]*256;//目标卡路里 + uint8_t target_km = data[2];//目标里程 + uint8_t target_stand = data[3];//目标站立 + uint8_t target_fattime = data[4];//目标燃脂 + uint8_t ring = data[5];//铃声 + uint8_t vibratior = data[6];//振动 + uint8_t notify = data[7];//通知 set_goal_caloriescount(target_kcal); set_goal_discount(target_km); @@ -1399,7 +1403,7 @@ static void jsonCheck_alarm(uint8_t *buf)//json 解析闹钟数据 } -void SetAlarmDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取app下发的屏幕参数 +void SetAlarmDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取app下发的屏幕参数 { uint32_t tmp = 1; uint16_t tmp_data = 1; @@ -1413,9 +1417,9 @@ void SetAlarmDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalDat memcpy(sendBuf+11,&tmp,4); memcpy(sendBuf+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { - jsonCheck_alarm(crcnum); + jsonCheck_alarm(data); sendBuf[17] = 1; sendBuf[18] = Calculate_CRC(sendBuf,18); @@ -1432,7 +1436,7 @@ void SetAlarmDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalDat -void GetWatchLcdParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取app下发的屏幕参数 +void GetWatchLcdParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取app下发的屏幕参数 { uint32_t tmp = 1; uint16_t tmp_data = 1; @@ -1446,16 +1450,16 @@ void GetWatchLcdParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tota memcpy(sendBuf+11,&tmp,4); memcpy(sendBuf+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { - uint8_t type = crcnum[0]; + uint8_t type = data[0]; if(type == 0)//只设置屏幕亮度 { - uint8_t brightness = crcnum[1]; + uint8_t brightness = data[1]; set_brigthness(brightness); }else if(type == 1)//设置亮屏时长 抬碗亮屏 { - uint8_t screen_type = crcnum[1];//ms级别 + uint8_t screen_type = data[1];//ms级别 int screen_time = 5*1000; switch (screen_type) { @@ -1480,7 +1484,7 @@ void GetWatchLcdParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tota default: break; } - bool raise = crcnum[2]; + bool raise = data[2]; set_ScreenDuration(screen_time); Set_RaiseToWake(raise); } @@ -1499,7 +1503,7 @@ void GetWatchLcdParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tota -void GetVoiceVibrateParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取app下发的声音与振动参数 +void GetVoiceVibrateParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取app下发的声音与振动参数 { uint32_t tmp = 1; uint16_t tmp_data = 1; @@ -1513,31 +1517,31 @@ void GetVoiceVibrateParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t * memcpy(sendBuf+11,&tmp,4); memcpy(sendBuf+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { - uint8_t type = crcnum[0]; + uint8_t type = data[0]; if(type == 0)//只改变系统音量参数 其他还是保持不变 按照原来的参数 { - int sys_volume = crcnum[1]; + int sys_volume = data[1]; Set_SystemVolume(sys_volume); }else if(type == 1)//只改变铃声音量参数 其他还是保持不变 按照原来的参数 { int ring_volume = 0; - ring_volume = crcnum[1]; + ring_volume = data[1]; Set_CallVolume(ring_volume); }else if(type == 2)//只改变媒体音量 { int ring_volume = 0; - ring_volume = crcnum[1]; + ring_volume = data[1]; Set_CallVolume(ring_volume); } else if(type == 3)//只改变铃声和振动开关 { - int bell_on = crcnum[1]; - int vibrate_on = crcnum[2]; + int bell_on = data[1]; + int vibrate_on = data[2]; set_SilentMode(bell_on); set_vibrationremiander(vibrate_on); } @@ -1555,7 +1559,7 @@ void GetVoiceVibrateParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t * } -void GetHrSetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取app下发的声音与振动参数 +void GetHrSetParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取app下发的声音与振动参数 { uint32_t tmp = 1; uint16_t tmp_data = 1; @@ -1569,7 +1573,7 @@ void GetHrSetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalDa memcpy(sendBuf+11,&tmp,4); memcpy(sendBuf+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { ble_recv_msg_callback_t func = ble_recv_get_send_msg_callback_func(); memset(&hr_param,0,sizeof(msg_get_heart_set_param_info_t)); @@ -1578,10 +1582,10 @@ void GetHrSetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalDa func(READ_FLASH_DATA,cmd,&hr_param,sizeof(msg_get_heart_set_param_info_t)); } // printf("drink_info:%d %d %d\r\n",drink_info.drink_on,drink_info.alarm_mode,drink_info.start_hour); - hr_param.frequence = crcnum[0]; - hr_param.remind_on = crcnum[1]; - hr_param.max_min = crcnum[2]; - hr_param.heart = crcnum[3]; + hr_param.frequence = data[0]; + hr_param.remind_on = data[1]; + hr_param.max_min = data[2]; + hr_param.heart = data[3]; if(func != NULL) { func(WRITE_FLASH_DATA,cmd,&hr_param,sizeof(msg_get_heart_set_param_info_t)); @@ -1601,7 +1605,7 @@ void GetHrSetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalDa } -void GetSpo2SetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue) +void GetSpo2SetParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue) { uint32_t tmp = 1; uint16_t tmp_data = 1; @@ -1615,7 +1619,7 @@ void GetSpo2SetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *total memcpy(sendBuf+11,&tmp,4); memcpy(sendBuf+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { ble_recv_msg_callback_t func = ble_recv_get_send_msg_callback_func(); memset(&spo2_param,0,sizeof(msg_get_spo2_set_param_info_t)); @@ -1624,11 +1628,11 @@ void GetSpo2SetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *total func(READ_FLASH_DATA,cmd,&spo2_param,sizeof(msg_get_spo2_set_param_info_t)); } // printf("drink_info:%d %d %d\r\n",drink_info.drink_on,drink_info.alarm_mode,drink_info.start_hour); - spo2_param.frequence = crcnum[0]; - spo2_param.remind_on = crcnum[1]; + spo2_param.frequence = data[0]; + spo2_param.remind_on = data[1]; if(spo2_param.remind_on) { - spo2_param.spo2 = crcnum[2]; + spo2_param.spo2 = data[2]; } if(func != NULL) @@ -1649,7 +1653,7 @@ void GetSpo2SetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *total } -void SetsleepSetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//设置睡眠 +void SetsleepSetParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//设置睡眠 { uint32_t tmp = 1; uint16_t tmp_data = 1; @@ -1663,15 +1667,15 @@ void SetsleepSetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tota memcpy(sendBuf+11,&tmp,4); memcpy(sendBuf+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { msg_get_sleep_param_info_t sleep_info; - sleep_info.schedule = crcnum[0]; - sleep_info.bedtime_hour= crcnum[1]; - sleep_info.bedtime_min= crcnum[2]; - sleep_info.waketime_hour= crcnum[3]; - sleep_info.waketime_min= crcnum[4]; - sleep_info.bedtime_alarm= crcnum[5]; + sleep_info.schedule = data[0]; + sleep_info.bedtime_hour= data[1]; + sleep_info.bedtime_min= data[2]; + sleep_info.waketime_hour= data[3]; + sleep_info.waketime_min= data[4]; + sleep_info.bedtime_alarm= data[5]; ble_set_sleep_remind(sleep_info); sendBuf[17] = 1; @@ -1686,7 +1690,7 @@ void SetsleepSetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tota } } -void SetDrinkSetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取喝水提醒s设置 +void SetDrinkSetParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取喝水提醒s设置 { uint32_t tmp = 1; uint16_t tmp_data = 1; @@ -1700,21 +1704,21 @@ void SetDrinkSetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tota memcpy(sendBuf+11,&tmp,4); memcpy(sendBuf+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { msg_drink_info_t drink_info; - drink_info.drink_on = crcnum[0]; - if(crcnum[1]) + drink_info.drink_on = data[0]; + if(data[1]) { drink_info.drink_on=2; } - // drink_info.drink_on = crcnum[1]; - drink_info.goal = crcnum[2]+crcnum[3]*256; - drink_info.time_start = crcnum[4]<<16|crcnum[5]; - if(crcnum[1]) + // drink_info.drink_on = data[1]; + drink_info.goal = data[2]+data[3]*256; + drink_info.time_start = data[4]<<16|data[5]; + if(data[1]) { - drink_info.time_end = crcnum[6]<<16|crcnum[7]; - drink_info.freq = crcnum[8]; + drink_info.time_end = data[6]<<16|data[7]; + drink_info.freq = data[8]; } ble_set_drink_remind(drink_info); @@ -1732,7 +1736,7 @@ void SetDrinkSetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tota } //APP设置步数目标 -void SetsteptargetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue) +void SetsteptargetParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue) { uint32_t tmp = 1; uint16_t tmp_data = 1; @@ -1746,14 +1750,14 @@ void SetsteptargetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *to memcpy(sendBuf+11,&tmp,4); memcpy(sendBuf+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { uint32_t targetStep; - memcpy(&targetStep,crcnum,4); - uint8_t ringOn=crcnum[5]; - uint8_t vibration=crcnum[6]; - uint8_t notify=crcnum[7]; + memcpy(&targetStep,data,4); + uint8_t ringOn=data[5]; + uint8_t vibration=data[6]; + uint8_t notify=data[7]; printf("设置步数:%d\r\n",targetStep); set_goal_stepcount(targetStep); @@ -1845,7 +1849,7 @@ uint8_t jsonCheck_weather(uint8_t *buf,uint8_t *check)//json 格式解析 天气 } -void GetWeatherCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取天气数据 +void GetWeatherCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取天气数据 { uint32_t tmp = 1; uint16_t tmp_data = 1; @@ -1858,11 +1862,11 @@ void GetWeatherCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData, memcpy(sendBuf+7,&tmp,4); memcpy(sendBuf+11,&tmp,4); memcpy(sendBuf+15,&tmp_data,2); - // printf("GetWeatherCmd:len:%d crcnum:%s\r\n",len,crcnum); - if(Check_CRC(crcnum,len,crcvalue)) + // printf("GetWeatherCmd:len:%d data:%s\r\n",len,data); + if(Check_CRC(data,len,crcvalue)) { uint8_t check = 1; - jsonCheck_weather(crcnum,&check); + jsonCheck_weather(data,&check); sendBuf[17] = check; sendBuf[18] = Calculate_CRC(sendBuf,18); sendBleData(sendBuf,19); @@ -1876,8 +1880,12 @@ void GetWeatherCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData, } //APP下发设置用户数据 -void getUserInfo(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)// +void getUserInfo(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)// { + + // 用户数据同步死机,暂时跳过 by Snicker + return; + uint8_t value[19]; memset(value,0,19); uint32_t tmp = 1; @@ -1888,8 +1896,7 @@ void getUserInfo(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,ui memcpy(value+7,&tmp,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp,2); - - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { printf("getUserInfo:!!!!!!!!\r\n"); msg_user_info_t user_info={0}; @@ -1898,26 +1905,26 @@ void getUserInfo(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,ui for(uint8_t i = 0;i 250)maxHr = 250;//最高心率是250 else if(maxHr <= 0) maxHr = 0; set_traning_heart_max(maxHr); @@ -2796,7 +2803,7 @@ static void SetMaxHrRemindCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t } //训练暂停/恢复 -static void GetSportPasueResetCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void GetSportPasueResetCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[19]; memset(value,0,19); @@ -2809,9 +2816,9 @@ static void GetSportPasueResetCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint memcpy(value+7,&tmp,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue))// + if(Check_CRC(data,len,crcvalue))// { - uint8_t PauseStop = crcnum[0];//0 暂停 1恢复 + uint8_t PauseStop = data[0];//0 暂停 1恢复 if(PauseStop==0) { training_ble_data.sportType= 4;//运动类型 0 健走 1跑步 2骑行 3 @@ -2841,7 +2848,7 @@ static void GetSportPasueResetCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint } //发送当前表盘到app -static void SendDialToAppCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void SendDialToAppCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[20]; memset(value,0,20); @@ -2855,7 +2862,7 @@ static void SendDialToAppCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t * memcpy(value+7,&datalen,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue))// + if(Check_CRC(data,len,crcvalue))// { uint16_t dialNum = 450;//0 暂停 1恢复 memcpy(&value[17],&dialNum,2); @@ -2870,7 +2877,7 @@ static void SendDialToAppCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t * } //获取手表当前状态 -static void GetWatchStatusCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void GetWatchStatusCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[20]; memset(value,0,20); @@ -2891,7 +2898,7 @@ static void GetWatchStatusCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t sendBleData(value,19); } //获取手表屏幕参数 -static void GetScreenParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void GetScreenParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[21]; memset(value,0,21); @@ -2941,7 +2948,7 @@ static void GetScreenParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t } //App删除表盘 (仅W4手表) -static void DeleteDialUidCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void DeleteDialUidCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[20]; memset(value,0,20); @@ -2954,10 +2961,10 @@ static void DeleteDialUidCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t * memcpy(value+7,&tmp,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { uint16_t deleteDial = 0;//删除的表盘UID - deleteDial=crcnum[0]+crcnum[1]*256; + deleteDial=data[0]+data[1]*256; value[17] = 1;// 1删除成功 2 没有改资源 0指令校验失败 value[18] = Calculate_CRC(value,18); sendBleData(value,19); @@ -2973,7 +2980,7 @@ static void DeleteDialUidCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t * } //获取手表声音与振动参数 Sound and Vibration -static void GetSoundVibrationCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void GetSoundVibrationCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[23]; memset(value,0,23); @@ -2987,7 +2994,7 @@ static void GetSoundVibrationCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8 memcpy(value+7,&datalen,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { int sys_volume = Get_SystemVolume(); @@ -3015,7 +3022,7 @@ static void GetSoundVibrationCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8 } //APP获取手表辅助功能参数Auxiliary functions -static void GetWatchAuxFuncCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void GetWatchAuxFuncCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[23]; memset(value,0,23); @@ -3028,7 +3035,7 @@ static void GetWatchAuxFuncCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t memcpy(value+7,&tmp,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { uint8_t paramCmt = 0;//辅助功能 0 paramCmt = get_quick_auxiliary_paramters(); @@ -3046,7 +3053,7 @@ static void GetWatchAuxFuncCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t } //APP获取手表心率设置 -static void GetHrGetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void GetHrGetParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[22]; memset(value,0,22); @@ -3061,7 +3068,7 @@ static void GetHrGetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t * memcpy(value+7,&datalen,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { uint8_t hrfreq = 0;//监测频率 uint8_t hrSwitch = 0;//心率提醒开关 @@ -3091,7 +3098,7 @@ static void GetHrGetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t * } //APP获取手表血氧设置 -static void GetSpo2GetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void GetSpo2GetParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[21]; memset(value,0,21); @@ -3105,7 +3112,7 @@ static void GetSpo2GetParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t memcpy(value+7,&datalen,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { uint8_t spo2freq = 0;//监测频率 uint8_t spo2Switch = 0;//心率提醒开关 @@ -3142,7 +3149,7 @@ void cameraSend(uint8_t flag)//2进行手势拍照 3退出拍照界面 sendBleData(value,19); } //手势拍照协议 -static void carmeraCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void carmeraCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[19]; memset(value,0,19); @@ -3155,9 +3162,9 @@ static void carmeraCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totald memcpy(value+7,&tmp,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { - uint8_t carmera_on = crcnum[0]; //0退出拍照界面 1进入拍照界面 + uint8_t carmera_on = data[0]; //0退出拍照界面 1进入拍照界面 //需要加界面弹窗提示 if(carmera_on == 1)//进入拍照界面 { @@ -3179,7 +3186,7 @@ static void carmeraCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totald } //APP获取手表喝水提醒设置 -static void GetDrinkParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void GetDrinkParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[19]; memset(value,0,19); @@ -3203,7 +3210,7 @@ static void GetDrinkParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t * } //APP发送恢复出厂设置 -static void GetFactoryCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void GetFactoryCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[19]; memset(value,0,19); @@ -3216,7 +3223,7 @@ static void GetFactoryCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tot memcpy(value+7,&tmp,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { value[17] = 1;// @@ -3231,7 +3238,7 @@ static void GetFactoryCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tot } //APP发送重新启动 static uint8_t power_buf[2]={0}; -static void GetResetCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void GetResetCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[19]; memset(value,0,19); @@ -3244,7 +3251,7 @@ static void GetResetCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *total memcpy(value+7,&tmp,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { value[17] = 1;// @@ -3261,7 +3268,7 @@ static void GetResetCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *total } } //APP发送关机 -static void GetPowerOffCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void GetPowerOffCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[19]; memset(value,0,19); @@ -3274,7 +3281,7 @@ static void GetPowerOffCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *to memcpy(value+7,&tmp,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { value[17] = 1;// @@ -3295,7 +3302,7 @@ static void GetPowerOffCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *to //app发送公英制单位 -static void GetMetricCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void GetMetricCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[19]; memset(value,0,19); @@ -3308,9 +3315,9 @@ static void GetMetricCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tota memcpy(value+7,&tmp,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { - uint8_t kmileter = crcnum[0];//公英制单位 0 是公英制 1英制单位 + uint8_t kmileter = data[0];//公英制单位 0 是公英制 1英制单位 value[17] = 1;// value[18] = Calculate_CRC(value,18); sendBleData(value,19); @@ -3323,7 +3330,7 @@ static void GetMetricCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tota } //app获取睡眠设置 -static void GetSleepParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void GetSleepParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[24]; memset(value,0,24); @@ -3366,7 +3373,7 @@ static void GetSleepParamCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t * } //app获取所有表盘UID -static void GetAllDialUidCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void GetAllDialUidCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[24]; memset(value,0,24); @@ -3393,7 +3400,7 @@ static void GetAllDialUidCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t * } } //app获取目标步数设置 -static void GetTargetStepCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void GetTargetStepCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[25]; memset(value,0,25); @@ -3429,7 +3436,7 @@ static void GetTargetStepCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t * } //app其他目标设置 -static void GetTargetOtherCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void GetTargetOtherCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[26]; memset(value,0,26); @@ -3478,7 +3485,7 @@ static void GetTargetOtherCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t } //app发送解除配对消息 -static void UnpairMessCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void UnpairMessCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[19]; memset(value,0,19); @@ -3492,7 +3499,7 @@ static void UnpairMessCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tot memcpy(value+7,&datalen,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { value[17] = 1;// @@ -3506,7 +3513,7 @@ static void UnpairMessCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tot } } //app发送同步数据结束消息 -static void GetSynDataEndCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void GetSynDataEndCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[19]; memset(value,0,19); @@ -3520,7 +3527,7 @@ static void GetSynDataEndCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t * memcpy(value+7,&datalen,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { value[17] = 1;// value[18] = Calculate_CRC(value,18); @@ -3533,7 +3540,7 @@ static void GetSynDataEndCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t * } } //同步历史步数 -static void stepDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void stepDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[58]; memset(value,0,58); @@ -3547,7 +3554,7 @@ static void stepDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *total memcpy(value+7,&tmpToall,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { uint8_t data_buf[40]; // uint8_t data_len = 0; @@ -3581,7 +3588,7 @@ static void stepDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *total } } //同步卡路里历史数据 -static void kcalDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void kcalDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[58]; memset(value,0,58); @@ -3595,7 +3602,7 @@ static void kcalDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *total memcpy(value+7,&tmpToall,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { uint8_t data_buf[40]; // uint8_t data_len = 4; @@ -3622,7 +3629,7 @@ static void kcalDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *total } } //同步距离历史数据 -static void disDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void disDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[58]; memset(value,0,58); @@ -3636,7 +3643,7 @@ static void disDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totald memcpy(value+7,&tmpToall,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { uint8_t data_buf[40]; // uint8_t data_len = 4; @@ -3715,7 +3722,7 @@ static void Send_json_Data_Cmd(uint16_t pack_size,uint8_t id) // ym_free(json_format); } //同步睡眠数据 -static void sleepDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void sleepDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[18+1]; memset(value,0,18+1); @@ -3729,7 +3736,7 @@ static void sleepDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tota memcpy(value+7,&tmpToall,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { value[17] = 0; value[18] = 0xff; @@ -3742,7 +3749,7 @@ static void sleepDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tota } } //同步数据结束完成 -static void synEndDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void synEndDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[18+1]; memset(value,0,18+1); @@ -3756,7 +3763,7 @@ static void synEndDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tot memcpy(value+7,&tmpToall,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { value[17] = 1; value[18] = Calculate_CRC(value,18); @@ -3769,7 +3776,7 @@ static void synEndDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tot } } //同步站立历史数据 -static void standDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void standDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[58]; memset(value,0,58); @@ -3783,7 +3790,7 @@ static void standDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tota memcpy(value+7,&tmpToall,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { uint8_t data_buf[40]; // uint8_t data_len = 4; @@ -3811,7 +3818,7 @@ static void standDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *tota } //同步燃脂时间数据 -static void burntimeDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void burntimeDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[48]; memset(value,0,48); @@ -3825,7 +3832,7 @@ static void burntimeDataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *t memcpy(value+7,&tmpToall,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { uint8_t data_buf[30]; // uint32_t data_len = 0; @@ -3861,7 +3868,7 @@ uint8 read_hart_jsondata(uint8 day) } //同步血氧历史数据 -static void spo2DataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) +static void spo2DataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { uint8_t value[43]; memset(value,0,43); @@ -3875,7 +3882,7 @@ static void spo2DataCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *total memcpy(value+7,&tmpToall,4); memcpy(value+11,&tmp,4); memcpy(value+15,&tmp_data,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { uint32_t data_len = 0; for(uint16_t i = 0;i<5;i++) @@ -4249,7 +4256,7 @@ void Read_file_buf_send_bin_Data(uint8_t num,uint16_t id,char *data_item) } //手机app下发读设备数据指令 -void readDevDataBle(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue) +void readDevDataBle(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue) { uint8_t sendBuf[19]; memset(sendBuf,0,19); @@ -4267,10 +4274,10 @@ void readDevDataBle(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData memcpy(sendBuf+11,&pack_count,4);//分包索引号 memcpy(sendBuf+15,&pack_datalen,2);//分包数据长度 - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { bleSendTypeID=cmd-((cmd/256)*256); - // printf("同步第%d天的数据\r\n",crcnum[0]); + // printf("同步第%d天的数据\r\n",data[0]); int num; switch (bleSendTypeID) { @@ -4281,7 +4288,7 @@ void readDevDataBle(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData { num=96; } - printf("同步心率数据,每包最多:%d 条数据 crcnum:%d\r\n",num,crcnum[0]); + printf("同步心率数据,每包最多:%d 条数据 data:%d\r\n",num,data[0]); Read_file_buf_send_bin_Data(num,0x40,"heart_data_list"); break; case 0x41://同步血氧历史数据 @@ -4440,6 +4447,9 @@ void bleLongRecvData(uint8_t *data, uint16_t data_size,uint8_t *buf_cmd,uint8_t case 0x03:// type2AE1Data(buf_cmd,data,data_size,totalData,crcvalue); break; + case 0x04: + type2AE0Data(buf_cmd,data,data_size,totalData,crcvalue); + break; default: break; } @@ -4680,7 +4690,7 @@ uint8_t jscheck_ancs(uint8_t *data) } return 1; } -void ancsDataShowCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)// +void ancsDataShowCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)// { uint8_t value[19]; memset(value,0,19); @@ -4693,11 +4703,11 @@ void ancsDataShowCmd(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalDat memcpy(value+11,&tmp,4); memcpy(value+15,&tmp,2); - if(Check_CRC(crcnum,len,crcvalue)) + if(Check_CRC(data,len,crcvalue)) { //解析ancs数据并且显示出来 uint8_t check_ok= 1; - check_ok = jscheck_ancs(crcnum); + check_ok = jscheck_ancs(data); value[17] = 1; value[18] = Calculate_CRC(value,18); sendBleData(value,19); @@ -4718,6 +4728,103 @@ void type2AE1Data(uint8_t *buf_cmd,uint8_t *data,uint16_t datalen,uint8_t *total break; } } + +static ota_file_struct_t g_ota_file_stat={0}; + +errcode_t ota_json_file_save(uint8_t *data,uint16_t datalen) +{ + printf("ota_json_file_save %s\n",data); + + /** + * * OTA文件信息格式 + * { + "type":1, + //"name":"MT2523_FOTA.bin", + "size":3894464, + "major":0, + "mid":3, + "minor":2 + "isForced":1 + } + + {"isForced":0,"size":254208,"minor":1,"type":1,"major":1,"mid":0} + */ + + cJSON* root = cJSON_Parse((const char *)data); + + if(root != NULL) + { + cJSON* ota_type_json = cJSON_GetObjectItem(root, "type"); + if(ota_type_json != NULL && cJSON_IsNumber(ota_type_json)) + { + g_ota_file_stat.ota_type = ota_type_json->valueint; + } + + cJSON* ota_name_json = cJSON_GetObjectItem(root, "name"); + if ( ota_name_json != NULL && cJSON_IsString(ota_name_json)) { + g_ota_file_stat.ota_name = ota_name_json->valuestring; + } + + cJSON* ota_size_json = cJSON_GetObjectItem(root, "size"); + if(ota_size_json != NULL && cJSON_IsNumber(ota_size_json)) + { + g_ota_file_stat.ota_size = ota_size_json->valueint; + } + cJSON* ota_major_json = cJSON_GetObjectItem(root, "major"); + if(ota_major_json != NULL && cJSON_IsNumber(ota_major_json)) + { + g_ota_file_stat.ota_major = ota_major_json->valueint; + } + cJSON* ota_mid_json = cJSON_GetObjectItem(root, "mid"); + if(ota_mid_json != NULL && cJSON_IsNumber(ota_mid_json)) + { + g_ota_file_stat.ota_mid = ota_mid_json->valueint; + } + cJSON* ota_minor_json = cJSON_GetObjectItem(root, "minor"); + if(ota_minor_json != NULL && cJSON_IsNumber(ota_minor_json)) + { + g_ota_file_stat.ota_minor = ota_minor_json->valueint; + } + cJSON* ota_isforced_json = cJSON_GetObjectItem(root, "isForced"); + if(ota_isforced_json != NULL && cJSON_IsNumber(ota_isforced_json)) + { + g_ota_file_stat.ota_isforced = ota_isforced_json->valueint; + } + cJSON_Delete(root); + + printf(" ota_type= %d, ota_name=%s, ota_size=%d, ota_major=%d, ota_mid=%d, ota_minor=%d, ota_isforced=%d \n", + g_ota_file_stat.ota_type, + g_ota_file_stat.ota_name, + g_ota_file_stat.ota_size, + g_ota_file_stat.ota_major, + g_ota_file_stat.ota_mid, + g_ota_file_stat.ota_minor, + g_ota_file_stat.ota_isforced + ); + + } + return ERRCODE_SUCC; +} + +void type2AE0Data(uint8_t *buf_cmd,uint8_t *data,uint16_t datalen,uint8_t *totalData,uint8_t crcvalue) +{ + uint16_t typeID = buf_cmd[1]*256 +buf_cmd[2]; + printf("type2AE0Data typeID:0x%x datalen %d\r\n",typeID,datalen); + bool checkcrc = Check_CRC(data,datalen,crcvalue); + if( checkcrc == true ) + { + switch (typeID) //ID + { + case OTA_FILE_RECV_CMD:// + ota_json_file_save( data, datalen); + break; + } + + }else{ + printf("type2AE0Data CRC failed!\n"); + } + +} void bleRecvANCSData(uint8_t *data, uint16_t data_size,uint8_t *buf_cmd,uint8_t *totalData,uint8_t crcvalue)//buf_cmd 指令前17个字节数据 { uint8_t type = buf_cmd[1]; @@ -4738,7 +4845,141 @@ uint8_t totalpack = 0; uint8_t cmd_data[17]; uint8_t *recvData; #include "los_memory.h" + + +#if USE_PROTOCOL_EN_DE_BY_SNICKER +#define MAX_BLE_MSG_PACKAGE_LEN (1024*5) //包缓存最大5k +typedef struct +{ + uint8_t *data; + int handle; + int data_len ; + int totalDataLen; + msg_header_t cmd_header; + uint8_t crcvalue; +} ble_read_data; + #define MAX_HANDLE_NUM 10 +//LITE_OS_SEC_TEXT_MINOR UINT32 LOS_MemInfoGet(VOID *pool, LOS_MEM_POOL_STATUS *poolStatus) +//根据特征值分开组合读取的数据,并处理 +static ble_read_data handle_l[MAX_HANDLE_NUM]={0}; + +void dumpHeader(msg_header_t *msgheader) +{ + printf("dumpHeader(%d) direction %02X, type %02X, id %02X, package_count %d, total_data_len %d,package_index %d , package_len %d\n", + sizeof(msg_header_t), + msgheader->direction, + msgheader->cmdtype, + msgheader->cmdid, + msgheader->package_count, + msgheader->total_data_len, + msgheader->package_index, + msgheader->package_len + ); +} + + +/***** + * 组包函数 + * 组包校验完成,在分发给对应的handler去解码协议。 + * +*/ +errcode_t combine_data_internal(ble_read_data *buffer_handle,uint8_t *totalData, uint16_t event_size) +{ + + msg_header_t *header = (msg_header_t*)totalData; + dumpHeader(header); + buffer_handle->cmd_header.direction = header->direction; + buffer_handle->cmd_header.cmdtype = header->cmdtype; + buffer_handle->cmd_header.cmdid = header->cmdid; + buffer_handle->cmd_header.package_count = header->package_count; + buffer_handle->cmd_header.total_data_len = header->total_data_len; + buffer_handle->cmd_header.package_len = header->package_len; + buffer_handle->cmd_header.package_index = header->package_index; + + //第一帧 + if (buffer_handle->cmd_header.package_index == 1) + { + //如果有历史数据,没有被清空,可能是历史错误数据,则清空内存。 + if (buffer_handle->data!=NULL && buffer_handle->data_len > 0) + { + free(buffer_handle->data); + buffer_handle->data = NULL; + buffer_handle->data_len = 0; + } + buffer_handle->totalDataLen = buffer_handle->cmd_header.total_data_len; + if (buffer_handle->totalDataLen > MAX_BLE_MSG_PACKAGE_LEN || buffer_handle->totalDataLen <= 0 ) + { + printf("package is too lardge (%d) than (%d) or too small !\n",buffer_handle->totalDataLen,MAX_BLE_MSG_PACKAGE_LEN); + return ERRCODE_FAIL; + } + buffer_handle->data = malloc(buffer_handle->totalDataLen); + if (buffer_handle->data== NULL) + { + return ERRCODE_MALLOC; + } + } + //经过第一包处理,仍然data==NULL证明第一帧就是错的,要退出解析。 + if (buffer_handle->data== NULL) + { + return ERRCODE_MALLOC; + } + //创建缓存开始存储包数据 + if(buffer_handle->cmd_header.package_len >0) + { + + + } + //如果包完整接收,进行crc校验 + if(buffer_handle->data_len == buffer_handle->totalDataLen) + { + + + } + return ERRCODE_SUCC; +} + +void bleDataRecv(uint8_t *totalData, uint16_t event_size,uint16_t handle) +{ + + if (event_size < sizeof(msg_header_t)) + { + printf("event size (%d) is less than msg_header_t (%d) ",event_size,sizeof(msg_header_t)); + return ; + } + if(sendbigDataBufState == true)//正在发送大数据不接收任何app指令下发的数据 + { + return; + } + printf("bleDataRecv handle:%d\r\n",handle); + + for(int i = 0;idata[read_data_tmp->totalDataLen]=0; } - bleLongRecvData(read_data_tmp->data,read_data_tmp->totalDataLen,read_data_tmp->cmd_data,NULL,read_data_tmp->crcvalue); + bleLongRecvData(read_data_tmp->data,read_data_tmp->totalDataLen,read_data_tmp->cmd_data,NULL,read_data_tmp->crcvalue); if(read_data_tmp->data)//只有数据不为NULL的才释放 { ym_free(read_data_tmp->data); @@ -4871,7 +5121,7 @@ void bleDataRecv(uint8_t *totalData, uint16_t event_size,uint16_t handle) memset(read_data_tmp->cmd_data,0,17); printf("pack data end!!!!!!\r\n"); } - + } void free_ble_data(void)//以防断开蓝牙没有释放数据类型 @@ -4886,10 +5136,13 @@ void free_ble_data(void)//以防断开蓝牙没有释放数据类型 sendbigDataBufState = false; } + +#endif + //接收app下发的原始数据 void revBleOldData(uint8_t *buf, uint16_t event_size,uint16_t handle)//每包的数据大小 { - printf("handle :%d data2ae3Cmd:%d data2ae4Cmd:%d event_size %d\r\n",handle,data2ae3Cmd,data2ae4Cmd,event_size); + printf("handle :%d %s event_size %d\r\n",handle,getHandlname(handle),event_size); bleDataRecv(buf,event_size,handle); } #endif 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 461390396..7321c58ad 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h @@ -95,7 +95,44 @@ void cameram_send_data(void); #define FIND_PHONE_CMD 0x0501 //同步睡眠历史数据 +#define USE_PROTOCOL_EN_DE_BY_SNICKER 0 + +#if USE_PROTOCOL_EN_DE_BY_SNICKER +#define MSG_DIRECTION_RECV 0x73 +#define MSG_DIRECTION_SEND 0x71 + /*******************data structure*************************/ + +#pragma pack(1) +/*** + * uint8_t direction;//指令方向 + uint8_t cmdtype;//指令 类型 + uint8_t cmdid;//指令 ID + uint32_t package_count;//总包数 + uint32_t total_data_len;//数据总长度 + uint32_t package_index;//分包索引 + uint16_t package_len;//分包数据长度 +*/ +typedef struct +{ + uint8_t direction;//指令方向 + uint8_t cmdtype;//指令 类型 + uint8_t cmdid;//指令 ID + uint32_t package_count;//总包数 + uint32_t total_data_len;//数据总长度 + uint32_t package_index;//分包索引 + uint16_t package_len;//分包数据长度 +}msg_header_t;//获取其他目标设置 +#pragma pack() + +typedef struct +{ + msg_header_t header; + uint8_t *package_data;//0-482字节 数据包 + uint8_t crc; //校验位 数据包后最后一位 +}msg_data_t; + +#endif #pragma pack(1) typedef struct { @@ -498,6 +535,9 @@ typedef struct #define ANDROID_ANCS_CMD 0x0301 +/****************OTA******************************************/ +#define OTA_FILE_RECV_CMD 0x0420 + /***********************长指令>20字节****************************************/ /*******************TYPE+ID**********************/ /* @@ -605,11 +645,29 @@ typedef struct #pragma pack() +typedef struct +{ + uint8_t ota_type; + uint32_t ota_size; + uint8_t ota_major; + uint8_t ota_mid; + uint8_t ota_minor; + uint8_t ota_isforced; + char *ota_name; +}ota_file_struct_t; + + + + void revBleOldData(uint8_t *buf, uint16_t event_size,uint16_t handle);//协议接收client下发的数据接口 //02类型的指令数据 void type2AE3Data(uint8_t *cmd_buf ,uint8_t *data,uint16_t datalen,uint8_t *totaldata,uint8_t crcvalue);//对不同指令ID进行区分 void type2AE1Data(uint8_t *buf_cmd,uint8_t *data,uint16_t datalen,uint8_t *totalData,uint8_t crcvalue); +void type2AE0Data(uint8_t *buf_cmd,uint8_t *data,uint16_t datalen,uint8_t *totalData,uint8_t crcvalue); +void type2AE4Data(uint8_t *buf_cmd,uint8_t *data,uint16_t datalen,uint8_t *totalData,uint8_t crcvalue); +void type2AE5Data(uint8_t *buf_cmd,uint8_t *data,uint16_t datalen,uint8_t *totalData,uint8_t crcvalue); + errcode_t sendBleData(uint8_t *buf,uint16_t len); void sendParieSuccess(uint8_t flag,bd_addr_t *addr);//发送配对成功指令to app mac手机端的地址 void getPhoneInfo_test(void); 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 f387ac741..fa92340eb 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c @@ -803,25 +803,25 @@ static void svr_ble_bt_gatts_characteristic_add_cb(uint8_t server_id, bt_uuid_t gatts_add_character_result_t *result, errcode_t status) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bt_gatts_characteristic_add_cb uuid:0x%02x%02x 0x%x %d %d\r\n",uuid->uuid[0],uuid->uuid[1],srv_handle,result->handle,result->value_handle); - bt_uuid_t chara_uuid_data4 = {0}; - bts_data_to_uuid_len2(BLE_CHARACTERISTIC_SNED_OTA_ID, &chara_uuid_data4); - - bt_uuid_t chara_uuid_data5 = {0}; - bts_data_to_uuid_len2(BLE_CHARACTERISTIC_SNED_ANDRIOD_ID, &chara_uuid_data5); - - bt_uuid_t chara_uuid_data1 = {0}; - bts_data_to_uuid_len2(BLE_CHARACTERISTIC_RECV_ID, &chara_uuid_data1); - bt_uuid_t chara_uuid_data2 = {0}; - bts_data_to_uuid_len2(BLE_CHARACTERISTIC_SNED_SHORT_ID, &chara_uuid_data2); - bt_uuid_t chara_uuid_data3 = {0}; - bts_data_to_uuid_len2(BLE_CHARACTERISTIC_SNED_LONG_ID, &chara_uuid_data3); + bt_uuid_t chara_uuid_data_2ae0 = {0}; + bts_data_to_uuid_len2(BLE_CHARACTERISTIC_SNED_OTA_ID, &chara_uuid_data_2ae0); + + bt_uuid_t chara_uuid_data_2ae1 = {0}; + bts_data_to_uuid_len2(BLE_CHARACTERISTIC_SNED_ANDRIOD_ID, &chara_uuid_data_2ae1); + + bt_uuid_t chara_uuid_data_2ae5 = {0}; + bts_data_to_uuid_len2(BLE_CHARACTERISTIC_RECV_ID, &chara_uuid_data_2ae5); + bt_uuid_t chara_uuid_data_2ae3 = {0}; + bts_data_to_uuid_len2(BLE_CHARACTERISTIC_SNED_SHORT_ID, &chara_uuid_data_2ae3); + bt_uuid_t chara_uuid_data_2ae4 = {0}; + bts_data_to_uuid_len2(BLE_CHARACTERISTIC_SNED_LONG_ID, &chara_uuid_data_2ae4); - bt_uuid_t chara_uuid_data6 = {0}; - bts_data_to_uuid_len2(BLE_CHARACTERISTIC_READ_BATTERY_ID, &chara_uuid_data6); + bt_uuid_t chara_uuid_data_2ae2 = {0}; + bts_data_to_uuid_len2(BLE_CHARACTERISTIC_READ_BATTERY_ID, &chara_uuid_data_2ae2); - bt_uuid_t hid_report_uuid = {0}; - bts_data_to_uuid_len2(BLE_UUID_REPORT, &hid_report_uuid); + bt_uuid_t hid_report_uuid_2a4d = {0}; + bts_data_to_uuid_len2(BLE_UUID_REPORT, &hid_report_uuid_2a4d); bt_uuid_t alipay_report_uuid = {0}; bts_data_to_uuid_len2(ALIPAYY_CHARACTERISTIC_ID, &alipay_report_uuid); @@ -832,7 +832,7 @@ static void svr_ble_bt_gatts_characteristic_add_cb(uint8_t server_id, bt_uuid_t alipay_handle = result->value_handle; } - if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data1)) + if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data_2ae5)) { if(g_ble_server_handle == 0) { @@ -845,7 +845,7 @@ static void svr_ble_bt_gatts_characteristic_add_cb(uint8_t server_id, bt_uuid_t WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " 2ae5 result->value_handle1 %d\r\n",result->value_handle); } - if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data2)) + if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data_2ae3 )) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "2ae3 result->value_handle2 %d\r\n",result->value_handle); if(data2ae3Cmd == 0) @@ -855,7 +855,7 @@ static void svr_ble_bt_gatts_characteristic_add_cb(uint8_t server_id, bt_uuid_t } - if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data4)) + if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data_2ae0)) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "2ae0 result->value_handle4 %d\r\n",result->value_handle); if(data2ae0Cmd == 0) @@ -863,7 +863,7 @@ static void svr_ble_bt_gatts_characteristic_add_cb(uint8_t server_id, bt_uuid_t data2ae0Cmd = result->value_handle; } } - if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data5)) + if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data_2ae1)) { if(data2ae1Cmd == 0) { @@ -873,12 +873,12 @@ static void svr_ble_bt_gatts_characteristic_add_cb(uint8_t server_id, bt_uuid_t WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "2ae1 result->value_handle5 %d\r\n",result->value_handle); // shortCmdChara = result->value_handle; } - if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data6)) + if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data_2ae2)) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "2ae2 result->value_handle6 %d\r\n",result->value_handle); // shortCmdChara = result->value_handle; } - if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data3)) + if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data_2ae4)) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "2ae4 result->value_handle3 %d\r\n",result->value_handle); if(data2ae4Cmd == 0) @@ -887,8 +887,8 @@ static void svr_ble_bt_gatts_characteristic_add_cb(uint8_t server_id, bt_uuid_t } // = result->value_handle; } - if (ble_gatts_cmp_uuid(uuid, &hid_report_uuid) == true) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "result->hid_report_uuid %d\r\n",result->value_handle); + if (ble_gatts_cmp_uuid(uuid, &hid_report_uuid_2a4d) == true) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "result->hid_report_uuid_2a4d %d\r\n",result->value_handle); if(g_hid_server_handle == 0){ g_hid_server_handle = result->value_handle; WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "g_hid_server_handle %d\r\n",g_hid_server_handle); diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.h b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.h index 5ffdb72b3..8ae66ecee 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.h +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.h @@ -21,6 +21,7 @@ extern uint16_t data2ae3Cmd;//2ae3短指令特征值 extern uint16_t data2ae4Cmd; extern uint16_t data2ae5Cmd; extern uint16_t data2ae1Cmd;//安卓消息来电 +extern uint16_t data2ae0Cmd;//OTA extern uint16_t ble_nus_max_data_len; extern uint16_t alipay_handle; extern uint16_t g_ble_conn_id;