用zstack实现自己的sample--点灯

这篇博客详细介绍了如何基于ZStack协议栈创建一个LED控制的示例应用。首先,复制并重命名GenericApp为LED,接着删除不必要的文件,并新建Coordinator及Enddevice源文件。在不同板子上编译并运行这两个程序,当协调器和终端设备连接成功后,LED灯将同步闪烁。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1,复制samples下面的GenericApp,并粘贴到当前文件夹下,重命名为LED;

2,删除GenericApp.c和GenericApp.h

3,  新建 文件Coordinator.h,Coordinator.c  Enddevice.c并且将文件添加到工程 。

三个文件里面的代码如下:

Coordinator.h:

#ifndef COORDINATOR_H
#define COORDINATOR_H
#include "ZComDef.h"

#define GENERICAPP_ENDPOINT                10

#define GENERICAPP_PROFID                  0x0F04 
#define GENERICAPP_DEVICEID                0x0001
#define GENERICAPP_DEVICE_VERSION          0   
#define GENERICAPP_FLAGS                   0
#define GENERICAPP_MAX_CLUSTERS            1  
#define GENERICAPP_CLUSTERID               1

extern void GenericApp_Init(byte task_id);
extern UINT16 GenericApp_ProcessEvent(byte task_id, UINT16 events);
#endif

Coordinator.c:

#include "OSAL.h"
#include "AF.h"
#include "ZDApp.h"
#include "ZDObject.h"
#include "ZDProfile.h"

#include "Coordinator.h"
#include "DebugTrace.h"


#if !defined( WIN32 )
  #include "OnBoard.h"
#endif

/* HAL */
#include "hal_lcd.h"
#include "hal_led.h"
#include "hal_key.h"
#include "hal_uart.h"
#include <string.h>


// This list should be filled with Application specific Cluster IDs.
const cId_t GenericApp_ClusterList[GENERICAPP_MAX_CLUSTERS] =
{
  GENERICAPP_CLUSTERID
};

const SimpleDescriptionFormat_t GenericApp_SimpleDesc =
{
  GENERICAPP_ENDPOINT,              //  int Endpoint;
  GENERICAPP_PROFID,                //  uint16 AppProfId[2];
  G
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值