166 lines
5.1 KiB
C
166 lines
5.1 KiB
C
/*----------------------------------------------------------------------------
|
|
* Copyright (c) TJD Technologies Co., Ltd. 2020. All rights reserved.
|
|
*
|
|
* Description: service_startup.c
|
|
*
|
|
* Author: saimen
|
|
*
|
|
* Create: 2024-9-24
|
|
*--------------------------------------------------------------------------*/
|
|
//lib
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
//os
|
|
#include "securec.h"
|
|
#include "common_def.h"
|
|
#include "debug_print.h"
|
|
#include "soc_osal.h"
|
|
#include "cmsis_os2.h"
|
|
//sdk
|
|
//drv
|
|
//user
|
|
#include "sys_config.h"
|
|
#include "sys_typedef.h"
|
|
#include "task_service_timer.h"
|
|
#include "service_startup.h"
|
|
#include "service_gsensor.h"
|
|
#include "service_hrsensor.h"
|
|
#include "tp_api.h"
|
|
#include "sql_setting.h"
|
|
#include "pm.h"
|
|
#include "power_display_service.h"
|
|
#include "service_alarm.h"
|
|
#include "cwm_port.h"
|
|
#include "ble_port_protocol.h"
|
|
#include "TjdAppStore.h"
|
|
|
|
/**********************************************************************************************************************
|
|
* DEFINE
|
|
*/
|
|
#ifdef true
|
|
#undef true
|
|
#define true (1)
|
|
#endif
|
|
|
|
#ifdef false
|
|
#undef false
|
|
#define false (0)
|
|
#endif
|
|
|
|
#define ENABLE_STATIC_PRINT_INFO false
|
|
#define ENABLE_STATIC_PRINT_WARN true
|
|
#define ENABLE_STATIC_PRINT_ERROR true
|
|
#if ENABLE_STATIC_PRINT_INFO
|
|
#define static_print_debug(...) sys_service_log_d(__VA_ARGS__)
|
|
#else
|
|
#define static_print_debug(...)
|
|
#endif
|
|
#if ENABLE_STATIC_PRINT_WARN
|
|
#define static_print_warn(...) sys_service_log_w(__VA_ARGS__)
|
|
#else
|
|
#define static_print_warn(...)
|
|
#endif
|
|
#if ENABLE_STATIC_PRINT_ERROR
|
|
#define static_print_error(...) sys_service_log_e(__VA_ARGS__)
|
|
#else
|
|
#define static_print_error(...)
|
|
#endif
|
|
|
|
#define SRARTUP_STATUS_CHECK_INTERVAL (3000)
|
|
|
|
/**********************************************************************************************************************
|
|
* VARIABLES
|
|
*/
|
|
typedef struct
|
|
{
|
|
unsigned int watchdog_status;
|
|
unsigned int ui_status;
|
|
bool depend_watchdog_status;
|
|
bool depend_ui_status;
|
|
} service_startup_info_t;
|
|
service_startup_info_t g_service_startup_info = {0};
|
|
|
|
/**********************************************************************************************************************
|
|
* LOCAL FUNCTIONS
|
|
*/
|
|
|
|
/*OS 启动完成需要开启的开机服务*/
|
|
static void tjd_service_startup_depend_task_watchdog(void)
|
|
{
|
|
//用户添加需要开启的服务
|
|
static_print_debug("tjd_service_startup_depend_task_watchdog():");
|
|
}
|
|
|
|
/*UI任务 启动完成需要开启的开机服务*/
|
|
static void tjd_service_startup_depend_task_ui(void)
|
|
{
|
|
//用户添加需要开启的服务
|
|
static_print_debug("tjd_service_startup_depend_task_ui():");
|
|
tjd_service_gsensor_open();
|
|
tjd_service_hrs_get_ops()->init();
|
|
tjd_service_hrs_get_ops()->hr_allday_open();
|
|
tjd_service_hrs_get_ops()->spo2_allday_open();
|
|
tjd_service_hrs_get_ops()->hrv_allday_open();
|
|
// tjd_service_msensor_open();
|
|
tjd_service_alarm_open();
|
|
tjd_service_gps_sync_open();
|
|
tjd_driver_tp_set_wakeup_enable(sql_setting_get_cover_to_turn_off_screen());
|
|
tjd_service_lucky_clover_open();
|
|
cwm_algo_task_init();
|
|
tjd_service_timing_init();
|
|
RegisterPkgOperationCallback(tjd_js_install_status_request);
|
|
}
|
|
|
|
signed int jd_service_startup_status_check_handle(void *param)
|
|
{
|
|
int ret = 0;
|
|
service_startup_info_t* startup_info = (service_startup_info_t* )param;
|
|
if(startup_info->depend_watchdog_status == true) {
|
|
ret++;
|
|
} else if(startup_info->watchdog_status){
|
|
ret++;
|
|
startup_info->depend_watchdog_status = true;
|
|
tjd_service_startup_depend_task_watchdog();
|
|
}
|
|
|
|
if(startup_info->depend_ui_status == true) {
|
|
ret++;
|
|
} else if(startup_info->ui_status) {
|
|
ret++;
|
|
startup_info->depend_ui_status = true;
|
|
tjd_service_startup_depend_task_ui();
|
|
}
|
|
|
|
static_print_debug("jd_service_startup_status_check_handle:%d", ret);
|
|
if(ret >= 2){
|
|
return 0;
|
|
} else{
|
|
return SRARTUP_STATUS_CHECK_INTERVAL;
|
|
}
|
|
}
|
|
|
|
/**********************************************************************************************************************
|
|
* PUBLIC FUNCTIONS
|
|
*/
|
|
void tjd_service_startup_task_watchdog_update(unsigned int status)
|
|
{
|
|
g_service_startup_info.watchdog_status = status;
|
|
}
|
|
|
|
void tjd_service_startup_task_ui_update(unsigned int status)
|
|
{
|
|
g_service_startup_info.ui_status = status;
|
|
}
|
|
|
|
void tjd_service_startup_status_check_start(void)
|
|
{
|
|
queue_default_info_t msg_data = { jd_service_startup_status_check_handle, &g_service_startup_info, SRARTUP_STATUS_CHECK_INTERVAL, NULL};
|
|
osal_msg_queue_write_copy(tjd_task_service_timer_get_queue_id(), (void *)&msg_data, sizeof(queue_default_info_t), 0);
|
|
}
|
|
|
|
void tjd_service_startup_status_check_stop(void)
|
|
{
|
|
queue_default_info_t msg_data = { jd_service_startup_status_check_handle, &g_service_startup_info, 0, NULL};
|
|
osal_msg_queue_write_copy(tjd_task_service_timer_get_queue_id(), (void *)&msg_data, sizeof(queue_default_info_t), 0);
|
|
} |