From 54e3b098fda2839c2f5ed56974f63fdfd1e713e6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=83=A1=E4=BC=A0=E5=86=9B?= <1224667075@qq.com> Date: Tue, 17 Dec 2024 08:31:31 +0000 Subject: [PATCH] Merge #1523 into sdk602patch0911 from refs/changes/1523/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 修改电话处理逻辑优化电话卡在单独界面问题 * refs/changes/1523/head: (4 commits squashed) - 修改电话处理逻辑优化电话卡在单独界面问题 - 优化ble传输成功后可能没有收到后续指令导致的卡在传输中界面 - 优化ble传输成功后可能没有收到后续指令导致的卡在传输中界面( - 添加运行日志保存服务 Signed-off-by: aliyun8003852482 <1224667075@qq.com> Reviewed-by: Caisking <3449750381@qq.com> Reviewed-by: 罗正 <1732036298@qq.com> Reviewed-by: aliyun8003852482 <1224667075@qq.com> Reviewed-by: snickersun@163.com Reviewed-by: aliyun6865282430 <1624952103@qq.com> Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1523 --- .../brandy/brandy_standard/thread_pri_init.c | 5 +- .../nativeui/callerlog/src/CallerLogModel.cpp | 4 +- .../nativeabilityfwk/include/Ability.h | 20 +- .../wearable/nativeabilityfwk/src/Ability.cpp | 25 ++ .../service/ble_service/blemoder/bletest.h | 2 + .../service/ble_service/bleservice/bleEvent.c | 9 + .../msg_center/src/msg_center_customer.cpp | 16 +- .../debug_output_notification.cpp | 33 +++ .../src/notify/makephone_notification.cpp | 14 ++ .../peripheral/config/include/ConfigModel.h | 4 + .../peripheral/config/include/ConfigModelC.h | 5 + .../peripheral/config/src/ConfigModel.cpp | 10 + .../drivers/peripheral/utils/CMakeLists.txt | 2 + .../peripheral/utils/custom_save_runtime.c | 223 ++++++++++++++++++ .../peripheral/utils/custom_save_runtime.h | 46 ++++ .../peripheral/utils/custom_utils_at_cmd.c | 6 +- 16 files changed, 393 insertions(+), 31 deletions(-) create mode 100644 code/sdk/drivers/peripheral/utils/custom_save_runtime.c create mode 100644 code/sdk/drivers/peripheral/utils/custom_save_runtime.h diff --git a/code/sdk/application/brandy/brandy_standard/thread_pri_init.c b/code/sdk/application/brandy/brandy_standard/thread_pri_init.c index e915f6e3e..99d5caf34 100755 --- a/code/sdk/application/brandy/brandy_standard/thread_pri_init.c +++ b/code/sdk/application/brandy/brandy_standard/thread_pri_init.c @@ -106,6 +106,8 @@ #ifdef ENABLE_CUSTOM_I2C #include "custom_utils.h" +#include "custom_save_runtime.h" + #endif #ifdef SUPPORT_A5133_SERVICE @@ -429,7 +431,8 @@ static void thread_main(const void *unused) * */ ConfigModelInit(); - + + uapi_runtime_log_service_init(); #if DSP_EXIST == YES audio_init(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp index 09f090064..63ff5a2b3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp @@ -173,11 +173,11 @@ void StatusReset(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "xxxxxxxxxxxxx"); PhoneServiceScreenCtr(false); - if(NativeAbility::GetInstance().GetCurSliceId() == VIEW_INCOMING_CALL || NativeAbility::GetInstance().GetCurSliceId() == VIEW_BLUETOOTH_EARPHONE) + if(NativeAbility::GetInstance().GetCurSliceId() == VIEW_INCOMING_CALL) { NativeAbility::GetInstance().Back_CountSlice_make_phone(); } - else if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_REBOOTANDSHUTDOWN ) + else if (!uapi_dev_runtime_get_train_status())// || NativeAbility::GetInstance().GetCurSliceId() == VIEW_BLUETOOTH_EARPHONE ) { NativeAbility::GetInstance().ClearSliceIdStack(); } diff --git a/code/sdk/application/wearable/nativeabilityfwk/include/Ability.h b/code/sdk/application/wearable/nativeabilityfwk/include/Ability.h index 69136fd70..8953b097d 100755 --- a/code/sdk/application/wearable/nativeabilityfwk/include/Ability.h +++ b/code/sdk/application/wearable/nativeabilityfwk/include/Ability.h @@ -28,7 +28,7 @@ #include "soc_osal.h" #include "stack" #include "wearable_log.h" -// #include "AppViewIDs.h" +#include "AppViewIDs.h" namespace OHOS { const static uint16_t gSliceInvalid = 0; const static uint16_t gSliceDefaultPriority = 4; // 页面默认是最低优先级 @@ -150,22 +150,8 @@ public: } //仅用于打电话结束恢复时使用 bool Back_CountSlice_make_phone(const TransitionType transitionId = TransitionType::TRANSITION_INVALID, - const uint16_t priority = gSliceDefaultPriority) { - if(!backStack_.empty()) - { - // 如果此时 backStack_ 栈不为空,取出栈顶的切片 ID ,并调用 ChangeSlice 切换到该切片,返回 true 。 - uint16_t preSlice = backStack_.top(); - backStack_.pop(); - ChangeSlice(preSlice,transitionId,priority); - return true; - } - else - { - //如果 backStack_ 栈为空,切换到默认切片,返回 false 。 - ChangeSlice(defaultSliceId_, transitionId, priority); - return false; // 返回false表示无前一个slice,退回到默认slice - } - } + const uint16_t priority = gSliceDefaultPriority); + bool make_phone_push(uint16_t preSlice) { if(backStack_.empty()) diff --git a/code/sdk/application/wearable/nativeabilityfwk/src/Ability.cpp b/code/sdk/application/wearable/nativeabilityfwk/src/Ability.cpp index c2ae26e2e..2404c1386 100755 --- a/code/sdk/application/wearable/nativeabilityfwk/src/Ability.cpp +++ b/code/sdk/application/wearable/nativeabilityfwk/src/Ability.cpp @@ -316,4 +316,29 @@ namespace OHOS curSlicePriority_ = gSliceDefaultPriority; } } + + bool Ability::Back_CountSlice_make_phone(const TransitionType transitionId, + const uint16_t priority ) { + if(!backStack_.empty()) + { + // 如果此时 backStack_ 栈不为空,取出栈顶的切片 ID ,并调用 ChangeSlice 切换到该切片,返回 true 。 + uint16_t preSlice = backStack_.top(); + backStack_.pop(); + + #ifdef FD230 + if(preSlice!=VIEW_INCOMING_CALL) + ChangeSlice(preSlice,transitionId,priority); + else + ChangeSlice(defaultSliceId_, transitionId, priority); + #endif + return true; + } + else + { + //如果 backStack_ 栈为空,切换到默认切片,返回 false 。 + ChangeSlice(defaultSliceId_, transitionId, priority); + return false; // 返回false表示无前一个slice,退回到默认slice + } + } + } // namespace OHOS 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 8f1e7eb71..afb704f2a 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h @@ -51,6 +51,8 @@ extern "C" OTA_UPDATA_FAIL, + FILE_IS_DONE, + TRANS_FREE, } transmitting_type; 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 954d8376e..fca83a19d 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -7021,6 +7021,12 @@ errcode_t decode_ota_data(ble_read_data *buffer_handle,uint8_t *data,uint16_t da BR_TRANSFER_timer = NULL; } ble_read_timer_p=NULL; + + TRANSMIT_DATA=FILE_IS_DONE; + + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + + ble_reply_cmd(OTA_FILE_SUCC_CMD,1);//接收成功 } @@ -8312,6 +8318,9 @@ errcode_t handle_recv_file(ble_read_data *buffer_handle,uint8_t *data, uint16_t BR_TRANSFER_timer = NULL; } ble_read_timer_p=NULL; + TRANSMIT_DATA=FILE_IS_DONE; + + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); ble_reply_cmd(FILE_RECV_REPLY_STAT_CMD,1);//接收成功 } diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index 4ef298ac6..85b45dafd 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -1073,7 +1073,6 @@ void MsgCenterNotifyCatIncomingCallProc(const Topic topic, Request* req) { CallerLogModel::GetInstance()->tempSetoperateNumberCAT1(call_data,req->len); - NotificationManager::GetInstance()->SetWatchCallStatus(true); cat1_phone_state_change_cb(OPERATE_WAITING); free(call_data); @@ -1099,8 +1098,7 @@ void MsgCenterNotifyCatIncomingCallProc(const Topic topic, Request* req) } CallerLogModel::GetInstance()->SetoperateNumber(call_data,strlen(call_data)); - CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1); - NotificationManager::GetInstance()->SetWatchCallStatus(true); + // NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); cat1_phone_state_change_cb(OPERATE_INCOMING); @@ -1136,13 +1134,11 @@ void MsgCenterNotifyCat1CallConnectedProc(const Topic topic, Request* req) cat1_ag_send_call_event(TOPIC_EVENT_CAT1_CALLCONNTED,NULL); #endif - CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1); - SetMicMutecat1(false); cat1_phone_state_change_cb(OPERATE_WATCH_ACTIVE); - NotificationManager::GetInstance()->SetWatchCallStatus(true); + } @@ -1179,10 +1175,6 @@ void MsgCenterNotifyCat1dialProc(const Topic topic, Request* req) #endif CallerLogModel::GetInstance()->SetoperateNumber(call_data,req->len); - CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1); - NotificationManager::GetInstance()->SetWatchCallStatus(true); - - cat1_phone_state_change_cb(OPERATE_DIALING); #ifdef SUPPORT_CAT1_HFP_AG_SERV if(headset_Is_connect()) @@ -1818,6 +1810,10 @@ void MsgCenterNotifybleTransmit(const Topic topic, Request* req) if(transmittingISShow()) NotificationManager::GetInstance()->StopNotify(); } + else if (data[0]==FILE_IS_DONE) + { + set_transmittingShow_falg(data[0]); + } else { set_transmittingShow_falg(data[0]); 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 fe5e7a6de..0ec8a7dc5 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 @@ -60,6 +60,8 @@ #include "displaybrightness/include/DisplayBrightnessModel.h" #include "ppg_service.h" #include "diag_log.h" + +#include "ConfigModelC.h" namespace OHOS { /**************************************************************************************************** */ @@ -168,6 +170,9 @@ namespace OHOS //心率广播 debugOutputItemInfo[index++] = {index, "hrs_ble_swtich"}; + debugOutputItemInfo[index++] = {index, "save_runtime_log_swtich"}; + + usedLen = index; /* -------------------------------- Add data -------------------------------- */ for (uint8_t i = 0; i < usedLen; i++) @@ -816,6 +821,21 @@ namespace OHOS } return true; //进行UI刷新 } + else if (viewId == "runtime_log_is_save") + { + if (toggleButtonOffline) { + if (toggleButtonOffline->GetState() == false) { + set_save_runtime_log_switch(1); + } + else { + set_save_runtime_log_switch(0); + } + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"组件不存在"); + } + return true; //进行UI刷新 + } + else if (viewId == NEXTORPREPAGELABELBUTTON) { // std::string str; @@ -956,6 +976,19 @@ namespace OHOS } } break; + case 19: + // str = get_hrs_ble_status(); + str = "runtime_log_is_save"; + if(toggleButtonOffline) + { + if(toggleButtonOffline->IsVisible() == false) + { + toggleButtonOffline->SetState(get_save_runtime_log_switch()); + toggleButtonOffline->SetViewId("runtime_log_is_save"); + toggleButtonOffline->SetVisible(true); + } + } + break; default: str = "--"; break; diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp index 6d8d8b395..745be7313 100755 --- a/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp @@ -629,6 +629,10 @@ static int g_callOperate = OPERATE_NO_OPE; static void DialingHandle(void) { + + CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1); + NotificationManager::GetInstance()->SetWatchCallStatus(true); + CallerLogModel::GetInstance()->SetDialingStatus("正在拨号"); CallerLogModel::GetInstance()->SetMakePhoneStatus(true); @@ -649,6 +653,9 @@ static void IncomingHandle(void) { CallerLogModel::GetInstance()->SetMakePhoneStatus(false); + CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1); + NotificationManager::GetInstance()->SetWatchCallStatus(true); + InitCallingTimer(); @@ -657,6 +664,9 @@ static void IncomingHandle(void) static void WaitingOpreate() { { + // CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1); + NotificationManager::GetInstance()->SetWatchCallStatus(true); + cat1_call_hungup(); CustomEventPublish(TOPIC_EVENT_HFP_HINT,NULL,0); CallerLogModel::GetInstance()->set_RejectIncomingCall_falg(1); @@ -668,6 +678,10 @@ static void WaitingOpreate() static void WatchActiveHandle() { + + CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1); + NotificationManager::GetInstance()->SetWatchCallStatus(true); + InitCallingTimer(); CallerLogModel::GetInstance()->SetCallStatus(true); CallerLogModel::GetInstance()->SetWaitingStatus(false); diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModel.h b/code/sdk/drivers/peripheral/config/include/ConfigModel.h index f752a514b..88f2e7885 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModel.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModel.h @@ -153,6 +153,8 @@ namespace OHOS CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE_TIME, //运动目标距离 CONFIGMODEL_ITEM_URAT_AT_CONTROL_STATUS,//串口控制状态 + + CONFIGMODEL_ITEM_SAVE_RUNTIMR_LOG_STATUS,//运行日志保存 CONFIGMODEL_ITEM_MAX, @@ -417,6 +419,8 @@ namespace OHOS {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 默认 关闭 + {ConfigDataType::DATATYPE_INT, "runtime_log_status", "0" },//CONFIGMODEL_ITEM_SAVE_RUNTIMR_LOG_STATUS,//运行日志保存 + }; ConfigModel(); // 私有构造函数,确保无法在外部实例化 diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModelC.h b/code/sdk/drivers/peripheral/config/include/ConfigModelC.h index 6265f3dd6..8e6291b37 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModelC.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModelC.h @@ -140,6 +140,11 @@ bool mmi_play_vibrate_is_permitted(void); /*停止音乐播放*/ void mmi_stop_music_play(void); +void set_save_runtime_log_switch(int value); + +int get_save_runtime_log_switch(void); + + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp index 736b7bed3..401cbbc31 100644 --- a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp +++ b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp @@ -1616,6 +1616,16 @@ void mmi_stop_music_play(void) stopPlayingMusic(); } + +void set_save_runtime_log_switch(int value) +{ + OHOS::ConfigModel::GetInstance()->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SAVE_RUNTIMR_LOG_STATUS,value); +} + +int get_save_runtime_log_switch(void) +{ + return OHOS::ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SAVE_RUNTIMR_LOG_STATUS); +} #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/drivers/peripheral/utils/CMakeLists.txt b/code/sdk/drivers/peripheral/utils/CMakeLists.txt index f2f953ea1..347a6d7dc 100644 --- a/code/sdk/drivers/peripheral/utils/CMakeLists.txt +++ b/code/sdk/drivers/peripheral/utils/CMakeLists.txt @@ -13,6 +13,8 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/pdu.c ${CMAKE_CURRENT_SOURCE_DIR}/microtar.c ${CMAKE_CURRENT_SOURCE_DIR}/custom_resfile_check.c + ${CMAKE_CURRENT_SOURCE_DIR}/custom_save_runtime.c + ) set(PUBLIC_HEADER diff --git a/code/sdk/drivers/peripheral/utils/custom_save_runtime.c b/code/sdk/drivers/peripheral/utils/custom_save_runtime.c new file mode 100644 index 000000000..0cc3b21a1 --- /dev/null +++ b/code/sdk/drivers/peripheral/utils/custom_save_runtime.c @@ -0,0 +1,223 @@ +/** + * Copyright (c) @CompanyNameMagicTag 2022-2022. All rights reserved. \n + * + * Description: Test adc source \n + * Author: @CompanyNameTag \n + * History: \n + * 2022-08-16, Create file. \n + */ +#include "pinctrl.h" +#include "debug_print.h" +#include "soc_osal.h" +#include "tcxo.h" +#include "irmalloc.h" +#include "errcode.h" +#include "common_def.h" + +#include "chip_core_irq.h" +#include "chip_io.h" +#include "gpio.h" +#include "pm_veto.h" + +#include "rtc.h" +#include "timer.h" +#include "systick.h" + +#include "tcxo.h" + +#include "cmsis_os2.h" + +#include "los_printf.h" + +#include "custom_utils.h" + +#include "BluetoothModelC.h" + +#include "PhoneServiceC.h" + +#include "ui_serviceC.h" + +#include "bletest.h" + +#include "safemodemanager/include/SafeModeManagerModelC.h" +#include "set_dial/include/SetDialModelC.h" + +#include "alarmclocktimerconfig/include/AlarmClockTimerConfig.h" + +#include + +#define RUNTIME_LOG_SAVE_PATH EXC_TAR_PATH + + + +typedef struct +{ + uint16_t cmd; + uint32_t time; +} custom_cmd_t; + +static unsigned long g_custom_runtime_log_cmd_queue= 0xFFFFFFFF; +static uint8_t custom_running_log_state_stat=0; +static bool g_runtime_log_queue_created = 0; + +static char save_path[128]={0}; + + +errcode_t uapi_save_runtime_log(uint16_t cmd) +{ + int ret; + + custom_cmd_t mail = {0}; + mail.cmd = (uint16_t)cmd; + mail.time= (uint32_t)get_local_timestamp(); + + if(custom_running_log_state_stat==0 || g_runtime_log_queue_created==0) + { + return ERRCODE_FAIL; + } + ret = osal_msg_queue_write_copy(g_custom_runtime_log_cmd_queue, (void *)&mail, sizeof(custom_cmd_t), 0); + + if (ret != OSAL_SUCCESS) + { + PRINT("Error custom_cmd Check MSG 0x%02X send failed! err=0x%x! \r\n", cmd, ret); + return ERRCODE_FAIL; + } + + return ERRCODE_SUCC; +} + +#define RUNTIME_FILE_PATH "%s/%s_runtime_%d.bin" + +void create_runtime_log_path(char *path,uint16_t max_len,uint8_t count) +{ + char buildversion[64]={0}; + uapi_get_buildversion((uint8_t*)&buildversion[0],sizeof(buildversion)); + + sprintf_s(path,max_len,RUNTIME_FILE_PATH,RUNTIME_LOG_SAVE_PATH,buildversion,count); +} + + +uint8_t uapi_runtime_file_count(char *folderpath) +{ + DIR *dir; + struct dirent *entry; + uint8_t count = 0; + + dir = opendir(folderpath); + if (dir == NULL) + { + PRINT("open %s failed \n",folderpath); + return 0; + } + + while ((entry = readdir(dir))!= NULL) //遍历tar文件找到时间戳最老的文件名 + { + if (strstr(entry->d_name, "_runtime_")!= NULL) + { + count++; + + } + } + + closedir(dir); + return count; +} + + +static void custom_save_runtime_log_service_task(void const *arg) +{ + + int32_t ret; + custom_cmd_t mail; + uint32_t msgsize = (uint32_t)sizeof(custom_cmd_t); + custom_running_log_state_stat = true; + int code=0; + + while (1) + { + ret = osal_msg_queue_read_copy(g_custom_runtime_log_cmd_queue, (void *)&mail, &msgsize, + OSAL_MSGQ_WAIT_FOREVER); + if (ret != OSAL_SUCCESS) + { + continue; + } + + FILE *fp=fopen(save_path,"ab+"); + if(fp) + { + int ret= fwrite(&mail.cmd,sizeof(mail.cmd),1,fp); + if(ret!=1) + { + printf("[custom_save_runtime_log_service_task],save_fail%d \n",__LINE__); + + uint8_t file_count= uapi_runtime_file_count(RUNTIME_LOG_SAVE_PATH); + create_runtime_log_path(save_path,128,file_count); + + } + ret= fwrite(&mail.time,sizeof(mail.time),1,fp); + if(ret!=1) + { + printf("[custom_save_runtime_log_service_task],save_fail%d \n",__LINE__); + + uint8_t file_count= uapi_runtime_file_count(RUNTIME_LOG_SAVE_PATH); + create_runtime_log_path(save_path,128,file_count); + + } + } + else + { + printf("[custom_save_runtime_log_service_task],save_fail%d \n",__LINE__); + uint8_t file_count= uapi_runtime_file_count(RUNTIME_LOG_SAVE_PATH); + create_runtime_log_path(save_path,128,file_count); + + } + fclose(fp); + + } +} +#define CUSTOM_RUNTIME_LOG_COUNT 1000 + +#define CUSTOM_RUNTIME_LOG_TASK_SIZE 0x1000 +#define CUSTOM_CMD_BOARD_TASK_PRIO 7 + +void create_runtime_log_queue(void) +{ + if (osal_msg_queue_create("custom_runtime_log_queue", CUSTOM_RUNTIME_LOG_COUNT, &g_custom_runtime_log_cmd_queue, + 0, sizeof(custom_cmd_t)) != ERRCODE_SUCC) + { + printf("[custom_cmd][service] app create mail fail\n"); + g_runtime_log_queue_created = 0; + }else{ + g_runtime_log_queue_created = 1; + } +} +errcode_t uapi_runtime_log_service_init(void) +{ + + PRINT("uapi_custom_cmd_service_init !\r\n"); + + if(get_save_runtime_log_switch()==0) + return ERRCODE_FAIL; + + + app_task_definition_t taskcfg = {0}; + taskcfg.create_queue_handle = create_runtime_log_queue; + taskcfg.attr.name = "custom_runtime_log_service"; + taskcfg.attr.priority = osPriorityNormal; + taskcfg.attr.stack_size = CUSTOM_RUNTIME_LOG_TASK_SIZE; + taskcfg.func = custom_save_runtime_log_service_task; + taskcfg.use_mem = USE_EXTEND_MEM; + + errcode_t ret = uapi_create_osThread_custom(&taskcfg); + uint8_t file_count= uapi_runtime_file_count(RUNTIME_LOG_SAVE_PATH); + create_runtime_log_path(save_path,128,file_count); + + + if (ret != ERRCODE_SUCC) + { + PRINT("create custom_cmd_service failed %d!\r\n", ret); + return ERRCODE_FAIL; + } + + return ERRCODE_SUCC; +} diff --git a/code/sdk/drivers/peripheral/utils/custom_save_runtime.h b/code/sdk/drivers/peripheral/utils/custom_save_runtime.h new file mode 100644 index 000000000..dba2b365d --- /dev/null +++ b/code/sdk/drivers/peripheral/utils/custom_save_runtime.h @@ -0,0 +1,46 @@ +/** + * Copyright (c) @CompanyNameMagicTag 2022-2022. All rights reserved. \n + * + * Description: Provides at cmd register func \n + * Author: @CompanyNameTag \n + * History: \n + * 2022-07-20, Create file. \n + */ +#ifndef CUSTOM_RUNTIME_LOG_H +#define CUSTOM_RUNTIME_LOG_H + +#include +#include +#include "errcode.h" +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + + +typedef enum { + //开机关机 + RUNTIME_LOG_POWER_MIN =0x0000, + //蓝牙 + RUNTIME_LOG_POWER_BLE_MIN=0x0100, + //cat1 + RUNTIME_LOG_POWER_CAT1_MIN=0x0200, + + +} runtime_log_cmd_Id; + + + + +errcode_t uapi_save_runtime_log(uint16_t cmd); + +errcode_t uapi_runtime_log_service_init(void); + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#endif diff --git a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c index 2dc6907b1..248d17c1f 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c @@ -1082,6 +1082,7 @@ static uint32_t PBAP_LS(uint8_t *para, uint32_t paraLen, char *strCommonCmd) #include "battery_service.h" #include "cywee_hal.h" #include "broadcast_feature.h" +#include "custom_save_runtime.h" static uint32_t BLE_TEST(uint8_t *para, uint32_t paraLen, char *strCommonCmd) { @@ -1163,7 +1164,10 @@ static uint32_t BLE_TEST(uint8_t *para, uint32_t paraLen, char *strCommonCmd) case 19: uapi_ble_connect_param_update(type_2); break; - + case 20: + uapi_save_runtime_log(0x0001); + break; + default: break; } -- 2.17.1