diff --git a/docs/changes.md b/docs/changes.md index 3b4de6bba..ad3f17a81 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -1,5 +1,9 @@ # 最新动态 +2023/12/03 + * 修复编译警告。 + * 完善remote ui service + 2023/12/01 * conf_json 支持块注释/**/和行注释// * 修复 iostream_serial.c 交叉编译问题(感谢明浩提供补丁) diff --git a/src/remote_ui/service/remote_ui_service.c b/src/remote_ui/service/remote_ui_service.c index 5aaabbc25..89e9aad37 100644 --- a/src/remote_ui/service/remote_ui_service.c +++ b/src/remote_ui/service/remote_ui_service.c @@ -617,7 +617,7 @@ static ret_t remote_ui_on_log(void* ctx, log_level_t level, const char* msg) { tk_service_send_resp(&(ui->service), MSG_CODE_NOTIFY, MSG_DATA_TYPE_BINARY, RET_OK, wb); } else { - log_set_hook(NULL, NULL); + remote_ui_service_hook_log(ui, FALSE); } return RET_OK; @@ -653,7 +653,7 @@ static ret_t remote_ui_service_dispatch_impl(remote_ui_service_t* ui, tk_msg_hea resp.resp_code = remote_ui_service_logout(ui); resp.data_type = MSG_DATA_TYPE_NONE; wbuffer_rewind(wb); - log_set_hook(NULL, NULL); + remote_ui_service_hook_log(ui, FALSE); break; } case REMOTE_UI_GET_DEV_INFO: { @@ -965,13 +965,13 @@ static ret_t remote_ui_service_dispatch_impl(remote_ui_service_t* ui, tk_msg_hea break; } case REMOTE_UI_HOOK_LOG: { - log_set_hook(remote_ui_on_log, ui); + remote_ui_service_hook_log(ui, TRUE); resp.resp_code = RET_OK; resp.data_type = MSG_DATA_TYPE_NONE; break; } case REMOTE_UI_UNHOOK_LOG: { - log_set_hook(NULL, NULL); + remote_ui_service_hook_log(ui, FALSE); resp.resp_code = RET_OK; resp.data_type = MSG_DATA_TYPE_NONE; break; @@ -1004,7 +1004,7 @@ static ret_t remote_ui_service_dispatch(remote_ui_service_t* ui) { static ret_t remote_ui_service_destroy(remote_ui_service_t* ui) { return_value_if_fail(ui != NULL, RET_BAD_PARAMS); - log_set_hook(NULL, NULL); + remote_ui_service_hook_log(ui, FALSE); memset(ui, 0x00, sizeof(*ui)); TKMEM_FREE(ui); @@ -1037,3 +1037,16 @@ tk_service_t* remote_ui_service_start_with_uart(tk_iostream_t* io, void* args) { return service; } + +ret_t remote_ui_service_hook_log(remote_ui_service_t* ui, bool_t hook) { + return_value_if_fail(ui != NULL, RET_BAD_PARAMS); + + if (hook) { + log_set_hook(remote_ui_on_log, ui); + } else { + log_set_hook(NULL, NULL); + } + + return RET_OK; +} + diff --git a/src/remote_ui/service/remote_ui_service.h b/src/remote_ui/service/remote_ui_service.h index 7beab3a5d..cd1786788 100644 --- a/src/remote_ui/service/remote_ui_service.h +++ b/src/remote_ui/service/remote_ui_service.h @@ -101,6 +101,15 @@ tk_service_t* remote_ui_service_create(tk_iostream_t* io, void* args); */ tk_service_t* remote_ui_service_start_with_uart(tk_iostream_t* io, void* args); +/** + * @method remote_ui_service_hook_log + * 是否hook log。 + * @param {remote_ui_service_t*} ui remote ui服务端。 + * @param {bool_t} hook 是否hook log。 + * @return {ret_t} 返回RET_OK表示成功,否则表示失败。 + */ +ret_t remote_ui_service_hook_log(remote_ui_service_t* ui, bool_t hook); + END_C_DECLS #endif /*TK_REMOTE_UI_SERVICE_H*/