关注zigbee(五)--单播,组播,广播
2014-06-30 17:26
302 查看
凡是组网,必然涉及到单播,组播,广播这几个概念。
这几个概念的含义一目了然。这节主要关注怎么在zigbee中实现单播,组播,广播。
回到 afStatus_t AF_DataRequest( afAddrType_t *dstAddr, endPointDesc_t *srcEP,
uint16 cID, uint16 len, uint8 *buf, uint8 *transID,
uint8 options, uint8 radius )
的第一个参数afAddrType_t *dstAddr, 是什么类型的消息,由这个参数决定。
typedef struct
{
union
{
uint16 shortAddr;
ZLongAddr_t extAddr;
} addr;
afAddrMode_t addrMode; //决定了数据发送模式,这个值为 afAddr16Bit表示单播, afAddrGroup 是组播, afAddrBroadcast 是广播
uint8 endPoint;
uint16 panId; // used for the INTER_PAN feature
} afAddrType_t;
除了设置addrMode,目的地址还需要设置 shortAddr,它是节点的网络地址,如协调器为0x0000。
单播
将目的地址设置成单播形式即可。
Point_To_Point_DstAddr.addrMode = (afAddrMode_t)Addr16Bit;
Point_To_Point_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;
Point_To_Point_DstAddr.addr.shortAddr = 0x0000; //发给协调器
组播
使用组播方式,难点是如何加入特定的组。 组播的要素(见结构体aps_Group_t)为 组播ID, 组播名字。
typedef struct
{
uint16 ID; // Unique to this table
uint8 name[APS_GROUP_NAME_LEN]; // Human readable name of group
} aps_Group_t;
然后调用aps_AddGroup,将端口加入组播组。
如 // By default, all devices start out in Group 1
SampleApp_Group.ID = 0x0001;
osal_memcpy( SampleApp_Group.name, "Group 1", 7 );
aps_AddGroup( SAMPLEAPP_ENDPOINT, &SampleApp_Group );
广播
使用广播通信时,shortAddr的网络地址可以为0xffff, 0xfffd, 0xfffc
0xffff 表示数据在全网广播,包括处于休眠的节点;
0xfffd 表示数据包只发往处于active的节点,不发往处于休眠的节点;
0xfffc表示数据包发往网络中的所有路由器节点。
如:
SampleApp_Periodic_DstAddr.addrMode = (afAddrMode_t)AddrBroadcast;
SampleApp_Periodic_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;
SampleApp_Periodic_DstAddr.addr.shortAddr = 0xFFFF;
这几个概念的含义一目了然。这节主要关注怎么在zigbee中实现单播,组播,广播。
回到 afStatus_t AF_DataRequest( afAddrType_t *dstAddr, endPointDesc_t *srcEP,
uint16 cID, uint16 len, uint8 *buf, uint8 *transID,
uint8 options, uint8 radius )
的第一个参数afAddrType_t *dstAddr, 是什么类型的消息,由这个参数决定。
typedef struct
{
union
{
uint16 shortAddr;
ZLongAddr_t extAddr;
} addr;
afAddrMode_t addrMode; //决定了数据发送模式,这个值为 afAddr16Bit表示单播, afAddrGroup 是组播, afAddrBroadcast 是广播
uint8 endPoint;
uint16 panId; // used for the INTER_PAN feature
} afAddrType_t;
除了设置addrMode,目的地址还需要设置 shortAddr,它是节点的网络地址,如协调器为0x0000。
单播
将目的地址设置成单播形式即可。
Point_To_Point_DstAddr.addrMode = (afAddrMode_t)Addr16Bit;
Point_To_Point_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;
Point_To_Point_DstAddr.addr.shortAddr = 0x0000; //发给协调器
组播
使用组播方式,难点是如何加入特定的组。 组播的要素(见结构体aps_Group_t)为 组播ID, 组播名字。
typedef struct
{
uint16 ID; // Unique to this table
uint8 name[APS_GROUP_NAME_LEN]; // Human readable name of group
} aps_Group_t;
然后调用aps_AddGroup,将端口加入组播组。
如 // By default, all devices start out in Group 1
SampleApp_Group.ID = 0x0001;
osal_memcpy( SampleApp_Group.name, "Group 1", 7 );
aps_AddGroup( SAMPLEAPP_ENDPOINT, &SampleApp_Group );
广播
使用广播通信时,shortAddr的网络地址可以为0xffff, 0xfffd, 0xfffc
0xffff 表示数据在全网广播,包括处于休眠的节点;
0xfffd 表示数据包只发往处于active的节点,不发往处于休眠的节点;
0xfffc表示数据包发往网络中的所有路由器节点。
如:
SampleApp_Periodic_DstAddr.addrMode = (afAddrMode_t)AddrBroadcast;
SampleApp_Periodic_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;
SampleApp_Periodic_DstAddr.addr.shortAddr = 0xFFFF;
相关文章推荐
- zigbee单播、组播、广播
- zigbee单播、组播、广播
- zigbee单播、组播、广播
- zigbee 广播 组播 单播
- zigbee网络单播、广播和组播--简单笔记
- AF_DataRequest zigbee单播、组播、广播
- zigbee单播、组播、广播
- zigbee单播、组播、广播
- Zigbee单播、组播、广播网络通信
- 单播、多播(组播)和广播的
- UDP 单播 组播 广播
- 单播、广播、组播的区别和特点
- 单播、多播(组播)和广播的区别
- 组播、单播、任播和广播
- linux udp 单播组播广播实现
- 单播、多播(组播)和广播的区别
- 单播,组播和广播
- 单播、多播(组播)和广播的区别
- Linux UDP 单播 组播 广播实现
- 单播、组播、广播、组播以及泛洪的区别