From 678003ab0ad553d36b1af0236108c5ee7e926d3f Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Sat, 15 Jun 2024 11:36:34 +0800 Subject: [PATCH] =?utf8?q?=E5=A4=A9=E6=B0=94=E5=8D=8F=E8=AE=AE=E4=BC=98?= =?utf8?q?=E5=8C=96=20=E8=A1=A8=E7=9B=98=E7=9B=B8=E5=85=B3=E5=8D=8F?= =?utf8?q?=E8=AE=AE=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../brandy/brandy_standard/input_app.h | 2 +- .../nativeui/set_dial/src/SetDialModel.cpp | 33 ++++--- .../nativeui/weather/include/WeatherModel.h | 2 +- .../nativeui/weather/src/WeatherModel.cpp | 27 ++++-- .../nativeui/set_dial/src/SetDialModel.cpp | 63 +++++++++----- .../ble_service/blemoder/CMakeLists.txt | 9 ++ .../service/ble_service/blemoder/bletest.cpp | 64 +++++++++++--- .../service/ble_service/blemoder/bletest.h | 17 ++++ .../service/ble_service/bleservice/bleEvent.c | 85 +++++++++++++------ mkota.sh | 0 10 files changed, 218 insertions(+), 84 deletions(-) mode change 100644 => 100755 mkota.sh diff --git a/code/sdk/application/brandy/brandy_standard/input_app.h b/code/sdk/application/brandy/brandy_standard/input_app.h index 918ec12f3..8cf2557e5 100755 --- a/code/sdk/application/brandy/brandy_standard/input_app.h +++ b/code/sdk/application/brandy/brandy_standard/input_app.h @@ -39,7 +39,7 @@ #define BUTTON_PRESS_TIME_9S 9000 #define BUTTON_INVALID_PRESS_TIME (BUTTON_PRESS_TIME_9S + BUTTON_APP_TIMER_INTERVAL) #define APP_BOARD_MSG_COUNT 16 -#define APP_BOARD_TASK_SIZE 0x800 +#define APP_BOARD_TASK_SIZE 0x900 #define APP_BOARD_TASK_PRIO 5 #define BUTTON_TASK_SIZE 0x800 #define BUTTON_TASK_PRIO 3 diff --git a/code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp index 9f28c153e..2e0bd59e5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp @@ -35,11 +35,14 @@ namespace OHOS {DEFAULT_DIAL_ID_1, "KUMI"}, {DEFAULT_DIAL_ID_2, "classic"}, // 经典表盘 {101, "motiondial"}, // 运动表盘 - {102, "kaleidoscope"}, // 万花筒表盘 + {102, "kaleidoscope"}, // 万花筒表盘102 {MAX_DEFAULT_DIAL_ID, "jellyfish"}, // 水母表盘 }; - SetDialModel::SetDialModel() {} + SetDialModel::SetDialModel() + { + LoadAllDial(); + } SetDialModel::~SetDialModel() {} @@ -86,23 +89,26 @@ namespace OHOS int SetDialModel::GetAllDialIDs(char *allidStr) { std::string allIDs; + int length = 0; for (const auto &entry : registeredDials) { - // 格式化表盘ID为两个字节长度的字符串,不足两位则在前面补0 - std::stringstream ss; - ss << std::setw(2) << std::setfill('0') << entry.first; - allIDs += ss.str(); + memcpy_s(allidStr+length,512,&entry.first,2); + length+=2; + // // 格式化表盘ID为两个字节长度的字符串,不足两位则在前面补0 + // std::stringstream ss; + // ss << std::setw(2) << std::setfill('0') << entry.first; + // allIDs += ss.str(); } WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "allidStr is %s", allIDs.c_str()); - // 将字符串拷贝到allidStr中 - int length = allIDs.size(); - if (length > 0) - { - strcpy(allidStr, allIDs.c_str()); - allidStr[length] = '\0'; // 添加字符串结尾的空字符 - } + // // 将字符串拷贝到allidStr中 + // int length = allIDs.size(); + // if (length > 0) + // { + // strcpy(allidStr, allIDs.c_str()); + // allidStr[length] = '\0'; // 添加字符串结尾的空字符 + // } return length; } @@ -326,6 +332,7 @@ namespace OHOS /*获取表盘的总数*/ size_t SetDialModel::GetDialCount(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " %d ", dialInfoList.size()); return dialInfoList.size(); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherModel.h b/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherModel.h index c9f5a2dd3..e2f5c0fd0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherModel.h @@ -56,7 +56,7 @@ namespace OHOS void UI_set_weather_address_data(int lat, char *atm, char *city, char *subLocality, int lon); - void UI_set_weather_seven_day_data(struct ONE_DAY_DATA *t); + void UI_set_weather_seven_day_data(struct ONE_DAY_DATA t,int count); #if __cplusplus } #endif /* __cplusplus */ 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 39cfd0b14..72848d63d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp @@ -17,6 +17,7 @@ namespace OHOS static Weather_data Weather_data_t_now; static Weather_data_address Weather_data_t_address; static ONE_DAY_DATA Weather_data_seven_data[7]; + uint8_t Weather_data_seven_count=0; /* * @brief 设置当前天气数据 @@ -64,18 +65,26 @@ namespace OHOS /* * @brief 设置七天天气数据 */ - void UI_set_weather_seven_day_data(struct ONE_DAY_DATA *t) + void UI_set_weather_seven_day_data(struct ONE_DAY_DATA t,int count) { - for (int i = 0; i < 7; i++) + if(count=0) { - Weather_data_seven_data[i].fxDate = t[i].fxDate; - Weather_data_seven_data[i].iconDay = t[i].iconDay; - Weather_data_seven_data[i].tempMax = t[i].tempMax; - Weather_data_seven_data[i].tempMin = t[i].tempMin; - Weather_data_seven_data[i].fxDate = t[i].fxDate; - memset((void *)Weather_data_seven_data[i].textDay, 0, 16); - strcpy(Weather_data_seven_data[i].textDay, t[i].textDay); + Weather_data_seven_count=0; } + if(count>=7) + { + return; + } + Weather_data_seven_data[count].fxDate = t.fxDate; + Weather_data_seven_data[count].iconDay = t.iconDay; + Weather_data_seven_data[count].tempMax = t.tempMax; + Weather_data_seven_data[count].tempMin = t.tempMin; + Weather_data_seven_data[count].fxDate = t.fxDate; + memset((void *)Weather_data_seven_data[count].textDay, 0, 16); + strcpy(Weather_data_seven_data[count].textDay, t.textDay); + + Weather_data_seven_count++; + } #if __cplusplus diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_dial/src/SetDialModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/set_dial/src/SetDialModel.cpp index 93f3e8355..ec2691d13 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/set_dial/src/SetDialModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/set_dial/src/SetDialModel.cpp @@ -13,8 +13,12 @@ #include "DialBinParser.h" #include "wearable_log.h" -namespace OHOS { - SetDialModel::SetDialModel() {} +namespace OHOS +{ + SetDialModel::SetDialModel() + { + LoadAllDial(); + } SetDialModel::~SetDialModel() {} @@ -30,23 +34,25 @@ namespace OHOS { size_t dialSize = dialInfoList.size(); LoadAllDialFromFs(); /* 只排序离线表盘 */ - std::sort(dialInfoList.begin() + dialSize, dialInfoList.end(), [](const SetDialInfo& f, const SetDialInfo& n) { - return f.dialName < n.dialName; - }); + std::sort(dialInfoList.begin() + dialSize, dialInfoList.end(), [](const SetDialInfo &f, const SetDialInfo &n) + { return f.dialName < n.dialName; }); } void SetDialModel::LoadAllDialFromRam() { - for (uint8_t i = DIAL_CLOCK; i < DIAL_MAX; i++) { + for (uint8_t i = DIAL_CLOCK; i < DIAL_MAX; i++) + { const DialInfo *info = MainModel::GetInstance().GetDialInfo((DialId)i); - if (info != nullptr) { + if (info != nullptr) + { SetDialInfo dialInfo{0}; dialInfo.dialFlag = 0; dialInfo.id = i; dialInfo.dialName = info->dialName; dialInfo.imageFullName = info->dialImg; - ImageInfo* imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(info->dialImg, false); - if (info == nullptr) { + ImageInfo *imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(info->dialImg, false); + if (info == nullptr) + { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "LoadAllDialFromRam loadimage %s fail", info->dialImg); continue; @@ -65,11 +71,14 @@ namespace OHOS { // 打开目录 DIR *dirp = opendir(APP_DIAL_PATH); // 遍历文件 - if (dirp != nullptr) { - while ((direntp = readdir(dirp)) != nullptr) { + if (dirp != nullptr) + { + while ((direntp = readdir(dirp)) != nullptr) + { SetDialInfo dialInfo{0}; int ret = ParseDialHeader(direntp->d_name, dialInfo); - if (ret == 0) { + if (ret == 0) + { dialInfoList.push_back(dialInfo); } } @@ -85,14 +94,16 @@ namespace OHOS { dialFullName += "/"; dialFullName += dialFileName; FILE *fp = fopen(dialFullName.c_str(), "rb"); - if (fp == nullptr) { + if (fp == nullptr) + { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ParseDialHeader cannot open file: %s", dialFullName.c_str()); return -1; } DialPreviewInfo preInfo{0}; bool ret = DialBinParser::GetInstance()->GetDialPreviewInfo(fp, &preInfo); - if (!ret) { + if (!ret) + { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetDialPreviewInfo %s fail", dialFullName.c_str()); return -1; @@ -109,7 +120,8 @@ namespace OHOS { preInfo.offset); ImageInfo *info = ImageCacheManager::GetInstance().LoadOneInMultiRes( preInfo.imgId, dialFullName, fp, false, preInfo.offset); - if (info == nullptr) { + if (info == nullptr) + { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ParseDialHeader loadimage fail"); return -1; } @@ -127,7 +139,8 @@ namespace OHOS { void SetDialModel::SaveDialSetting(uint8_t pageIndex) { - if (pageIndex >= dialInfoList.size()) { + if (pageIndex >= dialInfoList.size()) + { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialModel SaveDialSetting [%u %u]", pageIndex, dialInfoList.size()); return; @@ -145,7 +158,7 @@ namespace OHOS { return dialInfoList.size(); } - std::vector& SetDialModel::GetDialInfo(void) + std::vector &SetDialModel::GetDialInfo(void) { return dialInfoList; } @@ -154,13 +167,19 @@ namespace OHOS { { uint8_t index = 0; DialSetting dialSetting = MainModel::GetInstance().GetDialSetting(); - for (auto iter : dialInfoList) { - if (dialSetting.dialFlag) { - if (strcmp(iter.dialFullName.c_str(), dialSetting.dialFullName.c_str()) == 0) { + for (auto iter : dialInfoList) + { + if (dialSetting.dialFlag) + { + if (strcmp(iter.dialFullName.c_str(), dialSetting.dialFullName.c_str()) == 0) + { return index; } - } else { - if ((!iter.dialFlag) && (iter.id == dialSetting.dialId)) { + } + else + { + if ((!iter.dialFlag) && (iter.id == dialSetting.dialId)) + { return index; } } diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/CMakeLists.txt b/code/sdk/application/wearable/service/ble_service/blemoder/CMakeLists.txt index 93db44219..b4c86931d 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/CMakeLists.txt +++ b/code/sdk/application/wearable/service/ble_service/blemoder/CMakeLists.txt @@ -23,6 +23,15 @@ ${ROOT_DIR}/application/wearable/fd230app/nativeui/traing/include #${ROOT_DIR}/application/wearable/fd230app/nativeui/alarm/include ${ROOT_DIR}/application/wearable/fd230app/nativeui/alarmclockmanage/include ${ROOT_DIR}/application/wearable/fd230app/nativeui/alarmclocktimerconfig/include +#code/sdk/middleware/services/gui/uikit/proprietary/src/utils/innerkits/hals/gralloc_engines.h +#/home/hcj/FD230/code/sdk/open_source/openharmony/drivers/peripheral/display/interfaces/include/display_gralloc.h +${ROOT_DIR}/open_source/openharmony/drivers/peripheral/display/interfaces/include +${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src +${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src/utils/innerkits +${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include +${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include/common +${ROOT_DIR}/application/wearable/fd230app/nativeui/set_dial/include +#/home/hcj/FD230/code/sdk/middleware/services/gui/uikit/proprietary/include/common/image_cache_manager.h ) 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 5858b7e0e..a4be6ce10 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -28,6 +28,7 @@ #include "AlmmgrAlarmClockManage.h" #include "AlarmClockManage.h" +#include "SetDialModel.h" //#include "AlarmClockModel.h" #ifdef __cplusplus @@ -61,6 +62,46 @@ extern "C" { #include "bletest.h" #include +void ble_set_dial_by_id(uint16_t id) +{ + return OHOS::SetDialModel::GetInstance().UpdateDialSetting(id); +} + +uint8_t ble_get_dial_id(void) +{ + return OHOS::SetDialModel::GetInstance().GetCurrentDialID(); +} + +bool ble_is_dial_install_by_id(uint16_t id) +{ + return OHOS::SetDialModel::GetInstance().IsDialInstalled(id); +} + +int ble_get_dial_num(void) +{ + return OHOS::SetDialModel::GetInstance().GetDialCount(); +} + +bool ble_delete_dial(uint16_t id) +{ + if(id==OHOS::SetDialModel::GetInstance().GetCurrentDialID()) + return false; + else + return OHOS::SetDialModel::GetInstance().UninstallDial(id); +} + +int get_all_dial_id( char * buf) +{ + return OHOS::SetDialModel::GetInstance().GetAllDialIDs(buf); +} + +void install_Register_dial( char * name,uint16_t id) +{ + return OHOS::SetDialModel::GetInstance().RegisterDial(id,name); +} + + + #define CWM_HISTORY_DATA_PATH "/user/userdata/step_" @@ -99,7 +140,7 @@ char * ble_sywee_history(uint8_t day,uint16_t *len ,uint8_t type) FILE * fp = fopen(path_,"rb+"); if(fp==NULL) { - printf("fopen fail\r\n"); + printf(" fopen type %d %s fail\r\n",type,path_); return NULL; } uint32_t size; @@ -448,7 +489,7 @@ void set_languaage(uint32_t id) #ifdef FD230 OHOS::language::GetInstance()->ChangeLanguage(id); #endif - + } char *addressbook(void)//获取通讯录保存文件地址路径 @@ -814,18 +855,19 @@ void set_weather_address_data(int lat, char* atm, char* city,char* subLocality,i // int tempMax; // }; #ifdef FD230 -static OHOS::ONE_DAY_DATA data_t[7]; + void set_weather_one_data(int tempMin, int iconDay,int fxDate, int tempMax, char *textDay,int x) { - data_t[x].tempMin=tempMin; - data_t[x].iconDay=iconDay; - data_t[x].fxDate=fxDate; - data_t[x].tempMax=tempMax; - memset((void*)data_t[x].textDay,0,16); - strcpy(data_t[x].textDay,textDay); + OHOS::ONE_DAY_DATA data_t; - if(x==6) - return UI_set_weather_seven_day_data(data_t); + data_t.tempMin=tempMin; + data_t.iconDay=iconDay; + data_t.fxDate=fxDate; + data_t.tempMax=tempMax; + memset((void*)data_t.textDay,0,16); + strcpy(data_t.textDay,textDay); + + return UI_set_weather_seven_day_data(data_t ,x); } #else void set_weather_one_data(int tempMin, int iconDay,int fxDate, int tempMax, char *textDay,int x) 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 947ee0cd9..4d71ad9eb 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h @@ -204,6 +204,23 @@ char * ble_sywee_history(uint8_t day,uint16_t *len,uint8_t type); void Set_DmpChangeMode(int state); int Get_DmpChangeMode(void); + +//////////////////////表盘相关//////////////////////////// +void ble_set_dial_by_id(uint16_t id); + +uint8_t ble_get_dial_id(void); + +bool ble_is_dial_install_by_id(uint16_t id); + +int ble_get_dial_num( void); + +bool ble_delete_dial(uint16_t id); + +int get_all_dial_id( char * buf); + +void install_Register_dial( char * name,uint16_t 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 c12a97415..5f43e3577 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -279,7 +279,7 @@ static uint8_t get_crc_from_lrc(uint8_t lrcValue) return crcbuf; } -//#define USE_DEMO +#define USE_DEMO static bool Check_CRC(uint8_t *data,uint16_t len,uint8_t crcvalue)//计算20byte的的校验位 { uint8_t crcbuf = 0; @@ -1790,7 +1790,7 @@ void SetsleepSetParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalD } } -void SetDrinkSetParamCmd(uint16_t cmd,uint8_t *data,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; @@ -1890,7 +1890,6 @@ uint8_t jsonCheck_weather(uint8_t *buf,uint8_t *check)//json 格式解析 天气 json = buf; // printf("jsonCheck_weather:len: json:%f jsonlen:%d\r\n",0.011,strlen((char *)json)); #if 0 - FILE *fp=fopen("user/weather.json","wb+"); printf("jsonCheck_weather len %d",strlen((char *)buf)+1); //fwrite((void*)buf,1,strlen((char *)buf)+1,fp); @@ -1932,7 +1931,8 @@ uint8_t jsonCheck_weather(uint8_t *buf,uint8_t *check)//json 格式解析 天气 set_weather_address_data(lat,atm,city,subLocality,lon); cJSON *daily = cJSON_GetObjectItem(root, "daily"); - for(int i=0;i<7;i++) + int count= cJSON_GetArraySize(daily); + for(int i=0;ivalueint; char * textDay=cJSON_GetObjectItem(data,"textDay")->valuestring; int tempMax=cJSON_GetObjectItem(data,"tempMax")->valueint; + set_weather_one_data(tempMin,iconDay,fxDate,tempMax,textDay,i); + } + cJSON_Delete(root); *check = 1; return 1; @@ -1993,7 +1996,13 @@ void query_dial_installed(ble_read_data *buffer_handle,uint16_t cmd,uint8_t *dat { uint16_t dial_uid = *(uint16_t*)data; printf("query dial 0x%04X installed !!!!!!!!\r\n",dial_uid); + + if(!ble_is_dial_install_by_id(dial_uid)) reply[0]=2; //该表盘是否已安装 0:指令校验失败 1:已安装 2:未安装 + else + reply[0]=1; //该表盘是否已安装 0:指令校验失败 1:已安装 2:未安装 + + reply[1]=0; //表盘列表是否已满 0:未满 1:已满 ble_reply_cmdarr(cmd,reply,2); @@ -2219,7 +2228,7 @@ void type2AE4Data(ble_read_data *buffer_handle,uint8_t *buf_cmd,uint8_t *data,ui break; case SET_ALARM_DATA_CMD: SetAlarmDataCmd(typeID,data,datalen,totalData,crcvalue); - printf("alarm infor !!!!!!!!!!\r\n"); + break; case SET_OTHER_TARGET_CMD: GetOtherTarget(typeID,data,datalen,totalData,crcvalue); @@ -2282,6 +2291,9 @@ static void switchDialCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *total { uint16_t daila_type = 0; memcpy(&daila_type,&data[17],2); + printf("switchDialCmd %d !!!!!!!!!!\r\n",daila_type); + + ble_set_dial_by_id(daila_type); value[17] = 1;//校验成功 value[18] = Calculate_CRC(value,18); sendBleData(value,19); @@ -2985,7 +2997,7 @@ static void SendDialToAppCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *to memcpy(value+15,&tmp_data,2); if(Check_CRC(data,len,crcvalue))// { - uint16_t dialNum = 450;//0 暂停 1恢复 + uint16_t dialNum =ble_get_dial_id(); memcpy(&value[17],&dialNum,2); value[19] = Calculate_CRC(value,19); sendBleData(value,20); @@ -3086,7 +3098,12 @@ static void DeleteDialUidCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *to { uint16_t deleteDial = 0;//删除的表盘UID deleteDial=data[0]+data[1]*256; + + if(ble_delete_dial(deleteDial)) value[17] = 1;// 1删除成功 2 没有改资源 0指令校验失败 + else + value[17] = 2;// 1删除成功 2 没有改资源 0指令校验失败 + value[18] = Calculate_CRC(value,18); sendBleData(value,19); }else @@ -3496,28 +3513,30 @@ static void GetSleepParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *to //app获取所有表盘UID 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); - uint32_t tmp = 1; - uint16_t tmp_data = 1; - value[0] = 0x72; - value[1] = 0x01; - value[2] = 0x2a; - memcpy(value+3,&tmp,4); - memcpy(value+7,&tmp,4); - memcpy(value+11,&tmp,4); - memcpy(value+15,&tmp_data,2); - if(1) + + + if(Check_CRC(data,len,crcvalue)) { + int dial_num=ble_get_dial_num(); + + uint8_t data_size=1+dial_num*2; + char *dail_uid_buf=(char *)ym_malloc(data_size); + dail_uid_buf[0]=(uint8_t)dial_num; + if(dial_num *2 !=get_all_dial_id(dail_uid_buf+1)) + { + printf( "GetAllDialUidCmd dial_num % err\r\n",dial_num); + } + else + { + printf( "GetAllDialUidCmd yes\r\n"); + } + + send_big_data(0,dail_uid_buf,data_size,data_size,1,1,0x2a,1); + free(dail_uid_buf); - value[17] = 0; - value[18] = Calculate_CRC(value,18); - sendBleData(value,19); }else { - value[17] = 0; - value[18] = Calculate_CRC(value,18); - sendBleData(value,19); + ble_reply_cmd(cmd,0); } } //app获取目标步数设置 @@ -4225,7 +4244,6 @@ void type2AE3Data(ble_read_data *buffer_handle,uint8_t *cmd_buf ,uint8_t *data,u case ALARM_CMD://获取手表闹钟//同步闹钟 readDevDataBle(cmd,data,datalen,totaldata,crcvalue); break; - case SET_DMP_MODE_CMD://0X0131 SetDMPModeCmd(cmd,data,datalen,totaldata,crcvalue); break; @@ -5237,7 +5255,7 @@ errcode_t decode_dial_info(ble_read_data *buffer_handle) return ERRCODE_SUCC; } - +static uint16_t ble_dial_uid=0; errcode_t decode_single_dial_info(ble_read_data *buffer_handle) { @@ -5285,6 +5303,10 @@ errcode_t decode_single_dial_info(ble_read_data *buffer_handle) filename[dialinfo.file_name_len] ='\0'; //在runtime中备份一个安装文件名。 uapi_dev_runtime_set_dialname(filename); + //存表盘id + ble_dial_uid = dialinfo.dial_uid; + + buffer_handle->file_recv_stat.file_name = filename; buffer_handle->file_recv_stat.file_size = file_size; buffer_handle->file_recv_stat.file_type = 3;//表盘 @@ -5334,8 +5356,13 @@ static errcode_t install_dial(void) return ERRCODE_FAIL; } printf("lzma_filepath %s\n",lzma_filepath); + errcode_t ret = uapi_dial_pkg_decompress(lzma_filepath,dialbin_filepath); + printf("decode %s to %s , ret %X \n",lzma_filepath,dialbin_filepath, ret); + + install_Register_dial(lzmapkgname,ble_dial_uid); + if ( ret == ERRCODE_SUCC) return ERRCODE_SUCC; else @@ -5380,10 +5407,12 @@ void decode_file_checksum(ble_read_data *buffer_handle) //TODO: 设置成当前下载的表盘 if (install_dial() == ERRCODE_SUCC) { - + ble_set_dial_by_id(ble_dial_uid); + TRANSMIT_DATA= TRANS_DIAL_SUCC; CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + ble_reply_cmd(DIAL_INSTALL_REPY_CMD,1); } else @@ -5490,8 +5519,10 @@ void type2AE0Data(ble_read_data *buffer_handle) if (decode_single_dial_info( buffer_handle) == ERRCODE_SUCC) { ble_reply_cmd(SINGLE_DIAL_FILE_RECV_CMD,1); + }else{ ble_reply_cmd(SINGLE_DIAL_FILE_RECV_CMD,2); + } break; case EPO_DATA_RECV_CMD: diff --git a/mkota.sh b/mkota.sh old mode 100644 new mode 100755 -- 2.17.1