From 236e3c8dfc2b9a5f5828b43e23a3673ef51dcb5e Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Thu, 28 Aug 2025 15:17:51 +0800 Subject: [PATCH] =?utf8?q?1.bin=5FCheck=5Fschedule=E5=87=BD=E6=95=B0?= =?utf8?q?=E4=BC=98=E5=8C=96=202.=E8=A7=A3=E5=86=B3=E6=97=A5=E7=A8=8B?= =?utf8?q?=E5=90=8C=E6=AD=A5=E8=BF=87=E6=9D=A5=E5=90=8E=EF=BC=8C=E7=95=8C?= =?utf8?q?=E9=9D=A2=E6=98=AF=E9=BB=91=E5=B1=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../schedule/include/SchedulePresenter.h | 3 - .../nativeui/schedule/include/ScheduleView.h | 1 - .../schedule/src/SchedulePresenter.cpp | 24 +-- .../nativeui/schedule/src/ScheduleView.cpp | 7 +- code/sdk/zhihui/config/include/ConfigModel.h | 3 - .../ble_service/bleservice/bleEvent.c | 193 +++++++++++------- 6 files changed, 119 insertions(+), 112 deletions(-) diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/schedule/include/SchedulePresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/schedule/include/SchedulePresenter.h index 12a83ef8a..66be206cb 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/schedule/include/SchedulePresenter.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/schedule/include/SchedulePresenter.h @@ -25,9 +25,6 @@ namespace OHOS static SchedulePresenter * GetInstance(); void OnStart() override; - void OnResume() override; - void OnPause() override; - void OnStop() override; private: bool OnClick(UIView &view, const ClickEvent &event) override; diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/schedule/include/ScheduleView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/schedule/include/ScheduleView.h index fe44f2b8e..daefb8815 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/schedule/include/ScheduleView.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/schedule/include/ScheduleView.h @@ -40,7 +40,6 @@ namespace OHOS static ScheduleView * GetInstance(void); void OnStart() override; - void OnStop() override; void ItemListAdd(const ScheduleListItemInfo &item); void ItemListClear(void); diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/schedule/src/SchedulePresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/schedule/src/SchedulePresenter.cpp index a93b13aa3..0334330df 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/schedule/src/SchedulePresenter.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/schedule/src/SchedulePresenter.cpp @@ -40,29 +40,7 @@ namespace OHOS // 启动时执行的逻辑 void SchedulePresenter::OnStart() { - } - - // 页面已经展示后的调用逻辑 - void SchedulePresenter::OnResume(void) - { - Presenter::OnResume(); - if (nullptr == view_) - { - return; - } - - view_->ItemListContentUpdate(); - } - - // 页面准备切换到后台前执行的逻辑 - void SchedulePresenter::OnPause(void) - { - Presenter::OnPause(); - } - - // 页面完全置于后台时的逻辑。 - void SchedulePresenter::OnStop(void) - { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SchedulePresenter::OnStart"); } bool SchedulePresenter::OnClick(UIView &view, const ClickEvent &event) diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/schedule/src/ScheduleView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/schedule/src/ScheduleView.cpp index 9ad5f3c69..e0e7c0747 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/schedule/src/ScheduleView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/schedule/src/ScheduleView.cpp @@ -30,6 +30,7 @@ namespace OHOS void ScheduleView::OnStart() { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScheduleView::OnStart"); ScreenGroupArray_[ENUM_SCHEDULE_SCREEN_NO_DATA] = InitNoDataScreen(); ScreenGroupArray_[ENUM_SCHEDULE_SCREEN_LIST] = InitDataScreen(); ScreenGroupArray_[ENUM_SCHEDULE_SCREEN_CONTENT] = InitContentScreen(); @@ -48,11 +49,6 @@ namespace OHOS RootView::GetInstance()->SetOnKeyActListener(presenter_); } - void ScheduleView::OnStop() - { - - } - void ScheduleView::DisplaySelectScreen(uint8_t ScreenIndex) { if(ENUM_SCHEDULE_SCREEN_MAX <= ScreenIndex) @@ -301,6 +297,7 @@ namespace OHOS ScheduleList_->SetDraggable(true); ScheduleList_->SetThrowDrag(true); // ScheduleList_->EnableAutoAlign(true); + ItemListContentUpdate(); ScheduleList_->SetAdapter(ScheduleListAdapter_); // ScheduleList_->SetScrollStateListener(presenter_); ScheduleList_->SetMaxScrollDistance(1000); // 1000: max scroll distance diff --git a/code/sdk/zhihui/config/include/ConfigModel.h b/code/sdk/zhihui/config/include/ConfigModel.h index 04a61f021..97f1749a2 100644 --- a/code/sdk/zhihui/config/include/ConfigModel.h +++ b/code/sdk/zhihui/config/include/ConfigModel.h @@ -7,9 +7,6 @@ #include "cJSON.h" #include "wearable_log.h" #include "vector" -#ifdef FD230_650 -#include "ui_resource_string.h" -#endif #define USE_KVSTORE_STORE_CONFIG diff --git a/code/sdk/zhihui/services/ble_service/bleservice/bleEvent.c b/code/sdk/zhihui/services/ble_service/bleservice/bleEvent.c index 103de4506..845156294 100644 --- a/code/sdk/zhihui/services/ble_service/bleservice/bleEvent.c +++ b/code/sdk/zhihui/services/ble_service/bleservice/bleEvent.c @@ -3308,115 +3308,152 @@ void SaveChatGPTCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,u bool bin_Check_schedule(uint8_t *data,uint16_t len) { - uint16 offset=0; - uint16 buf_len=0; - uint16 id_=1; - // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"len %d\r\n",len); - // for(int i=0;i=len) + // 解析ID + memcpy_s(&id, 2, &data[offset], 2); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Parsing ID: 0x%04X at offset: %d", id, offset); + offset += 2; + if (offset >= len) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Offset exceed len after parsing ID, break"); break; } - memcpy_s(&buf_len,2,&data[offset],2); - offset+=2; - if(offset>=len) - break; + // 解析标题长度 + memcpy_s(&buf_len, 2, &data[offset], 2); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Title length: %d at offset: %d", buf_len, offset); + offset += 2; + if (offset >= len) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Offset exceed len after parsing title length, break"); + break; + } - char *title=(char*)malloc(buf_len+1); - memset_s(title,512,0,buf_len+1); - memcpy_s(title,512,&data[offset],buf_len); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"len:%d str %s\r\n",buf_len,title); + // 解析标题内容 + char *title = (char*)malloc(buf_len + 1); + if (!title) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to allocate memory for title"); + break; + } + memset_s(title, buf_len + 1, 0, buf_len + 1); // 修正为实际分配的大小 + memcpy_s(title, buf_len + 1, &data[offset], buf_len); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Parsed title: [%s] (length: %d) at offset: %d", title, buf_len, offset); - offset+=buf_len; + offset += buf_len; - if(offset>=len) + if (offset >= len) { - if(title) - { - free(title); - } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Offset exceed len after parsing title, free title and break"); + free(title); break; } - uint32_t timetemp_begin=0; - memcpy_s(&timetemp_begin,4,&data[offset],4); - offset+=4; - if(offset>=len) - break; - uint32_t timetemp_end=0; - memcpy_s(&timetemp_end,4,&data[offset],4); - offset+=4; - if(offset>=len) - break; + // 解析开始时间 + uint32_t timetemp_begin = 0; + memcpy_s(&timetemp_begin, 4, &data[offset], 4); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Start time: %u at offset: %d", timetemp_begin, offset); + offset += 4; + if (offset >= len) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Offset exceed len after parsing start time, free title and break"); + free(title); + break; + } - memcpy_s(&buf_len,2,&data[offset],2); - offset+=2; - if(buf_len==0) + // 解析结束时间 + uint32_t timetemp_end = 0; + memcpy_s(&timetemp_end, 4, &data[offset], 4); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "End time: %u at offset: %d", timetemp_end, offset); + offset += 4; + if (offset >= len) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"%d %d\r\n",offset,len); - if(offset==len) - Ble_Set_ScheduleInfo(id_,timetemp_begin,timetemp_end,title,"",true); - else - Ble_Set_ScheduleInfo(id_,timetemp_begin,timetemp_end,title,"",false); - - id_++; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Offset exceed len after parsing end time, free title and break"); + free(title); + break; + } + + // 解析附加信息长度 + memcpy_s(&buf_len, 2, &data[offset], 2); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Additional info length: %d at offset: %d", buf_len, offset); + offset += 2; - if(title) + if (buf_len == 0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "No additional info, offset: %d, len: %d", offset, len); + // 调用设置函数 + if (offset == len) + { + Ble_Set_ScheduleInfo(id_, timetemp_begin, timetemp_end, title, "", true); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Set schedule info (complete), id_: %d", id_); + } + else { - free(title); + Ble_Set_ScheduleInfo(id_, timetemp_begin, timetemp_end, title, "", false); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Set schedule info (incomplete), id_: %d", id_); } + + id_++; + free(title); continue; } - if(offset>=len) + + if (offset >= len) { - if(title) - { - free(title); - } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Offset exceed len before parsing additional info, free title and break"); + free(title); break; } - - - char *str_=(char*)malloc(buf_len+1); - memset_s(str_,512,0,buf_len+1); - memcpy_s(str_,512,&data[offset],buf_len); - - offset+=buf_len; - if(offset==len) - Ble_Set_ScheduleInfo(id_,timetemp_begin,timetemp_end,title,str_,true); - else - Ble_Set_ScheduleInfo(id_,timetemp_begin,timetemp_end,title,str_,false); - - id_++; - - if(title) + // 解析附加信息 + char *str_ = (char*)malloc(buf_len + 1); + if (!str_) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to allocate memory for additional info"); free(title); + break; } - if(str_) + memset_s(str_, buf_len + 1, 0, buf_len + 1); // 修正为实际分配的大小 + memcpy_s(str_, buf_len + 1, &data[offset], buf_len); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Parsed additional info: [%s] (length: %d) at offset: %d", str_, buf_len, offset); + + offset += buf_len; + + // 调用设置函数 + if (offset == len) { - free(str_); + Ble_Set_ScheduleInfo(id_, timetemp_begin, timetemp_end, title, str_, true); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Set schedule info with additional info (complete), id_: %d", id_); } - if(offset>=len) + else { - break; + Ble_Set_ScheduleInfo(id_, timetemp_begin, timetemp_end, title, str_, false); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Set schedule info with additional info (incomplete), id_: %d", id_); } - } - + id_++; + // 释放内存 + free(title); + free(str_); + + if (offset >= len) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "All data parsed, exit loop"); + break; + } + } + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bin_Check_schedule end, total parsed id count: %d", id_ - 1); return true; } void APP_send_schedule_Cmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue) @@ -3437,8 +3474,10 @@ void APP_send_schedule_Cmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *tota if(Check_CRC(data,len,crcvalue)) { - - if(bin_Check_schedule(data,len)) + printf("11111111111111111\n"); + bool val = bin_Check_schedule(data,len); + printf("222222222222222222222\n"); + if(val) { sendBuf[17] = 1; } -- 2.17.1