#include "displaybrightness/include/DisplayBrightnessModel.h"
#include "ppg_service.h"
#include "diag_log.h"
+
+#include "ConfigModelC.h"
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++)
}
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;
}
}
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;
--- /dev/null
+/**
+ * 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 <dirent.h>
+
+#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;
+}