From 496d9712baf4c7d49d53cc04aeb69537f79bbd37 Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Mon, 4 Nov 2024 19:59:09 +0800 Subject: [PATCH] =?utf8?q?=E7=B3=BB=E7=BB=9F=EF=BC=9A=E5=A2=9E=E5=8A=A0=20?= =?utf8?q?uartAT=E6=8C=87=E4=BB=A4=20=E6=8E=A5=E5=8F=97=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/system/include/SystemLogModel.h | 14 +++-- .../nativeui/system/include/SystemLogModelC.h | 2 +- .../nativeui/system/src/SystemLogModel.cpp | 22 +++++++ .../debug_output_notification.h | 1 + .../debug_output_notification.cpp | 62 ++++++++++++++++++- .../peripheral/config/include/ConfigModel.h | 3 + .../drivers/peripheral/utils/custom_utils.c | 6 +- 7 files changed, 102 insertions(+), 8 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemLogModel.h b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemLogModel.h index aa32dcbbb..11ce5b1ab 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemLogModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemLogModel.h @@ -107,8 +107,11 @@ public: bool load_popup_windows_log(); // 加载popup_windows日志 const std::deque &get_popup_windows_log() const; // 获取popup_windows日志记录(常量引用) size_t get_popup_windows_log_size() const; // 获取日志大小 - void clear_popup_windows_log(); // 清空popup_windows日志记录 - + void clear_popup_windows_log(); // 清空popup_windows日志记录 + /* ---------------------------------- 串口控制 ---------------------------------- */ + void init_uart(); + void set_uart_status(bool status); + bool get_uart_status(); private: SystemLogModel() = default; // 私有构造函数 @@ -119,8 +122,11 @@ private: SystemLogModel &operator=(const SystemLogModel &) = delete; std::deque logData; // 存储日志数据 - std::deque nextday_log; // 存储nextday时间戳 - std::deque popup_windows_log; // 存储popup_windows时间戳 + std::deque nextday_log; // 存储nextday时间戳 + std::deque + popup_windows_log; // 存储popup_windows时间戳 + + bool uart_status{false}; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemLogModelC.h b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemLogModelC.h index 2eb82ebd5..cbcbc4bb2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemLogModelC.h +++ b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemLogModelC.h @@ -16,7 +16,7 @@ void start_report_nextday_log_start(void); void start_report_nextday_log_end(void); void nextday_clear_popup_windows_log(void); void save_popup_windows_log_c(int type); - +void system_init_uart(void); #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLogModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLogModel.cpp index 68a3a2c22..31db5284a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLogModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLogModel.cpp @@ -26,6 +26,7 @@ #include #include #include +#include "ConfigModel.h" #define SYSTEM_LOG_PATH "/user/system/" #define SYSTEM_LOG_FILE_PATH "/user/system/system_log.txt" @@ -80,6 +81,11 @@ void save_popup_windows_log_c(int type) { OHOS::SystemLogModel::GetInstance()->save_popup_windows_log_type(type); } +//进行开机配置uart +void system_init_uart(void) +{ + OHOS::SystemLogModel::GetInstance()->init_uart(); +} } namespace OHOS { @@ -414,4 +420,20 @@ void SystemLogModel::clear_popup_windows_log() { outFile << ""; outFile.close(); } +/*串口控制*/ +void SystemLogModel::init_uart() { + //读取configmodle + uart_status = ConfigModel::GetInstance()->get_configData_bool( + ConfigModel::CONFIGMODEL_ITEM_URAT_AT_CONTROL_STATUS); + uapi_custom_set_uart_rx_enable_flag(uart_status); +} +//设置串口状态 +void SystemLogModel::set_uart_status(bool status) { + uart_status = status; + uapi_custom_set_uart_rx_enable_flag(uart_status); + ConfigModel::GetInstance()->set_condigData_Bool( + ConfigModel::CONFIGMODEL_ITEM_URAT_AT_CONTROL_STATUS,uart_status); +} +//获取串口状态 +bool SystemLogModel::get_uart_status() { return uart_status;} } // namespace OHOS diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/debug_output_notification/debug_output_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/debug_output_notification/debug_output_notification.h index 24b95eae0..3be8b491d 100644 --- a/code/sdk/application/wearable/service/msg_center/include/notify/debug_output_notification/debug_output_notification.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/debug_output_notification/debug_output_notification.h @@ -45,6 +45,7 @@ namespace OHOS std::string get_heart_rate(void); std::string get_popup_windows_log(void); std::string get_system_screen_time(void); + std::string get_uart_at_status(void); private: DebugOutputViewEventListener(); diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp index 3914017b2..0f7303707 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp @@ -14,6 +14,7 @@ #include "components/ui_label_button.h" #include "components/ui_label_ext.h" #include "components/ui_scroll_view.h" +#include "components/ui_toggle_button.h" #include "custom_runtime.h" #include "custom_utils.h" #include "graphic_service.h" @@ -115,6 +116,7 @@ namespace OHOS DebugOutputAdapter *debugOutputAdapter{nullptr}; UILabel *debugOutputLabel{nullptr}; UILabelButton *debugOutputLabelButton{nullptr}; + UIToggleButton* toggleButton = nullptr; UILabelButton *debugOutputbleServiceLabelButton{nullptr}; static constexpr const char *DEBUGOUTPUTLABELBUTTON = "debugOutputLabelButton"; static constexpr const char *DEBUGOUTPUTBLESERVICELABELBUTTON = "debugOutputbleServiceLabelButton"; @@ -145,6 +147,8 @@ namespace OHOS debugOutputItemInfo[index++] = {index, "popup_windows_log"}; //当前系统亮屏时长 debugOutputItemInfo[index++] = {index, "current_screen_time"}; + //串口状态服务 + debugOutputItemInfo[index++] = {index, "uart_service_status"}; usedLen = index; /* -------------------------------- Add data -------------------------------- */ for (uint8_t i = 0; i < usedLen; i++) @@ -554,6 +558,13 @@ namespace OHOS str<<"["<get_uart_status(); + return std::string("uart_at_status:") + std::to_string(status); + } bool DebugOutputViewEventListener::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event) { std::string viewId = view.GetViewId(); @@ -571,6 +582,25 @@ namespace OHOS { viewIndex = GetCurViewIndex(); } + //点击开启按键 + else if (viewId == "uart_at_set") { + if (toggleButton) { + if (toggleButton->GetState() == false) { + // toggleButton->SetState(false); + SystemLogModel::GetInstance()->set_uart_status(false); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"uart_at_set false"); + } + else { + // toggleButton->SetState(true); + SystemLogModel::GetInstance()->set_uart_status(true); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"uart_at_set true"); + } + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"组件不存在"); + } + // viewIndex = GetCurViewIndex(); + return true; //进行UI刷新 + } else // 如果点击的是列表中的itemview { DebugOutputItemView *debugOutputItemView = static_cast(&view); @@ -624,9 +654,17 @@ namespace OHOS case 11: str = get_popup_windows_log(); break; - case 12: + case 12: str = get_system_screen_time(); break; + case 13: + str = get_uart_at_status(); + if (toggleButton) { + if (toggleButton->IsVisible() == false) { + toggleButton->SetVisible(true); + } + } + break; default: str = "--"; break; @@ -826,6 +864,28 @@ namespace OHOS } debugOutputLabelButton->SetOnClickListener(clickListener); DebugScrollView[1]->Add(debugOutputLabelButton); + /* -------------------------------------------------------------------------- */ + if (toggleButton == nullptr) { + toggleButton = new UIToggleButton(); + } + toggleButton->SetPosition(147, debugOutputLabel->GetY() + debugOutputLabel->GetHeight() + 20+120); // widget's left position and top position + toggleButton->Resize(171, 121); // widget's width and height + toggleButton->SetViewId("uart_at_set");// Set style + toggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + //获取状态 + auto logModel = SystemLogModel::GetInstance(); + bool status = logModel->get_uart_status(); + toggleButton->SetState(status); + toggleButton->SetVisible(false); //设置不可见 + UIView::OnClickListener *clickListener_ = static_cast(&DebugOutputViewEventListener::GetInstance()); + if (clickListener_ == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener is new fail!!"); + return nullptr; + } + toggleButton->SetOnClickListener(clickListener_); + DebugScrollView[1]->Add(toggleButton); return DebugScrollView[1]; } diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModel.h b/code/sdk/drivers/peripheral/config/include/ConfigModel.h index f9183b946..f752a514b 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModel.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModel.h @@ -151,6 +151,8 @@ namespace OHOS CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES_TIME, //运动目标站立次数 CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION_TIME, //运动燃脂达成时间 CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE_TIME, //运动目标距离 + + CONFIGMODEL_ITEM_URAT_AT_CONTROL_STATUS,//串口控制状态 CONFIGMODEL_ITEM_MAX, @@ -414,6 +416,7 @@ namespace OHOS {ConfigDataType::DATATYPE_INT, "goal_standup_times_time", "1" },// CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES, //运动目标站立次数 10 {ConfigDataType::DATATYPE_INT, "goal_duration_time", "1" },// CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION, //运动目标时长 30(分钟) {ConfigDataType::DATATYPE_INT, "goal_distance_time", "1" },// CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE, //运动目标距离 8.0(km) + {ConfigDataType::DATATYPE_INT, "urat_at_status", "false" },//CONFIGMODEL_ITEM_URAT_AT_CONTROL_STATUS // 串口AT 默认 关闭 }; ConfigModel(); // 私有构造函数,确保无法在外部实例化 diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 2e6039e9c..833419c57 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -480,6 +480,8 @@ void startup_post_init_task(void) ota_updata_init(); + system_init_uart();//配置uartat + if ( cm_poweron_cat1_on_bootup_flag() ) { PRINT("PowerOn Cat1 !\r\n"); @@ -1336,7 +1338,7 @@ void uapi_set4GCapability(bool isopen) uapi_dev_runtime_set_cat1_powerstat(1); } /*4G 开电有时有干扰进日志串口,因此关闭日志串口*/ - uapi_custom_set_uart_rx_enable_flag(false); + // uapi_custom_set_uart_rx_enable_flag(false); #ifdef SUPPORT_TCPIP tcp_thread_id = tcp_get_thread_id(); @@ -1355,7 +1357,7 @@ void uapi_set4GCapability(bool isopen) uapi_dev_runtime_set_cat1_powerstat(0); } /*4G 开电有时有干扰进日志串口,因此关闭4G才开启日志串口*/ - uapi_custom_set_uart_rx_enable_flag(true); + // uapi_custom_set_uart_rx_enable_flag(true); #ifdef SUPPORT_TCPIP tcp_thread_id = tcp_get_thread_id(); -- 2.17.1