1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef BASE_STARTUP_INIT_PARAM_H 17 #define BASE_STARTUP_INIT_PARAM_H 18 #include <stdint.h> 19 #include <stdio.h> 20 21 #include "cJSON.h" 22 #include "param.h" 23 #ifdef __cplusplus 24 #if __cplusplus 25 extern "C" { 26 #endif 27 #endif 28 /** 29 * Init 接口 30 * 初始化参数服务 31 * 32 */ 33 void InitParamService(void); 34 35 /** 36 * Init 接口 37 * 启动参数服务,在main启动的最后调用,阻赛当前线程 38 * 39 */ 40 int StartParamService(void); 41 42 /** 43 * Init 接口 44 * 停止参数服务 45 * 46 */ 47 void StopParamService(void); 48 49 /** 50 * Init 接口 51 * 加载默认的参数值 52 * 53 */ 54 int LoadDefaultParams(const char *fileName, unsigned int mode); 55 56 /** 57 * Init 接口 58 * 加载默认参数。 59 * 60 */ 61 int LoadPersistParams(void); 62 63 /** 64 * Init 接口 65 * 设置参数,主要用于其他进程使用,通过管道修改参数 66 * 67 */ 68 int SystemWriteParam(const char *name, const char *value); 69 70 /** 71 * Init 接口 72 * 查询参数。 73 * 74 */ 75 int SystemReadParam(const char *name, char *value, unsigned int *len); 76 77 /** 78 * 对Init接口 79 * 触发一个trigger操作。 80 * 81 */ 82 void PostTrigger(EventType type, const char *content, uint32_t contentLen); 83 84 /** 85 * 对Init接口 86 * 解析trigger文件。 87 * 88 */ 89 int ParseTriggerConfig(const cJSON *fileRoot, int (*checkJobValid)(const char *jobName)); 90 91 /** 92 * 对Init接口 93 * 按名字执行对应的trigger。 94 * 95 */ 96 void DoTriggerExec(const char *triggerName); 97 void DoJobExecNow(const char *triggerName); 98 99 /** 100 * 对Init接口 101 * 按名字添加一个job,用于group支持。 102 * 103 */ 104 int AddCompleteJob(const char *name, const char *condition, const char *cmdContent); 105 106 /** 107 * 对Init接口 108 * dump 参数和trigger信息 109 * 110 */ 111 void DumpParametersAndTriggers(void); 112 113 void RegisterBootStateChange(void (*bootStateChange)(const char *)); 114 #ifdef __cplusplus 115 #if __cplusplus 116 } 117 #endif 118 #endif 119 #endif