Files
TencentOS-tiny/components/connectivity/iot-hub-device-c-sdk/docs/数据模板开发/数据模板代码生成.md

35 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!-- TOC -->
- [简介](#%E7%AE%80%E4%BB%8B)
- [数据模板创建](#%E6%95%B0%E6%8D%AE%E6%A8%A1%E6%9D%BF%E5%88%9B%E5%BB%BA)
- [数据模板描述文件导出](#%E6%95%B0%E6%8D%AE%E6%A8%A1%E6%9D%BF%E6%8F%8F%E8%BF%B0%E6%96%87%E4%BB%B6%E5%AF%BC%E5%87%BA)
- [数据模板模板代码生成](#%E6%95%B0%E6%8D%AE%E6%A8%A1%E6%9D%BF%E6%A8%A1%E6%9D%BF%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90)
<!-- /TOC -->
## 简介
本文介绍基于物联开发平台 IoT Explorer 创建的数据模板如何生成模板代码。
## 数据模板创建
参阅[产品定义](https://cloud.tencent.com/document/product/1081/34739?!preview&!editLang=zh#.E6.95.B0.E6.8D.AE.E6.A8.A1.E6.9D.BF)创建数据模板
## 数据模板描述文件导出
数据模板描述文件是一个 JSON 格式的文件描述了产品定义的属性、事件及其他信息在平台导出此json文件如下图示:
![data_template_json](https://main.qcloudimg.com/raw/0951d7c3f540ca716442e08651a0efa5.jpg)
## 数据模板模板代码生成
将下载的json文件拷贝到tools目录执行`./data_template_codegen.py -c xx/example_config.json -d ../targetdir/`命令,则会根据json文件在target目录生成所定义产品的数据模板及事件的配置文件,
将这个生成的文件拷贝到`app/data_template`的目录下,
data_template_app.c 示例了智能灯的数据模板处理框架,可以基于此框架修改业务逻辑。
```bash
./data_template_codegen.py -c example_config.json
加载 .\example_config.json 文件成功
文件 ./data_template_config_header.include 生成成功
文件 ./data_template_config_src_c.include 生成成功
```