#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
{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() {}
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;
}
/*获取表盘的总数*/
size_t SetDialModel::GetDialCount(void)
{
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " %d ", dialInfoList.size());
return dialInfoList.size();
}
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 */
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 设置当前天气数据
/*
* @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
#include "DialBinParser.h"
#include "wearable_log.h"
-namespace OHOS {
- SetDialModel::SetDialModel() {}
+namespace OHOS
+{
+ SetDialModel::SetDialModel()
+ {
+ LoadAllDial();
+ }
SetDialModel::~SetDialModel() {}
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;
// 打开目录
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);
}
}
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;
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;
}
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;
return dialInfoList.size();
}
- std::vector<SetDialInfo>& SetDialModel::GetDialInfo(void)
+ std::vector<SetDialInfo> &SetDialModel::GetDialInfo(void)
{
return dialInfoList;
}
{
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;
}
}
#${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
)
#include "AlmmgrAlarmClockManage.h"
#include "AlarmClockManage.h"
+#include "SetDialModel.h"
//#include "AlarmClockModel.h"
#ifdef __cplusplus
#include "bletest.h"
#include <cywee_hal.h>
+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_"
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;
#ifdef FD230
OHOS::language::GetInstance()->ChangeLanguage(id);
#endif
-
+
}
char *addressbook(void)//获取通讯录保存文件地址路径
// 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)
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
}
return crcbuf;\r
}\r
\r
-//#define USE_DEMO\r
+#define USE_DEMO\r
static bool Check_CRC(uint8_t *data,uint16_t len,uint8_t crcvalue)//计算20byte的的校验位\r
{\r
uint8_t crcbuf = 0;\r
}\r
}\r
\r
-void SetDrinkSetParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//è\8e·å\8f\96喝水提醒s设置\r
+void SetDrinkSetParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//设置喝水提醒s设置\r
{\r
uint32_t tmp = 1;\r
uint16_t tmp_data = 1;\r
json = buf;\r
// printf("jsonCheck_weather:len: json:%f jsonlen:%d\r\n",0.011,strlen((char *)json));\r
#if 0\r
-\r
FILE *fp=fopen("user/weather.json","wb+");\r
printf("jsonCheck_weather len %d",strlen((char *)buf)+1);\r
//fwrite((void*)buf,1,strlen((char *)buf)+1,fp);\r
set_weather_address_data(lat,atm,city,subLocality,lon);\r
\r
cJSON *daily = cJSON_GetObjectItem(root, "daily");\r
- for(int i=0;i<7;i++)\r
+ int count= cJSON_GetArraySize(daily);\r
+ for(int i=0;i<count;i++)\r
{ \r
//{"tempMin":22,"iconDay":6,"fxDate":1712505600,"textDay":"阵雨","tempMax":29},\r
cJSON *data=cJSON_GetArrayItem(daily,i);\r
int fxDate=cJSON_GetObjectItem(data,"fxDate")->valueint;\r
char * textDay=cJSON_GetObjectItem(data,"textDay")->valuestring;\r
int tempMax=cJSON_GetObjectItem(data,"tempMax")->valueint;\r
+\r
set_weather_one_data(tempMin,iconDay,fxDate,tempMax,textDay,i);\r
+\r
}\r
+ \r
cJSON_Delete(root);\r
*check = 1;\r
return 1;\r
{\r
uint16_t dial_uid = *(uint16_t*)data;\r
printf("query dial 0x%04X installed !!!!!!!!\r\n",dial_uid);\r
+\r
+ if(!ble_is_dial_install_by_id(dial_uid))\r
reply[0]=2; //该表盘是否已安装 0:指令校验失败 1:已安装 2:未安装\r
+ else\r
+ reply[0]=1; //该表盘是否已安装 0:指令校验失败 1:已安装 2:未安装\r
+ \r
+\r
reply[1]=0; //表盘列表是否已满 0:未满 1:已满\r
ble_reply_cmdarr(cmd,reply,2);\r
\r
break;\r
case SET_ALARM_DATA_CMD:\r
SetAlarmDataCmd(typeID,data,datalen,totalData,crcvalue);\r
- printf("alarm infor !!!!!!!!!!\r\n");\r
+ \r
break;\r
case SET_OTHER_TARGET_CMD:\r
GetOtherTarget(typeID,data,datalen,totalData,crcvalue);\r
{\r
uint16_t daila_type = 0;\r
memcpy(&daila_type,&data[17],2);\r
+ printf("switchDialCmd %d !!!!!!!!!!\r\n",daila_type);\r
+\r
+ ble_set_dial_by_id(daila_type);\r
value[17] = 1;//校验成功\r
value[18] = Calculate_CRC(value,18);\r
sendBleData(value,19);\r
memcpy(value+15,&tmp_data,2);\r
if(Check_CRC(data,len,crcvalue))//\r
{\r
- uint16_t dialNum = 450;//0 暂停 1恢复\r
+ uint16_t dialNum =ble_get_dial_id();\r
memcpy(&value[17],&dialNum,2);\r
value[19] = Calculate_CRC(value,19);\r
sendBleData(value,20);\r
{\r
uint16_t deleteDial = 0;//删除的表盘UID \r
deleteDial=data[0]+data[1]*256;\r
+ \r
+ if(ble_delete_dial(deleteDial))\r
value[17] = 1;// 1删除成功 2 没有改资源 0指令校验失败\r
+ else\r
+ value[17] = 2;// 1删除成功 2 没有改资源 0指令校验失败\r
+\r
value[18] = Calculate_CRC(value,18);\r
sendBleData(value,19);\r
}else\r
//app获取所有表盘UID\r
static void GetAllDialUidCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue)\r
{\r
- uint8_t value[24];\r
- memset(value,0,24);\r
- uint32_t tmp = 1;\r
- uint16_t tmp_data = 1;\r
- value[0] = 0x72;\r
- value[1] = 0x01;\r
- value[2] = 0x2a;\r
- memcpy(value+3,&tmp,4);\r
- memcpy(value+7,&tmp,4);\r
- memcpy(value+11,&tmp,4);\r
- memcpy(value+15,&tmp_data,2);\r
- if(1)\r
+ \r
+\r
+ if(Check_CRC(data,len,crcvalue))\r
{\r
+ int dial_num=ble_get_dial_num();\r
+\r
+ uint8_t data_size=1+dial_num*2;\r
+ char *dail_uid_buf=(char *)ym_malloc(data_size);\r
+ dail_uid_buf[0]=(uint8_t)dial_num;\r
+ if(dial_num *2 !=get_all_dial_id(dail_uid_buf+1))\r
+ {\r
+ printf( "GetAllDialUidCmd dial_num % err\r\n",dial_num);\r
+ }\r
+ else\r
+ {\r
+ printf( "GetAllDialUidCmd yes\r\n");\r
+ }\r
+\r
+ send_big_data(0,dail_uid_buf,data_size,data_size,1,1,0x2a,1);\r
+ free(dail_uid_buf);\r
\r
- value[17] = 0;\r
- value[18] = Calculate_CRC(value,18);\r
- sendBleData(value,19);\r
}else\r
{\r
- value[17] = 0;\r
- value[18] = Calculate_CRC(value,18);\r
- sendBleData(value,19);\r
+ ble_reply_cmd(cmd,0);\r
}\r
}\r
//app获取目标步数设置\r
case ALARM_CMD://获取手表闹钟//同步闹钟\r
readDevDataBle(cmd,data,datalen,totaldata,crcvalue);\r
break;\r
-\r
case SET_DMP_MODE_CMD://0X0131\r
SetDMPModeCmd(cmd,data,datalen,totaldata,crcvalue);\r
break;\r
return ERRCODE_SUCC;\r
\r
}\r
-\r
+static uint16_t ble_dial_uid=0;\r
errcode_t decode_single_dial_info(ble_read_data *buffer_handle)\r
{\r
\r
filename[dialinfo.file_name_len] ='\0';\r
//在runtime中备份一个安装文件名。\r
uapi_dev_runtime_set_dialname(filename);\r
+ //存表盘id\r
+ ble_dial_uid = dialinfo.dial_uid;\r
+\r
+\r
buffer_handle->file_recv_stat.file_name = filename;\r
buffer_handle->file_recv_stat.file_size = file_size;\r
buffer_handle->file_recv_stat.file_type = 3;//表盘\r
return ERRCODE_FAIL;\r
}\r
printf("lzma_filepath %s\n",lzma_filepath);\r
+\r
errcode_t ret = uapi_dial_pkg_decompress(lzma_filepath,dialbin_filepath);\r
+\r
printf("decode %s to %s , ret %X \n",lzma_filepath,dialbin_filepath, ret);\r
+\r
+ install_Register_dial(lzmapkgname,ble_dial_uid);\r
+\r
if ( ret == ERRCODE_SUCC)\r
return ERRCODE_SUCC;\r
else\r
//TODO: 设置成当前下载的表盘\r
if (install_dial() == ERRCODE_SUCC)\r
{\r
- \r
+ ble_set_dial_by_id(ble_dial_uid);\r
+\r
TRANSMIT_DATA= TRANS_DIAL_SUCC;\r
CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1);\r
\r
+\r
ble_reply_cmd(DIAL_INSTALL_REPY_CMD,1);\r
}\r
else\r
if (decode_single_dial_info( buffer_handle) == ERRCODE_SUCC)\r
{\r
ble_reply_cmd(SINGLE_DIAL_FILE_RECV_CMD,1);\r
+\r
}else{\r
ble_reply_cmd(SINGLE_DIAL_FILE_RECV_CMD,2);\r
+\r
} \r
break;\r
case EPO_DATA_RECV_CMD:\r