LiteOs-A 组件集成
- communication.json 文件路径:build/lite/components/communication.json
{
"component": "iot_management",
"description": "iot management service",
"optional": "true",
"dirs": [
"foundation/communication/iot_management"
],
"targets": [
"//foundation/communication/iot_management:iotc_management_lite"
],
"rom": "",
"ram": "",
"output": [ ],
"adapted_kernel": [ "liteos_a", "liteos_m", "linux" ],
"features": [],
"deps": {
"components": [
"hilog_lite",
"ipc"
],
"third_party": [
"bounds_checking_function",
"cJSON",
"mbedtls"
]
}
}
- 产品config.json
{
"subsystem": "communication",
"components": [
{
"component": "iot_management",
"features": [
"iot_management_kv_support=true",
"iot_management_kv_backend=\"posix\"",
"iot_management_kv_root_dir=\"/storage/data/iot_management\""
]
}
]
}
KV 后端配置
KV 由业务层和可替换 Backend 组成。一个构建中只会编译一个真实 Backend;关闭 KV 时只编译 stub,POSIX、UtilsFile/HAL 代码和依赖均不参与编译。
| 配置 | 含义 |
|---|---|
iot_management_kv_support |
是否启用真实 KV;设为 false 时数据库接口返回“不支持” |
iot_management_kv_backend |
posix:直接使用 POSIX 文件系统;utils_file:使用系统 UtilsFile*/file HAL |
iot_management_kv_root_dir |
POSIX 后端的数据根目录;UtilsFile 后端不使用 |
内核类型只提供默认值:liteos_m 默认使用 utils_file,liteos_a 和 linux 默认使用 posix。产品 config.json 中的显式配置优先。adapted_kernel 仅声明组件支持的内核范围,不会选择 KV 后端。
POSIX 后端会创建 0700 的根目录和表目录,数据文件使用 0600,覆盖写通过同目录临时文件和 rename() 完成。UtilsFile 后端使用 SHA-256 派生的扁平短文件名,以兼容不支持多级目录且文件名受限的 SPIFFS;初始化时会验证 open/write/stat/read/delete 契约。选择 utils_file 的产品必须提供可用的 UtilsFile* 和 file HAL 实现,否则 KV 初始化会明确失败。
两种 Backend 的物理存储格式不同。量产后切换 Backend 前必须制定数据迁移或清理策略,不应直接依赖另一 Backend 已有的数据文件。
LiteOs-A 服务集成
以下配置是LiteOs-A开机启动常驻服务集成方式
- policy_preset.h 文件路径:base/security/permission_lite/services/ipc_auth/include/policy_preset.h
FeaturePolicy iotcManagementFeature[] = {
{
NULL,
{
{
.type = RANGE,
.uidMin = 0,
.uidMax = __INT_MAX__,
},
}
},
};
static PolicySetting g_presetPolicies[] = {
......
{"iotc_management", iotcManagementFeature, 1}
};
- init.cfg ohos/vendor/hisilicon/xxx/init_configs/init.cfg
"jobs": [{
...
"name" : "init",
"cmds" : [
...
"start iotc_management"
]
}]
"services" : [{
{
"name" : "iotc_management",
"path" : ["/bin/iotc_management"],
"uid" : 0,
"gid" : 0,
"once" : 1,
"importance" : 0,
"caps" : []
}
}]
LiteOs-A DMEO
LiteOs-A DMEO示例可参考文档Demo README