打印

【转】zigbee之group与scene

[复制链接]
1073|14
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
傲视群熊|  楼主 | 2016-9-11 23:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
group     首先是建组;第一步:通过配置终端(带可视化界面,通过主控它知道当前网络中所有设备的地址)下发命令到主控,主控转发到Z接口模块,最后到coordinator,这条命令中包含了所有要建组的设备ID和地址,还有组ID等,到coordinator后,解析这条命令,这个时候下面的终端设备还没有这个组的信息,所以coordinator不会组播,会解析这条命令后,根据endpoint地址单独发送建组请求命令到需要家组的endpoint,在endpoint建组并保持组ID的信息到本地组表;
                        第二步:建组成功了后,主控再次发送具体操作组的命令到coordinator时才会组播到各个该组的endpoint。
    与之前理解有点出入,开始理解的是没有开始的单播过程了,直接从主控发建组的命令到协调器就开始组表建组,但开始的时候,各endpoint是没有组的信息的,需要单播建立组后,具体的操作该组命令(例如关闭一组灯泡)才是在协调器发送组播信息。

   另外:1)同一个组中既可以有server,也可以有client(例如:三个灯和两个开关建组,在灯的组应答回调函数中实现开关簇的incluster操作;在开关的组应答回调函数中实现outcluster。但是这样做不好,开关不应该加入该组,在该组中没有什么意义,灯的具体开关操作不是通过这些开关设备来控制,而是上层主控下发下来的)。
                2)一个组中可以包含多个簇,(例如:一个dimmer灯和几个普通灯组成一组,dimmer灯有两种簇:开关簇和dimmer簇,普通灯只有开关簇。假如在这个组上建一个看电视的情景——关闭所有普通灯和调光灯到30%,则在普通灯的recall回调函数中实现关操作,在dimmer灯的recall的回到函数中实现开关操作,并执行dimmer操作)

group是将一些节点分到一个群组中;
在节点分到一个群组之后,就可以在节点上建立scene;在建立scene的时候group ID是一个参数,所以必须先有group才能有scene。
ZCL中,scene有add,recall,remove等管理函数,比如你给一个节点发送一个命令让他add到一个scene中,你在scene的回调函数中就需要填一下存的是哪些个atrribute,然后在recall的回调函数中根据add时候的attribute来设置你被控节点的状态。
add的时候把被控设备放置到你想要的状态,然后add,然后store,可以了。
恢复情境的时候调用recall啊。
store和recall的时候会有一个回调函数,回调函数中实现你真正地设备控制状态恢复。

SceneENG:
In most cases scenes are associated with a particular group ID. Scenes may also
exist without a group, in which case the value 0x0000 replaces the group ID. Note
that extra care is required in these cases to avoid a scene ID collision, and that
commands related to scenes without a group may only be unicast, i.e.: they may
not be multicast or broadcast.
CHI:
在绝大多数情况下,情景和一个特定的GroupID关联在一起,情景也可能没有组而存在,在这种情况下,用GroupID 为0x0000来代替。值得特别注意的是:要避免情景ID冲突,并且没与组关联的情景相关的命令只支持单播,也就是说:它们不支持多播或组播。



资料搜索:
group是将一些节点分到一个群组中;
在节点分到一个群组之后,就可以在节点上建立scene;在建立scene的时候group ID是一个参数,所以必须先有group才能有scene。
ZCL中,scene有add,recall,remove等管理函数,比如你给一个节点发送一个命令让他add到一个scene中,你在scene的回调函数中就需要填一下存的是哪些个atrribute,然后在recall的回调函数中根据add时候的attribute来设置你被控节点的状态。
add的时候把被控设备放置到你想要的状态,然后add,然后store,可以了。
恢复情境的时候调用recall啊。
store和recall的时候会有一个回调函数,回调函数中实现你真正地设备控制状态恢复。

ZigBee Home Automation Public Application Profile.pdf
5.9.3 Commissioning Documentation
Enable Identify Mode
Sets the device in Identify mode for 60 seconds. This is used for adding devices to
a group or create a scene.
Group Nodes
Used to add devices to a group. This action sends the “Add group if Identifying”
command. This adds all devices that are in “identify mode” to the group. The
group ID is picked by the implementer.
Create Scene
This action creates a scene using devices present in a group.
For example, by a button press a “store scene” command is sent. The store scene
command should sent to a Group already existing in the network. The Group ID is
up to the implementer to pick.

5.9.5 Group Messaging vs. Unicast Messaging
It is important to consider that groups make use of broadcast transmissions. Group
messaging should only be used when a device needs to communicate with a group
of greater than 5. For groups of less than 5, standard binding and unicast messages
should be employed. Also, there is no acknowledgement service for group
messages, because they are broadcast. Unicast messaging shall be used if a device
requires APS acknowledgments.
The procedures for group commissioning described above can also be used to
create one-to-one bindings for unicast messaging with little or no modification.
When these procedures are utilized, the decision to create a group or not can be
made by the application based on a local device policy. If a device is being bound
to only 2 or 3 other devices, a unicast binding entry can be created for each target,
and three unicasts will be sent instead of a group broadcast. When the destination
is a large number of devices, a group binding entry should be created. This makes
group vs. unicast messaging transparent to the user.

Home_Automation_Profile_for_public_Download.pdf
Table 7.4

Group Nodes (Add Group If Identify)
If this feature is supported the device must provide a way for the user to send an
“Add Group if Identifying Request”.
Create Scene (Store Scene)
The device must provide a way for the user to send a Store Scene request.

Compile Options
The ZCL compile options are defined in the ZCL configuration file f8wZCL.cfg, which is located in theToolsfolder of the Z-Stack installation, along with other configuration files. Thef8wZCL.cfgfile is used by all projects that include the ZCL (i.e., all Home Automation projects). Therefore, any change made to this file will affect all HA projects. Compile options for other profiles, such as Smart Energy[5], can be found in their API documents. If needed, you can create a private version of thef8wZCL.cfgfile and modify your project to use the new version. The ZCL supported compile options and their definitions are listed in the following table:
ZCL_GROUPS
Enable the following commands:
1) Add Group
2) View Group
3) Get Group Membership
4) Remove Group
5) Remove All Groups
6) Add Group If Identifying
7) Add Group Response
8) View Group Response
9) Get Group Membership Response
10) Remove Group Response
ZCL_SCENES
Enable the following commands:
1) Add Scene
2) View Scene
3) Remove Group
4) Remove All Groups
5) Store Scene
6) Recall Scene
7) Get Scene Membership
8) Add Scene Response
9) View Scene Response
10) Remove Scene Response
11) Remove All Scenes Response
12) Store Scene Response
13) Get Scene Membership Response


相关帖子

沙发
傲视群熊|  楼主 | 2016-9-11 23:15 | 只看该作者

3.3.3 Group Table Management

The APS group table is a link list defined with allocated RAM [osal_mem_alloc()], so as groups are added to the table the amount of OSAL heap used increases. The maximum table size can be changed by adjusting APS_MAX_GROUPS in f8wConfig.cfg. The table is defined in nwk_globals.c. To use the group table functions include “aps_groups.h” in your application.


3.3.3.1 Group Table Structures

3.3.3.1.1 Group Item - aps_Group_t

This structure is the group item and contains the group ID and a text group name.

typedef struct

{

uint16 ID; // Unique to this table

uint8 name[APS_GROUP_NAME_LEN]; // Human readable name of group

} aps_Group_t;

ID – 16 bit group ID. This is the group ID that is set over the air.

name – text group name (Human readable). APS_GROUP_NAME_LEN is defined as 16 and is

not changeable.

3.3.3.1.2 Group Table Entry - apsGroupItem_t

This structure is a Group Table record (entry). The group table is a linked list and it is highly recommended that you use the Group Table search and maintenance functions(next sections) to transverse the group table.

typedef struct apsGroupItem

{

struct apsGroupItem *next;

uint8 endpoint;

aps_Group_t group;

} apsGroupItem_t;

next – points to the next group table entry. The group table is a linked list. A NULL indicates that this is the last entry in the list. It is highly recommended that you use the Group Table search and maintenance functions (next sections) to transverse the group table.

endpoint – the endpoint that will receive messages sent to the group in the group

field.

group – group ID and group name.


3.3.3.2 Group Table Maintenance

3.3.3.2.1 aps_AddGroup()

Call this function to add a group into the group table. Define an aps_Group_t item,

fill it in, then call this function. If NV_RESTORE is enabled, this function will save

the update in non-volatile memory.

Prototype

ZStatus_t aps_AddGroup( uint8 endpoint, aps_Group_t *group );

Parameter Details

endpoint – the endpoint that will receive messages sent to the group in the group

field.

group - group ID and group name to add into the group table.

Return

ZSuccess if add was successful. Errors are ZApsDuplicateEntry, ZApsTableFull, or ZMemError (all defined in ZComDef.h).

3.3.3.2.2 aps_ RemoveGroup()

Call this function to remove a group from the group table. If NV_RESTORE is enabled,

this function will save the update in non-volatile memory.

Prototype

uint8 aps_RemoveGroup( uint8 endpoint, uint16 groupID );

Parameter Details

endpoint – the endpoint to removed from a group.

groupID - group ID of the group to remove from the table.

Return

true if remove is successful, false if not the group/endpoint is not found.

3.3.3.2.3 aps_ RemoveAllGroup ()

Call this function to remove all groups for a given endpoint from the group table. If

NV_RESTORE is enabled, this function will save the update in non-volatile memory.

Prototype

void aps_RemoveAllGroup( uint8 endpoint );

Parameter Details

endpoint – the endpoint to removed from the group table.

Return

none.


3.3.3.3 Group Table Searching

3.3.3.3.1 aps_ FindGroup ()

Call this function to find a group in the group table for an endpoint and group ID.

Prototype

aps_Group_t *aps_FindGroup( uint8 endpoint, uint16 groupID );

Parameter Details

endpoint – the endpoint that will receive messages sent to the group in the group

field.

groupID - group ID.

Return

Pointer to group item found or NULL if not found.

3.3.3.3.2 aps_ FindGroupForEndpoint ()

Call this function to find an endpoint from a group ID. This function can be used to

skip past an endpoint, then return the next endpoint. Use this function to find all

the endpoints for a group ID.

Prototype

uint8 aps_FindGroupForEndpoint( uint16 groupID, uint8 lastEP );

Parameter Details

groupID - group ID searching for.

lastEP – endpoint to skip past first before returning an endpoint. Use

APS_GROUPS_FIND_FIRST to indicate that you want the first endpoint found.

Return

Returns the endpoint that matches the groupID and lastEP criteria, or

APS_GROUPS_EP_NOT_FOUND if no (more) endpoints found.

3.3.3.3.3 aps_ FindAllGroupsForEndpoint()

Call this function to get a list of all endpoints belong to a group. The caller must

provide the space to copy the groups into.

Prototype

uint8 aps_FindAllGroupsForEndpoint( uint8 endpoint, uint16 *groupList );

Parameter Details

endpoint – endpoint for search.

groupList – pointer to a place to build the list of groups that the endpoint belongs.

The caller must provide the memory. To be safe, the caller should create (local or

allocated) an array of APS_MAX_GROUPS 16-bit items.

Return

Returns the number of endpoints copied.

3.3.3.3.4 aps_ CountGroups()

Call this function to get a count of the number of groups that a given endpoint

belongs.

Prototype

uint8 aps_CountGroups( uint8 endpoint );

Parameter Details

endpoint – endpoint for search.

Return

Returns the number of groups.

3.3.3.3.5 aps_ CountAllGroups ()

Call this function to get the number of entries in the group table.

Prototype

uint8 aps_CountAllGroups( void );

Parameter Details

none.

Return

Returns the number of groups.


使用特权

评论回复
板凳
傲视群熊|  楼主 | 2016-9-11 23:20 | 只看该作者

3.3.3.4 Group Table Non-Volitile Storage

If NV_RESTORE is defined in either the compiler preprocessor section or in

f8wConfig.cfg, the group table will automatically save when when a group add or remove

is performed. Group table NV init and restore functions are automatically called on

device startup.

If a group table entry is modified by the user application, it must call

Aps_GroupsWriteNV() directly.

3.3.3.4.1 aps_GroupsWriteNV()

This function will write the group table to non-volatile memory, and is to be called

if the user application changes anything in a group table entry (other than add,

remove or remove all). If the group table is updated normally through group add,

remove or remove all functions, there is no need to call this function.

Prototype

void aps_GroupsWriteNV( void );

Parameter Details

none.

Return

none.


中文翻译:

APS组表是由分配的RAM【osal_mem_alloc()】定义得链表,因此当组表增加时,OSAL堆也将增加。表定义在nwk_globals.c,通过调整APS_MAX_GROUPS【f8wConfig.cfg】来改变组表的最大大小。用这些API需要包含aps_groups.h头文件。


:组是用来将一系列节点集合到一个单地址实体的方式。一个数据请求能够到达组中的每个节点。在Zigbee协议中组是可选配置,但是在某些剖面中是必选的,比如家庭自动化剖面。组关注的是一系列设备同时执行一个行为。


组表结构体

typedef struct
{
uint16 ID; // Unique to this table
uint8 name【APS_GROUP_NAME_LEN】; // Human readable name of group
} aps_Group_t;
ID -16位的组ID
name -文本组名(人类语言)APS_GROUP_NAME_LEN为16且不可更改                          

组表入口-apsGroupItem_t


组表记录(入口)
typedef struct apsGroupItem
{
struct apsGroupItem *next;
uint8 endpoint;
aps_Group_t group;
} apsGroupItem_t;
next -指向组表的下一个入口(组表为链表结构),推荐使用组表查找和维护函数来遍历组表。
endpoint -接受消息的终端
group -组ID和组名


组表维护函数
ZStatus_t aps_AddGroup( uint8 endpoint, aps_Group_t *group );
往组表中添加一个组。先定义aps_Group_t,然后填充这个结构,最后调用此函数来添加。若NV_RESTORE使能,则函数将更新保存到非易失性储存。
返回值:成功则返回ZSuccess,否则返回错误,错误可以是:ZApsDuplicateEntry,ZApsTableFull,ZMemError【ZComDef.h】

uint8 aps_RemoveGroup( uint8 endpoint, uint16 groupID );
移除一个组,若NV_RESTORE使能,则函数将更新保存到非易失性储存。

void aps_RemoveAllGroup( uint8 endpoint );
按给定的参数,移除终端的所有组。


组表查询函数
aps_Group_t *aps_FindGroup( uint8 endpoint, uint16 groupID );
endpoint -将接收消息的终端
返回值:指向组元件的指针

uint8 aps_FindGroupForEndpoint( uint16 groupID, uint8 lastEP );
从组ID中查找终端,这个函数用来跳过终端,然后返回下一个终端。
lastEP -返回的终端前要跳过的终端。用APS_GROUPS_FIND_FIRST来指定要查找的第一个终端。 返回终端,或者APS_GROUPS_EP_NOT_FOUND(没有找到或者找到多个)

uint8 aps_FindAllGroupsForEndpoint( uint8 endpoint, uint16 *groupList );
得到一个属于一个组的所有终端。 endpoint -要查找的终端
groupList -指向存放终端所有表的空间

uint8 aps_CountGroups( uint8 endpoint );
uint8 aps_CountAllGroups( void );


组表的非易失性储存
若定义了编译选项NV_RESTORE,则当组发生改变时会自动储存。组表的NV初始化和恢复在器件启动时自动执行。若用户应用改变了组表的入口,则必须直接调用Aps_GroupsWriteNV()
void aps_GroupsWriteNV( void )
若是通过正常的组添加、移除函数的调用来更改组表,则不必调用此函数。


使用特权

评论回复
地板
傲视群熊|  楼主 | 2016-9-11 23:22 | 只看该作者

// The maximum number of characters to allow in a scene's name

// remember that the first byte is the length

#define ZCL_GEN_SCENE_NAME_LEN                           16


// The maximum length of the scene extension field:

//   2 + 1 + 1 for On/Off cluster (onOff attibute)

//   2 + 1 + 1 for Level Control cluster (currentLevel attribute)

//   2 + 1 + 4 for Color Control cluster (currentX/currentY attributes)

//   2 + 1 + 1 for Door Lock cluster (Lock State attribute)

//   2 + 1 + 2 for Window Covering cluster (LiftPercentage/TiltPercentage attributes)

#define ZCL_GEN_SCENE_EXT_LEN                            24


// The maximum number of entries in the Scene table

#define ZCL_GEN_MAX_SCENES                               16


。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

所有组和情景需要用到的结构体的类型定义

// The format of a Scene Table Entry

typedef struct

{

  uint16 groupID;                   // The group ID for which this scene applies

  uint8 ID;                         // Scene ID

  uint16 transTime;                 // Time to take to transition to this scene

  uint8 name[ZCL_GEN_SCENE_NAME_LEN]; // Scene name

  uint8 extLen;                     // Length of extension fields

  uint8 extField[ZCL_GEN_SCENE_EXT_LEN]; // Extension fields

} zclGeneral_Scene_t;

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

typedef struct

{

  afAddrType_t *srcAddr; // requestor's address

  uint8        cmdID;    // which group message - COMMAND_GROUP_ADD_RSP,COMMAND_GROUP_VIEW_RSP, COMMAND_GROUP_REMOVE_RSP or COMMAND_GROUP_GET_MEMBERSHIP_RSP

  uint8        status;   // GROUP_STATUS_SUCCESS, GROUP_STATUS_TABLE_FULL,

                         // GROUP_STATUS_ALREADY_IN_TABLE, or GROUP_STATUS_NOT_IN_TABLE. Not

                         // valid for COMMAND_GROUP_GET_MEMBERSHIP_RSP

  uint8        grpCnt;   // number of groups contained in group list

  uint16       *grpList; // what group IDs the action was performed on

  uint8        capacity; // remaining capacity of group table

  uint8        *grpName; // only valid for COMMAND_GROUP_VIEW_RSP

} zclGroupRsp_t;


typedef struct

{

   afAddrType_t       *srcAddr; // requestor's address

   zclGeneral_Scene_t *scene;   // pointer to the scene structure

} zclSceneReq_t;


typedef struct

{

  afAddrType_t       *srcAddr;   // requestor's address

  uint8              cmdID;      // which response - COMMAND_SCENE_ADD_RSP, COMMAND_SCENE_VIEW_RSP,

                                  COMMAND_SCENE_REMOVE_RSP, COMMAND_SCENE_REMOVE_ALL_RSP,

                                  COMMAND_SCENE_STORE_RSP or COMMAND_SCENE_GET_MEMBERSHIPSHIP_RSP

  uint8              status;     // response status

  uint8              sceneCnt;   // number of scenes in the scene list (only valid for

                                 // COMMAND_SCENE_GET_MEMBERSHIPSHIP_RSP)

  uint8              *sceneList;   // list of scene IDs (only valid for COMMAND_SCENE_GET_MEMBERSHIPSHIP_RSP)

  uint8              capacity;   // remaining capacity of the scene table (only valid for

                                 // COMMAND_SCENE_GET_MEMBERSHIPSHIP_RSP)

  zclGeneral_Scene_t *scene;     // pointer to the scene structure

} zclSceneRsp_t;


使用特权

评论回复
5
傲视群熊|  楼主 | 2016-9-11 23:23 | 只看该作者

//几个需要用到的回调函数

// This callback is called to process an received Group Response message.

// This means that this app sent the request message.

//   srcAddr - requestor's address

//   cmdID - which group message - COMMAND_GROUP_ADD_RSP, COMMAND_GROUP_VIEW_RSP,

//           COMMAND_GROUP_REMOVE_RSP or COMMAND_GROUP_GET_MEMBERSHIP_RSP

//   status - GROUP_STATUS_SUCCESS, GROUP_STATUS_TABLE_FULL,

//            GROUP_STATUS_ALREADY_IN_TABLE, or GROUP_STATUS_NOT_IN_TABLE. Not

//            valid for COMMAND_GROUP_GET_MEMBERSHIP_RSP

//   grpCnt - number of groups contained in group list

//   grpList - what group IDs the action was performed on

//   capacity - remaining capacity of group table

//   grpName - only valid for COMMAND_GROUP_VIEW_RSP

typedef void (*zclGCB_GroupRsp_t)( zclGroupRsp_t *pRsp );


// This callback is called to process an incoming Scene Store request.

// The app will fill in the "extField" with what is needed to restore its

// current settings.

//   srcAddr - requestor's address

//   scene - pointer to the scene structure

//   returns TRUE if extField is filled in, FALSE if not used.

typedef uint8 (*zclGCB_SceneStoreReq_t)( zclSceneReq_t *pReq );


// This callback is called to process an incoming Scene Recall request

// The app will use what's in the "extField" to restore to these settings.

//   srcAddr - requestor's address

//   scene - pointer to the scene structure

typedef void (*zclGCB_SceneRecallReq_t)( zclSceneReq_t *pReq );


// This callback is called to process an incoming Scene responses. This means

// that this app sent the request for this response.

//   srcAddr - requestor's address

//   cmdID - which response - COMMAND_SCENE_ADD_RSP, COMMAND_SCENE_VIEW_RSP,

//            COMMAND_SCENE_REMOVE_RSP, COMMAND_SCENE_REMOVE_ALL_RSP,

//            COMMAND_SCENE_STORE_RSP or COMMAND_SCENE_GET_MEMBERSHIPSHIP_RSP

//   status - response status

//   sceneCnt - number of scenes in the scene list (only valid for

//              COMMAND_SCENE_GET_MEMBERSHIPSHIP_RSP)

//   sceneList - list of scene IDs (only valid for COMMAND_SCENE_GET_MEMBERSHIPSHIP_RSP)

//   capacity - remaining capacity of the scene table (only valid for

//              COMMAND_SCENE_GET_MEMBERSHIPSHIP_RSP)

//   scene - pointer to the scene structure

typedef void (*zclGCB_SceneRsp_t)( zclSceneRsp_t *pRsp );


使用特权

评论回复
6
傲视群熊|  楼主 | 2016-9-11 23:24 | 只看该作者

#ifdef ZCL_GROUPS

/*********************************************************************

* @fn      zclGeneral_SendAddGroupRequest

*

* @brief   Send the Add Group Request to a device

*

* @param   srcEP - Sending Apps endpoint

* @param   dstAddr - where to send the request

* @param   cmd - one of the following:

*                COMMAND_GROUP_ADD

*                COMMAND_GROUP_ADD_IF_IDENTIFYING

* @param   groupID - pointer to the group structure

* @param   groupName - pointer to Group Name.  This is a Zigbee

*          string data type, so the first byte is the length of the

*          name (in bytes), then the name.

*

* @return  ZStatus_t

ZStatus_t zclGeneral_SendAddGroupRequest( uint8 srcEP, afAddrType_t *dstAddr,

                                          uint8 cmd, uint16 groupID, uint8 *groupName,

                                         uint8 disableDefaultRsp, uint8 seqNum );

*/

#define zclGeneral_SendGroupAdd(a,b,c,d,e,f) zclGeneral_SendAddGroupRequest( (a), (b), COMMAND_GROUP_ADD, (c), (d), (e), (f) )


/*********************************************************************

* @fn      zclGeneral_SendGroupRequest

*

* @brief   Send a Group Request to a device.  You can also use the

*          appropriate macro.

*

* @param   srcEP - Sending Apps endpoint

* @param   dstAddr - where to send the request

* @param   cmd - one of the following:

*              COMMAND_GROUP_VIEW

*              COMMAND_GROUP_REMOVE

* @param   groupID -

*

* @return  ZStatus_t

     ZStatus_t zclGeneral_SendGroupRequest( uint8 srcEP, afAddrType_t *dstAddr,

                     uint8 cmd, uint16 groupID, uint8 disableDefaultRsp, uint8 seqNum );

*/

#define zclGeneral_SendGroupView(a,b,c,d,e) zclGeneral_SendGroupRequest( (a), (b), COMMAND_GROUP_VIEW, (c), (d), (e) )


/*********************************************************************

* @fn      zclGeneral_SendGroupGetMembershipRequest

*

* @brief   Send a Get Group Membership (Resposne) Command to a device

*

* @param   srcEP - Sending Apps endpoint

* @param   dstAddr - where to send the request

* @param   cmd - one of the following:

*                COMMAND_GROUP_GET_MEMBERSHIP

*                COMMAND_GROUP_GET_MEMBERSHIP_RSP

* @param   groupID - pointer to the group structure

* @param   groupName - pointer to Group Name.  This is a Zigbee

*          string data type, so the first byte is the length of the

*          name (in bytes), then the name.

* @return  ZStatus_t

*/

ZStatus_t zclGeneral_SendGroupGetMembershipRequest( uint8 srcEP, afAddrType_t *dstAddr,

                              uint8 cmd, uint8 rspCmd, uint8 direction, uint8 capacity,

                              uint8 grpCnt, uint16 *grpList, uint8 disableDefaultRsp, uint8 seqNum )

#define  zclGeneral_SendGroupGetMembership(a,b,c,d,e,f) zclGeneral_SendGroupGetMembershipRequest( (a), (b), COMMAND_GROUP_GET_MEMBERSHIP, FALSE, ZCL_FRAME_CLIENT_SERVER_DIR, 0, (c), (d), (e), (f) )


/*  Send a Group Remove Command

*  Use like:

*      ZStatus_t zclGeneral_SendGroupRemove( uint8 srcEP, afAddrType_t *dstAddr, uint16 groupID, uint8 disableDefaultRsp, uint8 seqNum );

#define zclGeneral_SendGroupRemove(a,b,c,d,e) zclGeneral_SendGroupRequest( (a), (b), COMMAND_GROUP_REMOVE, (c), (d), (e) )


/*********************************************************************

* @fn      zcl_SendCommand

*

* @brief   Used to send Profile and Cluster Specific Command messages.

*

*          NOTE: The calling application is responsible for incrementing

*                the Sequence Number.

*

* @param   srcEp - source endpoint

* @param   destAddr - destination address

* @param   clusterID - cluster ID

* @param   cmd - command ID

* @param   specific - whether the command is Cluster Specific

* @param   direction - client/server direction of the command

* @param   disableDefaultRsp - disable Default Response command

* @param   manuCode - manufacturer code for proprietary extensions to a profile

* @param   seqNumber - identification number for the transaction

* @param   cmdFormatLen - length of the command to be sent

* @param   cmdFormat - command to be sent

*

* @return  ZSuccess if OK

*/

ZStatus_t zcl_SendCommand( uint8 srcEP, afAddrType_t *destAddr,

                           uint16 clusterID, uint8 cmd, uint8 specific, uint8 direction,

                           uint8 disableDefaultRsp, uint16 manuCode, uint8 seqNum,

                           uint16 cmdFormatLen, uint8 *cmdFormat );

#define zclGeneral_SendGroupRemoveAll(a,b,c,d)  zcl_SendCommand( (a), (b), ZCL_CLUSTER_ID_GEN_GROUPS, COMMAND_GROUP_REMOVE_ALL, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR, (c), 0, (d), 0, NULL )


/*********************************************************************

* @fn      zclGeneral_SendAddGroupRequest

*

* @brief   Send the Add Group Request to a device

*

* @param   srcEP - Sending Apps endpoint

* @param   dstAddr - where to send the request

* @param   cmd - one of the following:

*                COMMAND_GROUP_ADD

*                COMMAND_GROUP_ADD_IF_IDENTIFYING

* @param   groupID - pointer to the group structure

* @param   groupName - pointer to Group Name.  This is a Zigbee

*          string data type, so the first byte is the length of the

*          name (in bytes), then the name.

*

* @return  ZStatus_t

*/

ZStatus_t zclGeneral_SendAddGroupRequest( uint8 srcEP, afAddrType_t *dstAddr,

                                         uint8 cmd, uint16 groupID, uint8 *groupName,

                                         uint8 disableDefaultRsp, uint8 seqNum )

#define zclGeneral_SendGroupAddIfIdentifying(a,b,c,d,e,f)  zclGeneral_SendAddGroupRequest( (a), (b), COMMAND_GROUP_ADD_IF_IDENTIFYING, (c), (d), (e), (f) )



使用特权

评论回复
7
傲视群熊|  楼主 | 2016-9-11 23:28 | 只看该作者

* @fn      zclGeneral_SendGroupResponse

*

* @brief   Send Group Response (not Group View Response)

*

* @param   srcEP - Sending application's endpoint

* @param   dstAddr - where you want the message to go

* @param   cmd - either COMMAND_GROUP_ADD_RSP or COMMAND_GROUP_REMOVE_RSP

* @param   status - group command status

* @param   groupID - what group

*

* @return  ZStatus_t

*/

ZStatus_t zclGeneral_SendGroupResponse( uint8 srcEP, afAddrType_t *dstAddr,

                                       uint8 cmd, uint8 status, uint16 groupID,

                                       uint8 disableDefaultRsp, uint8 seqNum ) */

#define zclGeneral_SendGroupAddResponse(a,b,c,d,e,f)  zclGeneral_SendGroupResponse( (a), (b), COMMAND_GROUP_ADD_RSP, (c), (d), (e), (f) )


/*********************************************************************

* @fn      zclGeneral_SendGroupGetMembershipRequest

*

* @brief   Send a Get Group Membership (Resposne) Command to a device

*

* @param   srcEP - Sending Apps endpoint

* @param   dstAddr - where to send the request

* @param   cmd - one of the following:

*                COMMAND_GROUP_GET_MEMBERSHIP

*                COMMAND_GROUP_GET_MEMBERSHIP_RSP

* @param   groupID - pointer to the group structure

* @param   groupName - pointer to Group Name.  This is a Zigbee

*          string data type, so the first byte is the length of the

*          name (in bytes), then the name.

*

* @return  ZStatus_t

*/

ZStatus_t zclGeneral_SendGroupGetMembershipRequest( uint8 srcEP, afAddrType_t *dstAddr,

                              uint8 cmd, uint8 rspCmd, uint8 direction, uint8 capacity,

                              uint8 grpCnt, uint16 *grpList, uint8 disableDefaultRsp, uint8 seqNum )  */

#define  zclGeneral_SendGroupGetMembershipResponse(a,b,c,d,e,f,g) zclGeneral_SendGroupGetMembershipRequest( (a), (b), COMMAND_GROUP_GET_MEMBERSHIP_RSP, TRUE, ZCL_FRAME_SERVER_CLIENT_DIR, (c), (d), (e), (f), (g) )


/*********************************************************************

* @fn      zclGeneral_SendGroupResponse

*

* @brief   Send Group Response (not Group View Response)

*

* @param   srcEP - Sending application's endpoint

* @param   dstAddr - where you want the message to go

* @param   cmd - either COMMAND_GROUP_ADD_RSP or COMMAND_GROUP_REMOVE_RSP

* @param   status - group command status

* @param   groupID - what group

*

* @return  ZStatus_t

*/

ZStatus_t zclGeneral_SendGroupResponse( uint8 srcEP, afAddrType_t *dstAddr,

                                       uint8 cmd, uint8 status, uint16 groupID,

                                       uint8 disableDefaultRsp, uint8 seqNum ) */

#define zclGeneral_SendGroupRemoveResponse(a,b,c,d,e,f) zclGeneral_SendGroupResponse( (a), (b), COMMAND_GROUP_REMOVE_RSP, (c), (d), (e), (f) )

#endif // ZCL_GROUPS


#ifdef ZCL_SCENES

/*********************************************************************

* @fn      zclGeneral_SendAddScene

*

* @brief   Send the Add Scene Request to a device

*

* @param   srcEP - Sending Apps endpoint

* @param   dstAddr - where to send the request

* @param   scene - pointer to the scene structure

*

* @return  ZStatus_t

*/

ZStatus_t zclGeneral_SendAddScene( uint8 srcEP, afAddrType_t *dstAddr,

                      zclGeneral_Scene_t *scene, uint8 disableDefaultRsp, uint8 seqNum )


/*********************************************************************

* @fn      zclGeneral_SendSceneRequest

* @brief   Send a Scene Request to a device.  You can also use the

*          appropriate macro.

* @param   srcEP - Sending Apps endpoint

* @param   dstAddr - where to send the request

* @param   cmd - one of the following:

*              COMMAND_SCENE_VIEW

*              COMMAND_SCENE_REMOVE

*              COMMAND_SCENE_REMOVE_ALL

*              COMMAND_SCENE_STORE

*              COMMAND_SCENE_RECALL

*              COMMAND_SCENE_GET_MEMBERSHIP

* @param   groupID - group ID

* @param   sceneID - scene ID (not applicable to COMMAND_SCENE_REMOVE_ALL and

*                    COMMAND_SCENE_GET_MEMBERSHIP)

* @return  ZStatus_t

*/

ZStatus_t zclGeneral_SendSceneRequest( uint8 srcEP, afAddrType_t *dstAddr,

                                       uint8 cmd, uint16 groupID, uint8 sceneID,

                                      uint8 disableDefaultRsp, uint8 seqNum )*/

#define zclGeneral_SendSceneView(a,b,c,d,e,f)  zclGeneral_SendSceneRequest( (a), (b), COMMAND_SCENE_VIEW, (c), (d), (e), (f) )


/*

*  Send a Scene Remove Command

*  Use like:

*      ZStatus_t zclGeneral_SendSceneRemove( uint8 srcEP, afAddrType_t *dstAddr, uint16 groupID, uint8 sceneID, uint8 disableDefaultRsp, uint8 seqNum );

*/

#define zclGeneral_SendSceneRemove(a,b,c,d,e,f)  zclGeneral_SendSceneRequest( (a), (b), COMMAND_SCENE_REMOVE, (c), (d), (e), (f) )


/*

*  Send a Scene Store Command

*  Use like:

*      ZStatus_t zclGeneral_SendSceneStore( uint8 srcEP, afAddrType_t *dstAddr, uint16 groupID, uint8 sceneID, uint8 disableDefaultRsp, uint8 seqNum );

*/

#define zclGeneral_SendSceneStore(a,b,c,d,e,f)  zclGeneral_SendSceneRequest( (a), (b), COMMAND_SCENE_STORE, (c), (d), (e), (f) )


/*

*  Send a Scene Recall Command

*  Use like:

*      ZStatus_t zclGeneral_SendSceneRecall( uint8 srcEP, afAddrType_t *dstAddr, uint16 groupID, uint8 sceneID, uint8 disableDefaultRsp, uint8 seqNum );

*/

#define zclGeneral_SendSceneRecall(a,b,c,d,e,f)  zclGeneral_SendSceneRequest( (a), (b), COMMAND_SCENE_RECALL, (c), (d), (e), (f) )


/*

*  Send a Scene Remove ALL Command - COMMAND_SCENE_REMOVE_ALL

*  Use like:

*      ZStatus_t zclGeneral_SendSceneRemoveAll( uint16 srcEP, afAddrType_t *dstAddr, uint16 groupID, uint8 disableDefaultRsp, uint8 seqNum );

*/

#define zclGeneral_SendSceneRemoveAll(a,b,c,d,e)  zclGeneral_SendSceneRequest( (a), (b), COMMAND_SCENE_REMOVE_ALL, (c), 0, (d), (e) )


/*

*  Send a Scene Get Membership Command - COMMAND_SCENE_GET_MEMBERSHIPSHIP

*  Use like:

*      ZStatus_t zclGeneral_SendSceneGetMembership( uint16 srcEP, afAddrType_t *dstAddr, uint16 groupID, uint8 disableDefaultRsp, uint8 seqNum );

*/

#define zclGeneral_SendSceneGetMembership(a,b,c,d,e)  zclGeneral_SendSceneRequest( (a), (b), COMMAND_SCENE_GET_MEMBERSHIP, (c), 0, (d), (e) )


使用特权

评论回复
8
傲视群熊|  楼主 | 2016-9-11 23:30 | 只看该作者
* @fn      zclGeneral_SendSceneResponse
* @brief   Send Group Response (not Group View Response)
* @param   srcEP - Sending application's endpoint
* @param   dstAddr - where you want the message to go
* @param   cmd - either COMMAND_SCENE_ADD_RSP, COMMAND_SCENE_REMOVE_RSP
*                COMMAND_SCENE_STORE_RSP, or COMMAND_SCENE_REMOVE_ALL_RSP
* @param   status - scene command status
* @param   groupID - what group
* @param   sceneID - what scene (not applicable to COMMAND_SCENE_REMOVE_ALL_RSP)
* @return  ZStatus_t
*/
ZStatus_t zclGeneral_SendSceneResponse( uint8 srcEP, afAddrType_t *dstAddr,
                                  uint8 cmd, uint8 status, uint16 groupID,
                                  uint8 sceneID, uint8 disableDefaultRsp, uint8 seqNum ) */
#define zclGeneral_SendSceneAddResponse(a,b,c,d,e,f,g)  zclGeneral_SendSceneResponse( (a), (b), COMMAND_SCENE_ADD_RSP, (c), (d), (e), (f), (g) )

/*
*  Send a Scene Remove Response Command - COMMAND_SCENE_REMOVE_RSP
*  Use like:
*      ZStatus_t zclGeneral_SendSceneRemoveResponse( uint16 srcEP, afAddrType_t *dstAddr, uint8 status, uint16 groupID, uint8 sceneID, uint8 disableDefaultRsp, uint8 seqNum );
*/
#define zclGeneral_SendSceneRemoveResponse(a,b,c,d,e,f,g) zclGeneral_SendSceneResponse( (a), (b), COMMAND_SCENE_REMOVE_RSP, (c), (d), (e), (f), (g) )

/*
*  Send a Scene Remove All Response Command - COMMAND_SCENE_REMOVE_ALL_RSP
*  Use like:
*      ZStatus_t zclGeneral_SendSceneRemoveAllResponse( uint16 srcEP, afAddrType_t *dstAddr, uint8 status, uint16 groupID, uint8 disableDefaultRsp, uint8 seqNum );
*/
#define zclGeneral_SendSceneRemoveAllResponse(a,b,c,d,e,f) zclGeneral_SendSceneResponse( (a), (b), COMMAND_SCENE_REMOVE_ALL_RSP, (c), (d), 0, (e), (f) )

/*
*  Send a Scene Remove ALL Response Command - COMMAND_SCENE_STORE_RSP
*  Use like:
*      ZStatus_t zclGeneral_SendSceneStoreResponse( uint16 srcEP, afAddrType_t *dstAddr, uint8 status, uint16 groupID, uint8 sceneID, uint8 disableDefaultRsp, uint8 seqNum );
*/
#define zclGeneral_SendSceneStoreResponse(a,b,c,d,e,f,g) zclGeneral_SendSceneResponse( (a), (b), COMMAND_SCENE_STORE_RSP, (c), (d), (e), (f), (g) )
#endif // ZCL_SCENE

. Group management: this provides the ability to declare a single address
shared by multiple devices, to add devices to the group, and to remove devices
from the group.

使用特权

评论回复
9
lwsn| | 2016-9-12 21:49 | 只看该作者
在建立scene的时候group ID是一个参数,所以必须先有group才能有scene

使用特权

评论回复
10
yu515301489| | 2016-9-13 16:34 | 只看该作者
又是说zigbee的  赞一个。

使用特权

评论回复
11
baimiaocun2015| | 2016-9-18 20:57 | 只看该作者
资料绝对是好资料的,只不过一次性分享这么多的,难以消化呀

使用特权

评论回复
12
baimiaocun2015| | 2016-9-18 20:57 | 只看该作者
这个关于zigbee开发中的资料,关于group的概念的还是第一次听说的

使用特权

评论回复
13
yujielun| | 2016-9-19 22:31 | 只看该作者
这个分享的是什么?

使用特权

评论回复
14
yujielun| | 2016-9-19 22:33 | 只看该作者
看不是很明白的,楼主讲解一下吧。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

51

主题

84

帖子

1

粉丝