Z-Stack Home Developer's Guide—4.Using the sample applications as base for new applications 中文翻译

本章节是官方提供的文档说明 如何将样例程序改为我们自己需要开发的程序,下面是中文翻译

4.使用样例程序为基础开发一个新的应用程序

HA样例程序旨在用作用户开的应用程序的基础,修改他们需要遵循如下步骤:

1.拷贝你选择的样例程序到新的文件夹并且根据你的需要进行重命名

拷贝
Projects\zstack\HomeAutomation\SampleLight*.*

Projects\zstack\HomeAutomation\YourApp*.*

这里写图片描述

2.源文件重命名以匹配你的应用程序

以下的文件名需要更改 Projects\zstack\HomeAutomation\YourApp\Source, 重命名的规则如下:

  • OSAL_SampleLight.c -> OSAL_YourApp.c
  • zcl_samplelight.c -> zcl_yourapp.c
  • zcl_samplelight.h -> zcl_yourapp.h
  • zcl_samplelight_data.c -> zcl_yourapp_data.c

3.在Projects\zstack\HomeAutomation\YourApp\CC2538文件夹中, 重命名以下文件(插一句CC2530也一样):

  • SampleLight.ewd -> YourApp.ewd
  • SampleLight.ewp -> YYourApp.ewp
  • SampleLight.eww -> YourApp.eww
    如果这个文件下面有其他子文件/文件夹,请将他们删掉。
    这里写图片描述

4.使用文本编辑器,将YourApp.ewp和YourApp.eww中的SimpleLight(其他同理)替换为YourApp.

5.使用IAR开发工具打开你的应用程序YourApp.eww,它将是以下样子。

使用CC2538应用程序将无法打开,会弹出警告,因为笔者iar安装的是基于8051架构的的应该使用CC2530,CC2538是基于ARM架构的用 基于8051架构的 IAR开发工具 无法打开。
这里写图片描述
这里写图片描述
下面是CC2530应用程序的结构:
这里写图片描述

6.更改3个c源文件中包含的zcl_SampleLight.h->zcl_YourApp.h

一般我们会将程序文件中的SampleLight全部替换为YourApp
我们进行编译,如果有遇到下面错误,Error[e46]: Undefined external “?V11” referred in AF ,原因是iar的高版本和z-stack不兼容。
这里写图片描述
解决方案:
1.右键项目文件的options
这里写图片描述
2.下载TI官方提供的[替换文件chipcon_cstartup.s51,将Z-Stack Home 1.2.0\Projects\zstack\ZMain\TI2530DB下的这个文件进行替换
再次进行编译:
这里写图片描述

7.现在您已经准备好更改应用程序代码来满足您的需求,比如 修改 按键有效,修改设备类型,修改之处的cluster,等等。查看更多的信息,请阅读整个文档的最后有列出来。

英语原文

4. Using the sample applications as base for new applications

The HA Sample Applications are intended to be used as foundations for the user’s applications. Modifying them
will usually consist of the following steps:

1. Copy the Sample Application of your choice to a new folder, and name it according to your new application:

Copy
Project\zstack\HomeAutomation\SampleLight*.*
To
Project\zstack\HomeAutomation\YourApp*.*

2. Rename the files to match your application’s name:

Under Projects\zstack\HomeAutomation\YourApp\Source, rename the files as follows:
o OSAL_SampleLight.c  OSAL_YourApp.c
o zcl_samplelight.c  zcl_yourapp.c
Etc.

3. In Projects\zstack\HomeAutomation\YourApp\CC2538, rename the following files:

o SampleLight.ewdYourApp.ewd
o SampleLight.ewpYourApp.ewp
o SampleLight.ewwYourApp.eww
Z-Stack Home Developer’s Guide SWRA441 Version 1.0
14 Copyright © 2013 Texas Instruments, Inc. All rights reserved.
Delete all the other files and subfolders from this folder, if there are any.

4. Using a text editor, replace all occurrences of “SampleLight” (case insensitive) to “YourApp”, in YourApp.ewp

and YourApp.eww.

5. You can now open YourApp.eww with IAR. Notice that the application files that are included in the project are

the files from your application:
Figure 1 - Application files within YourApp

6. You will have to edit the application files, to replace any occurrence of “zcl_samplelight.h” with

“zcl_yourapp.h”.

7. Now you are ready to manipulate the application code to suite your needs, e.g. modify key-press activities,

change the device type, modify the supported clusters, etc. For further information, please refer to the applicable
documents, listed at the end of this user guide.

猜你喜欢

转载自blog.csdn.net/qq_29542611/article/details/81263897